修改bug
This commit is contained in:
parent
29b29c6cea
commit
cbbe62aef4
|
|
@ -222,6 +222,11 @@ public class NuConfigSuppliersApplyController extends JeecgController<NuConfigSu
|
|||
public Result<List<Map<String, Object>>> getModifyInfo(@RequestBody NuConfigSuppliersApply suppliersApply) {
|
||||
return Result.OK(nuConfigSuppliersApplyService.getModifyInfo(suppliersApply));
|
||||
}
|
||||
@ApiOperation(value = "供应商变更历史比对信息", notes = "供应商变更历史比对信息")
|
||||
@PostMapping(value = "/getModifyHistoryInfo")
|
||||
public Result<List<Map<String, Object>>> getModifyHistoryInfo(@RequestBody NuConfigSuppliersApply suppliersApply) {
|
||||
return Result.OK(nuConfigSuppliersApplyService.getModifyHistoryInfo(suppliersApply));
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更审核
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ public interface INuConfigSuppliersApplyService extends IService<NuConfigSupplie
|
|||
String audit(NuConfigSuppliersApply nuConfigSuppliersApply);
|
||||
|
||||
IPage<NuConfigSuppliersApply> listPage(Page<NuConfigSuppliersApply> page, QueryWrapper<NuConfigSuppliersApply> queryWrapper);
|
||||
|
||||
List<Map<String, Object>> getModifyHistoryInfo(NuConfigSuppliersApply suppliersApply);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,4 +152,87 @@ public class NuConfigSuppliersApplyServiceImpl extends ServiceImpl<NuConfigSuppl
|
|||
public IPage<NuConfigSuppliersApply> listPage(Page<NuConfigSuppliersApply> page, QueryWrapper<NuConfigSuppliersApply> queryWrapper) {
|
||||
return baseMapper.listPage(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getModifyHistoryInfo(NuConfigSuppliersApply suppliersApply) {
|
||||
// 1. 查询变更后数据
|
||||
NuConfigSuppliersApply modifyData = baseMapper.selectById(suppliersApply.getId());
|
||||
|
||||
// 2. 查询当前使用中数据
|
||||
QueryWrapper<NuConfigSuppliersApply> usingQW = new QueryWrapper<>();
|
||||
usingQW.eq("suppliers_id", modifyData.getSuppliersId());
|
||||
usingQW.eq("apply_status", "2");
|
||||
usingQW.lt("create_time", modifyData.getCreateTime());
|
||||
usingQW.last("limit 1");
|
||||
NuConfigSuppliersApply usingData = baseMapper.selectOne(usingQW);
|
||||
if(usingData == null || usingData.getId() == null){
|
||||
usingData = modifyData;
|
||||
}
|
||||
|
||||
// 3. 准备结果列表
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
|
||||
// 4. 获取 ConfigSuppliersInfo 所有字段(用于遍历)
|
||||
Field[] infoFields = NuConfigSuppliersApply.class.getDeclaredFields();
|
||||
|
||||
// 5. 遍历每个字段,从两个对象中分别取值比较
|
||||
for (Field usingField : infoFields) {
|
||||
try {
|
||||
String fieldName = usingField.getName();
|
||||
|
||||
// 跳过序列化ID 和 @TableField(exist = false) 的字段
|
||||
if ("serialVersionUID".equals(fieldName)) {
|
||||
continue;
|
||||
}
|
||||
TableField tableField = usingField.getAnnotation(TableField.class);
|
||||
if (tableField != null && !tableField.exist()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 设置可访问
|
||||
usingField.setAccessible(true);
|
||||
|
||||
// 获取 ElderInfo 中对应的字段(必须同名)
|
||||
Field modifyField = null;
|
||||
try {
|
||||
modifyField = NuConfigSuppliersApply.class.getDeclaredField(fieldName);
|
||||
modifyField.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
// 如果员工信息表中没有这个字段,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取两个对象中该字段的值
|
||||
Object modifyValue = modifyField.get(modifyData);
|
||||
Object usingValue = usingField.get(usingData);
|
||||
|
||||
// 处理日期类型
|
||||
if (usingField.getType() == Date.class) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
modifyValue = modifyValue != null ? sdf.format((Date) modifyValue) : null;
|
||||
usingValue = usingValue != null ? sdf.format((Date) usingValue) : null;
|
||||
}
|
||||
|
||||
if(StringUtils.equals(fieldName,"suppliersNature")){
|
||||
usingValue = usingValue != null ? dictUtils.translateDictValue("suppliers_nature", usingValue.toString()) : null;
|
||||
modifyValue = modifyValue != null ? dictUtils.translateDictValue("suppliers_nature", modifyValue.toString()) : null;
|
||||
}
|
||||
// 创建结果项
|
||||
Map<String, Object> fieldMap = new HashMap<>();
|
||||
fieldMap.put("id", IdUtil.simpleUUID());
|
||||
fieldMap.put("d1", fieldName); // 字段名
|
||||
fieldMap.put("d2", usingValue); // 原始值
|
||||
fieldMap.put("d3", modifyValue); // 修改值
|
||||
fieldMap.put("d4", Objects.equals(usingValue, modifyValue) ? "相同" : "不同"); // 比较结果
|
||||
|
||||
result.add(fieldMap);
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
// 忽略访问失败或字段不存在的情况
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue