From cb41c6645777148f78788b369a6f66ecbdc7111a Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期三, 03 一月 2024 16:14:10 +0800
Subject: [PATCH] 整合代码
---
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/service/impl/MdmEngineServiceImpl.java | 168 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 149 insertions(+), 19 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 2dd56b5..9ea8b4d 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
@@ -44,6 +44,7 @@
import com.vci.ubcs.starter.revision.service.RevisionModelUtil;
import com.vci.ubcs.starter.util.MdmBtmTypeConstant;
import com.vci.ubcs.starter.util.SaveLogUtil;
+import com.vci.ubcs.starter.util.SpecialCharacterConverter;
import com.vci.ubcs.starter.util.UBCSSqlKeyword;
import com.vci.ubcs.starter.web.constant.QueryOptionConstant;
import com.vci.ubcs.starter.web.constant.RegExpConstant;
@@ -59,6 +60,7 @@
import com.vci.ubcs.system.feign.ISysClient;
import com.vci.ubcs.system.user.entity.User;
import com.vci.ubcs.system.user.feign.IUserClient;
+import io.swagger.models.auth.In;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import oracle.sql.TIMESTAMP;
import org.slf4j.Logger;
@@ -66,6 +68,7 @@
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.annotation.OperateLog;
import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
@@ -85,6 +88,8 @@
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
@@ -451,8 +456,14 @@
throw new VciBaseException("鏇存柊鏁版嵁鍑洪敊锛岄噸璇曪紒"+r.getMsg());
}
}
+ // 鍒氬ソ椤哄簭鏄竴鑷寸殑锛屾墍浠ョ洿鎺ユ寜鐓odeallcode鐨勯『搴忔潵鎷夸笟鍔℃暟鎹�
+ int i = -1;
for (CodeAllCode codeCbo : codeCbos) {
codeCbo.setLcStatus(baseModelDTO.getLcStatus());
+ // 濡傛灉鏄洖鏀讹紝灏遍渶瑕佸皢涓氬姟鏁版嵁瀛樺偍鍒扮爜鍊艰〃涓�
+ if(baseModelDTO.getLcStatus().equals(FrameWorkDefaultValueConstant.FRAMEWORK_RELEASE_TAKEBACK)){
+ codeCbo.setBusinessData(JSON.toJSONString(baseModels.get(++i)));
+ }
}
codeAllCodeService.updateBatchById(codeCbos);
@@ -464,7 +475,7 @@
);
}catch (Exception e){
// 鎻掑叆鏇存敼鏃ュ織璁板綍
- saveLogUtil.operateLog(CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()),true,e.getMessage());
+ saveLogUtil.operateLog(CodeDefaultLC.getTextByValue(baseModelDTO.getLcStatus()),true,e.toString());
throw e;
}
}
@@ -503,6 +514,7 @@
CodeClassifyFullInfoBO classifyFullInfo = classifyService.getClassifyFullInfo(orderDTO.getCodeClassifyOid());
CodeClassifyTemplateVO templateVO = templateService.getObjectHasAttrByOid(orderDTO.getTemplateOid());
CodeRuleVO ruleVO = ruleService.getObjectHasSecByOid(orderDTO.getCodeRuleOid());
+ final BladeUser user = AuthUtil.getUser();
//1.鍒ゆ柇瑙勫垯涓櫎浜嗘祦姘寸爜娈碉紝鏄惁鏈夊叾浠栫爜娈�
checkSecValueOnOrder(ruleVO, orderDTO);
//2.鍒ゆ柇蹇呰緭椤�
@@ -533,13 +545,13 @@
//cbo.setCreator(String.valueOf(AuthUtil.getUser().getUserId()));銆�
if(authUser) {
// 瑕佹眰鏄剧ず璐﹀彿锛屾墍浠ュ仛浜嗘洿鏀�
- cbo.setCreator(String.valueOf(AuthUtil.getUser().getAccount()));
- cbo.setLastModifier(String.valueOf(AuthUtil.getUser().getAccount()));
+ cbo.setCreator(String.valueOf(user.getAccount()));
+ cbo.setLastModifier(String.valueOf(user.getAccount()));
}else{
cbo.setCreator(orderDTO.getCreator());
cbo.setLastModifier(orderDTO.getLastModifier());
}
- cbo.setTenantId(AuthUtil.getTenantId());
+ cbo.setTenantId(user.getTenantId());
if(StringUtils.isNotBlank(orderDTO.getLcStatus())||StringUtils.isNotBlank(orderDTO.getData().get("lcStatus"))){
cbo.setLcStatus(StringUtils.isNotBlank(orderDTO.getLcStatus())?orderDTO.getLcStatus():orderDTO.getData().get("lcStatus"));
}
@@ -552,7 +564,7 @@
cbo.setDescription(orderDTO.getDescription());
cboList.add(cbo);
- List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList);
+ List<String> codeList = productCodeService.productCodeAndSaveData(classifyFullInfo, templateVO, ruleVO, orderDTO.getSecDTOList(), cboList,user);
batchSaveSelectChar(templateVO, cboList);
return codeList.size() > 0 ? codeList.get(0) : "";
@@ -702,7 +714,6 @@
}
}
-
/**
* 璁剧疆鏂扮殑鍊煎埌鐢宠瀵硅薄涓�
*
@@ -791,6 +802,7 @@
sql[0] += " and oid != '" + orderDTO.getCopyFromVersion() + "'";
}
sql[0] += " and lastR = '1' and lastV = '1' ";
+ // 鑾峰彇涓嶅弬涓庢牎楠岀殑鍒嗙被oid
String isParticipateCheckOids = classifyService.selectLeafByParentClassifyOid(classifyFullInfo.getTopClassifyVO().getOid(), classifyFullInfo.getCurrentClassifyVO().getOid());
if(Func.isNotEmpty(isParticipateCheckOids)){
sql[0] += " and codeclsfid not in(" + isParticipateCheckOids + ")";
@@ -1142,6 +1154,76 @@
}
/**
+ * 鑾峰彇缁熻鍒嗘瀽鏁版嵁
+ * @param btmNames 涓氬姟绫诲瀷
+ * @return 鏁版嵁闆�
+ */
+ @Override
+ public R getStatisticAnalysis(String btmNames) {
+ //鏌ヨ涓氬姟绫诲瀷瀵瑰簲鐨勬暟鎹簱琛�
+ R<List<BtmTypeVO>> listR = btmTypeClient.selectByIdCollection(Arrays.asList(btmNames.split(",")));
+ if (!listR.isSuccess() || listR.getData().size() == 0) {
+ throw new ServiceException("浼犲叆涓氬姟绫诲瀷鏈煡璇㈠埌鐩稿簲琛ㄥ崟锛岃妫�鏌ワ紒");
+ }
+ List tableData = new ArrayList();
+ for (BtmTypeVO datum : listR.getData()) {
+ String sql = "select count(*) countNum, to_char(CREATETIME, 'mm') countDate\n" +
+ "from "+ datum.getTableName() +"\n" +
+ "where CREATETIME >= to_date(EXTRACT(YEAR FROM SYSDATE) || '-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND LASTV = '1'\n" +
+ "group by to_char(CREATETIME, 'mm')\n" +
+ "order by to_char(CREATETIME, 'mm')";
+ //鏌ヨ鍑洪渶瑕佸鐞嗙殑鏁版嵁
+ List<Map> maps = commonsMapper.selectBySql(sql);
+
+ //褰撳勾姣忔湀鏈堜唤涔嬪墠涔嬪拰
+ List<Integer> monthCount = new ArrayList<>(12);
+ //褰撳勾姣忔湀鐨勬湀浠芥暟鎹�
+ List<Integer> month = new ArrayList<>();
+ //鑾峰彇褰撳墠鏈堢殑鏁板瓧
+ Calendar instance = Calendar.getInstance();
+ int nowmonth = instance.get(Calendar.MONTH) + 1;
+ if(maps.size() == 0){
+ nowmonth = 0;
+ }
+ //浠�1鍒�12鏈堣繘琛屽鐞�
+ for (Integer i = 1; i <= 12; i++) {
+ //褰撳墠鏈堝悗鎵�鏈夋暟鎹缃负0
+ if(i>nowmonth){
+ monthCount.add(0);
+ month.add(0);
+ continue;
+ }
+ //褰撳墠鏈堜唤涔嬪墠涔嬪拰
+ Integer count = 0;
+ //褰撳墠鏈堜唤鏁版嵁
+ Integer sameMonth = 0;
+ //瀵规暟鎹簱鏌ョ殑鏁版嵁杩涜澶勭悊锛屽褰撳墠鏈堜唤杩涜绱姞
+ for (Map map : maps) {
+ Integer mounDate = Integer.parseInt(String.valueOf(map.get("COUNTDATE")));
+ if(mounDate <= i){
+ count += Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
+ }
+ if (mounDate == i) {
+ sameMonth = Integer.parseInt(String.valueOf(map.get("COUNTNUM")));
+ }
+ }
+ monthCount.add(count);
+ month.add(sameMonth);
+ }
+ //瀵规暟鎹繘琛屾暣鍚�
+ HashMap<String,Object> menuData = new HashMap<>();
+ menuData.put("menuName",datum.getName());
+ menuData.put("codeType",null);
+ ArrayList monthData = new ArrayList();
+ monthData.add(monthCount);
+ monthData.add(month);
+ menuData.put("menuData",monthData);
+ tableData.add(menuData);
+ }
+ return R.data(tableData);
+ }
+
+ /**
* 灏佽鍏抽敭灞炴�х殑鏌ヨ璇彞
*
* @param value 褰撳墠鐨勫��
@@ -1193,12 +1275,12 @@
temp = "%s";
}
queryKey = String.format(temp, "nvl("+ "t." + attrId +",'/')");
- queryValue = String.format(temp, "'" + (trim ? value.trim() : value) + "'");
+ queryValue = String.format(temp, "'" + (trim ? SpecialCharacterConverter.escapeSpecialCharacters(value.trim()):SpecialCharacterConverter.escapeSpecialCharacters(value)) + "'");
conditionMap.put(queryKey, queryValue);
} else {
if(StringUtils.isNotBlank(value)) {
//涓虹┖鐨勬椂鍊欎笉浠h〃涓嶆牎楠岋紝鍙槸涓嶅幓闄ょ浉鍏崇殑淇℃伅
- conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + value + "'");
+ conditionMap.put("nvl("+ "t." + attrId+",'/')", "'" + SpecialCharacterConverter.escapeSpecialCharacters(value) + "'");
}else{
conditionMap.put("t." + attrId, QueryOptionConstant.ISNULL);
}
@@ -2433,7 +2515,15 @@
} else {
return (field.contains(".") ? "" : "t.") + field + SPACE + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
}
- } else {
+ } else if(key.endsWith("_in")){
+ 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 + "= " + getStringValueInWhere(field, value, attrVOMap) + "" + SPACE;
+ }
+
+ }else {
// if (referFieldMap.containsKey(key)) {
// //璇存槑鏄弬鐓х殑锛屾垜浠弬鐓х殑鏌ヨ閮借涓烘槸瀛楃涓诧紝濡傛灉鏄椂闂存牸寮忕殑鏌ヨ鑲畾鏈夐棶棰橈紝
// String selectKey = referFieldMap.get(key);
@@ -2472,7 +2562,6 @@
return getSqlByValue(key, value, attrVOMap,btmType);
}
}*/
-
}
/**
@@ -2507,12 +2596,24 @@
}
DateConverter dateConverter = new DateConverter();
if (VciFieldTypeEnum.VTDateTime.equals(fieldTypeEnum)) {
- //瀹為檯涓婏紝鏁版嵁搴撻兘鏄痶imestamp鐨勭被鍨�.
- dateConverter.setAsText(value);
- return "to_date('" + dateConverter.getAsText(VciDateUtil.DateTimeFormat) + "','" + DATETIME_FORMAT + "')";
+ //瀹為檯涓婏紝鏁版嵁搴撻兘鏄痶imestamp鐨勭被鍨�. TODO:铏界劧娌¤兘瑙e喅鏌ヨ鏃ユ湡鐨勯棶棰橈紝浣嗘槸鑳芥殏鏃惰В鍐虫姤閿欓棶棰�
+ if(value.contains("*")){
+ value = value.replace("*","%");
+ return "'" + value + "'";
+ }else{
+ value = value.replace("*","");
+ dateConverter.setAsText(value);
+ return "to_date('" + dateConverter.getAsText(VciDateUtil.DateTimeFormat) + "','" + DATETIME_FORMAT + "')";
+ }
} else if (VciFieldTypeEnum.VTDate.equals(fieldTypeEnum)) {
- dateConverter.setAsText(value);
- return "to_date('" + dateConverter.getAsText(VciDateUtil.DateFormat) + "','" + DATE_FORMAT + "')";
+ if(value.contains("*")){
+ value = value.replace("*","%");
+ return "'" + value + "'";
+ }else {
+ value = value.replace("*","");
+ dateConverter.setAsText(value);
+ return "to_date('" + dateConverter.getAsText(VciDateUtil.DateFormat) + "','" + DATE_FORMAT + "')";
+ }
} else if (VciFieldTypeEnum.VTDouble.equals(fieldTypeEnum)
|| VciFieldTypeEnum.VTLong.equals(fieldTypeEnum)
|| VciFieldTypeEnum.VTInteger.equals(fieldTypeEnum)) {
@@ -2879,7 +2980,17 @@
}
conditionMap.put("t.lastr", "1");
conditionMap.put("t.lastv", "1");
- return queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
+ DataGrid<Map<String, String>> mapDataGrid = queryGrid(btmTypeId, templateVO, conditionMap, pageHelper);
+ //澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
+ templateVO.getAttributes().stream().forEach(e->{
+ for (Map<String, String> datum : mapDataGrid.getData()) {
+ if(datum.containsKey(e.getId().toLowerCase()) && !datum.containsKey(e.getId())){
+ datum.put(e.getId(),datum.get(e.getId().toLowerCase()));
+ datum.remove(e.getId().toLowerCase());
+ }
+ }
+ });
+ return mapDataGrid;
// List<String> selectFieldList = templateVO.getAttributes().stream().map(CodeClassifyTemplateAttrVO::getId).collect(Collectors.toList());
// //鍙傜収璁╁钩鍙扮洿鎺ユ煡璇㈠氨琛�
// List<String> finalSelectFieldList = selectFieldList;
@@ -3108,11 +3219,20 @@
updateBatchByBaseModel(oldCbo.getBtmname(), Collections.singletonList(oldCbo));
// 鎻掑叆鏂扮殑鏁版嵁
insertBatchByType(cbo.getBtmname(), Collections.singletonList(cbo));
+ //澶勭悊鐮佸�艰〃锛屽鐮佸�艰〃杩涜澶勭悊鏇挎崲鍒涘缓鏁版嵁鐨刼id
+ QueryWrapper<CodeAllCode> wrapper = new QueryWrapper<>();
+ wrapper.eq("CREATECODEOID",orderDTO.getCopyFromVersion());
+ CodeAllCode codeAllCode = codeAllCodeService.getOne(wrapper);
+ codeAllCode.setCreateCodeOid(cbo.getOid());
+ codeAllCode.setLastModifyTime(new Date());
+ codeAllCode.setTs(new Date());
+ codeAllCode.setLastModifier(AuthUtil.getUser().getUserName());
+ codeAllCodeService.updateById(codeAllCode);
// 璁板綍鏁版嵁鏇存敼鏃ュ織
saveLogUtil.operateLog("鏁版嵁鏇存敼",false, StringUtil.format("{}\n淇敼涓�:\n{}",JSON.toJSONString(Collections.singletonList(oldCbo)),JSON.toJSONString(Collections.singletonList(cbo))));
} catch (Exception vciError) {
// 璁板綍鏁版嵁鏇存敼鎶ラ敊鏃剁殑鏃ュ織
- saveLogUtil.operateLog("鏁版嵁鏇存敼",true,vciError.getMessage());
+ saveLogUtil.operateLog("鏁版嵁鏇存敼",true,vciError.toString());
throw new VciBaseException("鏁版嵁鏇存敼淇濆瓨鍑洪敊浜�", new String[0], vciError);
}
@@ -3313,6 +3433,16 @@
dataList.add(cbo);
wrapperData(dataList, templateVO, sqlBO.getSelectFieldList(), true);
R<List<Map<String, String>>> result = R.data(Collections.singletonList(cbo));
+ //澶勭悊杩斿洖鏁版嵁涓庢ā鏉挎暟鎹厤缃殑瀛楁涓嶄竴鏍烽棶棰�
+ templateVO.getAttributes().stream().forEach(e->{
+ for (Map<String, String> datum : result.getData()) {
+ if(datum.containsKey(e.getId().toLowerCase()) && !datum.containsKey(e.getId())){
+ datum.put(e.getId(),datum.get(e.getId().toLowerCase()));
+ datum.remove(e.getId().toLowerCase());
+ }
+ }
+ });
+
//鎴戜滑瑕佺湅鏄惁涓嶆槸鍗囩増鐨勶紝鍗囩増鐨勮瘽锛岄渶瑕佸姣斾笉鐩哥瓑鐨勫睘鎬�
/* String copy = cbo.get("copyfromversion");
// if (StringUtils.isBlank(copy)) {
@@ -4087,7 +4217,7 @@
bo.setFirstV("1");
bo.setLastV("1");
bo.setRevisionRule(listR.getData().get(0).getRevisionRuleId());
- bo.setVersionRule("".equals(listR.getData().get(0).getVersionRule())?"0":listR.getData().get(0).getVersionRule());
+ bo.setVersionRule("".equals(listR.getData().get(0).getVersionRule())?"1":listR.getData().get(0).getVersionRule());
if (StringUtils.isNotBlank(listR.getData().get(0).getRevisionRuleId())) {
R<List<RevisionRuleVO>> revisionRuleVO = revisionRuleClient
.selectByIdCollection(Collections.singletonList(listR.getData().get(0).getRevisionRuleId().toLowerCase()));
@@ -4108,7 +4238,7 @@
bo.setId("");
bo.setName("");
bo.setDescription("");
- bo.setOwner("1");
+ bo.setOwner(AuthUtil.getUser().getUserId().toString());
// bo.setCheckinby(userName);
bo.setCopyFromVersion("");
// this.initTypeAttributeValue(bo,btmTypeVO);
--
Gitblit v1.9.3