xyh
2021-06-24 b1e9f850ffa9406c7df90d9cb9fd6dc0b7446202
springcloud_k8s_panzhihuazhihuishequ/service_grid/src/main/java/com/panzhihua/service_grid/service/impl/EventVisitingTasksServiceImpl.java
@@ -1,10 +1,12 @@
package com.panzhihua.service_grid.service.impl;
import com.alibaba.fastjson.JSONObject;
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.enums.PopulPoliticalOutlookEnum;
import com.panzhihua.common.model.dtos.grid.EventVisitingTasksAddDTO;
import com.panzhihua.common.model.dtos.grid.EventVisitingTasksDeleteDTO;
import com.panzhihua.common.model.dtos.grid.EventVisitingTasksEditDTO;
@@ -31,9 +33,7 @@
import javax.crypto.NoSuchPaddingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * @auther lyq
@@ -137,10 +137,21 @@
    }
    @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));
        }
        page.getRecords().forEach(e->{
        });
        return R.ok(page);
    }
@@ -179,8 +190,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 +199,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 +216,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){
@@ -232,7 +242,9 @@
        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());
@@ -247,7 +259,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)
@@ -316,6 +368,10 @@
            taskCompleteDTO.setEventStatus(EventTasksStatusEnum.YC.getCode());
        }
        JSONObject json = JSONObject.parseObject(eventVisitingTasksDO.getTableContentJson());
        json.put("check",taskCompleteDTO.getOption());
        taskCompleteDTO.setOption(json.toJSONString());
        if(!CollectionUtils.isEmpty(taskCompleteDTO.getImgList())){
            taskCompleteDTO.getImgList().forEach(e->{
                createResource(eventVisitingTasksDO.getId(),eventVisitingTasksDO.getDellUserId(),2,1,e);
@@ -331,6 +387,7 @@
                createResource(eventVisitingTasksDO.getId(),eventVisitingTasksDO.getDellUserId(),2,3,e);
            });
        }
        int rt = eventVisitingTasksMapper.complete(taskCompleteDTO);
        if(rt > 0){
            return R.ok();