feat: 迁移国内标准法规部分2 创建国内标准法规
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.adc.da.slrs.sarUpdLog.controller;
|
||||
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-06-01
|
||||
*/
|
||||
@RestController
|
||||
@Api(description = "|SarUpdLog|")
|
||||
@RequestMapping("/SarUpdLog/sar-upd-log")
|
||||
public class SarUpdLogController extends BaseController<SarUpdLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.slrs.sarUpdLog.dao;
|
||||
|
||||
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-06-01
|
||||
*/
|
||||
public interface SarUpdLogDao extends BaseMapper<SarUpdLog> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.adc.da.slrs.sarUpdLog.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-06-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="SarUpdLog对象", description="")
|
||||
public class SarUpdLog extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "数据类型")
|
||||
@TableField("SAR_TYPE")
|
||||
private String sarType;
|
||||
|
||||
@ApiModelProperty(value = "数据id")
|
||||
@TableField("SAR_ID")
|
||||
private String sarId;
|
||||
|
||||
@ApiModelProperty(value = "更新内容")
|
||||
@TableField("CONTENT")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@TableField("CREATION_TIME")
|
||||
private Date creationTime;
|
||||
|
||||
@TableField("CREATION_USER")
|
||||
private String creationUser;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.adc.da.slrs.sarUpdLog.service;
|
||||
|
||||
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-06-01
|
||||
*/
|
||||
public interface ISarUpdLogService extends IService<SarUpdLog> {
|
||||
|
||||
void createBaseLog(String sarId, String sarType, String content) throws Exception;
|
||||
|
||||
void createUpdateLog(String sarType, String sarId, Map<String, Object> oldMap, Map<String, Object> newMap, String standContent) throws Exception;
|
||||
}
|
||||
+259
@@ -0,0 +1,259 @@
|
||||
package com.adc.da.slrs.sarUpdLog.service.impl;
|
||||
|
||||
import com.adc.da.common.SarTypeEnum;
|
||||
import com.adc.da.slrs.sarStandAttrDetails.dao.SarStandAttrDetailsDao;
|
||||
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
|
||||
import com.adc.da.slrs.sarUpdLog.dao.SarUpdLogDao;
|
||||
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
|
||||
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
|
||||
import com.adc.da.util.LoginUserUtil;
|
||||
import com.adc.da.util.UUIDUtils;
|
||||
import com.adc.da.utils.util.DateUtil;
|
||||
import com.adc.da.utils.util.InitStandAttrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author super_liu
|
||||
* @since 2021-06-01
|
||||
*/
|
||||
@Service
|
||||
public class SarUpdLogServiceImpl extends ServiceImpl<SarUpdLogDao, SarUpdLog> implements ISarUpdLogService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SarUpdLogServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SarUpdLogDao dao;
|
||||
|
||||
public SarUpdLogDao getDao() {
|
||||
return dao;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SarStandAttrDetailsDao sarStandAttrDetailsEODao;
|
||||
|
||||
@Autowired
|
||||
private SysInfoEOService sysInfoEOService;
|
||||
|
||||
private String notCheckField = "XGLC,CHJL"; //不检测的是否修改字段
|
||||
|
||||
private List<String> notCheckFieldList = Arrays.asList(notCheckField.split(","));
|
||||
|
||||
public void createUpdateLog (String sarType, String sarId, Map<String,Object> oldMap, Map<String,Object> newMap,String standContent) throws Exception {
|
||||
SarUpdLog sarUpdLogEO = new SarUpdLog();
|
||||
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
|
||||
sarUpdLogEO.setSarId(sarId);
|
||||
sarUpdLogEO.setSarType(sarType);
|
||||
sarUpdLogEO.setCreationTime(new Date());
|
||||
sarUpdLogEO.setCreationUser(LoginUserUtil.getUserId());
|
||||
// 比对两个map组成content
|
||||
String content = createStandContent(oldMap,newMap,sarType,standContent);
|
||||
if (StringUtils.isNotBlank(content)) {
|
||||
sarUpdLogEO.setContent(content);
|
||||
dao.insert(sarUpdLogEO);
|
||||
}
|
||||
}
|
||||
|
||||
public String createStandContent (Map<String,Object> oldMap, Map<String,Object> newMap,String sarType,String standContent) throws Exception{
|
||||
String content = "";
|
||||
StringBuilder contentBuider = new StringBuilder();
|
||||
for (Map.Entry<String,Object> entry : oldMap.entrySet()) {
|
||||
String label = entry.getKey();
|
||||
String value = String.valueOf(entry.getValue());
|
||||
String newValue = String.valueOf(newMap.get(label));
|
||||
if (StringUtils.isNotBlank(newValue) && label.equals("EOPSSRQ") && newValue.length()>10) {
|
||||
newValue = DateUtil.formatStrUTCToDateStr(newValue);
|
||||
}
|
||||
List<String> allTimeField = new ArrayList<>();
|
||||
allTimeField.addAll(InitStandAttrUtil.timeFieldList);
|
||||
allTimeField.addAll(InitStandAttrUtil.timeFieldListLaws);
|
||||
allTimeField.addAll(InitStandAttrUtil.timeFieldListBuss);
|
||||
if (allTimeField.contains(label)) {
|
||||
if (StringUtils.isNotBlank(value) && value.length() > 10) {
|
||||
value = value.substring(0,10);
|
||||
}
|
||||
if (StringUtils.isNotBlank(newValue) && newValue.length() > 10) {
|
||||
newValue = newValue.substring(0,10);
|
||||
}
|
||||
}
|
||||
boolean item3 = !("null".equals(value) && StringUtils.isBlank(newValue));
|
||||
boolean item4 = !("null".equals(newValue) && StringUtils.isBlank(value));
|
||||
if (!StringUtils.equals(value,newValue) && !notCheckFieldList.contains(label) && item3 && item4) {
|
||||
String fieldName = "";
|
||||
if (SarTypeEnum.INLAND_STAND.getValue().equals(sarType) || SarTypeEnum.FOREIGN_STAND.getValue().equals(sarType)) {
|
||||
fieldName = changeStandName(label,sarType);
|
||||
} else if (SarTypeEnum.INLAND_LAWS.getValue().equals(sarType) || SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) {
|
||||
fieldName = changeLawsName(label,sarType);
|
||||
} else if (SarTypeEnum.BUSINESS.getValue().equals(sarType)) {
|
||||
fieldName = changeBussName(label,sarType);
|
||||
}
|
||||
value = changeVal(label,value,sarType);
|
||||
newValue = changeVal(label,newValue,sarType);
|
||||
if ("null".equals(value) || StringUtils.isBlank(value)) {
|
||||
value = "";
|
||||
}
|
||||
if ("null".equals(newValue) || StringUtils.isBlank(newValue)) {
|
||||
newValue = "";
|
||||
}
|
||||
String con = "“" + fieldName + "”由“" + value + "”改为“" + newValue + "”;";
|
||||
// String con = "“" + fieldName + "”";
|
||||
if (StringUtils.isNotBlank(fieldName) && !"null".equals(fieldName)) {
|
||||
contentBuider.append(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (contentBuider != null && contentBuider.length() > 0) {
|
||||
content += "修改" + standContent + ",";
|
||||
}
|
||||
content += contentBuider.toString();
|
||||
return content;
|
||||
}
|
||||
|
||||
public String changeVal (String field,String value,String sarType) {
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
Map<String,String> selectFieldMap = new HashMap<>();
|
||||
String selVal = "";
|
||||
if (SarTypeEnum.INLAND_STAND.getValue().equals(sarType) || SarTypeEnum.FOREIGN_STAND.getValue().equals(sarType)) {
|
||||
selectFieldMap = InitStandAttrUtil.selectFieldMap;
|
||||
selectFieldMap.put("isRelateAccess","SHIFOUGL");
|
||||
selectFieldMap.put("country","COUNTRY");
|
||||
selectFieldMap.put("standSort","STANDCLASSIFY");
|
||||
selectFieldMap.put("standState","STANDSTATE");
|
||||
} else if (SarTypeEnum.INLAND_LAWS.getValue().equals(sarType) || SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) {
|
||||
selectFieldMap = InitStandAttrUtil.selectFieldMapLaws;
|
||||
selectFieldMap.put("isRelateAccess","SHIFOUGL");
|
||||
selectFieldMap.put("country","COUNTRY");
|
||||
selectFieldMap.put("standSort","STANDCLASSIFY");
|
||||
selectFieldMap.put("standState","STANDSTATE");
|
||||
} else if (SarTypeEnum.BUSINESS.getValue().equals(sarType)) {
|
||||
selectFieldMap = InitStandAttrUtil.selectFieldMapBuss;
|
||||
selectFieldMap.put("standSort","BUSSSTANDCLASS");
|
||||
selectFieldMap.put("standState","STANDSTATE");
|
||||
}
|
||||
selVal = selectFieldMap.get(field);
|
||||
if (StringUtils.isNotBlank(selVal)) {
|
||||
value = getSelectionValueName(selVal,value);
|
||||
} else {
|
||||
List<String> fileList = new ArrayList<>();
|
||||
if (SarTypeEnum.INLAND_STAND.getValue().equals(sarType) || SarTypeEnum.FOREIGN_STAND.getValue().equals(sarType)) {
|
||||
fileList = InitStandAttrUtil.fileFieldList;
|
||||
} else if (SarTypeEnum.INLAND_LAWS.getValue().equals(sarType) || SarTypeEnum.FOREIGN_LAWS.getValue().equals(sarType)) {
|
||||
fileList = InitStandAttrUtil.fileFieldListLaws;
|
||||
} else if (SarTypeEnum.BUSINESS.getValue().equals(sarType)) {
|
||||
fileList = InitStandAttrUtil.fileFieldListBuss;
|
||||
}
|
||||
if (fileList != null && fileList.contains(field)) {
|
||||
value = sysInfoEOService.getFileNamesByIds(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getSelectionValueName (String selVal,String value) {
|
||||
switch (selVal) {
|
||||
case "SVPPS":
|
||||
value = sysInfoEOService.getSvppsNamesByIds(value);
|
||||
return value;
|
||||
case "GZZXX":
|
||||
value = sysInfoEOService.getGroupNamesByIds(value);
|
||||
return value;
|
||||
case "USERLIST":
|
||||
value = sysInfoEOService.getUserNamesByIds(value);
|
||||
return value;
|
||||
case "ORGLIST":
|
||||
value = sysInfoEOService.getOrgNamesByIds(value);
|
||||
return value;
|
||||
case "ROLELIST":
|
||||
value = sysInfoEOService.getRoleNamesByIds(value);
|
||||
return value;
|
||||
case "SHIFOUGL":
|
||||
if ("1".equals(value)) {
|
||||
value = "是";
|
||||
} else if ("0".equals(value)) {
|
||||
value = "否";
|
||||
}
|
||||
return value;
|
||||
default:
|
||||
value = sysInfoEOService.getDicNamesByCodes(value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public String changeStandName (String field,String sarType) throws Exception{
|
||||
switch (field) {
|
||||
case "country": return "适用区域";
|
||||
case "isRelateAccess": return "重要度";
|
||||
case "issueTime": return "发布日期";
|
||||
case "standYear": return "标准年份";
|
||||
case "standNature": return "标准性质";
|
||||
case "standEnName": return "英文名称";
|
||||
case "standName": return "中文名称";
|
||||
case "standNumber": return "标准编号";
|
||||
case "standSort": return "标准类别";
|
||||
case "standState": return "标准状态";
|
||||
case "synopsis": return "文本说明";
|
||||
default:
|
||||
String name = sarStandAttrDetailsEODao.selectNameByField(field,sarType);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public String changeLawsName (String field,String sarType) throws Exception{
|
||||
switch (field) {
|
||||
case "country": return "适用区域";
|
||||
case "isRelateAccess": return "重要度";
|
||||
case "issueTime": return "发布日期";
|
||||
case "standEnName": return "英文名称";
|
||||
case "standName": return "中文名称";
|
||||
case "standNumber": return "政策编号";
|
||||
case "standState": return "政策状态";
|
||||
case "replaceStandNum": return "代替政策编号";
|
||||
default:
|
||||
String name = sarStandAttrDetailsEODao.selectNameByField(field,sarType);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public String changeBussName (String field,String sarType) throws Exception{
|
||||
switch (field) {
|
||||
// case "country": return "适用区域";
|
||||
// case "isRelateAccess": return "重要度";
|
||||
case "issueTime": return "发布日期";
|
||||
case "putTime": return "标准实施日期";
|
||||
// case "standYear": return "标准年份";
|
||||
// case "standNature": return "标准性质";
|
||||
case "standEnName": return "英文名称";
|
||||
case "standName": return "中文名称";
|
||||
case "standNumber": return "标准编号";
|
||||
case "standSort": return "企标类别";
|
||||
case "standState": return "标准状态";
|
||||
case "replaceStandNum": return "代替企标编号";
|
||||
case "replacedStandNum": return "被代替企标编号";
|
||||
default:
|
||||
String name = sarStandAttrDetailsEODao.selectNameByField(field,"BUSS");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public void createBaseLog (String sarId,String sarType,String content) throws Exception {
|
||||
SarUpdLog sarUpdLogEO = new SarUpdLog();
|
||||
sarUpdLogEO.setId(UUIDUtils.randomUUID20());
|
||||
sarUpdLogEO.setSarId(sarId);
|
||||
sarUpdLogEO.setSarType(sarType);
|
||||
sarUpdLogEO.setCreationTime(new Date());
|
||||
sarUpdLogEO.setCreationUser(LoginUserUtil.getUserId());
|
||||
sarUpdLogEO.setContent(content);
|
||||
dao.insert(sarUpdLogEO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user