From 784a24a80896f2a31cba72887b75d30bf0f645da Mon Sep 17 00:00:00 2001 From: xyh <18782104331@139.com> Date: 星期一, 28 六月 2021 10:12:45 +0800 Subject: [PATCH] 合并代码 --- springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 203 insertions(+), 37 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java index b8c1aa7..b01bcf4 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java @@ -1,36 +1,43 @@ package com.panzhihua.service_grid.service.impl; +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.enums.EventTasksStatusEnum; -import com.panzhihua.common.model.dtos.grid.EventVisitingTasksAddDTO; -import com.panzhihua.common.model.dtos.grid.EventVisitingTasksDeleteDTO; -import com.panzhihua.common.model.dtos.grid.EventVisitingTasksEditDTO; -import com.panzhihua.common.model.dtos.grid.PageEventVisitingTasksDTO; +import com.panzhihua.common.enums.PopulPoliticalOutlookEnum; +import com.panzhihua.common.model.dtos.EventResourceDTO; +import com.panzhihua.common.model.dtos.grid.*; +import com.panzhihua.common.model.dtos.visit.EventVisitCompleteDTO; import com.panzhihua.common.model.helper.AESUtil; import com.panzhihua.common.model.query.visit.EventTasksQuery; import com.panzhihua.common.model.query.visit.EventVisitListQuery; import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.grid.EventDetailsVO; +import com.panzhihua.common.model.vos.grid.EventResourceVO; import com.panzhihua.common.model.vos.visit.*; +import com.panzhihua.common.utlis.CopyUtil; import com.panzhihua.common.utlis.StringUtils; -import com.panzhihua.service_grid.dao.*; -import com.panzhihua.service_grid.model.dos.*; +import com.panzhihua.service_grid.dao.EventResourceMapper; +import com.panzhihua.service_grid.dao.EventVisitingTasksMapper; +import com.panzhihua.service_grid.model.dos.EventResourceDO; +import com.panzhihua.service_grid.model.dos.EventVisitingTasksDO; +import com.panzhihua.service_grid.service.EventResourceService; import com.panzhihua.service_grid.service.EventVisitingTasksService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.beans.BeanUtils; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; +import java.util.*; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; @@ -50,10 +57,15 @@ @Resource private EventResourceMapper eventResourceMapper; + @Resource + private EventResourceService eventResourceService; + @Value("${domain.aesKey:}") private String aesKey; + /** * 新增重点人群走访记录 + * * @param eventVisitingTasksAddDTO * @return 新增结果 */ @@ -100,6 +112,7 @@ /** * 删除重点人群走访记录 + * * @param EventVisitingTasksDeleteDTO * @return 平台用户信息 */ @@ -109,6 +122,7 @@ /** * 查询重点人群走访记录详细信息 + * * @param id 重点人群走访记录 id * @return 查找结果 */ @@ -137,10 +151,32 @@ } @Override - public R taskList(EventTasksQuery query) { + public R taskList(EventTasksQuery query) throws Exception{ IPage<EventVisitingTasksVO> page = eventVisitingTasksMapper.findListByPage(new Page(query.getPageNum(),query.getPageSize()),query); + for(EventVisitingTasksVO eventVisitingTasksVO:page.getRecords()){ + if(eventVisitingTasksVO.getNationCode() != null){ + eventVisitingTasksVO.setNation(PopulPoliticalOutlookEnum.getCnDescByName(eventVisitingTasksVO.getNationCode())); + } + if(eventVisitingTasksVO.getVisiterTele() != null){ + eventVisitingTasksVO.setVisiterTele(AESUtil.decrypt128(eventVisitingTasksVO.getVisiterTele(), aesKey)); + } + } + return R.ok(page); + } + @Override + public R appTaskList(EventTasksQuery query) throws Exception{ + + IPage<EventVisitingTasksVO> page = eventVisitingTasksMapper.appFindListByPage(new Page(query.getPageNum(),query.getPageSize()),query); + for(EventVisitingTasksVO eventVisitingTasksVO:page.getRecords()){ + if(eventVisitingTasksVO.getNationCode() != null){ + eventVisitingTasksVO.setNation(PopulPoliticalOutlookEnum.getCnDescByName(eventVisitingTasksVO.getNationCode())); + } + if(eventVisitingTasksVO.getVisiterTele() != null){ + eventVisitingTasksVO.setVisiterTele(AESUtil.decrypt128(eventVisitingTasksVO.getVisiterTele(), aesKey)); + } + } return R.ok(page); } @@ -179,8 +215,8 @@ if(eventVisitingTasksDO!=null) { EventVisitingTasksDetailsVO eventVisitingTasksDetailsVO = new EventVisitingTasksDetailsVO(); BeanUtils.copyProperties(eventVisitingTasksDO, eventVisitingTasksDetailsVO); - ; eventVisitingTasksDetailsVO.setVisiterTele(AESUtil.decrypt128(eventVisitingTasksDO.getVisiterTele(), aesKey)); + eventVisitingTasksDetailsVO.setTableContentJson(JSONObject.parseObject(eventVisitingTasksDO.getTableContentJson())); return R.ok(eventVisitingTasksDetailsVO); } return R.fail(); @@ -188,7 +224,7 @@ @Transactional(rollbackFor = Exception.class) @Override - public R add(String ids, Long communityId, Long userId) { + public R add(String ids, Long communityId, Long userId) throws Exception { Map<String,Object> map = eventVisitingTasksMapper.findUserByCommunityId(communityId,6); if(CollectionUtils.isEmpty(map)){ return R.fail("网格员不存在"); @@ -205,15 +241,14 @@ } @Override - public List<EventVisitingTasksVO> exportTaskList(EventTasksQuery query) { + public List<EventVisitingTasksVO> exportTaskList(EventTasksQuery query) throws Exception { IPage<EventVisitingTasksVO> page = eventVisitingTasksMapper.findListByPage(new Page(query.getPageNum(),query.getPageSize()),query); - return page.getRecords(); } - private void addVisitingTask(Long id, Map<String, Object> gridMap,Long communityId,Long userId) { + private void addVisitingTask(Long id, Map<String, Object> gridMap,Long communityId,Long userId) throws Exception{ Integer count = eventVisitingTasksMapper.countNoneComplete(id); if(count > 0){ @@ -224,22 +259,24 @@ return ; } EventVisitingTasksDO visitingTasksDO = new EventVisitingTasksDO(); - visitingTasksDO.setGridMemberStreet(Long.valueOf(gridMap.get("street_id").toString())); - visitingTasksDO.setGridMemberCommunity(communityId); - visitingTasksDO.setGridMember(Long.valueOf(gridMap.get("user_id").toString())); - visitingTasksDO.setGridMemberName(gridMap.get("name").toString()); - visitingTasksDO.setGridMenberTele(gridMap.get("phone") ==null?"":gridMap.get("phone").toString()); +// visitingTasksDO.setGridMemberStreet(Long.valueOf(gridMap.get("street_id").toString())); +// visitingTasksDO.setGridMemberCommunity(communityId); +// visitingTasksDO.setGridMember(Long.valueOf(gridMap.get("user_id").toString())); +// visitingTasksDO.setGridMemberName(gridMap.get("name").toString()); +// visitingTasksDO.setGridMenberTele(gridMap.get("phone") ==null?"":gridMap.get("phone").toString()); visitingTasksDO.setVisiterId(Long.valueOf(map.get("id").toString())); visitingTasksDO.setVisiterName(map.get("name").toString()); visitingTasksDO.setVisiterSex(Integer.valueOf(map.get("sex").toString())); - visitingTasksDO.setVisiterTele(map.get("phone") == null?"":map.get("phone").toString()); + if(map.get("phone") != null){ + visitingTasksDO.setVisiterTele(AESUtil.decrypt128(map.get("phone").toString(),aesKey)); + } StringBuilder sb = new StringBuilder(); sb.append(map.get("address")).append(map.get("road")).append(map.get("door_no")).append(map.get("floor")).append("栋").append(map.get("unit_no")).append("单元").append(map.get("house_no")).append("号"); visitingTasksDO.setVisiterAddress(sb.toString()); visitingTasksDO.setVisiterType(0); visitingTasksDO.setActOpara(0); if(map.get("lat") != null && map.get("lng") != null){ - visitingTasksDO.setHappentLatLng(map.get("lat")+"-"+map.get("lng")); + visitingTasksDO.setHappentLatLng(map.get("lat")+","+map.get("lng")); } visitingTasksDO.setEventStatus(EventTasksStatusEnum.DZF.getCode()); visitingTasksDO.setReporting(0); @@ -247,7 +284,47 @@ visitingTasksDO.setUrgent(false); visitingTasksDO.setUrgentDell(false); visitingTasksDO.setCreateBy(userId); + visitingTasksDO.setOutOrLocal(map.get("out_or_local") == null?null:Integer.valueOf(map.get("out_or_local").toString())); + + if(map.get("label") != null){ + List<String> option = getOption(map.get("label").toString()); + if(!CollectionUtils.isEmpty(option)){ + JSONObject json = new JSONObject(); + json.put("option",option); + visitingTasksDO.setTableContentJson(json.toJSONString()); + } + } + eventVisitingTasksMapper.insert(visitingTasksDO); + } + + private List<String> getOption(String label) { + List<String> option = new ArrayList<>(); + if(!Objects.isNull(label)) { + if (label.contains("精神障碍")) { + option.add("精神障碍异常1"); + option.add("精神障碍异常2"); + option.add("精神障碍异常3"); + option.add("精神障碍异常4"); + + } else if (label.contains("吸毒")) { + option.add("疑似复吸"); + option.add("失联"); + option.add("复吸"); + option.add("空挂户"); + } else if (label.contains("刑满释放")) { + option.add("刑满释放异常1"); + option.add("刑满释放异常2"); + option.add("刑满释放异常3"); + option.add("刑满释放异常4"); + } else if (label.contains("社区矫正")) { + option.add("社区矫正异常1"); + option.add("社区矫正异常2"); + option.add("社区矫正异常3"); + option.add("社区矫正异常4"); + } + } + return option; } @Transactional(rollbackFor = Exception.class) @@ -280,13 +357,23 @@ return R.fail(); } + @Transactional(rollbackFor = Exception.class) @Override - public R start(Long id) { + public synchronized R start(Long id,Long userId) { EventVisitingTasksDO eventVisitingTasksDO = eventVisitingTasksMapper.selectById(id); if(eventVisitingTasksDO == null || eventVisitingTasksDO.getEventStatus() != EventTasksStatusEnum.DZF.getCode()){ return R.fail("当前状态不可开始走访"); } - int rt = eventVisitingTasksMapper.start(id,EventTasksStatusEnum.JXZ.getCode()); + Map<String,Object> map = eventVisitingTasksMapper.findUserById(userId); + EventVisitingTasksDO start = new EventVisitingTasksDO(); + start.setId(id); + start.setGridMemberStreet(Long.valueOf(map.get("street_id").toString())); + start.setGridMemberCommunity(Long.valueOf(map.get("community_id").toString())); + start.setGridMember(Long.valueOf(map.get("user_id").toString())); + start.setGridMemberName(map.get("name").toString()); + start.setGridMenberTele(map.get("phone") ==null?"":map.get("phone").toString()); + start.setEventStatus(EventTasksStatusEnum.JXZ.getCode()); + int rt = eventVisitingTasksMapper.start(start); if(rt > 0){ return R.ok(); } @@ -297,45 +384,124 @@ @Override public R complete(EventVisitCompleteDTO taskCompleteDTO) { EventVisitingTasksDO eventVisitingTasksDO = eventVisitingTasksMapper.selectById(taskCompleteDTO.getId()); - if(eventVisitingTasksDO == null || eventVisitingTasksDO.getEventStatus() != EventTasksStatusEnum.JXZ.getCode()){ + if(eventVisitingTasksDO == null || eventVisitingTasksDO.getEventStatus() != EventTasksStatusEnum.DZF.getCode()){ return R.fail("当前状态不可完成走访"); } + EventVisitingTasksDO complete = new EventVisitingTasksDO(); + BeanUtils.copyProperties(taskCompleteDTO,complete); if(taskCompleteDTO.getException().intValue() == 0){ - taskCompleteDTO.setEventStatus(EventTasksStatusEnum.ZJJJ.getCode()); + complete.setEventStatus(EventTasksStatusEnum.ZJJJ.getCode()); }else{ - taskCompleteDTO.setEventStatus(EventTasksStatusEnum.YC.getCode()); + complete.setEventStatus(EventTasksStatusEnum.YC.getCode()); } + complete.setSubmitDate(DateUtil.parse(taskCompleteDTO.getSubmitDate(), DatePattern.NORM_DATETIME_FORMAT)); + JSONObject json = JSONObject.parseObject(eventVisitingTasksDO.getTableContentJson()); + json.put("check",taskCompleteDTO.getOption()); + complete.setTableContentJson(json.toJSONString()); - if(!CollectionUtils.isEmpty(taskCompleteDTO.getImgList())){ + if(!StringUtils.isEmpty(taskCompleteDTO.getImgList())){ taskCompleteDTO.getImgList().forEach(e->{ - createResource(eventVisitingTasksDO.getId(),eventVisitingTasksDO.getDellUserId(),2,1,e); + createResource(eventVisitingTasksDO.getId(),taskCompleteDTO.getUserId(),2,1,e); }); } if(!CollectionUtils.isEmpty(taskCompleteDTO.getVosList())){ taskCompleteDTO.getVosList().forEach(e->{ - createResource(eventVisitingTasksDO.getId(),eventVisitingTasksDO.getDellUserId(),2,2,e); + createResource(eventVisitingTasksDO.getId(),taskCompleteDTO.getUserId(),2,2,e); }); } if(!CollectionUtils.isEmpty(taskCompleteDTO.getVideoList())){ taskCompleteDTO.getVosList().forEach(e->{ - createResource(eventVisitingTasksDO.getId(),eventVisitingTasksDO.getDellUserId(),2,3,e); + createResource(eventVisitingTasksDO.getId(),taskCompleteDTO.getUserId(),2,3,e); }); } - int rt = eventVisitingTasksMapper.complete(taskCompleteDTO); + + Map<String,Object> map = eventVisitingTasksMapper.findUserById(taskCompleteDTO.getUserId()); + complete.setGridMemberStreet(Long.valueOf(map.get("street_id").toString())); + complete.setGridMemberCommunity(Long.valueOf(map.get("community_id").toString())); + complete.setGridMember(Long.valueOf(map.get("user_id").toString())); + complete.setGridMemberName(map.get("name").toString()); + complete.setGridMenberTele(map.get("phone") ==null?"":map.get("phone").toString()); + + int rt = eventVisitingTasksMapper.complete(complete); if(rt > 0){ return R.ok(); } return R.fail(); } - private void createResource(Long id, Long dellUserId, int classification, int type,String url) { + + private void createResource(Long id, Long dellUserId, int classification, int type, EventResourceDTO resourceDTO) { EventResourceDO eventResourceDO = new EventResourceDO(); eventResourceDO.setRefId(id); eventResourceDO.setClassification(classification); eventResourceDO.setType(type); eventResourceDO.setCreateBy(dellUserId); - eventResourceDO.setUrl(url); + eventResourceDO.setUrl(resourceDTO.getUrl()); + eventResourceDO.setResourceTime(resourceDTO.getResourceTime()); eventResourceMapper.insert(eventResourceDO); } + @Override + public List<LcEventVisitingTasksListDTO> getUnUploadVisitingTask() { + List<LcEventVisitingTasksListDTO> lcEventVisitingTasksList =new ArrayList<>(); + List<EventVisitingTasksDO> eventVisitingTasksList = baseMapper.selectList( + new QueryWrapper<EventVisitingTasksDO>() + .eq("lc_upload", false) + .eq("event_status",2) + ); + lcEventVisitingTasksList= CopyUtil.beanCopyList(eventVisitingTasksList,LcEventVisitingTasksListDTO.class); + lcEventVisitingTasksList.forEach(visitingTasks -> { + addVisitingTasksFile(visitingTasks); + }); + return lcEventVisitingTasksList; + } + + private LcEventVisitingTasksListDTO addVisitingTasksFile(LcEventVisitingTasksListDTO visitingTasks) { + //查询事件关联附件 + List<EventResourceDO> eventResourceDOList = + eventResourceService.getBaseMapper().selectList(new LambdaQueryWrapper<EventResourceDO>() + .eq(EventResourceDO::getClassification, 2) + .eq(EventResourceDO::getRefId, visitingTasks.getId()) + ); + List<EventResourceVO> picList = new ArrayList<>(); + List<EventResourceVO> audioList = new ArrayList<>(); + List<EventResourceVO> videoList = new ArrayList<>(); + eventResourceDOList.forEach(eventResourceDO -> { + switch (eventResourceDO.getType()) { + case 1: + EventResourceVO picEventResourceVO = new EventResourceVO(); + BeanUtils.copyProperties(eventResourceDO, picEventResourceVO); + picList.add(picEventResourceVO); + break; + case 2: + EventResourceVO audioResourceVO = new EventResourceVO(); + BeanUtils.copyProperties(eventResourceDO, audioResourceVO); + audioList.add(audioResourceVO); + break; + case 3: + EventResourceVO videoResourceVO = new EventResourceVO(); + BeanUtils.copyProperties(eventResourceDO, videoResourceVO); + videoList.add(videoResourceVO); + break; + } + }); + visitingTasks.setAudios(audioList); + visitingTasks.setPics(picList); + visitingTasks.setVideos(videoList); + return visitingTasks; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean updateLcUploadFlagVisitingTask(Long id) { + EventVisitingTasksDO eventVisitingTasksDO = baseMapper.selectById(id); + eventVisitingTasksDO.setLcUpload(true); + int flag = baseMapper.updateById(eventVisitingTasksDO); + if (flag > 0) { + return true; + } + return false; + } + + } -- Gitblit v1.7.1