|  |  | 
 |  |  |  * @since 2021-04-06 | 
 |  |  |  */ | 
 |  |  | @Service | 
 |  |  | @ConfigurationProperties(prefix = "log-aspect") | 
 |  |  | public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Organization> implements OrganizationService { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     MonitorPointService monitorPointService; | 
 |  |  |  | 
 |  |  |     Map<String, String> organizationFormMap; | 
 |  |  |  | 
 |  |  |     public void setOrganizationFormMap(Map<String, String> organizationFormMap) { | 
 |  |  |         this.organizationFormMap = organizationFormMap; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @Description: 添加客户组织 | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @Description: 将更新操作插入日志 | 
 |  |  |      * @Param: [updateForm, newOrganization, oldOrganization] | 
 |  |  |      * @return: void | 
 |  |  |      * @Author: 陈凯裕 | 
 |  |  |      * @Date: 2021/4/8 | 
 |  |  |      */ | 
 |  |  |     private void insertUpdateLog(OrganizationUpdateForm updateForm, Organization newOrganization, Organization oldOrganization) { | 
 |  |  |         //操作插入日志 | 
 |  |  |         HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | 
 |  |  |         StringBuilder content = new StringBuilder(); | 
 |  |  |         content.append("修改了组织:").append(oldOrganization.getName()).append(";"); | 
 |  |  |         //对象转为Map,获取对象更新前后的属性 | 
 |  |  |         Map<String, Object> newParameters = JSONObject.parseObject(JSON.toJSONString(updateForm), Map.class); | 
 |  |  |         Map<String, Object> oldParameters = JSONObject.parseObject(JSON.toJSONString(oldOrganization), Map.class); | 
 |  |  |         //遍历配置文件中的Map,将属性转化为汉字 | 
 |  |  |         Set<String> keys = organizationFormMap.keySet(); | 
 |  |  |         for (String key : keys) { | 
 |  |  |             String value = organizationFormMap.get(key);//属性对应的汉字 | 
 |  |  |             if ("parentName".equals(key)) {//更新父组织特殊处理 | 
 |  |  |                 if (updateForm.getParentId() != null) {//判断父组织是否进行了更新 | 
 |  |  |                     String oldParentName = "空"; | 
 |  |  |                     String newParentName = "空"; | 
 |  |  |                     if (!oldOrganization.getParentId().equals(0)) { | 
 |  |  |                         oldParentName = organizationMapper.selectById(oldOrganization.getParentId()).getName(); | 
 |  |  |                     } | 
 |  |  |                     if (!newOrganization.getParentId().equals(0)) { | 
 |  |  |                         newParentName = organizationMapper.selectById(newOrganization.getParentId()).getName(); | 
 |  |  |                     } | 
 |  |  |                     content.append(value + ":" + oldParentName + "->" + newParentName + ";"); | 
 |  |  |                 } | 
 |  |  |             } else if ("expireTime".equals(key)) {//expireTime时间格式特殊处理 | 
 |  |  |                 if (updateForm.getExpireTime() != null) { | 
 |  |  |                     Date oldExpireTime = oldOrganization.getExpireTime(); | 
 |  |  |                     Date newExpireTime = newOrganization.getExpireTime(); | 
 |  |  |                     String oldExpireTimeStr = DateUtils.dateToDateString(oldExpireTime, "yyyy-MM-dd"); | 
 |  |  |                     String newExpireTimeStr = DateUtils.dateToDateString(newExpireTime, "yyyy-MM-dd"); | 
 |  |  |                     content.append(value + ":" + oldExpireTimeStr + "->" + newExpireTimeStr + ";"); | 
 |  |  |                 } | 
 |  |  |             } else {//处理其他属性 | 
 |  |  |                 if (newParameters.get(key) != null) { | 
 |  |  |                     String newValue = "空"; | 
 |  |  |                     String oldValue = "空"; | 
 |  |  |                     if (newParameters.get(key) != null && !newParameters.get(key).equals(" ")) { | 
 |  |  |                         newValue = String.valueOf(newParameters.get(key)); | 
 |  |  |                     } | 
 |  |  |                     if (oldParameters.get(key) != null && !oldParameters.get(key).equals(" ")) { | 
 |  |  |                         oldValue = String.valueOf(oldParameters.get(key)); | 
 |  |  |                     } | 
 |  |  |                     content.append(value + ":" + oldValue + "->" + newValue + ";"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * @Description: 根据父组织获取所有子组织 | 
 |  |  |      * @Param: [] | 
 |  |  |      * @return: java.util.List<com.moral.api.entity.Organization> | 
 |  |  | 
 |  |  |                 result.setFieldAnnoName("过期时间"); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         String content = CompareFieldUtils.resultsConvertContent(results, "修改了组织;组织名称:"+oldOrganization.getName()); | 
 |  |  |         logUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  |