Compare commits

...

2 Commits

Author SHA1 Message Date
youhong.ai b5d95fb201 Merge branch 'dev' of https://gitea.yeyaguitu.cn/ecology/ebu_ecology_dev1 into dev
修复dealwith bug、洲际酒店任务元素开发
2023-05-12 11:15:41 +08:00
youhong.ai 0cc0b9889a 洲际酒店任务元素开发、delwithbug修复 2023-05-12 11:15:29 +08:00
12 changed files with 386 additions and 209 deletions

View File

@ -115,6 +115,19 @@ class CusUtils {
return Utils.convertNameObjToId(fieldName)
}
getQueryString(name) {
let reg = new RegExp("(^|&|\/?)" + name + "=([^&]*)(&|$)", "i");
let searchStr = window.location.href
if (searchStr.startsWith('&')) {
searchStr = searchStr.substr(1)
}
let search = searchStr.match(reg)
if (search != null) {
return unescape(search[2]);
}
return null;
}
/**
* 将字段名称转为字段id
* @param fieldObj 字段名称对象 {string|object}

View File

@ -32,6 +32,7 @@ import weaver.file.ImageFileManager;
import javax.ws.rs.core.MediaType;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.*;
@ -127,7 +128,11 @@ public class HttpUtils {
builder.append("&");
builder.append(entry.getKey());
builder.append("=");
builder.append(entry.getValue());
try {
builder.append(URLEncoder.encode(Util.null2String(entry.getValue()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
builder.append(entry.getKey());
}
}
return removeSeparator(builder);
}

View File

@ -460,7 +460,7 @@ public class ResultMapper {
}
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
@ -473,11 +473,11 @@ public class ResultMapper {
}
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
@ -507,7 +507,7 @@ public class ResultMapper {
}
}
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
@ -569,7 +569,7 @@ public class ResultMapper {
cassociationValue = paramType.get(declaredField.getType()).apply(String.valueOf(cassociationValue));
}
try {
if (Objects.nonNull(value)) {
if (Objects.nonNull(cassociationValue)) {
propertyDescriptor.getWriteMethod().invoke(o, cassociationValue);
}
} catch (Exception e) {
@ -651,7 +651,6 @@ public class ResultMapper {
Association[] mappings = annotation.value();
Association mapping = null;
for (Association item : mappings) {
Util.getLogger().info("column: " + item.column() + " ===property: " + item.property() + " ====fieldName: " + filedName);
String property = isMap ? item.column() : item.property();
if (isMap ? filedName.equalsIgnoreCase(property) : filedName.equals(property)) {
mapping = item;
@ -664,7 +663,6 @@ public class ResultMapper {
Id id = annotation.id();
String column = annotation.column();
String columnValue = rs.getString(column);
Util.getLogger().info(Arrays.toString(rs.getColumnName()));
if (Objects.isNull(columnValue) || "".equals(columnValue)) {
columnValue = rs.getString(column.toUpperCase());
}

View File

@ -52,10 +52,40 @@ public class TaskElementController {
@QueryParam("id") String configId) {
User user = HrmUserVarify.getUser(request, response);
try {
return ApiResult.success(service.getList(user, params,configId));
return ApiResult.success(service.getList(user, params, configId));
} catch (Exception e) {
log.error("get task list error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");
}
}
@Path("/get-btn")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String buttonInfo(@Context HttpServletRequest request,
@Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
try {
return ApiResult.success(service.buttonInfo(user));
} catch (Exception e) {
log.error("get button info error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");
}
}
@Path("/clear-config")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String clearConfig() {
try {
service.clearConfig();
return ApiResult.successNoData();
} catch (Exception e) {
log.error("clear config error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");
}
}
}

View File

@ -29,6 +29,11 @@ public class IhgTaskElementConfigItem {
private String unitEn;
/** icon */
private String icon;
/** 移动端图标 */
private String iconMobile;
/** 移动端激活图标 */
private String iconMobileActive;
/** 激活icon */
private String iconActive;
/** 查看权限 */
@ -36,6 +41,9 @@ public class IhgTaskElementConfigItem {
/** 数据来源 */
private String dataSource;
/** 序号 */
private String sortNum;
/** 跳转链接 */
private String link;
/** 数据来源值 */

View File

@ -23,7 +23,7 @@ public interface TaskElementMapper {
*
* @return
*/
@Select("select * from uf_ihg_el_config ")
@Select("select * from uf_ihg_el_config where enable_status = 1")
@Associations({
@Association(
property = "icon",
@ -32,6 +32,14 @@ public interface TaskElementMapper {
@Association(
property = "iconActive",
column = "icon_active",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobile",
column = "icon_mobile",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobileActive",
column = "icon_mobile_active",
id = @Id(methodId = 1, value = String.class))
})
List<IhgTaskElementConfigItem> selectConfig();
@ -42,7 +50,7 @@ public interface TaskElementMapper {
* @param configId id
* @return
*/
@Select("select * from uf_ihg_el_config where id = #{configId}")
@Select("select * from uf_ihg_el_config where id = #{configId} and enable_status = 1")
@Associations({
@Association(
property = "icon",
@ -51,6 +59,14 @@ public interface TaskElementMapper {
@Association(
property = "iconActive",
column = "icon_active",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobile",
column = "icon_mobile",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobileActive",
column = "icon_mobile_active",
id = @Id(methodId = 1, value = String.class))
})
IhgTaskElementConfigItem selectConfig(@ParamMapper("configId") String configId);
@ -72,7 +88,6 @@ public interface TaskElementMapper {
* @param viewAuthoritySql sql
* @param user
* @param map
* @param where
* @return
*/
@Select(custom = true)
@ -86,6 +101,7 @@ public interface TaskElementMapper {
* @param customerValue sql
* @param item
* @param user
* @param map
* @param where
* @return
*/
@ -93,5 +109,16 @@ public interface TaskElementMapper {
List<Map<String, Object>> selectWorkList(@SqlString String customerValue,
@ParamMapper("param") Map<String, Object> item,
@ParamMapper("user") User user,
@ParamMapper("where") Map<String, Object> where);
@ParamMapper("where") Map<String, Object> where,
@ParamMapper("current") Map<String, Object> map);
/**
* <h2></h2>
*
* @param sql
* @param o
* @return
*/
@Select(custom = true)
String selectConvert(@SqlString String sql, @ParamMapper("value") String o);
}

View File

@ -9,13 +9,11 @@ import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
import com.api.youhong.ai.ihgzhouji.taskele.mapstruct.TaskElementMapstruct;
import com.api.youhong.ai.ihgzhouji.taskele.vo.IhgTaskElementVo;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* <h1>service</h1>
@ -26,6 +24,29 @@ import java.util.stream.Collectors;
*/
public class TaskElementService {
private final TaskElementMapper mapper = Util.getMapper(TaskElementMapper.class);
private final Logger log = Util.getLogger();
private final RecordSet rs = new RecordSet();
private volatile Map<String, Object> config = null;
public void clearConfig() {
this.config = null;
}
private Map<String, Object> getConfig() {
if (this.config == null) {
synchronized (TaskElementService.class) {
if (this.config == null) {
this.config = Util.readProperties2Map("IHGWorkListInfoConvert", "cus");
if (config == null) {
this.config = Collections.emptyMap();
}
}
}
}
return config;
}
public List<IhgTaskElementVo> getList(User user) {
List<IhgTaskElementConfigItem> ihgTaskElementConfItemList = mapper.selectConfig();
@ -50,7 +71,7 @@ public class TaskElementService {
for (Map.Entry<IhgTaskElementConfigItem, List<Map<String, Object>>> entry : taskConfigMap.entrySet()) {
IhgTaskElementConfigItem taskElementConfigItem = entry.getKey();
List<Map<String, Object>> authorityList = entry.getValue();
List<Map<String, Object>> workList = queryWorkList(taskElementConfigItem, authorityList, user, "", Collections.emptyMap());
List<Map<String, Object>> workList = queryWorkList(taskElementConfigItem, authorityList, user, "", Collections.emptyMap(), map);
IhgTaskElementVo ihgTaskElementVo = TaskElementMapstruct.INSTANCE.entity2Vo(taskElementConfigItem);
ihgTaskElementVo.setList(workList);
ihgTaskElementVo.setSize(workList.size());
@ -60,26 +81,44 @@ public class TaskElementService {
}
result.add(ihgTaskElementVo);
}
result.sort(Comparator.comparing(item -> StrUtil.isBlank(item.getSortNum()) ? -1 : Integer.parseInt(item.getSortNum())));
return result;
}
private List<Map<String, Object>> queryWorkList(IhgTaskElementConfigItem taskElementConfigItem,
List<Map<String, Object>> authorityList,
User user, String whereStr,
Map<String, Object> whereMap) {
Map<String, Object> whereMap,
Map<String, Object> currentMap) {
String dataSource = taskElementConfigItem.getDataSource();
String customerValue = taskElementConfigItem.getCustomerValue();
if (StrUtil.isBlank(customerValue)) {
throw new CustomerException("自定义sql或自定义接口不能为空");
}
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> convertConfig = getConfig();
for (Map<String, Object> item : authorityList) {
if ("0".equals(dataSource)) {
// 自定义sql
customerValue += " " + whereStr;
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap);
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap);
if (CollectionUtil.isNotEmpty(list)) {
result.addAll(list);
Map<String, Object> convert = (Map<String, Object>) convertConfig.get("convert");
if (Objects.nonNull(convert)) {
// 自定义转换设置
for (Map<String, Object> listItem : list) {
for (Map.Entry<String, Object> entry : convert.entrySet()) {
String sql = Util.null2String(entry.getValue());
String replace = sql.replace("$?$", "#{value}");
if (StrUtil.isNotBlank(replace)) {
String value = mapper.selectConvert(replace, Util.null2String(listItem.get(Util.null2String(entry.getKey()))));
listItem.put(entry.getKey(), value);
}
}
}
}
}
} else {
// 自定义接口
@ -99,19 +138,24 @@ public class TaskElementService {
}
}
}
// 去重
result = result.stream()
.filter(distinctByKey(item -> item.get("id")))
.collect(Collectors.toList());
return result;
return removeDuplicates(result);
}
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>(8);
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
public List<Map<String, Object>> removeDuplicates(List<Map<String, Object>> list) {
Set<String> idSet = new HashSet<>();
List<Map<String, Object>> resultList = new ArrayList<>();
for (Map<String, Object> map : list) {
String id = Util.null2String(map.get("id"));
if (!idSet.contains(id)) {
idSet.add(id);
resultList.add(map);
}
}
return resultList;
}
/**
* <h2></h2>
*
@ -134,8 +178,14 @@ public class TaskElementService {
Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
String key = Util.null2String(valueMap.get("key"));
String value = Util.null2String(valueMap.get("value"));
String type = Util.null2String(valueMap.get("type"));
if (StrUtil.isNotBlank(value)) {
builder.append(" and ").append(key).append(" = ").append("#{where.").append(key).append("}");
if ("like".equalsIgnoreCase(type)) {
value = "%" + value + "%";
builder.append(" and ").append(key).append(" like ").append("#{where.").append(key).append("}");
} else {
builder.append(" and ").append(key).append(" = ").append("#{where.").append(key).append("}");
}
map.put(key, value);
}
}
@ -147,7 +197,7 @@ public class TaskElementService {
return null;
}
// 查询数据
List<Map<String, Object>> workList = this.queryWorkList(ihgTaskElementConfItem, authorityList, user, whereStr, map);
List<Map<String, Object>> workList = this.queryWorkList(ihgTaskElementConfItem, authorityList, user, whereStr, map, map);
IhgTaskElementVo ihgTaskElementVo = TaskElementMapstruct.INSTANCE.entity2Vo(ihgTaskElementConfItem);
ihgTaskElementVo.setList(workList);
ihgTaskElementVo.setSize(workList.size());
@ -157,4 +207,35 @@ public class TaskElementService {
}
return ihgTaskElementVo;
}
/**
* <h2></h2>
*
* @param user
* @return
*/
public Map<String, Object> buttonInfo(User user) {
String sendWorkButtonAuthority = Util.getCusConfigValue("SEND_WORK_BUTTON_AUTHORITY");
String sendWorkButtonLink = Util.getCusConfigValue("SEND_WORK_BUTTON_LINK");
String workListButtonAuthority = Util.getCusConfigValue("WORK_LIST_BUTTON_AUTHORITY");
String workListButtonLink = Util.getCusConfigValue("WORK_LIST_BUTTON_LINK");
Map<String, Object> result = new HashMap<>(8);
// 设置查询基础参数
Map<String, Object> map = new HashMap<>(8);
map.put("currentDate", Util.getTime("yyyy-MM-dd"));
map.put("currentTime", Util.getTime("HH:mm:ss"));
if (StrUtil.isNotBlank(sendWorkButtonAuthority)) {
List<Map<String, Object>> maps = mapper.selectAuthority(sendWorkButtonAuthority, user, map);
if (CollectionUtil.isNotEmpty(maps)) {
result.put("sendWork", sendWorkButtonLink);
}
}
if (StrUtil.isNotBlank(sendWorkButtonAuthority)) {
List<Map<String, Object>> maps = mapper.selectAuthority(workListButtonAuthority, user, map);
if (CollectionUtil.isNotEmpty(maps)) {
result.put("workList", workListButtonLink);
}
}
return result;
}
}

View File

@ -25,15 +25,18 @@ public class IhgTaskElementVo {
private String title;
/** 单位 */
private String unit;
/** icon */
private String icon;
/** 激活icon */
private String iconActive;
/** 移动端图标 */
private String iconMobile;
/** 移动端激活图标 */
private String iconMobileActive;
/** 跳转链接 */
private String link;
/** 序号 */
private String sortNum;
/** 数据长度 */
private Integer size;
/** 数据 */

View File

@ -1297,8 +1297,11 @@ public class DealWithMapping extends ToolUtil {
if (null == resultList || resultList.isEmpty()) {
return;
}
if (Objects.isNull(childList) || childList.isEmpty()) {
list.addAll(resultList);
return;
}
if ("0".equals(childType)) {
// 对象类型
for (Object o : resultList) {
Map<String, Object> item = new HashMap<>();
@ -1376,6 +1379,10 @@ public class DealWithMapping extends ToolUtil {
if (null == resultList || resultList.isEmpty()) {
return;
}
if (Objects.isNull(childList) || childList.isEmpty()) {
list.addAll(resultList);
return;
}
if ("0".equals(childType)) {
// 对象类型

View File

@ -0,0 +1,2 @@
# 任务接受人转换规则
cus.convert.rwjsr=select lastname from hrmresource where id = $?$

View File

@ -31,189 +31,182 @@ import java.util.stream.Collectors;
@ActionDesc(value = "部门属于酒店的部门分级分权控制定时任务,只能查看到同层的酒店部门信息", author = "aiyh")
public class DecentralizationOfPowersCronJob extends BaseCronJob {
@RequiredMark("支持中心部门ID")
@PrintParamMark
private String supportCenterDeptId;
@RequiredMark("支持中心部门ID")
@PrintParamMark
private String supportCenterDeptId;
@Setter(AccessLevel.NONE)
private final Logger log = Util.getLogger();
@Setter(AccessLevel.NONE)
private final Logger log = Util.getLogger();
private final RecordSet recordSet = new RecordSet();
private final RecordSet recordSet = new RecordSet();
private final DecentralizationMapper mapper = Util.getMapper(DecentralizationMapper.class);
private final DecentralizationMapper mapper = Util.getMapper(DecentralizationMapper.class);
@Override
public void execute() {
try {
Util.verifyRequiredField(this);
doExecute();
} catch (Exception e) {
log.error(Util.logStr("execute cronJob fail! error msg is [{}]stack trace is [\n{}\n]",
e.getMessage(), Util.getErrString(e)));
throw new CustomerException("execute cronJob fail," + e.getMessage());
}
}
@Override
public void execute() {
try {
Util.verifyRequiredField(this);
doExecute();
} catch (Exception e) {
log.error(Util.logStr("execute cronJob fail! error msg is [{}]stack trace is [\n{}\n]",
e.getMessage(), Util.getErrString(e)));
throw new CustomerException("execute cronJob fail," + e.getMessage());
}
}
public void doExecute() {
List<OrgInfoHotelEntity> hotelInfoList = mapper.selectCnTileFromOrginfo();
public void doExecute() {
List<OrgInfoHotelEntity> hotelInfoList = mapper.selectCnTileFromOrginfo();
for (OrgInfoHotelEntity orgInfoHotelEntity : hotelInfoList) {
insertSysdetachinfo(orgInfoHotelEntity);
}
log.info("查询酒店后信息数据: " + hotelInfoList.size());
for (OrgInfoHotelEntity orgInfoHotelEntity : hotelInfoList) {
insertSysdetachinfo(orgInfoHotelEntity);
}
// 将没有infoID的数据过滤
List<OrgInfoHotelEntity> hasInfoIdHotelInfo = hotelInfoList.stream()
.filter(item -> item.getInfoId() != null && item.getInfoId() > 0)
.collect(Collectors.toList());
log.info("过滤后数据信息:" + hasInfoIdHotelInfo.size());
Map<String, List<OrgInfoHotelEntity>> groupByUpdate = hasInfoIdHotelInfo
.stream().collect(Collectors.groupingBy(OrgInfoHotelEntity::getUpdate));
List<OrgInfoHotelEntity> hasInfoIdHotelInfo = hotelInfoList.stream()
.filter(item -> item.getInfoId() != null && item.getInfoId() > 0)
.collect(Collectors.toList());
Map<String, List<OrgInfoHotelEntity>> groupByUpdate = hasInfoIdHotelInfo
.stream().collect(Collectors.groupingBy(OrgInfoHotelEntity::getUpdate));
log.info("分组后数据信息:" + groupByUpdate.size());
List<OrgInfoHotelEntity> updateInfo = groupByUpdate.get("true");
List<OrgInfoHotelEntity> insertInfo = groupByUpdate.get("false");
if (updateInfo == null) {
updateInfo = new ArrayList<>();
}
if (insertInfo == null) {
insertInfo = new ArrayList<>();
}
List<List> insertSqlArgs = new ArrayList<>();
insertInfo.forEach(item -> {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");
insertSqlArgs.addAll(lists);
});
log.info("将待插入数据插入数据表中: " + insertSqlArgs.size());
if (!insertSqlArgs.isEmpty()) {
boolean insertSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), insertSqlArgs);
if (!insertSuccess) {
log.error("批量插入权限数据失败!" + OrgInfoHotelEntity.getInsertSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
List<OrgInfoHotelEntity> updateDetachDetailList = new ArrayList<>();
List<OrgInfoHotelEntity> insertDetachDetailList = new ArrayList<>();
for (OrgInfoHotelEntity orgInfoHotelEntity : updateInfo) {
log.info("循环查询权限ID " + orgInfoHotelEntity);
Integer detachdetailId1 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 1);
if (null != detachdetailId1 && detachdetailId1 > 0) {
List<OrgInfoHotelEntity> updateInfo = groupByUpdate.get("true");
List<OrgInfoHotelEntity> insertInfo = groupByUpdate.get("false");
if (updateInfo == null) {
updateInfo = new ArrayList<>();
}
if (insertInfo == null) {
insertInfo = new ArrayList<>();
}
List<List> insertSqlArgs = new ArrayList<>();
insertInfo.forEach(item -> {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");
insertSqlArgs.addAll(lists);
});
if (!insertSqlArgs.isEmpty()) {
boolean insertSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), insertSqlArgs);
if (!insertSuccess) {
log.error("批量插入权限数据失败!" + OrgInfoHotelEntity.getInsertSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
List<OrgInfoHotelEntity> updateDetachDetailList = new ArrayList<>();
List<OrgInfoHotelEntity> insertDetachDetailList = new ArrayList<>();
for (OrgInfoHotelEntity orgInfoHotelEntity : updateInfo) {
Integer detachdetailId1 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 1);
if (null != detachdetailId1 && detachdetailId1 > 0) {
// 需要更新
OrgInfoHotelEntity copy = OrgInfoHotelEntity.copy(orgInfoHotelEntity);
copy.setId(String.valueOf(detachdetailId1));
copy.setSourceType(1);
updateDetachDetailList.add(copy);
}
Integer detachdetailId2 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 2);
if (null != detachdetailId2 && detachdetailId2 > 0) {
OrgInfoHotelEntity copy = OrgInfoHotelEntity.copy(orgInfoHotelEntity);
copy.setId(String.valueOf(detachdetailId1));
copy.setSourceType(1);
updateDetachDetailList.add(copy);
}
Integer detachdetailId2 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 2);
if (null != detachdetailId2 && detachdetailId2 > 0) {
// 需要更新
OrgInfoHotelEntity copy = OrgInfoHotelEntity.copy(orgInfoHotelEntity);
copy.setId(String.valueOf(detachdetailId2));
copy.setSourceType(2);
updateDetachDetailList.add(copy);
}
boolean hasSourceType1 = null == detachdetailId1 || detachdetailId1 < 0;
boolean hasSourceType2 = null == detachdetailId2 || detachdetailId2 < 0;
if (hasSourceType1 && hasSourceType2) {
OrgInfoHotelEntity copy = OrgInfoHotelEntity.copy(orgInfoHotelEntity);
copy.setId(String.valueOf(detachdetailId2));
copy.setSourceType(2);
updateDetachDetailList.add(copy);
}
boolean hasSourceType1 = null == detachdetailId1 || detachdetailId1 < 0;
boolean hasSourceType2 = null == detachdetailId2 || detachdetailId2 < 0;
if (hasSourceType1 && hasSourceType2) {
// 需要插入
insertDetachDetailList.add(orgInfoHotelEntity);
}
}
log.info("需要插入的数据: " + insertDetachDetailList.size());
log.info("需要更新的数据: " + updateDetachDetailList.size());
insertSqlArgs.clear();
insertDetachDetailList.forEach(item -> {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");
insertSqlArgs.addAll(lists);
});
if (!insertSqlArgs.isEmpty()) {
boolean insertSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), insertSqlArgs);
if (!insertSuccess) {
log.error("批量插入权限数据失败!" + OrgInfoHotelEntity.getInsertSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
insertDetachDetailList.add(orgInfoHotelEntity);
}
}
insertSqlArgs.clear();
insertDetachDetailList.forEach(item -> {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");
insertSqlArgs.addAll(lists);
});
if (!insertSqlArgs.isEmpty()) {
boolean insertSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), insertSqlArgs);
if (!insertSuccess) {
log.error("批量插入权限数据失败!" + OrgInfoHotelEntity.getInsertSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
List<List> updateSqlArgs = new ArrayList<>();
updateDetachDetailList.forEach(item -> {
List lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlUpdateList(item);
updateSqlArgs.add(lists);
});
if (!updateSqlArgs.isEmpty()) {
boolean updateSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getUpdateSql(), updateSqlArgs);
if (!updateSuccess) {
log.error("批量跟新权限数据失败!" + OrgInfoHotelEntity.getUpdateSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
List<List> updateSqlArgs = new ArrayList<>();
updateDetachDetailList.forEach(item -> {
List lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlUpdateList(item);
updateSqlArgs.add(lists);
});
if (!updateSqlArgs.isEmpty()) {
boolean updateSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getUpdateSql(), updateSqlArgs);
if (!updateSuccess) {
log.error("批量跟新权限数据失败!" + OrgInfoHotelEntity.getUpdateSql() + " " +
JSON.toJSONString(insertSqlArgs.get(0)));
}
}
// 特殊权限设置
List<String> idList = mapper.selectBrotherDeptIds(supportCenterDeptId);
Integer infoId = mapper.selectInfoIdByCnTitle("支持中心分权查看");
List<String> idList = mapper.selectBrotherDeptIds(supportCenterDeptId);
Integer infoId = mapper.selectInfoIdByCnTitle("支持中心分权查看");
if (null == infoId || infoId < 0) {
if (null == infoId || infoId < 0) {
// 插入
OrgInfoHotelEntity orgInfoHotelEntity = new OrgInfoHotelEntity();
orgInfoHotelEntity.setDeptId(Util.join(idList, ","));
boolean insertSuccess = mapper.insertSysdetachinfo("支持中心分权查看");
if (insertSuccess) {
OrgInfoHotelEntity orgInfoHotelEntity = new OrgInfoHotelEntity();
orgInfoHotelEntity.setDeptId(Util.join(idList, ","));
boolean insertSuccess = mapper.insertSysdetachinfo("支持中心分权查看");
if (insertSuccess) {
// 查询最大ID
infoId = mapper.selectIdByCntitle("支持中心分权查看");
orgInfoHotelEntity.setInfoId(infoId);
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(orgInfoHotelEntity, supportCenterDeptId);
if (!lists.isEmpty()) {
boolean b = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), lists);
if (!b) {
log.error("插入特殊权限失败!" + OrgInfoHotelEntity.getInsertSql() + " : " + JSON.toJSONString(lists));
}
}
}
} else {
infoId = mapper.selectIdByCntitle("支持中心分权查看");
orgInfoHotelEntity.setInfoId(infoId);
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(orgInfoHotelEntity, supportCenterDeptId);
if (!lists.isEmpty()) {
boolean b = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), lists);
if (!b) {
log.error("插入特殊权限失败!" + OrgInfoHotelEntity.getInsertSql() + " : " + JSON.toJSONString(lists));
}
}
}
} else {
// 更新
Integer sysdetachId1 = mapper.selectSysdetachdetailByInfoIdAndYh(infoId, 1);
Integer sysdetachId2 = mapper.selectSysdetachdetailByInfoIdAndYh(infoId, 2);
OrgInfoHotelEntity orgInfoHotelEntity = new OrgInfoHotelEntity();
orgInfoHotelEntity.setDeptId(Util.join(idList, ","));
orgInfoHotelEntity.setInfoId(infoId);
orgInfoHotelEntity.setId(String.valueOf(sysdetachId1));
orgInfoHotelEntity.setSourceType(1);
List list = OrgInfoHotelEntity.orgInfoHotelEntityToSqlUpdateList(orgInfoHotelEntity);
if (!list.isEmpty()) {
recordSet.executeUpdate(OrgInfoHotelEntity.getUpdateSql(), list);
}
orgInfoHotelEntity.setId(String.valueOf(sysdetachId2));
orgInfoHotelEntity.setSourceType(2);
if (!list.isEmpty()) {
recordSet.executeUpdate(OrgInfoHotelEntity.getUpdateSql(), list);
}
}
Integer sysdetachId1 = mapper.selectSysdetachdetailByInfoIdAndYh(infoId, 1);
Integer sysdetachId2 = mapper.selectSysdetachdetailByInfoIdAndYh(infoId, 2);
OrgInfoHotelEntity orgInfoHotelEntity = new OrgInfoHotelEntity();
orgInfoHotelEntity.setDeptId(Util.join(idList, ","));
orgInfoHotelEntity.setInfoId(infoId);
orgInfoHotelEntity.setId(String.valueOf(sysdetachId1));
orgInfoHotelEntity.setSourceType(1);
List list = OrgInfoHotelEntity.orgInfoHotelEntityToSqlUpdateList(orgInfoHotelEntity);
if (!list.isEmpty()) {
recordSet.executeUpdate(OrgInfoHotelEntity.getUpdateSql(), list);
}
orgInfoHotelEntity.setId(String.valueOf(sysdetachId2));
orgInfoHotelEntity.setSourceType(2);
if (!list.isEmpty()) {
recordSet.executeUpdate(OrgInfoHotelEntity.getUpdateSql(), list);
}
}
AppDetachComInfo appDetachComInfo = new AppDetachComInfo();
appDetachComInfo.resetAppDetachInfo();
}
AppDetachComInfo appDetachComInfo = new AppDetachComInfo();
appDetachComInfo.resetAppDetachInfo();
}
/**
*
*
* @param orgInfoHotelEntity
*/
private void insertSysdetachinfo(OrgInfoHotelEntity orgInfoHotelEntity) {
Integer integer = mapper.selectIdByCntitle(orgInfoHotelEntity.getCnTitle());
if (null != integer && integer > 0) {
orgInfoHotelEntity.setInfoId(integer);
orgInfoHotelEntity.setUpdate("true");
return;
}
boolean insertSuccess = mapper.insertSysdetachinfo(orgInfoHotelEntity.getCnTitle());
if (insertSuccess) {
/**
*
*
* @param orgInfoHotelEntity
*/
private void insertSysdetachinfo(OrgInfoHotelEntity orgInfoHotelEntity) {
Integer integer = mapper.selectIdByCntitle(orgInfoHotelEntity.getCnTitle());
if (null != integer && integer > 0) {
orgInfoHotelEntity.setInfoId(integer);
orgInfoHotelEntity.setUpdate("true");
return;
}
boolean insertSuccess = mapper.insertSysdetachinfo(orgInfoHotelEntity.getCnTitle());
if (insertSuccess) {
// 查询最大ID
Integer infoId = mapper.selectIdByCntitle(orgInfoHotelEntity.getCnTitle());
orgInfoHotelEntity.setInfoId(infoId);
orgInfoHotelEntity.setUpdate("false");
}
}
Integer infoId = mapper.selectIdByCntitle(orgInfoHotelEntity.getCnTitle());
orgInfoHotelEntity.setInfoId(infoId);
orgInfoHotelEntity.setUpdate("false");
}
}
}

View File

@ -3,6 +3,8 @@ package youhong.ai.yihong;
import aiyh.utils.Util;
import basetest.BaseTest;
import com.alibaba.fastjson.JSON;
import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
import org.junit.Test;
import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper;
import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldConfig;
@ -35,4 +37,12 @@ public class YiHongTest extends BaseTest {
System.out.println(strings.stream().filter(item -> !item.equals("2")).collect(Collectors.toList()));
}
@Test
public void tesetst() {
TaskElementMapper mapper = Util.getMapper(TaskElementMapper.class);
List<IhgTaskElementConfigItem> ihgTaskElementConfigItems = mapper.selectConfig();
System.out.println(JSON.toJSONString(ihgTaskElementConfigItems));
}
}