From 805e157050677bc75e14df94e5181c71dd295cb2 Mon Sep 17 00:00:00 2001 From: "java_cuibaocheng@163.com" Date: Wed, 15 Nov 2023 16:21:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=8F=A3=E5=9F=BA=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF-=E5=A2=9E=E5=8A=A0=E4=BA=BA=E5=8F=A3=E8=AE=A4?= =?UTF-8?q?=E9=A2=86=E5=8A=9F=E8=83=BD=20=E4=BA=BA=E5=8F=A3=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF-=E5=A2=9E=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PopulationLogApiController.java | 50 +++ .../PopulationLogAppController.java | 52 +++ .../PopulationInfoRouteController.java | 14 + .../populationinfo/IPopulationInfoDao.java | 2 + .../dao/populationlog/IPopulationLogDao.java | 46 +++ .../populationinfo/PopulationInfoDTO.java | 10 + .../dtos/populationlog/PopulationLogDTO.java | 117 ++++++ .../IPopulationInfoService.java | 3 +- .../impl/PopulationInfoServiceImpl.java | 54 ++- .../populationlog/IPopulationLogService.java | 57 +++ .../impl/PopulationLogServiceImpl.java | 359 ++++++++++++++++++ .../cm/population/utils/IdCardVerifyUtil.java | 5 + .../populationinfo/population-info-mapper.xml | 9 + .../populationlog/population-log-mapper.xml | 73 ++++ .../templates/populationinfo/bind.html | 244 ++++++++++++ .../populationinfo/list-creator.html | 70 +++- .../templates/populationinfo/list.html | 44 ++- .../templates/populationinfo/log.html | 132 +++++++ .../templates/populationinfo/query.html | 1 + 19 files changed, 1325 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/cm/population/controller/api/populationlog/PopulationLogApiController.java create mode 100644 src/main/java/com/cm/population/controller/app/api/populationlog/PopulationLogAppController.java create mode 100644 src/main/java/com/cm/population/dao/populationlog/IPopulationLogDao.java create mode 100644 src/main/java/com/cm/population/pojo/dtos/populationlog/PopulationLogDTO.java create mode 100644 src/main/java/com/cm/population/service/populationlog/IPopulationLogService.java create mode 100644 src/main/java/com/cm/population/service/populationlog/impl/PopulationLogServiceImpl.java create mode 100644 src/main/resources/mybatis/mapper/populationlog/population-log-mapper.xml create mode 100644 src/main/resources/templates/populationinfo/bind.html create mode 100644 src/main/resources/templates/populationinfo/log.html diff --git a/src/main/java/com/cm/population/controller/api/populationlog/PopulationLogApiController.java b/src/main/java/com/cm/population/controller/api/populationlog/PopulationLogApiController.java new file mode 100644 index 0000000..c13e57c --- /dev/null +++ b/src/main/java/com/cm/population/controller/api/populationlog/PopulationLogApiController.java @@ -0,0 +1,50 @@ +package com.cm.population.controller.api.populationlog; + +import com.cm.common.base.AbstractController; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.ErrorResult; +import com.cm.common.result.SuccessResult; +import com.cm.population.pojo.dtos.populationlog.PopulationLogDTO; +import com.cm.population.service.populationlog.IPopulationLogService; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @ClassName: PopulationInfoAppController + * @Description: 基础人口创建人日志 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +@Api(tags = ISystemConstant.API_PREFIX + "基础人口创建人日志接口") +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/populationlog") +public class PopulationLogApiController extends AbstractController { + @Autowired + private IPopulationLogService populationLogService; + + @ApiOperation(value = "新增基础人口创建人日志", notes = "新增基础人口创建人日志接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("save/{populationInfoIds}") + public SuccessResult save(@PathVariable("populationInfoIds") String populationInfoIds) { + populationLogService.save(null, populationInfoIds); + return new SuccessResult(); + } + + @ApiOperation(value = "基础人口信息列表", notes = "基础人口信息列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list/{populationInfoId}") + public List list(@PathVariable("populationInfoId") String populationInfoId) { + return populationLogService.list(null, populationInfoId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/cm/population/controller/app/api/populationlog/PopulationLogAppController.java b/src/main/java/com/cm/population/controller/app/api/populationlog/PopulationLogAppController.java new file mode 100644 index 0000000..a09373a --- /dev/null +++ b/src/main/java/com/cm/population/controller/app/api/populationlog/PopulationLogAppController.java @@ -0,0 +1,52 @@ +package com.cm.population.controller.app.api.populationlog; + +import com.cm.common.base.AbstractController; +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.ErrorResult; +import com.cm.common.result.SuccessResult; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; +import com.cm.population.pojo.dtos.populationlog.PopulationLogDTO; +import com.cm.population.service.populationlog.IPopulationLogService; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: PopulationInfoAppController + * @Description: 基础人口创建人日志 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "基础人口创建人日志接口") +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/populationlog") +public class PopulationLogAppController extends AbstractController { + @Autowired + private IPopulationLogService populationLogService; + + @ApiOperation(value = "新增基础人口创建人日志", notes = "新增基础人口创建人日志接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("save/{populationInfoIds}") + public SuccessResult save(@RequestHeader("token") String token, @PathVariable("populationInfoIds") String populationInfoIds) { + populationLogService.save(token, populationInfoIds); + return new SuccessResult(); + } + + @ApiOperation(value = "基础人口信息列表", notes = "基础人口信息列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list/{populationInfoId}") + public List list(@RequestHeader("token") String token, @PathVariable("populationInfoId") String populationInfoId) { + return populationLogService.list(token, populationInfoId); + } + +} \ No newline at end of file diff --git a/src/main/java/com/cm/population/controller/route/populationinfo/PopulationInfoRouteController.java b/src/main/java/com/cm/population/controller/route/populationinfo/PopulationInfoRouteController.java index a3737e3..f6731f1 100644 --- a/src/main/java/com/cm/population/controller/route/populationinfo/PopulationInfoRouteController.java +++ b/src/main/java/com/cm/population/controller/route/populationinfo/PopulationInfoRouteController.java @@ -57,4 +57,18 @@ public class PopulationInfoRouteController extends AbstractController { return new ModelAndView("populationinfo/query"); } + @GetMapping("bind") + public ModelAndView bind() { + ModelAndView mv = new ModelAndView("populationinfo/bind"); + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + mv.addObject("creator", userInfoBO.getUserId()); + return mv; + } + @GetMapping("log") + public ModelAndView log(String populationInfoId) { + ModelAndView mv = new ModelAndView("populationinfo/log"); + mv.addObject("populationInfoId", populationInfoId); + return mv; + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java b/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java index c056768..062df2b 100644 --- a/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java +++ b/src/main/java/com/cm/population/dao/populationinfo/IPopulationInfoDao.java @@ -118,4 +118,6 @@ public interface IPopulationInfoDao { Integer count(Map params) throws SearchException; PopulationInfoBaseDTO getBase(Map params); + + void updateCreator(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/populationlog/IPopulationLogDao.java b/src/main/java/com/cm/population/dao/populationlog/IPopulationLogDao.java new file mode 100644 index 0000000..15b2c00 --- /dev/null +++ b/src/main/java/com/cm/population/dao/populationlog/IPopulationLogDao.java @@ -0,0 +1,46 @@ +package com.cm.population.dao.populationlog; + +import com.cm.common.exception.SaveException; +import com.cm.common.exception.SearchException; +import com.cm.population.pojo.dtos.populationlog.PopulationLogDTO; +import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IPopulationLogDao + * @Description: 基础人口创建人修改日志 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +@Repository +public interface IPopulationLogDao { + + /** + * 新增基础人口信息 + * + * @param params + * @throws SaveException + */ + void save(Map params) throws SaveException; + + /** + * 基础人口信息列表 + * + * @param params + * @return + * @throws SearchException + */ + List list(Map params) throws SearchException; + + /** + * 基础人口信息统计 + * + * @param params + * @return + * @throws SearchException + */ + Integer count(Map params) throws SearchException; + +} \ No newline at end of file diff --git a/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoDTO.java b/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoDTO.java index b005baa..a3aed69 100644 --- a/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/populationinfo/PopulationInfoDTO.java @@ -177,6 +177,16 @@ public class PopulationInfoDTO { private Integer age; @ApiModelProperty(name = "创建人", value = "创建人") private String creator; + @ApiModelProperty(name = "创建人姓名", value = "创建人姓名") + private String creatorName; + + public String getCreatorName() { + return creatorName; + } + + public void setCreatorName(String creatorName) { + this.creatorName = creatorName; + } public List getLabelList() { return labelList == null ? new ArrayList() : labelList; diff --git a/src/main/java/com/cm/population/pojo/dtos/populationlog/PopulationLogDTO.java b/src/main/java/com/cm/population/pojo/dtos/populationlog/PopulationLogDTO.java new file mode 100644 index 0000000..16cf737 --- /dev/null +++ b/src/main/java/com/cm/population/pojo/dtos/populationlog/PopulationLogDTO.java @@ -0,0 +1,117 @@ +package com.cm.population.pojo.dtos.populationlog; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * + * @ClassName: PopulationInfoLogDTO + * @Description: 基础人口创建人调整记录 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +@ApiModel +public class PopulationLogDTO { + + @ApiModelProperty(name = "populationInfoId", value = "人员ID") + private String populationInfoId; + @ApiModelProperty(name = "populationLogId", value = "日志ID") + private String populationLogId; + @ApiModelProperty(name = "populationInfoNewCreatorName", value = "新的创建人姓名") + private String populationInfoNewCreatorName; + @ApiModelProperty(name = "populationInfoNewCreator", value = "新的创建人") + private String populationInfoNewCreator; + @ApiModelProperty(name = "populationInfoOldCreatorName", value = "旧的创建人姓名") + private String populationInfoOldCreatorName; + @ApiModelProperty(name = "populationInfoOldCreator", value = "旧的创建人") + private String populationInfoOldCreator; + @ApiModelProperty(name = "populationInfoContent", value = "日志内容") + private String populationInfoContent; + @ApiModelProperty(name = "populationInfoData", value = "日志内容") + private String populationInfoData; + @ApiModelProperty(name = "creator") + private String creator; + @ApiModelProperty(name = "gmtCreate") + private String gmtCreate; + + public String getPopulationInfoData() { + return populationInfoData; + } + + public void setPopulationInfoData(String populationInfoData) { + this.populationInfoData = populationInfoData; + } + + public String getPopulationInfoId() { + return populationInfoId; + } + + public void setPopulationInfoId(String populationInfoId) { + this.populationInfoId = populationInfoId; + } + + public String getPopulationLogId() { + return populationLogId; + } + + public void setPopulationLogId(String populationLogId) { + this.populationLogId = populationLogId; + } + + public String getPopulationInfoNewCreatorName() { + return populationInfoNewCreatorName; + } + + public void setPopulationInfoNewCreatorName(String populationInfoNewCreatorName) { + this.populationInfoNewCreatorName = populationInfoNewCreatorName; + } + + public String getPopulationInfoNewCreator() { + return populationInfoNewCreator; + } + + public void setPopulationInfoNewCreator(String populationInfoNewCreator) { + this.populationInfoNewCreator = populationInfoNewCreator; + } + + public String getPopulationInfoOldCreatorName() { + return populationInfoOldCreatorName; + } + + public void setPopulationInfoOldCreatorName(String populationInfoOldCreatorName) { + this.populationInfoOldCreatorName = populationInfoOldCreatorName; + } + + public String getPopulationInfoOldCreator() { + return populationInfoOldCreator; + } + + public void setPopulationInfoOldCreator(String populationInfoOldCreator) { + this.populationInfoOldCreator = populationInfoOldCreator; + } + + public String getPopulationInfoContent() { + return populationInfoContent; + } + + public void setPopulationInfoContent(String populationInfoContent) { + this.populationInfoContent = populationInfoContent; + } + + public String getCreator() { + return creator; + } + + public void setCreator(String creator) { + this.creator = creator; + } + + public String getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(String gmtCreate) { + this.gmtCreate = gmtCreate; + } +} diff --git a/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java b/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java index 695a49c..bc2f31f 100644 --- a/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java +++ b/src/main/java/com/cm/population/service/populationinfo/IPopulationInfoService.java @@ -194,7 +194,6 @@ public interface IPopulationInfoService { SuccessResultList> listPageBySelf(String token, ListPage page); - /** * 基础人口信息统计 * @@ -203,7 +202,7 @@ public interface IPopulationInfoService { */ Integer count(Map params); - List listByHouseId(String houseId); + void updateCreator(String populationInfoId, String creator); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java index 23c1ff4..5be1a9f 100644 --- a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java +++ b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java @@ -2,6 +2,8 @@ package com.cm.population.service.populationinfo.impl; import com.cm.common.base.AbstractService; import com.cm.common.exception.SaveException; +import com.cm.common.plugin.oauth.service.user.IUserService; +import com.cm.common.plugin.pojo.bos.UserResourceBO; import com.cm.common.plugin.pojo.dtos.dataarea.DataAreaDTO; import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO; import com.cm.common.plugin.service.dataarea.IDataAreaService; @@ -34,6 +36,7 @@ import com.cm.population.service.dispute.IDisputeService; import com.cm.population.service.drug.IDrugService; import com.cm.population.service.petition.IPetitionService; import com.cm.population.service.populationinfo.IPopulationInfoService; +import com.cm.population.service.populationlog.IPopulationLogService; import com.cm.population.service.release.IReleaseService; import com.cm.population.service.security.ISecurityService; import com.cm.population.utils.IdCardVerifyUtil; @@ -61,6 +64,9 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul @Autowired private IAreatreeDao iAreatreeDao; + @Autowired + private IPopulationLogService iPopulationLogService; + @Override public DataAreaDTO getAreaByCode(String code) { Map params = new HashMap<>(); @@ -267,7 +273,8 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul }else{ setSaveInfo(token, params); } - populationInfoDao.save(params);// + populationInfoDao.save(params); + iPopulationLogService.saveInit(token, populationInfoId, params);// 记录日志 return populationInfoId; } @@ -278,6 +285,7 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul @Override public void remove(String token, List ids) { + iPopulationLogService.delete(token, StringUtils.join(ids, "_")); Map params = getHashMap(2); params.put("populationInfoIds", ids); if(StringUtils.isEmpty(token)) { @@ -339,7 +347,24 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul }else{ setUpdateInfo(token, params); } + PopulationInfoDTO populationInfoDTO = get(populationInfoId); populationInfoDao.update(params); + /** + * 找出变更的字段 + */ + Map oldParams = HashMapUtil.objectToMap(populationInfoDTO); + Map change = new LinkedHashMap<>(); + for(Map.Entry p : oldParams.entrySet()) { + Object obj = params.get(p.getKey()); + if (obj != null) { + if(!obj.toString().equals(p.getValue())) { + change.put(p.getKey(), p.getValue()); + change.put(p.getKey() + "New", obj); + } + } + } + if (change.size() > 0) + iPopulationLogService.update(token, populationInfoId, change);// 记录日志 } @Autowired @@ -400,11 +425,30 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul return getPO(params); } + @Autowired + private IUserService iUserService; + @Override public List list(Map params) { List listList = populationInfoDao.list(params); + ArrayList arr = new ArrayList(); + for(PopulationInfoDTO dto : listList) { + arr.add(dto.getCreator()); + } + // 查询用户 + List jsonArray = iUserService.listUserResourceByIds(arr); + UserResourceBO bo1 = new UserResourceBO(); + bo1.setUserId("1"); + bo1.setUserName("超级管理员"); + jsonArray.add(bo1); List list = iDataDictionaryService.listDictionaryByParentId("5ea50f00-3d76-492c-8680-9c30d50cce21"); for(PopulationInfoDTO populationInfoDTO : listList) { + for(UserResourceBO bo : jsonArray) { + if (bo.getUserId().equals(populationInfoDTO.getCreator())) { + populationInfoDTO.setCreatorName(bo.getUserName()); + break; + } + } if (populationInfoDTO != null && !StringUtil.isEmpty(populationInfoDTO.getLabel()) && populationInfoDTO.getLabel().length() > 0) { List dataList = new ArrayList<>(); for(DataDictionaryDTO dto : list) { @@ -456,4 +500,12 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul params.put("houseId", houseId); return list(params); } + + @Override + public void updateCreator(String populationInfoId, String creator) { + Map params = getHashMap(2); + params.put("populationInfoId", populationInfoId); + params.put("creator", creator); + populationInfoDao.updateCreator(params); + } } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/populationlog/IPopulationLogService.java b/src/main/java/com/cm/population/service/populationlog/IPopulationLogService.java new file mode 100644 index 0000000..55425e9 --- /dev/null +++ b/src/main/java/com/cm/population/service/populationlog/IPopulationLogService.java @@ -0,0 +1,57 @@ +package com.cm.population.service.populationlog; + +import com.cm.common.plugin.pojo.dtos.dataarea.DataAreaDTO; +import com.cm.common.pojo.ListPage; +import com.cm.common.result.SuccessResultList; +import com.cm.population.pojo.bos.populationinfo.PopulationInfoBO; +import com.cm.population.pojo.dtos.areatree.AreaZtreeDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; +import com.cm.population.pojo.dtos.populationlog.PopulationLogDTO; +import com.cm.population.pojo.pos.populationinfo.PopulationInfoPO; +import com.cm.population.pojo.vos.populationinfo.PopulationInfoVO; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IPopulationInfoService + * @Description: 基础人口信息 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +public interface IPopulationLogService { + + /** + * 修改认领人保存 + * @return + */ + void save(String token, String populationInfoIds); + + /** + * 首次人口信息保存 + * @param token + * @param populationInfoId + */ + void saveInit(String token, String populationInfoId, Map changeData); + + /** + * 人口信息修改 + * @param token + * @param populationInfoId + */ + void update(String token, String populationInfoId, Map changeData); + + void delete(String token, String populationInfoIds); + /** + * @return + */ + List list(String token, String populationInfoId); + + /** + * @return + */ + Integer count(String populationInfoId); + +} \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/populationlog/impl/PopulationLogServiceImpl.java b/src/main/java/com/cm/population/service/populationlog/impl/PopulationLogServiceImpl.java new file mode 100644 index 0000000..4c4594f --- /dev/null +++ b/src/main/java/com/cm/population/service/populationlog/impl/PopulationLogServiceImpl.java @@ -0,0 +1,359 @@ +package com.cm.population.service.populationlog.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cm.common.base.AbstractService; +import com.cm.common.exception.SaveException; +import com.cm.common.plugin.oauth.service.user.IUserService; +import com.cm.common.plugin.pojo.bos.UserResourceBO; +import com.cm.common.plugin.pojo.dtos.dataarea.DataAreaDTO; +import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO; +import com.cm.common.plugin.service.datadictionary.IDataDictionaryService; +import com.cm.common.pojo.ListPage; +import com.cm.common.pojo.bos.UserInfoBO; +import com.cm.common.result.SuccessResultList; +import com.cm.common.token.app.AppTokenManager; +import com.cm.common.token.app.entity.AppTokenUser; +import com.cm.common.utils.DateUtil; +import com.cm.common.utils.HashMapUtil; +import com.cm.common.utils.UUIDUtil; +import com.cm.population.dao.areatree.IAreatreeDao; +import com.cm.population.dao.populationinfo.IPopulationInfoDao; +import com.cm.population.dao.populationlog.IPopulationLogDao; +import com.cm.population.pojo.bos.populationinfo.PopulationInfoBO; +import com.cm.population.pojo.dtos.areatree.AreaZtreeDTO; +import com.cm.population.pojo.dtos.correct.CorrectDTO; +import com.cm.population.pojo.dtos.cult.CultDTO; +import com.cm.population.pojo.dtos.dispute.DisputeDTO; +import com.cm.population.pojo.dtos.drug.DrugDTO; +import com.cm.population.pojo.dtos.petition.PetitionDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoDTO; +import com.cm.population.pojo.dtos.populationinfo.PopulationInfoLabelDTO; +import com.cm.population.pojo.dtos.populationlog.PopulationLogDTO; +import com.cm.population.pojo.dtos.release.ReleaseDTO; +import com.cm.population.pojo.dtos.security.SecurityDTO; +import com.cm.population.pojo.pos.populationinfo.PopulationInfoPO; +import com.cm.population.pojo.vos.populationinfo.PopulationInfoVO; +import com.cm.population.service.correct.ICorrectService; +import com.cm.population.service.cult.ICultService; +import com.cm.population.service.dispute.IDisputeService; +import com.cm.population.service.drug.IDrugService; +import com.cm.population.service.petition.IPetitionService; +import com.cm.population.service.populationinfo.IPopulationInfoService; +import com.cm.population.service.populationlog.IPopulationLogService; +import com.cm.population.service.release.IReleaseService; +import com.cm.population.service.security.ISecurityService; +import com.cm.population.utils.IdCardVerifyUtil; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.github.pagehelper.util.StringUtil; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.record.BOFRecord; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import springfox.documentation.spring.web.json.Json; + +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @ClassName: PopulationLogServiceImpl + * @Description: 基础人口日志 + * @Author: CodeFactory + * @Date: 2023-10-24 11:55:46 + * @Version: 3.0 + **/ +@Service +public class PopulationLogServiceImpl extends AbstractService implements IPopulationLogService { + + @Autowired + private IPopulationLogDao populationLogDao; + + @Autowired + private IPopulationInfoService iPopulationInfoService; + + @Autowired + private IUserService iUserService; + + public static final SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + public static String getTime() { + return sdfTime.format(new Date()); + } + + @Override + public void delete(String token, String populationInfoIds) { + List ids = Arrays.asList(populationInfoIds.split("\\_")); + Map queryPopulation = new HashMap<>(); + queryPopulation.put("populationInfoIds", ids); + List populationList = iPopulationInfoService.list(queryPopulation); + // 拼接creator; + ArrayList arr = new ArrayList(); + for(PopulationInfoDTO dto : populationList) { + arr.add(dto.getCreator()); + } + // 查询用户 + List jsonArray = iUserService.listUserResourceByIds(arr); + UserResourceBO bo1 = new UserResourceBO(); + bo1.setUserId("1"); + bo1.setUserName("超级管理员"); + jsonArray.add(bo1); + // 获取登录人信息 + String creator = ""; + String creatorName = ""; + if(StringUtils.isEmpty(token)) { + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + if (userInfoBO != null) { + creator = userInfoBO.getUserId(); + creatorName = userInfoBO.getUserName(); + } + }else{ + AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser(); + creator = appTokenUser.getId(); + creatorName = appTokenUser.getName(); + } + if (StringUtils.isEmpty(creator)) { + throw new SaveException("请先登录"); + } + if (creatorName.equals("admin")) { + creatorName = "超级管理员"; + } + // 循环保存日志 + for(PopulationInfoDTO dto : populationList) { + String populationInfoId = dto.getPopulationInfoId(); + String oldCreator = dto.getCreator(); + String oldCreatorName = ""; + for(UserResourceBO bo : jsonArray) { + if (bo.getUserId().equals(oldCreator)) { + oldCreatorName = bo.getUserName(); + break; + } + } + String gmtCreate = getTime(); + String content = "DELETE --- 登录人将." + dto.getName() + "[" + dto.getIdcard() + "]基础人员信息删除 操作人." + creatorName + "[" + creator + "]"; + Map params = new HashMap<>(); + params.put("populationLogId", UUIDUtil.get32UUID()); + params.put("populationInfoId", populationInfoId); + params.put("populationInfoNewCreatorName", creatorName); + params.put("populationInfoNewCreator", creator); + params.put("populationInfoOldCreatorName", oldCreatorName); + params.put("populationInfoOldCreator", oldCreator); + params.put("populationInfoContent", content); + params.put("creator", creator); + params.put("gmtCreate", gmtCreate); + populationLogDao.save(params); + } + } + + @Override + public void saveInit(String token, String populationInfoId, Map changeParams) { + // 获取登录人信息 + String creator = ""; + String creatorName = ""; + if(StringUtils.isEmpty(token)) { + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + if (userInfoBO != null) { + creator = userInfoBO.getUserId(); + creatorName = userInfoBO.getUserName(); + } + }else{ + AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser(); + creator = appTokenUser.getId(); + creatorName = appTokenUser.getName(); + } + if (StringUtils.isEmpty(creator)) { + throw new SaveException("请先登录"); + } + if (creatorName.equals("admin")) { + creatorName = "超级管理员"; + } + String gmtCreate = getTime(); + PopulationInfoDTO dto = iPopulationInfoService.get(populationInfoId); + String content = "INSERT --- 登录人将." + dto.getName() + "[" + dto.getIdcard() + "]基础人员信息创建 操作人." + creatorName + "[" + creator + "]"; + Map params = new HashMap<>(); + params.put("populationLogId", UUIDUtil.get32UUID()); + params.put("populationInfoId", populationInfoId); + params.put("populationInfoNewCreatorName", creatorName); + params.put("populationInfoNewCreator", creator); + params.put("populationInfoOldCreatorName", ""); + params.put("populationInfoOldCreator", ""); + params.put("populationInfoContent", content); + params.put("populationInfoData", JSON.toJSONString(changeParams)); + params.put("creator", creator); + params.put("gmtCreate", gmtCreate); + populationLogDao.save(params); + } + + @Override + public void update(String token, String populationInfoId, Map changeParams) { + // 获取登录人信息 + String creator = ""; + String creatorName = ""; + if(StringUtils.isEmpty(token)) { + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + if (userInfoBO != null) { + creator = userInfoBO.getUserId(); + creatorName = userInfoBO.getUserName(); + } + }else{ + AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser(); + creator = appTokenUser.getId(); + creatorName = appTokenUser.getName(); + } + if (StringUtils.isEmpty(creator)) { + throw new SaveException("请先登录"); + } + if (creatorName.equals("admin")) { + creatorName = "超级管理员"; + } + String gmtCreate = getTime(); + PopulationInfoDTO dto = iPopulationInfoService.get(populationInfoId); + String content = "UPDATE --- 登录人将." + dto.getName() + "[" + dto.getIdcard() + "]基础人员信息修改 操作人." + creatorName + "[" + creator + "]"; + Map params = new HashMap<>(); + params.put("populationLogId", UUIDUtil.get32UUID()); + params.put("populationInfoId", populationInfoId); + params.put("populationInfoNewCreatorName", creatorName); + params.put("populationInfoNewCreator", creator); + params.put("populationInfoOldCreatorName", ""); + params.put("populationInfoOldCreator", ""); + params.put("populationInfoContent", content); + params.put("populationInfoData", JSON.toJSONString(changeParams)); + params.put("creator", creator); + params.put("gmtCreate", gmtCreate); + populationLogDao.save(params); + } + + @Override + public void save(String token, String populationInfoIds) { + List ids = Arrays.asList(populationInfoIds.split("\\_")); + Map queryPopulation = new HashMap<>(); + queryPopulation.put("populationInfoIds", ids); + List populationList = iPopulationInfoService.list(queryPopulation); + // 拼接creator; + ArrayList arr = new ArrayList(); + for(PopulationInfoDTO dto : populationList) { + arr.add(dto.getCreator()); + } + // 查询用户 + List jsonArray = iUserService.listUserResourceByIds(arr); + UserResourceBO bo1 = new UserResourceBO(); + bo1.setUserId("1"); + bo1.setUserName("超级管理员"); + jsonArray.add(bo1); + // 获取登录人信息 + String creator = ""; + String creatorName = ""; + if(StringUtils.isEmpty(token)) { + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + if (userInfoBO != null) { + creator = userInfoBO.getUserId(); + creatorName = userInfoBO.getUserName(); + } + }else{ + AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser(); + creator = appTokenUser.getId(); + creatorName = appTokenUser.getName(); + } + if (StringUtils.isEmpty(creator)) { + throw new SaveException("请先登录"); + } + if (creatorName.equals("admin")) { + creatorName = "超级管理员"; + } + // 循环保存日志 + for(PopulationInfoDTO dto : populationList) { + String populationInfoId = dto.getPopulationInfoId(); + String oldCreator = dto.getCreator(); + if (oldCreator.equals(creator)) {// 人如果相同的不记录 + continue; + } + String oldCreatorName = ""; + for(UserResourceBO bo : jsonArray) { + if (bo.getUserId().equals(oldCreator)) { + oldCreatorName = bo.getUserName(); + break; + } + } + String gmtCreate = getTime(); + String content = "CHANGE --- 登录人将." + dto.getName() + "[" + dto.getIdcard() + "]基础人员信息的信息归属从." + oldCreatorName + "[" + oldCreator + "]修改为了." + creatorName + "[" + creator + "]"; + Map params = new HashMap<>(); + params.put("populationLogId", UUIDUtil.get32UUID()); + params.put("populationInfoId", populationInfoId); + params.put("populationInfoNewCreatorName", creatorName); + params.put("populationInfoNewCreator", creator); + params.put("populationInfoOldCreatorName", oldCreatorName); + params.put("populationInfoOldCreator", oldCreator); + params.put("populationInfoContent", content); + params.put("creator", creator); + params.put("gmtCreate", gmtCreate); + populationLogDao.save(params); + // 修改创建人 + iPopulationInfoService.updateCreator(populationInfoId, creator); + } + } + + @Override + public List list(String token, String populationInfoId) { + Map params = new HashMap<>(); + params.put("populationInfoId", StringUtils.isEmpty(populationInfoId) ? "-1" : populationInfoId); + // 获取登录人信息 + String creator = ""; + if(StringUtils.isEmpty(token)) { + UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); + if (userInfoBO != null) { + creator = userInfoBO.getUserId(); + } + }else{ + AppTokenUser appTokenUser = AppTokenManager.getInstance().getToken(token).getAppTokenUser(); + creator = appTokenUser.getId(); + } + if (StringUtils.isEmpty(creator)) { + throw new SaveException("请先登录"); + } + List list = populationLogDao.list(params); + if (!creator.equals("1")) { + for(PopulationLogDTO dto : list) { + dto.setPopulationInfoData(""); // 不给返回操作的数据 + String populationInfoContent = dto.getPopulationInfoContent(); + Pattern pattern = Pattern.compile("[a-zA-Z0-9-]{36}"); + Matcher matcher = pattern.matcher(populationInfoContent); + while(matcher.find()) { + String data = matcher.group(); + String text = data.substring(0, 8) + "-*-*-*-*" + data.substring(30, 36); + populationInfoContent = populationInfoContent.replace(data, text); + } + Pattern pattern2 = Pattern.compile("[X0-9]{18}"); + Matcher matcher2 = pattern2.matcher(populationInfoContent); + while(matcher2.find()) { + String idcard = matcher2.group(); + if (IdCardVerifyUtil.isIDCard(idcard)) { + String text = IdCardVerifyUtil.desensitizeIdCardNumber(idcard); + populationInfoContent = populationInfoContent.replace(idcard, text); + } + } + Pattern pattern3 = Pattern.compile("[X0-9]{15}"); + Matcher matcher3 = pattern3.matcher(populationInfoContent); + while(matcher3.find()) { + String idcard = matcher3.group(); + if (IdCardVerifyUtil.isIDCard(idcard)) { + String text = IdCardVerifyUtil.desensitizeIdCardNumber(idcard); + populationInfoContent = populationInfoContent.replace(idcard, text); + } + } + dto.setPopulationInfoContent(populationInfoContent); + } + } + return list; + } + + @Override + public Integer count(String populationInfoId) { + Map params = new HashMap<>(); + params.put("populationInfoId", StringUtils.isEmpty(populationInfoId) ? "-1" : populationInfoId); + return populationLogDao.count(params); + } +} \ No newline at end of file diff --git a/src/main/java/com/cm/population/utils/IdCardVerifyUtil.java b/src/main/java/com/cm/population/utils/IdCardVerifyUtil.java index bfa2710..5258815 100644 --- a/src/main/java/com/cm/population/utils/IdCardVerifyUtil.java +++ b/src/main/java/com/cm/population/utils/IdCardVerifyUtil.java @@ -75,6 +75,11 @@ public class IdCardVerifyUtil { return sb.toString(); } + /** + * 身份证号码脱敏 + * @param idCardNumber + * @return + */ public static String desensitizeIdCardNumber(String idCardNumber) { if (idCardNumber.length() < 15 || idCardNumber.length() > 18) { return idCardNumber; diff --git a/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml b/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml index 2b1353e..44b87f6 100644 --- a/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml +++ b/src/main/resources/mybatis/mapper/populationinfo/population-info-mapper.xml @@ -404,6 +404,15 @@ ) + + UPDATE + population_population_info + SET + creator = #{creator} + WHERE + population_info_id = #{populationInfoId} + + UPDATE diff --git a/src/main/resources/mybatis/mapper/populationlog/population-log-mapper.xml b/src/main/resources/mybatis/mapper/populationlog/population-log-mapper.xml new file mode 100644 index 0000000..ca744bd --- /dev/null +++ b/src/main/resources/mybatis/mapper/populationlog/population-log-mapper.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + INSERT INTO population_population_log( + population_log_id, + population_info_id, + population_info_new_creator_name, + population_info_new_creator, + population_info_old_creator_name, + population_info_old_creator, + population_info_content, + population_info_data, + creator, + gmt_create + ) VALUES( + #{populationLogId}, + #{populationInfoId}, + #{populationInfoNewCreatorName}, + #{populationInfoNewCreator}, + #{populationInfoOldCreatorName}, + #{populationInfoOldCreator}, + #{populationInfoContent}, + #{populationInfoData}, + #{creator}, + #{gmtCreate} + ) + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/populationinfo/bind.html b/src/main/resources/templates/populationinfo/bind.html new file mode 100644 index 0000000..00369b6 --- /dev/null +++ b/src/main/resources/templates/populationinfo/bind.html @@ -0,0 +1,244 @@ + + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/populationinfo/list-creator.html b/src/main/resources/templates/populationinfo/list-creator.html index 30d77fe..bf02ce2 100644 --- a/src/main/resources/templates/populationinfo/list-creator.html +++ b/src/main/resources/templates/populationinfo/list-creator.html @@ -55,6 +55,9 @@ + @@ -142,7 +145,7 @@ [ {type:'checkbox', fixed: 'left'}, {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'}, - {field: 'name', width: 180, title: '姓名', align:'center', + {field: 'name', width: 130, title: '姓名', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -151,7 +154,7 @@ return rowData; } }, - {field: 'idcardType', width: 180, title: '证件类型', align:'center', + {field: 'idcardType', width: 130, title: '证件类型', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -169,7 +172,7 @@ return rowData; } }, - {field: 'birthday', width: 180, title: '出生日期', align:'center', + {field: 'birthday', width: 130, title: '出生日期', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -178,7 +181,7 @@ return rowData; } }, - {field: 'sex', width: 180, title: '性别', align:'center', + {field: 'sex', width: 130, title: '性别', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -187,7 +190,7 @@ return rowData; } }, - {field: 'nation', width: 180, title: '民族', align:'center', + {field: 'nation', width: 130, title: '民族', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -208,6 +211,11 @@ } return b; } + }, + {field: 'creator', width:120, title: '认领记录', align:'center', + templet: function(row) { + return ''; + } } ] ], @@ -238,6 +246,27 @@ }); } + // 表格行中按钮事件 + table.on('tool(dataTable)', function(obj) { + var layEvent = obj.event; + var data = obj.data; + if(layEvent === 'bindEvent') { + top.layer.open({ + type: 2, + title: data.name + "[" + data.idcard + "]", + closeBtn: 1, + offset:"r", + area: ['500px', '100%'], + shadeClose: true, + anim: 2, + content: top.restAjax.path('route/populationinfo/log?populationInfoId={populationInfoId}', [data.populationInfoId]), + end: function() { + reloadTable(); + } + }); + } + }); + // 删除 function removeData(ids) { top.dialog.msg(top.dataMessage.delete, { @@ -322,6 +351,37 @@ } removeData(ids); } + } else if(layEvent === 'bindEvent') { + window.sessionStorage.setItem("tempBindPopulationInfo", null); + top.layer.open({ + type: 2, + title: "认领基础人口信息", + closeBtn: 1, + area: ['90%', '90%'], + shadeClose: true, + anim: 2, + content: top.restAjax.path('route/populationinfo/bind', []), + end: function() { + try{ + var loadLayerIndex; + var ids = window.sessionStorage.getItem("tempBindPopulationInfo"); + if(ids != null && ids != undefined && ids != 'null' && ids.length > 0) { + top.restAjax.post(top.restAjax.path('api/populationlog/save/' + ids, []), {}, null, function(code, data) { + layer.msg("认领成功"); + reloadTable(); + }, function(code, data) { + top.dialog.msg(data.msg); + }, function() { + loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3}); + }, function() { + top.dialog.close(loadLayerIndex); + }); + } + }catch(err){ + top.layer.msg('查询失败'); + } + } + }); } else if(layEvent === 'excelEvent') { top.layer.open({ type: 2, diff --git a/src/main/resources/templates/populationinfo/list.html b/src/main/resources/templates/populationinfo/list.html index e9da1f2..9736a8d 100644 --- a/src/main/resources/templates/populationinfo/list.html +++ b/src/main/resources/templates/populationinfo/list.html @@ -52,9 +52,9 @@ - + + + @@ -142,7 +142,7 @@ [ {type:'checkbox', fixed: 'left'}, {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '{{d.LAY_INDEX}}'}, - {field: 'name', width: 180, title: '姓名', align:'center', + {field: 'name', width: 130, title: '姓名', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -151,7 +151,7 @@ return rowData; } }, - {field: 'idcardType', width: 180, title: '证件类型', align:'center', + {field: 'idcardType', width: 130, title: '证件类型', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -169,7 +169,7 @@ return rowData; } }, - {field: 'birthday', width: 180, title: '出生日期', align:'center', + {field: 'birthday', width: 130, title: '出生日期', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -178,7 +178,7 @@ return rowData; } }, - {field: 'sex', width: 180, title: '性别', align:'center', + {field: 'sex', width: 130, title: '性别', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -187,7 +187,7 @@ return rowData; } }, - {field: 'nation', width: 180, title: '民族', align:'center', + {field: 'nation', width: 130, title: '民族', align:'center', templet: function(row) { var rowData = row[this.field]; if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') { @@ -208,6 +208,11 @@ } return b; } + }, + {field: 'creator', width:120, title: '认领记录', align:'center', + templet: function(row) { + return ''; + } } ] ], @@ -238,6 +243,27 @@ }); } + // 表格行中按钮事件 + table.on('tool(dataTable)', function(obj) { + var layEvent = obj.event; + var data = obj.data; + if(layEvent === 'bindEvent') { + top.layer.open({ + type: 2, + title: data.name + "[" + data.idcard + "]", + closeBtn: 1, + offset:"r", + area: ['500px', '100%'], + shadeClose: true, + anim: 2, + content: top.restAjax.path('route/populationinfo/log?populationInfoId={populationInfoId}', [data.populationInfoId]), + end: function() { + reloadTable(); + } + }); + } + }); + // 删除 function removeData(ids) { top.dialog.msg(top.dataMessage.delete, { @@ -322,7 +348,7 @@ } removeData(ids); } - } else if(layEvent === 'excelEvent') { + }else if(layEvent === 'excelEvent') { top.layer.open({ type: 2, title: false, diff --git a/src/main/resources/templates/populationinfo/log.html b/src/main/resources/templates/populationinfo/log.html new file mode 100644 index 0000000..3f2da4e --- /dev/null +++ b/src/main/resources/templates/populationinfo/log.html @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + +
+
+
+
+
+ +
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/populationinfo/query.html b/src/main/resources/templates/populationinfo/query.html index caa65ec..fadc0ee 100644 --- a/src/main/resources/templates/populationinfo/query.html +++ b/src/main/resources/templates/populationinfo/query.html @@ -99,6 +99,7 @@ elem: '#dataTable', id: 'dataTable', url: top.restAjax.path(tableUrl, []), + defaultToolbar: [], width: admin.screen() > 1 ? '100%' : '', height: $win.height() - 90, limit: 20,