Commit 3378a2d6 authored by fangxinjiang's avatar fangxinjiang

项目规则配置-fxj

parent 787c7ae5
......@@ -79,10 +79,10 @@ public class TAutoMainRel extends BaseEntity {
/**
* 规则最新更新人
*/
@ExcelAttribute(name = "规则最新更新人", maxLength = 50)
@Length(max = 50, message = "规则最新更新人不能超过50个字符")
@ExcelProperty("规则最新更新人")
@Schema(description = "规则最新更新人")
@ExcelAttribute(name = "最新更新人", maxLength = 50)
@Length(max = 50, message = "最新更新人不能超过50个字符")
@ExcelProperty("最新更新人")
@Schema(description = "最新更新人")
private String ruleUpdatePerson;
/**
......
......@@ -78,10 +78,10 @@ public class TAutoMainRelExportVo implements Serializable {
private String csUserName;
/**
* 规则最新更新时间
* 最新更新时间
*/
@HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("规则最新更新时间")
@ExcelProperty("最新更新时间")
@Schema(description = "最新更新时间")
private Date ruleUpdateTime;
/**
......
......@@ -111,7 +111,6 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName , CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter excelWriter = EasyExcel.write(out, TAutoMainRelExportVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT){
......@@ -224,7 +223,8 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
.eq(TAutoRuleLog::getMainId,id)));
//岗位信息表
detailVo.setAutoDictItems(autoDictItemMapper.selectList(Wrappers.<SysAutoDictItem>query().lambda()
.eq(SysAutoDictItem::getDeptNo,mainRel.getDeptNo())));
.eq(SysAutoDictItem::getDeptNo,mainRel.getDeptNo())
.eq(SysAutoDictItem::getDisable,CommonConstants.ZERO_STRING)));
//项目信息表
detailVo.setSettleDomainVo(archivesDaprUtil.selectDeptByNo(mainRel.getDeptNo()));
return R.ok(detailVo);
......@@ -251,7 +251,7 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
}
TAutoMainRel existRel = baseMapper.selectOne(Wrappers.<TAutoMainRel>query().lambda()
.eq(TAutoMainRel::getDeptNo,autoMainRel.getDeptNo()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(existRel)){
if (!Common.isEmpty(existRel)){
return R.failed("已存在对应项目规则配置!");
}
SysAutoDict autoDict = autoDictMapper.selectOne(Wrappers.<SysAutoDict>query().lambda()
......@@ -320,6 +320,10 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
if (Common.isEmpty(autoMainRel) || Common.isEmpty(autoMainRel.getId())){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TAutoMainRel autoMainRelOld = baseMapper.selectById(autoMainRel.getId());
if (!Common.isNotNull(autoMainRelOld)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
SysAutoDict autoDict = autoDictMapper.selectOne(Wrappers.<SysAutoDict>query().lambda()
.eq(SysAutoDict::getType,CommonConstants.POST_TYPE).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(autoDict)){
......@@ -360,14 +364,27 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
Map<String,String> diffKeyMap = new HashMap<>();
Map<String,Object> oldMap = new HashMap<>();
Map<String,Object> newMap = new HashMap<>();
if (!autoMainRel.getPostFlag().equals(autoMainRelOld.getPostFlag())){
oldMap.put("oldRuleRel",autoMainRelOld);
newMap.put("newRuleRel",autoMainRel);
diffKeyMap.put("ruleRel","postFlag");
}
//处理岗位字典数据
dictItemHandle(user, autoMainRel, autoDict, diffKeyMap, autoDictItems,oldAutoDictItems);
oldMap.put("oldItems",oldAutoDictItems);
newMap.put("newItems",autoDictItems);
//更新档案管理规则
if (Common.isNotNull(autoEmpRuleNew)){
oldMap.put("oldEmpRule",autoEmpRuleOld);
newMap.put("newEmpRule",autoEmpRuleNew);
String differenceKey = HrEquator.comparisonValue(autoEmpRuleOld, autoEmpRuleNew);
List<String> ignoreFields = new ArrayList<>();
ignoreFields.add("mainId");
ignoreFields.add("createBy");
ignoreFields.add("createName");
ignoreFields.add("createTime");
ignoreFields.add("deptId");
String differenceKey = HrEquator.comparisonValueIgnoreField(autoEmpRuleOld, autoEmpRuleNew,ignoreFields);
if (!Common.isEmpty(differenceKey)){
diffKeyMap.put("empRule",differenceKey);
}
......@@ -388,7 +405,9 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
checkItem = repeatItems.get(item.getLabel());
if (null != checkItem
&& item.getLabel().equals(checkItem.getLabel())
&& !checkItem.getId().equals(item.getId())){
&& CommonConstants.ZERO_STRING.equals(checkItem.getDisable())
&& (Common.isEmpty(checkItem.getId()) || !checkItem.getId().equals(item.getId()))
){
return R.failed(itemsLabelRepeat);
}
repeatItems.put(item.getLabel(),item);
......@@ -412,18 +431,21 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
SysAutoDictItem oldItem;
String diffKey;
StringBuilder difkeys = new StringBuilder("");
List<String> ignore = new ArrayList<>();
ignore.add("value");
for(SysAutoDictItem sysAutoDictItem : autoDictItems){
initDictItem(sysAutoDictItem, user, autoDict, autoMainRel);
if (Common.isNotNull(sysAutoDictItem.getId())){
oldItem = null==oldItemMap?null:oldItemMap.get(sysAutoDictItem.getId());
if (Common.isNotNull(oldItem)){
diffKey = HrEquator.comparisonValue(oldItem, sysAutoDictItem);
diffKey = HrEquator.comparisonValueIgnoreField(oldItem, sysAutoDictItem,ignore);
if (Common.isNotNull(diffKey)){
if (Common.isEmpty(difkeys.toString())){
difkeys.append(difkeys);
difkeys.append(diffKey);
}else {
difkeys.append(CommonConstants.COMMA_STRING);
difkeys.append(difkeys);
difkeys.append(diffKey);
}
}
}
......@@ -484,7 +506,9 @@ public class TAutoMainRelServiceImpl extends ServiceImpl<TAutoMainRelMapper, TAu
sysAutoDictItem.setClientId(ServiceNameConstants.SERVICE_CLIENT_ID_MVP);
sysAutoDictItem.setDictId(autoDict.getId());
sysAutoDictItem.setType(CommonConstants.POST_TYPE);
sysAutoDictItem.setDisable(CommonConstants.ZERO_STRING);
if (Common.isEmpty(sysAutoDictItem.getDisable())){
sysAutoDictItem.setDisable(CommonConstants.ZERO_STRING);
}
sysAutoDictItem.setDeptNo(autoMainRel.getDeptNo());
}
......
......@@ -115,6 +115,101 @@ public class HrEquator extends GetterBaseEquator {
}
return sb.toString();
}
private static boolean ignoreField(String fieldName, List<String> ignoreField){
if (Common.isNotNull(ignoreField)){
for(String fd:ignoreField){
if (fieldName.equals(fd)){
return true;
}
}
}
return false;
}
/**
* 比较对象的差异,返回差异的属性名
* @Author huyc
* @Date 2022-06-22 11:32
* @param oldInfo
* @param newInfo
* @return
**/
public static String comparisonValueIgnoreField(Object oldInfo, Object newInfo,List<String> ignoreField){
StringBuilder sb = new StringBuilder(CommonConstants.EMPTY_STRING);
Equator equator = new HrEquator();
// 获取不同的属性
List<FieldInfo> diff = equator.getDiffFields(oldInfo, newInfo);
Map<String, Integer> curMap = new HashMap<>();
String fieldName;
String fieldName2;
boolean newChange = false;
if (!Common.isEmpty(diff)) {
List<FieldInfo> diff2;
for(FieldInfo field:diff){
fieldName = field.getFieldName();
if (ignoreField(fieldName,ignoreField)){
continue;
}
curMap.put(fieldName, 1);
if (!"updateTime".equals(fieldName) && !"updateBy".equals(fieldName) && !"java.util.List".equals(field.getFirstFieldType().getName())) {
newChange = true;
sb.append(field.getFieldName()).append(",");
}
try {
if ("java.util.List".equals(field.getFirstFieldType().getName())) {
List<Object> firstList = (List<Object>) field.getFirstVal();
List<Object> secondList = (List<Object>) field.getSecondVal();
curMap.put(fieldName, 1);
if (firstList != null && secondList != null && !firstList.isEmpty()) {
if (firstList.size() == secondList.size()) {
boolean isTrue = true;
for (int i = 0; i < firstList.size(); i++) {
if (isTrue) {
diff2 = equator.getDiffFields(firstList.get(i), secondList.get(i));
for (FieldInfo field2 : diff2) {
fieldName2 = field2.getFieldName();
if (!"createTime".equals(fieldName2) && !"createBy".equals(fieldName2) && !"createName".equals(fieldName2)
&& !"updateTime".equals(fieldName2) && !"updateBy".equals(fieldName2)) {
newChange = true;
sb.append(field.getFieldName()).append(",");
isTrue = false;
break;
}
}
}
}
} else {
newChange = true;
sb.append(field.getFieldName()).append(",");
}
} else if ((firstList != null && !firstList.isEmpty()) || (secondList != null && !secondList.isEmpty())) {
newChange = true;
sb.append(field.getFieldName()).append(",");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 从有值变为空,也要记录变更日志
List<FieldInfo> diff2 = equator.getDiffFields(newInfo, oldInfo);
if (!Common.isEmpty(diff2)) {
for(FieldInfo field:diff2){
fieldName = field.getFieldName();
if (ignoreField(fieldName,ignoreField)){
continue;
}
if (curMap.get(fieldName) == null && !"updateTime".equals(field.getFieldName()) && !"updateBy".equals(field.getFieldName())) {
newChange = true;
sb.append(field.getFieldName()).append(",");
}
}
}
if (newChange) {
sb.deleteCharAt(sb.length()-1);
}
return sb.toString();
}
/**
* 比较对象的差异,返回差异的属性名
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment