diff --git a/aiyh/utils/Util.java b/aiyh/utils/Util.java index 5bd0543..595c8c3 100644 --- a/aiyh/utils/Util.java +++ b/aiyh/utils/Util.java @@ -5,6 +5,7 @@ import aiyh.utils.entity.AInputStream; import aiyh.utils.entity.AZipOutputStream; import aiyh.utils.entity.ApiConfigMainDTO; import aiyh.utils.entity.ListZipEntity; +import aiyh.utils.fileUtil.ProperUtil; import aiyh.utils.mapUtil.UtilHashMap; import aiyh.utils.mapUtil.UtilLinkedHashMap; import aiyh.utils.service.UtilService; @@ -1041,6 +1042,203 @@ public class Util extends weaver.general.Util { return map; } + /** + * 根据配置文件文件名以及前缀获取对应的配置文件信息 + * @param fileName + * @param prefix + * @return + */ + public static Map readProperties2Map(String fileName, String prefix) { + String propertyPath = GCONST.getPropertyPath(); + if (StringUtil.isNullOrEmpty(fileName)) { + return null; + } + if (fileName.contains(".properties")) { + fileName.replace(".properties", ""); + } + String path = propertyPath + "prop2map" + File.separator + fileName + ".properties"; + ProperUtil prop = new ProperUtil(); + Map map = new HashMap<>(); + InputStream inputStream = null; + try { + inputStream = new BufferedInputStream(new FileInputStream(path)); + prop.load(inputStream); +// Enumeration enumeration = prop.propertyNames(); +// 顺序读取 + Enumeration enumeration = prop.keys(); + while (enumeration.hasMoreElements()) { + String key = (String) enumeration.nextElement(); + String value = prop.getProperty(key); + keyHandler(prefix, key, value, map); + } + } catch (IOException e) { + throw new RuntimeException("找不到文件:" + path); + } finally { + try { + if (inputStream != null) { + inputStream.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return map; + } + + + /** + * 处理配置文件的key和value映射关系 + * @param prePrefix 前缀 + * @param key key + * @param value value + * @param preResult 结果对象 + * @return + */ + public static Map keyHandler(String prePrefix, String key, Object value, Map preResult) { + String objRegex = "^(" + prePrefix + "\\.)(?(\\w+))$"; + Pattern compile = Pattern.compile(objRegex); + Matcher matcher = compile.matcher(key); + if (matcher.find()) { +// 只匹配前缀.key=value模式的 + String resultKey = matcher.group("key"); + preResult.put(resultKey, prop2MapPutValue(value)); + } + String moreKey = "^(" + prePrefix + "\\.)(?(?(\\w+))\\.(\\S)+(?!\\[))"; + compile = Pattern.compile(moreKey); + matcher = compile.matcher(key); + if (matcher.find()) { +// 匹配前缀.key1.key2=value模式的 + String objKey = matcher.group("objKey"); + String prefixStr = prePrefix + "." + objKey; + Map valueMap; + if (preResult.containsKey(objKey)) { + valueMap = (Map) preResult.get(objKey); + keyHandler(prefixStr, key, value, valueMap); + return null; + } + valueMap = new HashMap<>(); + keyHandler(prefixStr, key, value, valueMap); + preResult.put(objKey, valueMap); + return null; + } + String strList = "^(" + prePrefix + "\\.)(?(\\w+))(\\[(?([0-9])+)])$"; + compile = Pattern.compile(strList); + matcher = compile.matcher(key); + if (matcher.find()) { +// 匹配前缀.key[0]=value模式的 + String objKey = matcher.group("key"); + int index = Integer.parseInt(matcher.group("index")); + if (preResult.containsKey(objKey)) { +// 存在值 + List valueList = (List) preResult.get(objKey); + if (index >= valueList.size()) { + valueList.add(prop2MapPutValue(value)); + } else { + valueList.set(index, prop2MapPutValue(value)); + } + return null; + } + List valueList = new ArrayList<>(); + valueList.add(prop2MapPutValue(value)); + preResult.put(objKey, valueList); + return null; + } + String objArray = "^(" + prePrefix + "\\.)(?(\\w+))(\\[(?([0-9])+)])\\.(?(\\S)+)$"; +// String objArray = "^("+prePrefix+"\\.)(?(\\w+))(\\[(?([0-9])+)])(\\.(?(\\S)+))+"; + compile = Pattern.compile(objArray); + matcher = compile.matcher(key); + if (matcher.find()) { +// 匹配前缀.key[0].name=value的模式 + String arrKey = matcher.group("arrKey"); + String objKey = matcher.group("objKey"); + int index = Integer.parseInt(matcher.group("index")); + List> mapList; + if (preResult.containsKey(arrKey)) { +// 存在 + mapList = (List>) preResult.get(arrKey); +// mapList + Map valueMap; + if (index >= mapList.size()) { + valueMap = new HashMap<>(); + valueMap.put(objKey, prop2MapPutValue(value)); + mapList.add(valueMap); + return null; + } + valueMap = mapList.get(index); + String arrMoreKey = "(?(\\w+))\\.(\\S)+(?!\\[)"; + Pattern arrMoreKeyCompile = Pattern.compile(arrMoreKey); + Matcher arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey); + if (arrMoreKeyMatcher.find()) { + String arrMoreObjKey = arrMoreKeyMatcher.group("key"); + Map arrMoreValue; + if (valueMap.containsKey(arrMoreObjKey)) { + arrMoreValue = (Map) valueMap.get(arrMoreObjKey); + keyHandler(arrMoreObjKey, objKey, value, arrMoreValue); + return null; + } + arrMoreValue = new HashMap<>(); + keyHandler(arrMoreObjKey, objKey, value, arrMoreValue); + valueMap.put(arrMoreObjKey, arrMoreValue); + return null; + } + arrMoreKey = "(?(\\w+))(\\[(?([0-9])+)])$"; + arrMoreKeyCompile = Pattern.compile(arrMoreKey); + arrMoreKeyMatcher = arrMoreKeyCompile.matcher(objKey); + if (arrMoreKeyMatcher.find()) { + String arrMoreArrKey = arrMoreKeyMatcher.group("key"); + int arrMoreIndex = Integer.parseInt(arrMoreKeyMatcher.group("index")); + List arrMoreListValue; + if (valueMap.containsKey(arrMoreArrKey)) { +// 存在值 + arrMoreListValue = (List) valueMap.get(arrMoreArrKey); + if (arrMoreIndex >= arrMoreListValue.size()) { + arrMoreListValue.add(prop2MapPutValue(value)); + } else { + arrMoreListValue.set(arrMoreIndex, prop2MapPutValue(value)); + } + return null; + } + arrMoreListValue = new ArrayList<>(); + arrMoreListValue.add(prop2MapPutValue(value)); + valueMap.put(arrMoreArrKey, arrMoreListValue); + return null; + } + +// 直接添加 + valueMap.put(objKey, prop2MapPutValue(value)); + return null; + } +// 不存在 + mapList = new ArrayList<>(); + Map valueMap = new HashMap<>(); + valueMap.put(objKey, prop2MapPutValue(value)); + mapList.add(valueMap); + preResult.put(arrKey, mapList); + } + return null; + } + + public static Object prop2MapPutValue(Object value) { + if(value == null){ + return null; + } + String valueStr = String.valueOf(value).trim(); + if (valueStr.startsWith("\"") && valueStr.endsWith("\"")) { + return valueStr.substring(1, valueStr.length() - 1); + } + if (valueStr.contains(",")) { + if(valueStr.contains("\\,")){ + String[] split = valueStr.split("(? getProperties2Map(String fileName, String prefix) { String propertyPath = GCONST.getPropertyPath(); if (StringUtil.isNullOrEmpty(fileName)) { @@ -1414,7 +1613,7 @@ public class Util extends weaver.general.Util { if(StringUtils.isNullOrEmpty(objStr) && !StringUtils.isNullOrEmpty(defaultStr)){ return defaultStr; } - return ""; + return objStr; } diff --git a/aiyh/utils/fileUtil/ProperUtil.java b/aiyh/utils/fileUtil/ProperUtil.java new file mode 100644 index 0000000..5448d07 --- /dev/null +++ b/aiyh/utils/fileUtil/ProperUtil.java @@ -0,0 +1,55 @@ +package aiyh.utils.fileUtil; + +import java.util.*; + +/** + * @author EBU7-dev1-ayh + * @create 2021/11/29 0029 13:53 + */ + + +public class ProperUtil extends Properties { + //LinkedHashSet有序,可以保证读取出来顺序不变 + private final LinkedHashSet keys = new LinkedHashSet<>(); + + /** + * 读取key集合 + */ + @Override + public Set stringPropertyNames() { + Set set = new LinkedHashSet<>(); + for (Object key : keys) { + set.add((String) key); + } + return set; + } + + @Override + public Set keySet() { + return keys; + } + + /** + * 枚举可以直接进行遍历,但是和iterator一样,遍历过程中不能进行修改删除等操作 + * 若要在遍历过程中进行修改擦除等操作,建议使用stringPropertyNames方法 + */ + @Override + public synchronized Enumeration keys() { + return Collections.enumeration(keys); + } + + @Override + public synchronized Object put(Object key, Object value) { + keys.add(key); + return super.put(key, value); + } + + /** + * 若要移除元素,要重写remove方法 + */ + @Override + public Object remove(Object o) { + keys.remove(o); + return super.remove(o); + } +} diff --git a/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java b/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java index 39ba7ab..d7b6f85 100644 --- a/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java +++ b/com/api/aiy_changeStatus/Impl/ChangeStatusImpl.java @@ -41,6 +41,11 @@ public class ChangeStatusImpl { ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "id", 2); } + @WeaReplaceBefore(value = "/api/hrm/forgotPassword/saveResetPassword", order = 1, description = "重置密码") + public void saveResetPasswordBefore(WeaBeforeReplaceParam weaBeforeReplaceParam) { + ChangeStatusUtil.changeHrmResourceStatus(weaBeforeReplaceParam, "id", 2); + } + /** * 批量数据修改,数据类型为数组 * diff --git a/com/api/aiyh_guijiu/service/WorkflowQueueService.java b/com/api/aiyh_guijiu/service/WorkflowQueueService.java index cc8c2dd..30b53cd 100644 --- a/com/api/aiyh_guijiu/service/WorkflowQueueService.java +++ b/com/api/aiyh_guijiu/service/WorkflowQueueService.java @@ -360,21 +360,22 @@ public class WorkflowQueueService { String isAppend = param.get("isAppend"); // String sourceField = param.get("sourceField"); String requestId = param.get("requestId"); + String oldFileIds = param.get("oldFileIds"); if ("true".equals(isWrite)) { if ("true".equals(isAppend)) { // // 查询原字段是否存在图片 - String queryStr = ""; - try { - queryStr = "select " + fieldName + " from " + tableName + " where requestid = ?"; - rs.executeQuery(queryStr, requestId); - rs.next(); - String oldImg = Util.null2String(rs.getString(1)); - if (!StringUtils.isNullOrEmpty(oldImg)) { - newDocIds.append(",").append(oldImg); - } - }catch (Exception e){ - toolUtil.writeErrorLog("查询错误:" + queryStr); - } +// String queryStr = ""; +// try { +// queryStr = "select " + fieldName + " from " + tableName + " where requestid = ?"; +// rs.executeQuery(queryStr, requestId); +// rs.next(); +// String oldImg = Util.null2String(rs.getString(1)); +// if (!StringUtils.isNullOrEmpty(oldImg)) { + newDocIds.append(",").append(oldFileIds); +// } +// }catch (Exception e){ +// toolUtil.writeErrorLog("查询错误:" + queryStr); +// } } if ("0".equals(isSaveResource)) { // 不保存原来的图片 diff --git a/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java b/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java index 5e1c9d0..887bb73 100644 --- a/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java +++ b/com/api/aiyh_pcn/patentWall/controller/PatentWallController.java @@ -1,14 +1,20 @@ package com.api.aiyh_pcn.patentWall.controller; import aiyh.utils.ApiResult; +import aiyh.utils.Util; import com.api.aiyh_pcn.patentWall.dto.FilterWhere; import com.api.aiyh_pcn.patentWall.service.PatentWallService; import com.api.aiyh_pcn.patentWall.vo.PatentVO; +import com.api.aiyh_pcn.patentWall.vo.SearchInputVO; import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; import java.util.List; import java.util.Map; @@ -23,17 +29,32 @@ import java.util.Map; public class PatentWallController { private final PatentWallService patentWallService = new PatentWallService(); - @Path("/getList") + @Path("/getSearchList/{prefix}") + @GET + @Produces(MediaType.APPLICATION_JSON) + public String getPatentList(@Context HttpServletRequest request, @Context HttpServletResponse response, + @PathParam("prefix") String prefix){ + User user = HrmUserVarify.getUser(request, response); + int languageId = user.getLanguage(); + List result = patentWallService.getSearchList(prefix,languageId); + return ApiResult.success(result); + } + + @Path("/getList/{prefix}") @POST - public String getPatentList(@RequestBody List filterWheres){ - List result = patentWallService.getList(filterWheres); + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public String getPatentList(@RequestBody List filterWheres, @PathParam("prefix") String prefix){ + List result = patentWallService.getList(filterWheres,prefix); return ApiResult.success(result); } @Path("/clearConf") @GET + @Produces(MediaType.APPLICATION_JSON) public String clearPatentWallConf(){ patentWallService.clearPatentWallConf(); + patentWallService.clearPatentWallSerachConf(); return ApiResult.success("清除配置缓存成功!"); } } diff --git a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java index dda24be..b513683 100644 --- a/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java +++ b/com/api/aiyh_pcn/patentWall/dao/PatentWallMapping.java @@ -25,63 +25,25 @@ public class PatentWallMapping { rs.executeQuery(query); return Util.recordSet2MapList(rs); } - public List> getListByFilterWhere(List filterWheres, String tableName) { - StringBuilder whereBuilder = new StringBuilder(" where "); - List args = new ArrayList<>(); - for (FilterWhere filterWhere : filterWheres) { - whereBuilder.append(" add "); - if(filterWhere.getType() == 1){ -// 等于 - whereBuilder.append(filterWhere.getDbField()) - .append(" = ? "); - args.add(filterWhere.getValue()); - continue; - } - if(filterWhere.getType() == 2){ -// 大于 - whereBuilder.append(filterWhere.getDbField()) - .append(" > ?"); - args.add(filterWhere.getValue()); - continue; - } - if(filterWhere.getType() == 3){ -// 小于 - whereBuilder.append(filterWhere.getDbField()) - .append(" < ?"); - args.add(filterWhere.getValue()); - continue; - } - if(filterWhere.getType() == 4){ -// in - whereBuilder.append(filterWhere.getDbField()) - .append(" in ( ") - .append(filterWhere.getValue()) - .append(") "); - continue; - } - if(filterWhere.getType() == 5){ -// 日期大于 - whereBuilder.append(" DATE_FORMAT(") - .append(filterWhere.getDbField()) - .append(",'%y-%m-%d') > ") - .append("DATE_FORMAT(?,'%y-%m-%d')"); - args.add(filterWhere.getValue()); - continue; - } - if(filterWhere.getType() == 6){ -// 日期小于 - whereBuilder.append(" DATE_FORMAT(") - .append(filterWhere.getDbField()) - .append(",'%y-%m-%d') < ") - .append("DATE_FORMAT(?,'%y-%m-%d')"); - args.add(filterWhere.getValue()); - continue; - } - } + + public List> getListByFilterWhere(StringBuilder whereBuilder,List args, String tableName) { RecordSet rs = new RecordSet(); String query = "select * from " + tableName + whereBuilder.toString().replace(" where add "," where "); rs.executeQuery(query,args); toolUtil.writeDebuggerLog(String.format("执行SQL: {%s} ---> 参数: {%s}",query,args)); return Util.recordSet2MapList(rs); } + + public List> getSelectOptions(String dataResource, String dbFieldName) { + RecordSet rs = new RecordSet(); + String query = "select wbf.id,wbf.fieldname,wbf.fieldlabel,wb.tablename, " + + "ws.selectname,ws.selectvalue " + + "from workflow_billfield wbf " + + "left join workflow_bill wb on wbf.billid = wb.id " + + "left join workflow_selectitem ws on ws.fieldid = wbf.id " + + "where wb.tablename = ? and fieldname = ? "; + rs.executeQuery(query,dataResource,dbFieldName); + toolUtil.writeDebuggerLog(String.format("执行SQL: {%s} ---> 参数: {%s}",query,dataResource + " -- " + dbFieldName)); + return Util.recordSet2MapList(rs); + } } diff --git a/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java b/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java index 16ce5f2..2373ab2 100644 --- a/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java +++ b/com/api/aiyh_pcn/patentWall/dto/FilterWhere.java @@ -14,7 +14,7 @@ import lombok.ToString; @Getter @ToString public class FilterWhere { - private int type; + private int searchType; private String dbField; private String value; } diff --git a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java index d4fa7f8..76fe25c 100644 --- a/com/api/aiyh_pcn/patentWall/service/PatentWallService.java +++ b/com/api/aiyh_pcn/patentWall/service/PatentWallService.java @@ -2,9 +2,12 @@ package com.api.aiyh_pcn.patentWall.service; import aiyh.utils.Util; import aiyh.utils.zwl.common.ToolUtil; +import com.alibaba.fastjson.JSON; import com.api.aiyh_pcn.patentWall.dao.PatentWallMapping; import com.api.aiyh_pcn.patentWall.dto.FilterWhere; import com.api.aiyh_pcn.patentWall.vo.PatentVO; +import com.api.aiyh_pcn.patentWall.vo.SearchInputVO; +import com.api.aiyh_pcn.patentWall.vo.SelectOptionsVo; import weaver.conn.RecordSet; import java.util.ArrayList; @@ -24,60 +27,159 @@ public class PatentWallService { private final PatentWallMapping patentWallMapping = new PatentWallMapping(); private final ToolUtil toolUtil = new ToolUtil(); private Map patentWallConf; + private Map patentWallSearchConf; + private final RecordSet rs = new RecordSet(); - public List getList(List filterWheres) { - Map patentWallConf = getPatentWallConf(); + + /** + * 查询搜索框配置信息 + * + * @param prefix 前缀 + * @return 配置信息 + */ + public List getSearchList(String prefix,int languageId) { + Map patentWallSearchConf = getPatentWallSearchConf(prefix + ".search"); + String dataResource = String.valueOf(patentWallSearchConf.get("dataResource")); + List> inputs = (List>) patentWallSearchConf.get("inputs"); + List searchInputList = new ArrayList<>(); + for (Map input : inputs) { + SearchInputVO searchInputVO = new SearchInputVO(); + int type = Integer.parseInt(Util.null2DefaultStr(input.get("type"), "0")); + String dbFieldName = Util.null2String(input.get("dbFieldName")); + String value = Util.null2String(input.get("value")); + String labelName = Util.null2String(input.get("labelName")); + Integer labelIndex = Integer.valueOf(Util.null2DefaultStr(input.get("labelIndex"),"0")); + Integer searchType = Integer.valueOf(Util.null2DefaultStr(input.get("searchType"),"0")); + Boolean multiple = Boolean.valueOf(Util.null2DefaultStr(input.get("multiple"),"false")); + searchInputVO.setType(type); + searchInputVO.setLabelName(labelName); + searchInputVO.setSearchType(searchType); + searchInputVO.setDbFieldName(dbFieldName); + searchInputVO.setLabelIndex(labelIndex); + searchInputVO.setLabelIndex(labelIndex); + searchInputVO.setMultiple(multiple); + searchInputVO.setValue(value); + searchInputList.add(searchInputVO); + switch (type) { + case 1: +// 下拉框 查询options + List optionsVos = getSelectOptions(dataResource, dbFieldName,languageId); + searchInputVO.setSelectOptions(optionsVos); + case 2: +// 单行文本 + break; + case 3: +// 日期 + case 4: +// 单人力资源 + break; + case 5: +// 多人力资源 + break; + case 6: +// 流程路径 + break; + case 7: +// 多流程路径 + break; + default: + toolUtil.writeDebuggerLog("未匹配输入框类型!请检查配置文件是否正确!"); + break; + } + } + return searchInputList; + } + + private List getSelectOptions(String dataResource, String dbFieldName, int languageId) { + List> selectOptions = patentWallMapping.getSelectOptions(dataResource, dbFieldName); + List optionsVos = new ArrayList<>(); + SelectOptionsVo optionsDefault = new SelectOptionsVo(); + optionsDefault.setSelected(true); + optionsDefault.setKey(""); + optionsDefault.setShowname(""); + optionsVos.add(optionsDefault); + for (Map selectOption : selectOptions) { + SelectOptionsVo optionsVo = new SelectOptionsVo(); + optionsVo.setSelected(false); + optionsVo.setKey(Util.null2DefaultStr(selectOption.get("selectvalue"),"")); + String selectName = Util.null2DefaultStr(selectOption.get("selectname"), ""); + String showName = selectName; + if (selectName.startsWith("~`~`") && selectName.endsWith("`~`~")) { + String pattern = "(`~`" + languageId + " )(?