From 4470052c3b6bdeb18e45987f8aa293d1e93d0552 Mon Sep 17 00:00:00 2001
From: Ludc <2870569285@qq.com>
Date: 星期二, 18 十一月 2025 11:59:12 +0800
Subject: [PATCH] 所有文件上传接口增加文件安全校验逻辑。
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 350 ++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 220 insertions(+), 130 deletions(-)
diff --git a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
index 8c7b56b..6850502 100644
--- a/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java
@@ -1,11 +1,14 @@
package com.vci.ubcs.code.service.impl;
+import cn.hutool.db.sql.Query;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.vci.ubcs.code.applyjtcodeservice.entity.DockingPreMetaAttr;
import com.vci.ubcs.code.applyjtcodeservice.vo.BaseModelVO;
import com.vci.ubcs.code.bo.CodeClassifyFullInfoBO;
import com.vci.ubcs.code.bo.CodeTemplateAttrSqlBO;
@@ -147,6 +150,7 @@
*/
@Value("${bzApply.seriesFlow:seriesFlow}")
private String seriesFlow;
+
/***
* 鏄惁鍙樻洿绯诲垪
*/
@@ -175,6 +179,11 @@
*/
@Resource
private MdmProductCodeService productCodeService;
+
+ /**
+ * 杩戜箟璇嶈鍒欐煡璇㈡湇鍔�
+ */
+ @Autowired ICodeSynonymService codeSynonymService;
/**
* 鍙緭鍙�夌殑鏈嶅姟
@@ -253,8 +262,9 @@
*/
@Autowired
private ICodeRuleService ruleService;
+
/**
- * 缂栫爜瑙勫垯鐨勬湇鍔�
+ * 鐮佸�肩殑鏈嶅姟
*/
@Autowired
private ICodeAllCodeService codeAllCodeService;
@@ -310,6 +320,12 @@
public static final String BTM_NAME = "btm:name";
/**
+ * 閰嶇疆鐨勭敤鏉ョ敵璇烽泦鍥㈢爜鐨勭敤鎴�
+ */
+ @Value("${docking.apply.personUserAccount:28201728}")
+ public String applyCodeUserAccount;
+
+ /**
* 瀵嗙骇鐨勫瓧娈�
*/
public static final String SECRET_FILED = "secretgrade";
@@ -358,7 +374,6 @@
*/
@Autowired
private SaveLogUtil saveLogUtil;
-
/**
* 浣跨敤鍒嗙被鐨勪富閿幏鍙栧彲浠ヤ娇鐢ㄧ殑妯℃澘瀵硅薄
@@ -423,16 +438,23 @@
try {
VciBaseUtil.alertNotNull(baseModelDTO, "鏁版嵁淇℃伅", baseModelDTO.getOid(), "涓婚敭", baseModelDTO.getBtmname(), "涓氬姟绫诲瀷", baseModelDTO.getLcStatus(), "鐩爣鐘舵��");
List<String> oids = VciBaseUtil.str2List(baseModelDTO.getOid());
- List<BaseModel> baseModels = new ArrayList<>();
- baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
+ List<BaseModel> baseModels = selectByTypeAndOid(baseModelDTO.getBtmname(), baseModelDTO.getOid());
if (baseModels.size() == 0) {
throw new VciBaseException("鏈煡璇㈠埌鐩稿叧鏁版嵁銆�");
}
//杩橀渶瑕佷慨鏀筧llCode鐨勭敓鍛藉懆鏈�
- QueryWrapper<CodeAllCode> allCodeWrapper = new QueryWrapper<>();
- allCodeWrapper.eq("createcodebtm", baseModelDTO.getBtmname());
- allCodeWrapper.in("createcodeoid", oids);
- List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);// 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄�
+ LambdaQueryWrapper<CodeAllCode> allCodeWrapper = Wrappers.<CodeAllCode>query().lambda();
+ allCodeWrapper.eq(CodeAllCode::getCreateCodeBtm, baseModelDTO.getBtmname());
+ allCodeWrapper.in(CodeAllCode::getCreateCodeOid, oids);
+
+ List<CodeAllCode> codeCbos = codeAllCodeService.selectByWrapper(allCodeWrapper);
+ if(codeCbos.size() != baseModels.size()){
+ throw new ServiceException("褰撳墠鍥炴敹鎿嶄綔涓煡璇㈠嚭鐨勪笟鍔℃暟鎹腑锛屽瓨鍦ㄥ鏉$爜鍊兼暟鎹搴斿叧绯伙紝璇疯仈绯诲紑鍙戜汉鍛樺鏁版嵁杩涜鎺掓煡澶勭悊锛侊紒");
+ }
+ //杞负map鍚庣画鍙栫殑鏃跺�欐柟渚�
+ Map<String, BaseModel> baseModelMap = baseModels.stream().collect(Collectors.toMap(BaseModel::getId, baseModel -> baseModel));
+
+ // 鍥炴敹闇�瑕佷笟鍔℃暟鎹垹闄�
if (CodeDefaultLC.TASK_BACK.getValue().equals(baseModelDTO.getLcStatus())) {
R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(baseModelDTO.getBtmname()));
if (!listR.isSuccess() || listR.getData().size() == 0) {
@@ -447,16 +469,17 @@
}
R r = updateBatchByBaseModel(baseModelDTO.getBtmname(), baseModels);
if (!r.isSuccess()) {
- throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岄噸璇曪紒" + r.getMsg());
+ throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岃閲嶈瘯锛�" + r.getMsg());
}
}
// 鍒氬ソ椤哄簭鏄竴鑷寸殑锛屾墍浠ョ洿鎺ユ寜鐓odeallcode鐨勯『搴忔潵鎷夸笟鍔℃暟鎹�
- int i = -1;
+ BaseModel baseModel = null;
for (CodeAllCode codeCbo : codeCbos) {
codeCbo.setLcStatus(baseModelDTO.getLcStatus());
// 濡傛灉鏄洖鏀讹紝灏遍渶瑕佸皢涓氬姟鏁版嵁瀛樺偍鍒扮爜鍊艰〃涓�
+ baseModel = baseModelMap.get(codeCbo.getId());
if (baseModelDTO.getLcStatus().equals(FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_TAKEBACK)) {
- codeCbo.setBusinessData(JSON.toJSONString(baseModels.get(++i)));
+ codeCbo.setBusinessData(JSON.toJSONString(baseModel));
}
}
codeAllCodeService.updateBatchById(codeCbos);
@@ -485,7 +508,7 @@
return addSaveCode(orderDTO, true);
}
- /***
+ /**
* 闆嗘垚鍙彉鐮佹鐢宠鎺ュ彛
* @param orderDTO 鐢宠鐨勪俊鎭紝闇�瑕佸寘鍚睘鎬х殑鍐呭鍜岀爜娈电浉鍏崇殑鍐呭
* @return
@@ -756,27 +779,36 @@
//娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗
//鑾峰彇鎵�鏈夌殑鍏抽敭灞炴��
Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+ // TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯
+ Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+ // 鑾峰彇鏄惁鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴��
+ Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
+ if(!sysonymAttrMaps.isEmpty()){
+ // 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛�
+ codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
+ }
Map<String, String> conditionMap = new HashMap<>();
boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
//鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖
boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag());
boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag());
+ Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
ketAttrMap.forEach((attrId, attrVO) -> {
String value = getValueFromOrderDTO(orderDTO, attrId);
if (value == null) {
value = "";
}
- wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
+ wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
});
//娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙�
if (!CollectionUtils.isEmpty(conditionMap)) {
// TODO: 鍚屼竴涓簱鍒ら噸涓嶉渶瑕佸尯鍒嗗垎绫籵id
// conditionMap.put("CODETEMPLATEOID","'" + orderDTO.getTemplateOid() + "'");
-// final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
+ // final String[] sql = {"select count(*) from " + VciBaseUtil.getTableName(classifyFullInfo.getTopClassifyVO().getBtmtypeid()) + " t where 1 = 1 "};
R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Collections.singletonList(classifyFullInfo.getTopClassifyVO().getBtmTypeId()));
-// String referTable = VciBaseUtil.getTableName(referVO.getReferType());
+ // String referTable = VciBaseUtil.getTableName(referVO.getReferType());
if (!listR.isSuccess() || listR.getData().size() == 0) {
throw new VciBaseException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
}
@@ -801,7 +833,7 @@
if (Func.isNotEmpty(isParticipateCheckOids)) {
sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
}
-// if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
+ // if (boService.queryCountBySql(sql[0], new HashMap<>()) > 0) {
List<String> repeatData = commonsMapper.selectList(sql[0]);
if (!repeatData.isEmpty()) {
String ruleInfoMsg = keyRuleVO == null ? "" : "鏌ヨ瑙勫垯锛氬幓闄ょ┖鏍�--{0},蹇界暐澶у皬鍐�--{1},蹇界暐鍏ㄥ崐瑙�--{2},蹇界暐鍏ㄩ儴绌烘牸--{3}";
@@ -826,18 +858,27 @@
//娉ㄦ剰鐨勬槸keyRuleVO鍙兘涓虹┖锛岃〃绀轰笉浣跨敤瑙勫垯鎺у埗
//鑾峰彇鎵�鏈夌殑鍏抽敭灞炴��
Map<String, CodeClassifyTemplateAttrVO> ketAttrMap = templateVO.getAttributes().stream().filter(s -> VciBaseUtil.getBoolean(s.getKeyAttrFlag())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+ // TODO:2024-02-01 鍏堣幏鍙栭厤缃簡杩戜箟璇嶆煡璇㈣鍒欑殑灞炴�э紝涓嶅悓浜庡叧閿睘鎬э紝璁剧疆浜嗚繎涔夎瘝鏌ヨ瑙勫垯鐨勫睘鎬у彲鑳芥槸澶氭潯涓嶅悓鐨勮繎涔夎瘝鏌ヨ瑙勫垯
+ Map<String, CodeClassifyTemplateAttrVO> sysonymAttrMaps = templateVO.getAttributes().stream().filter(item -> Func.isNotBlank(item.getSysonymRuleOids())).collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+ // 鑾峰彇鏄惁鏈夐厤缃繎涔夎瘝鏌ヨ瑙勫垯灞炴��
+ Map<String, List<CodeSynonym>> codeSynonymMaps = new HashMap<>();
+ if(!sysonymAttrMaps.isEmpty()){
+ // 鏌ヨ杩戜箟璇嶈鍒欙紝瀛樺偍鏂瑰紡key锛氬睘鎬d锛寁alue杩戜箟璇嶆煡璇㈣鍒欏垪琛�
+ codeSynonymMaps = codeSynonymService.getCodeSynonymByOids(sysonymAttrMaps);
+ }
Map<String, String> conditionMap = new HashMap<>();
boolean trimAll = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnoreallspaceflag());
//鍏ㄩ儴鍘荤┖鐨勪紭鍏堢骇澶т簬鍘荤┖
boolean trim = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorespaceflag());
boolean ignoreCase = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorecaseflag());
boolean ignoreWidth = keyRuleVO == null ? false : VciBaseUtil.getBoolean(keyRuleVO.getIgnorewidthflag());
+ Map<String, List<CodeSynonym>> finalCodeSynonymMaps = codeSynonymMaps;
ketAttrMap.forEach((attrId, attrVO) -> {
String value = getValueFromOrderDTO(orderDTO, attrId);
if (value == null) {
value = "";
}
- wrapperKeyAttrConditionMap(value, keyRuleVO, attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
+ wrapperKeyAttrConditionMap(value, keyRuleVO, finalCodeSynonymMaps.get(attrId), attrId, trim, ignoreCase, ignoreWidth, trimAll, conditionMap);
});
//娌℃湁闄愬埗鍒嗙被锛屼絾鏄竴涓ā鏉垮彧鍙兘鍦ㄤ竴涓笟鍔$被鍨嬮噷闈紝鎵�浠ョ洿鎺ユ煡璇㈣繖涓笟鍔$被鍨嬪嵆鍙�
@@ -928,7 +969,7 @@
}
//鏄惁绯诲垪
if (!codeBZApplyDTO.isSeries()) {
- boolean isSeriesValue = codeBZApplyDTO.getData().get(isSeries).equals("true") ? true : false;
+ boolean isSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isSeries));
codeBZApplyDTO.setSeries(isSeriesValue);
}
//鍘熸爣鍑嗗彿
@@ -948,7 +989,7 @@
}
//鏄惁鍙樻洿绯诲垪
if (!codeBZApplyDTO.isEditSeries()) {
- boolean isEditSeriesValue = codeBZApplyDTO.getData().get(isEditSeries).equals("true") ? true : false;
+ boolean isEditSeriesValue = Func.toBoolean(codeBZApplyDTO.getData().get(isEditSeries));
codeBZApplyDTO.setEditSeries(isEditSeriesValue);
}
VciBaseUtil.alertNotNull(codeBZApplyDTO.getOperationType(), "鎿嶄綔绫诲瀷",
@@ -966,7 +1007,7 @@
} else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_DISABLE.getValue())) {//浣滃簾
code = amendmentDataBZ(codeBZApplyDTO, authUser);
createChangeOder(code, codeBZApplyDTO, authUser);
- } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_AMENDMENT.getValue())) {//澶囨煡
+ } else if (codeBZApplyDTO.getOperationType().equals(CodeBZOperationTypeEnum.CODE_BZ_FOR_REFERENCE.getValue())) {//澶囨煡
code = amendmentDataBZ(codeBZApplyDTO, authUser);
createChangeOder(code, codeBZApplyDTO, authUser);
}
@@ -1236,14 +1277,18 @@
* @param conditionMap 鏌ヨ鏉′欢
*/
@Override
- public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO, String attrId,
+ public void wrapperKeyAttrConditionMap(String value, CodeKeyAttrRepeatVO keyRuleVO,
+ List<CodeSynonym> codeSynonymMaps, String attrId,
boolean trim, boolean ignoreCase, boolean ignoreWidth,
boolean trimAll, Map<String, String> conditionMap) {
boolean ignoreSpace = trim || trimAll;
if (StringUtils.isBlank(value)) {
- //涓虹┖鐨勬椂鍊欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜�
+ //鍊间负绌虹殑鏃跺�欙紝涓嶈兘鐢≦ueryOperation.ISNULL锛屽钩鍙颁笉鐭ラ亾鍟ユ椂鍊欎笉澶勭悊杩欑浜�
conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
} else {
+ //杩戜箟璇嶆煡璇㈣鍒檝alu鍊艰浆鎹�
+ value = this.getValueToSynony(codeSynonymMaps, value);
+
if (keyRuleVO != null) {
String queryKey = "";
String queryValue = "";
@@ -1279,13 +1324,30 @@
conditionMap.put(queryKey, queryValue);
} else {
if (StringUtils.isNotBlank(value)) {
- //涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
+ //鍏抽敭灞炴�ф煡閲嶈鍒欎负绌虹殑鏃跺�欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
conditionMap.put("nvl(" + "t." + attrId + ",'/')", "'" + SpecialCharacterConverter.escapeSpecialCharacters(value) + "'");
} else {
conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
}
}
}
+ }
+
+ /**
+ * 杩戜箟璇嶆煡璇㈣鍒欒浆鎹�
+ * @param codeSynonymMaps
+ * @param value
+ * @return
+ */
+ public String getValueToSynony(/*杩戜箟璇嶆煡璇㈣鍒�*/List<CodeSynonym> codeSynonymMaps,String value){
+ // 鑾峰彇骞跺垽鏂槸鍚﹂厤缃簡杩戜箟璇嶆煡璇㈣鍒�
+ // TODO锛氳繎涔夎瘝鏇挎崲鎴愭簮鍊硷紙婧愬�兼槸姝g‘鐨勫�硷紝杩戜箟璇嶆槸鐩稿綋浜庤緭閿欑瑪璇殑瀛楃锛�
+ if(Func.isNotEmpty(codeSynonymMaps)){
+ for (int i = 0; i < codeSynonymMaps.size(); i++) {
+ value = value.replace(codeSynonymMaps.get(i).getSynonymValue(),codeSynonymMaps.get(i).getSourceValue());
+ }
+ }
+ return value;
}
/**
@@ -1510,7 +1572,6 @@
wrapperResemble(templateVO, uiInfoVO);
return uiInfoVO;
}
-
/**
* 妯℃澘灞炴�ц浆鎹负琛ㄥ崟瀹氫箟鐨勪俊鎭�
@@ -1948,7 +2009,7 @@
boolean ignoreCase = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
boolean ignoreWidth = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorewidthflag());
boolean trimAll = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
- boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnoreallspaceflag());
+ boolean trim = VciBaseUtil.getBoolean(resembleRuleVO.getIgnorecaseflag());
String temp = "";
if (ignoreCase && ignoreSpace && ignoreWidth) {
//蹇界暐澶у皬鍐欙紝涓斿幓绌猴紝蹇界暐鍏ㄥ崐瑙�
@@ -1982,7 +2043,7 @@
temp = "replace(" + temp + ",'" + s + "','')";
}
}
- queryValue = String.format(temp, (trim ? value.trim() : value));
+ queryValue = String.format(temp, (trim ? "'"+value.trim()+"'" : "'"+value+"'"));
temp = temp.replace("to_single_byte('%s')", "to_single_byte(%s)");
queryKey = String.format(temp, "t." + attrId);
conditionMap.put(queryKey, QueryOptionConstant.OR + queryValue);
@@ -2001,14 +2062,14 @@
@Override
public DataGrid<Map<String, String>> queryGrid(String btmType, CodeClassifyTemplateVO templateVO, Map<String, String> conditionMap, PageHelper pageHelper) {
CodeTemplateAttrSqlBO sqlBO = getSqlByTemplateVO(btmType, templateVO, conditionMap, pageHelper);
-// List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
+ // List<Map> maps = boService.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
List<Map<String, String>> maps = null;
try {
maps = commonsMapper.queryByOnlySqlForMap(sqlBO.getSqlHasPage());
} catch (Exception e) {
String errorMessage = e.getMessage();
if (errorMessage.contains("鏃犳硶瑙f瀽鐨勬垚鍛樿闂〃杈惧紡")) {
- throw new ServiceException("缂哄皯" + errorMessage.substring(errorMessage.indexOf("[t.") + 1, errorMessage.indexOf("]")) + "瀛楁");
+ throw new ServiceException("缂哄皯" + errorMessage.substring(errorMessage.indexOf("[T.") + 1, errorMessage.indexOf("]")) + "瀛楁");
}
throw new ServiceException(e.getMessage());
}
@@ -2021,39 +2082,39 @@
for (String s : map.keySet()) {
data.put(s.toLowerCase(Locale.ROOT), map.get(s) == null ? null : String.valueOf(map.get(s)));
}
-// map.forEach((key, value) -> {
-// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-// });
+ // map.forEach((key, value) -> {
+ // data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+ // });
dataList.add(data);
});
wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), false);
-// maps.stream().forEach(map -> {
-// Map<String, String> data = new HashMap<>();
-//// map.forEach((key, value) -> {
-//// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-//// });
-// for (String s : map.keySet()) {
-// data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
-// }
-// dataList.add(data);
-// });
+ // maps.stream().forEach(map -> {
+ // Map<String, String> data = new HashMap<>();
+ // map.forEach((key, value) -> {
+ // data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+ // });
+ // for (String s : map.keySet()) {
+ // data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
+ // }
+ // dataList.add(data);
+ // });
}
-// dataGrid.setData(dataList);
-// if (!CollectionUtils.isEmpty(maps)) {
-// wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
-// maps.stream().forEach(map -> {
-// Map<String, String> data = new HashMap<>();
-//// map.forEach((key, value) -> {
-//// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
-//// });
-// for (String s : map.keySet()) {
-// data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
-// }
-// dataList.add(data);
-// });
+ // dataGrid.setData(dataList);
+ // if (!CollectionUtils.isEmpty(maps)) {
+ // wrapperData(maps, templateVO, sqlBO.getSelectFieldList(), false);
+ // maps.stream().forEach(map -> {
+ // Map<String, String> data = new HashMap<>();
+ //// map.forEach((key, value) -> {
+ //// data.put(((String) key).toLowerCase(Locale.ROOT), String.valueOf(value));
+ //// });
+ // for (String s : map.keySet()) {
+ // data.put(((String) s).toLowerCase(Locale.ROOT), String.valueOf(map.get(s)));
+ // }
+ // dataList.add(data);
+ // });
dataGrid.setData(dataList);
dataGrid.setTotal(Long.parseLong(commonsMapper.selectBySql(sqlBO.getSqlCount()).get(0).values().toArray()[0].toString()));
-// }
+ // }
return dataGrid;
}
@@ -2130,7 +2191,7 @@
userVOMap.put(String.valueOf(data.getId()), data);
}
}
-// Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
+ // Map<String, SmUserVO> userVOMap = Optional.ofNullable(userQueryService.listUserByUserIds(userIds)).orElseGet(() -> new ArrayList<>()).stream().collect(Collectors.toMap(s -> s.getId().toLowerCase(Locale.ROOT), t -> t));
dataMap.stream().forEach(data -> {
String creator = data.getOrDefault("creator", null);
if (StringUtils.isNotBlank(creator) && userVOMap.containsKey(creator.toLowerCase(Locale.ROOT))) {
@@ -2143,7 +2204,6 @@
});
}
}
-
/**
* 澶勭悊鏃堕棿鏍煎紡
@@ -2171,7 +2231,6 @@
});
}
}
-
/**
* 澶勭悊鏋氫妇鐨勫唴瀹癸紝濡傛灉涓嶅湪鏋氫妇涓紝浼氳繑鍥炲師鏈殑鍊�
@@ -2522,8 +2581,19 @@
if (referFieldMap.containsKey(field)) {
return VciBaseUtil.toInSql(referFieldMap.get(field), value); //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
} else {
- return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
+ //TODO:鏆傛椂娌¤�冭檻IN>1000鏉$殑闂
+ //return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
+ return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
}
+ } else if (key.endsWith("_notin")) {
+ String field = UBCSSqlKeyword.getColumn(key, "_in");
+ if (referFieldMap.containsKey(field)) {
+ return VciBaseUtil.toInSql(referFieldMap.get(field), value); //referFieldMap.get(field) + SPACE + "= '" + value + "'" + SPACE;
+ } else {
+ //return (field.contains(".") ? "" : "t.") + field + SPACE + "not in (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
+ return (field.contains(".") ? "" : "t.") + field + SPACE + "IN (" + getStringValueInWhere(field, "IN//"+value, attrVOMap) + ")" + SPACE;
+ }
+
} else {
// if (referFieldMap.containsKey(key)) {
// //璇存槑鏄弬鐓х殑锛屾垜浠弬鐓х殑鏌ヨ閮借涓烘槸瀛楃涓诧紝濡傛灉鏄椂闂存牸寮忕殑鏌ヨ鑲畾鏈夐棶棰橈紝
@@ -2620,13 +2690,21 @@
|| VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
return value;
} else {
+ if(value.contains("IN//")){
+ return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
+ }
return "'" + value + "'";
}
} else {
if ((value.startsWith("(") && value.endsWith(")")) || (value.startsWith("'") && value.endsWith("'"))) {
return value;
+ }else if(value.contains("IN//")){
+ //鏆傛椂涓嶈�冭檻>1000鐨勬儏鍐碉紝鍥犱负鎼滅储涓�鑸篃涓嶄細鍑虹幇鎼滅储1000鏉$殑鎯呭喌
+ //return MybatisParameterUtil.convertToOrConditions(field, Func.toStrList(value.replace("IN//","")));
+ return MybatisParameterUtil.getInClause(Func.toStrList(value.replace("IN//","")));
+ }else{
+ return "'" + value + "'";
}
- return "'" + value + "'";
}
}
@@ -2965,7 +3043,7 @@
conditionMap = new HashMap<>();
}
pageHelper.addDefaultDesc("createTime");
-// pageHelper.addDefaultDesc("id");
+ // pageHelper.addDefaultDesc("id");
if (!classifyService.checkHasChild(codeClassifyOid)) {
conditionMap.put("t." + CODE_CLASSIFY_OID_FIELD, codeClassifyOid);
} else {
@@ -2982,6 +3060,9 @@
conditionMap.put("t.lastr", "1");
conditionMap.put("t.lastv", "1");
DataGrid<Map<String, String>> mapDataGrid = queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
+ if(templateVO.getAttributes().isEmpty()){
+ throw new ServiceException(String.format("涓婚敭涓猴細{}鐨勬ā鏉夸笅锛屾ā鏉垮睘鎬ч厤缃负绌猴紒",templateVO.getOid()));
+ }
//澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
templateVO.getAttributes().stream().forEach(e -> {
for (Map<String, String> datum : mapDataGrid.getData()) {
@@ -2992,26 +3073,26 @@
}
});
return mapDataGrid;
-// List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
-// //鍙傜収璁╁钩鍙扮洿鎺ユ煡璇㈠氨琛�
-// List<String> finalSelectFieldList = selectFieldList;
-// List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
-// s -> StringUtils.isNotBlank(s.getReferbtmid())
-// &&
-// (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
-// ).collect(Collectors.toList());
-// if(!CollectionUtils.isEmpty(referAttrVOs)){
-// for (int i = 0; i < referAttrVOs.size(); i++) {
-// selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
-// }
-// }
-// //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
-// DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
-// //鎴戜滑闇�瑕佷娇鐢ㄦā鏉挎潵杞崲
-// if(!CollectionUtils.isEmpty(dataGrid.getData())){
-// wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
-// }
-// return dataGrid;
+ // List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
+ // //鍙傜収璁╁钩鍙扮洿鎺ユ煡璇㈠氨琛�
+ // List<String> finalSelectFieldList = selectFieldList;
+ // List<CodeClassifyTemplateAttrVO> referAttrVOs = templateVO.getAttributes().stream().filter(
+ // s -> StringUtils.isNotBlank(s.getReferbtmid())
+ // &&
+ // (finalSelectFieldList.size() ==0 || finalSelectFieldList.contains(s.getId().toLowerCase(Locale.ROOT)))
+ // ).collect(Collectors.toList());
+ // if(!CollectionUtils.isEmpty(referAttrVOs)){
+ // for (int i = 0; i < referAttrVOs.size(); i++) {
+ // selectFieldList.add(referAttrVOs.get(i).getId() + ".name");
+ // }
+ // }
+ // //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
+ // DataGrid<Map<String,String>> dataGrid = boService.queryGridByBo(btmTypeId, conditionMap, pageHelper, selectFieldList);
+ // //鎴戜滑闇�瑕佷娇鐢ㄦā鏉挎潵杞崲
+ // if(!CollectionUtils.isEmpty(dataGrid.getData())){
+ // wrapperData(dataGrid.getData(),templateVO,finalSelectFieldList,false);
+ // }
+ // return dataGrid;
}
/**
@@ -3424,17 +3505,20 @@
cbos.add(data);
});
-// List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
+ // List<ClientBusinessObject> cbos = boService.queryByOnlySql(sqlBO.getSqlUnPage());
if (CollectionUtils.isEmpty(cbos)) {
- throw new VciBaseException("鏁版嵁鍦ㄧ郴缁熶腑涓嶅瓨鍦紝鏄惁鍥犱负淇敼杩囦笟鍔$被鍨嬶紵");
+ return R.fail("鏁版嵁鍦ㄧ郴缁熶腑涓嶅瓨鍦紝鏄惁鍥犱负淇敼杩囦笟鍔$被鍨嬶紵");
}
-// Map<String, String> data = new HashMap<>();
+ // Map<String, String> data = new HashMap<>();
Map<String, String> cbo = cbos.get(0);
-// WebUtil.copyValueToMapFromCbos(cbo, data);
+ // WebUtil.copyValueToMapFromCbos(cbo, data);
List<Map<String, String>> dataList = new ArrayList<>();
dataList.add(cbo);
wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
+ if(templateVO.getAttributes().isEmpty()){
+ return R.fail(String.format("涓婚敭涓猴細%s鐨勬ā鏉夸笅锛屾ā鏉垮睘鎬ч厤缃负绌猴紒",templateVO.getOid()));
+ }
//澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
templateVO.getAttributes().stream().forEach(e -> {
for (Map<String, String> datum : result.getData()) {
@@ -3446,42 +3530,42 @@
});
//鎴戜滑瑕佺湅鏄惁涓嶆槸鍗囩増鐨勶紝鍗囩増鐨勮瘽锛岄渶瑕佸姣斾笉鐩哥瓑鐨勫睘鎬�
-/* String copy = cbo.get("copyfromversion");
-// if (StringUtils.isBlank(copy)) {
-// copy = cbo.getAttributeValue("copyfromversion");
-// }
- if (StringUtils.isNotBlank(copy)) {
- //璇存槑鏈夊彉鏇寸殑鍐呭
+ /* String copy = cbo.get("copyfromversion");
+ // if (StringUtils.isBlank(copy)) {
+ // copy = cbo.getAttributeValue("copyfromversion");
+ // }
+ if (StringUtils.isNotBlank(copy)) {
+ //璇存槑鏈夊彉鏇寸殑鍐呭
- CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
- //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
-// List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
- List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
- if (!CollectionUtils.isEmpty(oldCbos)) {
-// Map<String, String> newData = new HashMap<>();
-// WebUtil.copyValueToMapFromCbos(cbo, newData);
- Map<String, String> oldData = new HashMap<>();
- oldData = oldCbos.get(0);
- Map<String, String> difFieldMap = new HashMap<>();
- Map<String, String> finalOldData = oldData;
- cbo.forEach((key, value) -> {
- // 杩欏効oldmap涓殑鍏ㄦ槸澶у啓锛岃�宑bo涓殑鍏ㄦ槸灏忓啓鎵�浠ヤ細鎷夸笉鍒板彧锛岃繖鍎跨洿鎺ュ鐞嗘垚灏忓啓鎷夸笉鍒板氨鐢ㄥぇ鍐欐嬁
- String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
- if (value == null || value == "null") {
- value = "";
- }
- if (oldValue == null || oldValue == "null") {
- oldValue = "";
- }
- if (!value.equalsIgnoreCase(oldValue)) {
- difFieldMap.put(key, oldValue);
- }
- });
- List<Map<String, String>> difFieldList = new ArrayList<>();
- difFieldList.add(difFieldMap);
- result.setData(difFieldList);
- }
- }*/
+ CodeTemplateAttrSqlBO oldSqlBO = getSqlByTemplateVO(btmId, templateVO, WebUtil.getOidQuery(copy), new PageHelper(-1));
+ //鎴戜滑浣跨敤鍜屼笟鍔$被鍨嬬殑鏉ユ煡璇�
+ // List<Map> cbos = commonsMapper.selectBySql(sqlBO.getSqlUnPage());
+ List<Map> oldCbos = commonsMapper.selectBySql(oldSqlBO.getSqlUnPage());
+ if (!CollectionUtils.isEmpty(oldCbos)) {
+ // Map<String, String> newData = new HashMap<>();
+ // WebUtil.copyValueToMapFromCbos(cbo, newData);
+ Map<String, String> oldData = new HashMap<>();
+ oldData = oldCbos.get(0);
+ Map<String, String> difFieldMap = new HashMap<>();
+ Map<String, String> finalOldData = oldData;
+ cbo.forEach((key, value) -> {
+ // 杩欏効oldmap涓殑鍏ㄦ槸澶у啓锛岃�宑bo涓殑鍏ㄦ槸灏忓啓鎵�浠ヤ細鎷夸笉鍒板彧锛岃繖鍎跨洿鎺ュ鐞嗘垚灏忓啓鎷夸笉鍒板氨鐢ㄥぇ鍐欐嬁
+ String oldValue = String.valueOf(finalOldData.getOrDefault(key.toUpperCase(Locale.ROOT), finalOldData.getOrDefault(key, "")));
+ if (value == null || value == "null") {
+ value = "";
+ }
+ if (oldValue == null || oldValue == "null") {
+ oldValue = "";
+ }
+ if (!value.equalsIgnoreCase(oldValue)) {
+ difFieldMap.put(key, oldValue);
+ }
+ });
+ List<Map<String, String>> difFieldList = new ArrayList<>();
+ difFieldList.add(difFieldMap);
+ result.setData(difFieldList);
+ }
+ }*/
return result;
}
@@ -3909,13 +3993,13 @@
MdmUIInfoVO uiInfoVO = getTableDefineByTemplateVO(getUsedTemplateByClassifyOid(codeClassifyOid));
uiInfoVO.setLeaf(classifyService.countChildrenByClassifyOid(codeClassifyOid) == 0);
if (StringUtils.isNotBlank(functionId) && !"~".equalsIgnoreCase(functionId)) {
- List<Menu> buttonVOS = iSysClient.getMenuButtonByType(codeClassifyOid, uiInfoVO.getTemplateVO().getBtmTypeId(), "data_auth").getData();
- // List<SmOperationVO> operationVOS = operationService.listButtonByFunctionId(functionId);
- // if (operationVOS == null) {
- // operationVOS = new ArrayList<>();
- // }
- // //鏌ヨ鎵╁睍鎸夐挳
- // List<CodeButtonVO> buttonVOS = listButtonInToolbarByClassifyOid(codeClassifyOid);
+ // TODO:2024-1-25 18:42妯℃澘涓婄殑btmtypeid鏈夋椂鍊欎細瀛樺湪澶у皬鍐欑殑闂锛屾寜鐞嗘潵璇磋繖鍎跨洿鎺ョ敤functionId灏辫兘婊¤冻鏌ヨ鑿滃崟鎸夐挳浜唘iInfoVO.getTemplateVO().getBtmTypeId()
+ R<List<Menu>> buttonListR = iSysClient.getMenuButtonByType(codeClassifyOid, functionId, "data_auth");
+ if(!buttonListR.isSuccess()){
+ throw new ServiceException("鑾峰彇鎸夐挳鎺堟潈鍒楄〃澶辫触锛屽師鍥狅細"+buttonListR.getMsg());
+ }
+ List<Menu> buttonVOS = buttonListR.getData();
+
List<SmOperationVO> operationVOS = new ArrayList<>();
if (!CollectionUtils.isEmpty(buttonVOS)) {
for (int i = 0; i < buttonVOS.size(); i++) {
@@ -4352,8 +4436,8 @@
if (cboMap.containsKey(oid)) {
CodeAllCode codeAllCode = cboMap.get(oid);
codeAllCode.setId(baseModel.getId());
- // codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
- codeAllCode.setLastModifier(AuthUtil.getUser().getAccount());
+ // 涓绘暟鎹帹閫佸舰寮忥紝鏄嬁涓嶅埌鐢ㄦ埛淇℃伅鐨�
+ codeAllCode.setLastModifier(Func.isBlank(AuthUtil.getUserAccount()) ? applyCodeUserAccount:AuthUtil.getUserAccount());
codeAllCode.setLastModifyTime(new Date());
codeAllCode.setLcStatus(baseModel.getLcStatus());
newCodeAllCodeList.add(codeAllCode);
@@ -4676,7 +4760,13 @@
*/
Map<String, Object> nextRevision = commonsMapper.getCurrentRevision(listR.getData().get(0).getTableName(), fromBo.getNameOid());
R<RevisionRuleVO> revisionRuleVOR = revisionRuleClient.selectById(listR.getData().get(0).getRevisionRuleId());
- String revisionval = nextRevision.get("REVISIONVAL").toString();
+ String revisionval = "";
+ try{
+ revisionval = nextRevision.get("REVISIONVAL").toString();
+ }catch (Exception e){
+ throw new ServiceException("涓氬姟鏁版嵁鐗堟鍊艰幏鍙栧嚭閿�,鍘熷洜锛�" + e.getMessage());
+ }
+
// 鏈煡璇㈠埌鐗堟湰瑙勫垯锛岄粯璁ょ洿鎺ョ粰澶х増鏈姞涓�
if (!revisionRuleVOR.isSuccess() || Func.isEmpty(revisionRuleVOR.getData())) {
revisionval = String.valueOf((Integer.parseInt(revisionval) + 1));
--
Gitblit v1.9.3