diff --git a/javascript/common/Utils.js b/javascript/common/Utils.js index 5b7d700..45b545c 100644 --- a/javascript/common/Utils.js +++ b/javascript/common/Utils.js @@ -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} diff --git a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java index 6aabc85..f728648 100644 --- a/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java +++ b/src/main/java/aiyh/utils/httpUtil/util/HttpUtils.java @@ -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); } diff --git a/src/main/java/aiyh/utils/recordset/ResultMapper.java b/src/main/java/aiyh/utils/recordset/ResultMapper.java index cd3a2d7..1f1389d 100644 --- a/src/main/java/aiyh/utils/recordset/ResultMapper.java +++ b/src/main/java/aiyh/utils/recordset/ResultMapper.java @@ -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) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1)); + ((Map) 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) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); continue; } if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); + ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i])); } ((Map) o).put(columnName[i].toLowerCase(), rs.getString(i + 1)); ((Map) o).put(columnName[i].toUpperCase(), rs.getString(i + 1)); @@ -507,7 +507,7 @@ public class ResultMapper { } } if (enable) { - ((Map) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1)); + ((Map) 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()); } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java index dbb67f5..7e5ea84 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/contoller/TaskElementController.java @@ -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!"); + } + } } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/entity/IhgTaskElementConfigItem.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/entity/IhgTaskElementConfigItem.java index 5504335..e802d7e 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/entity/IhgTaskElementConfigItem.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/entity/IhgTaskElementConfigItem.java @@ -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; /** 数据来源值 */ diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java index 607155d..164c565 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/mapper/TaskElementMapper.java @@ -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 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> selectWorkList(@SqlString String customerValue, @ParamMapper("param") Map item, @ParamMapper("user") User user, - @ParamMapper("where") Map where); + @ParamMapper("where") Map where, + @ParamMapper("current") Map map); + + /** + *

查询自定义转换规则

+ * + * @param sql 自定义转换规则 + * @param o 值 + * @return 转换后的值 + */ + @Select(custom = true) + String selectConvert(@SqlString String sql, @ParamMapper("value") String o); } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java index 8df2385..5845bc2 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/service/TaskElementService.java @@ -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; /** *

任务列表元素service

@@ -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 config = null; + + public void clearConfig() { + this.config = null; + } + + private Map 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 getList(User user) { List ihgTaskElementConfItemList = mapper.selectConfig(); @@ -50,7 +71,7 @@ public class TaskElementService { for (Map.Entry>> entry : taskConfigMap.entrySet()) { IhgTaskElementConfigItem taskElementConfigItem = entry.getKey(); List> authorityList = entry.getValue(); - List> workList = queryWorkList(taskElementConfigItem, authorityList, user, "", Collections.emptyMap()); + List> 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> queryWorkList(IhgTaskElementConfigItem taskElementConfigItem, List> authorityList, User user, String whereStr, - Map whereMap) { + Map whereMap, + Map currentMap) { String dataSource = taskElementConfigItem.getDataSource(); String customerValue = taskElementConfigItem.getCustomerValue(); if (StrUtil.isBlank(customerValue)) { throw new CustomerException("自定义sql或自定义接口不能为空!"); } List> result = new ArrayList<>(); + Map convertConfig = getConfig(); for (Map item : authorityList) { if ("0".equals(dataSource)) { // 自定义sql customerValue += " " + whereStr; - List> list = mapper.selectWorkList(customerValue, item, user, whereMap); + List> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap); if (CollectionUtil.isNotEmpty(list)) { result.addAll(list); + Map convert = (Map) convertConfig.get("convert"); + if (Objects.nonNull(convert)) { + // 自定义转换设置 + for (Map listItem : list) { + for (Map.Entry 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 Predicate distinctByKey(Function keyExtractor) { - Map seen = new ConcurrentHashMap<>(8); - return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; + public List> removeDuplicates(List> list) { + Set idSet = new HashSet<>(); + List> resultList = new ArrayList<>(); + for (Map map : list) { + String id = Util.null2String(map.get("id")); + if (!idSet.contains(id)) { + idSet.add(id); + resultList.add(map); + } + } + return resultList; } + /** *

查询自定义的数据

* @@ -134,8 +178,14 @@ public class TaskElementService { Map valueMap = (Map) 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> workList = this.queryWorkList(ihgTaskElementConfItem, authorityList, user, whereStr, map); + List> 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; } + + /** + *

查询按钮权限和链接地址

+ * + * @param user 当前用户 + * @return 查询结果 + */ + public Map 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 result = new HashMap<>(8); + // 设置查询基础参数 + Map 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> maps = mapper.selectAuthority(sendWorkButtonAuthority, user, map); + if (CollectionUtil.isNotEmpty(maps)) { + result.put("sendWork", sendWorkButtonLink); + } + } + if (StrUtil.isNotBlank(sendWorkButtonAuthority)) { + List> maps = mapper.selectAuthority(workListButtonAuthority, user, map); + if (CollectionUtil.isNotEmpty(maps)) { + result.put("workList", workListButtonLink); + } + } + return result; + } } diff --git a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/vo/IhgTaskElementVo.java b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/vo/IhgTaskElementVo.java index 5202fc3..27feaee 100644 --- a/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/vo/IhgTaskElementVo.java +++ b/src/main/java/com/api/youhong/ai/ihgzhouji/taskele/vo/IhgTaskElementVo.java @@ -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; /** 数据 */ diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index f025602..a893b70 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -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 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)) { // 对象类型 diff --git a/src/main/resources/WEB-INF/prop/prop2map/IHGWorkListInfoConvert.properties b/src/main/resources/WEB-INF/prop/prop2map/IHGWorkListInfoConvert.properties new file mode 100644 index 0000000..d5ee66a --- /dev/null +++ b/src/main/resources/WEB-INF/prop/prop2map/IHGWorkListInfoConvert.properties @@ -0,0 +1,2 @@ +# 任务接受人转换规则 +cus.convert.rwjsr=select lastname from hrmresource where id = $?$ diff --git a/src/main/youhong_ai_old_src/weaver/aiyh_igh/schedule/decentralization/DecentralizationOfPowersCronJob.java b/src/main/youhong_ai_old_src/weaver/aiyh_igh/schedule/decentralization/DecentralizationOfPowersCronJob.java index 931f97d..a859682 100644 --- a/src/main/youhong_ai_old_src/weaver/aiyh_igh/schedule/decentralization/DecentralizationOfPowersCronJob.java +++ b/src/main/youhong_ai_old_src/weaver/aiyh_igh/schedule/decentralization/DecentralizationOfPowersCronJob.java @@ -30,190 +30,183 @@ import java.util.stream.Collectors; @Setter @ActionDesc(value = "部门属于酒店的部门分级分权控制定时任务,只能查看到同层的酒店部门信息", author = "aiyh") public class DecentralizationOfPowersCronJob extends BaseCronJob { - - @RequiredMark("支持中心部门ID") - @PrintParamMark - private String supportCenterDeptId; - - @Setter(AccessLevel.NONE) - private final Logger log = Util.getLogger(); - - private final RecordSet recordSet = new RecordSet(); - - 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()); - } - } - - - public void doExecute() { - List hotelInfoList = mapper.selectCnTileFromOrginfo(); - - for (OrgInfoHotelEntity orgInfoHotelEntity : hotelInfoList) { - insertSysdetachinfo(orgInfoHotelEntity); - } - log.info("查询酒店后信息数据: " + hotelInfoList.size()); + + @RequiredMark("支持中心部门ID") + @PrintParamMark + private String supportCenterDeptId; + + @Setter(AccessLevel.NONE) + private final Logger log = Util.getLogger(); + + private final RecordSet recordSet = new RecordSet(); + + 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()); + } + } + + + public void doExecute() { + List hotelInfoList = mapper.selectCnTileFromOrginfo(); + + for (OrgInfoHotelEntity orgInfoHotelEntity : hotelInfoList) { + insertSysdetachinfo(orgInfoHotelEntity); + } // 将没有infoID的数据过滤 - List hasInfoIdHotelInfo = hotelInfoList.stream() - .filter(item -> item.getInfoId() != null && item.getInfoId() > 0) - .collect(Collectors.toList()); - log.info("过滤后数据信息:" + hasInfoIdHotelInfo.size()); - Map> groupByUpdate = hasInfoIdHotelInfo - .stream().collect(Collectors.groupingBy(OrgInfoHotelEntity::getUpdate)); - - log.info("分组后数据信息:" + groupByUpdate.size()); - List updateInfo = groupByUpdate.get("true"); - List insertInfo = groupByUpdate.get("false"); - if (updateInfo == null) { - updateInfo = new ArrayList<>(); - } - if (insertInfo == null) { - insertInfo = new ArrayList<>(); - } - List insertSqlArgs = new ArrayList<>(); - insertInfo.forEach(item -> { - 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 updateDetachDetailList = new ArrayList<>(); - List insertDetachDetailList = new ArrayList<>(); - for (OrgInfoHotelEntity orgInfoHotelEntity : updateInfo) { - log.info("循环查询权限ID: " + orgInfoHotelEntity); - Integer detachdetailId1 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 1); - if (null != detachdetailId1 && detachdetailId1 > 0) { + List hasInfoIdHotelInfo = hotelInfoList.stream() + .filter(item -> item.getInfoId() != null && item.getInfoId() > 0) + .collect(Collectors.toList()); + Map> groupByUpdate = hasInfoIdHotelInfo + .stream().collect(Collectors.groupingBy(OrgInfoHotelEntity::getUpdate)); + + List updateInfo = groupByUpdate.get("true"); + List insertInfo = groupByUpdate.get("false"); + if (updateInfo == null) { + updateInfo = new ArrayList<>(); + } + if (insertInfo == null) { + insertInfo = new ArrayList<>(); + } + List insertSqlArgs = new ArrayList<>(); + insertInfo.forEach(item -> { + 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 updateDetachDetailList = new ArrayList<>(); + List 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 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 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))); - } - } + insertDetachDetailList.add(orgInfoHotelEntity); + } + } + insertSqlArgs.clear(); + insertDetachDetailList.forEach(item -> { + 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 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 idList = mapper.selectBrotherDeptIds(supportCenterDeptId); - Integer infoId = mapper.selectInfoIdByCnTitle("支持中心分权查看"); - - if (null == infoId || infoId < 0) { + List idList = mapper.selectBrotherDeptIds(supportCenterDeptId); + Integer infoId = mapper.selectInfoIdByCnTitle("支持中心分权查看"); + + 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 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 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); - } - } - - 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) { + 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(); + } + + /** + * 插入信息表数据 + * + * @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"); + } + } + + } diff --git a/src/test/java/youhong/ai/yihong/YiHongTest.java b/src/test/java/youhong/ai/yihong/YiHongTest.java index 30e826a..3d049b3 100644 --- a/src/test/java/youhong/ai/yihong/YiHongTest.java +++ b/src/test/java/youhong/ai/yihong/YiHongTest.java @@ -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 ihgTaskElementConfigItems = mapper.selectConfig(); + System.out.println(JSON.toJSONString(ihgTaskElementConfigItems)); + } }