cjl
2023-11-14 15369bf819ca82896bbcada782e6babf2a7d64c9
Merge remote-tracking branch 'origin/cjl' into qa
6 files added
43 files modified
1341 ■■■■ changed files
screen-api/pom.xml 22 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/config/Interceptor/SyncConfiguration.java 42 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/AllocationController.java 28 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java 3 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/AppUserController.java 55 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/controller/CruiserController.java 99 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/entity/AllocationLog.java 67 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/AllocationLogMapper.java 7 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/OrganizationMapper.java 6 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/mapper/ResponsibilityUnitMapper.java 8 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/enums/SysDictTypeEnum.java 1 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationExt.java 13 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationPageExt.java 8 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/query/allocation/AllocationPageCond.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/query/app/AppAllocationPushUserCond.java 49 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationPageVo.java 5 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationVo.java 7 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/app/AppAllocationFindVo.java 16 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/pojo/vo/app/AppAuthority.java 13 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/AllocationService.java 31 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/OrganizationService.java 8 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/UserService.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java 239 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java 22 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java 4 ●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java 34 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java 5 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java 6 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java 150 ●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java 14 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/utils/WechatUtils.java 27 ●●●●● patch | view | raw | blame | history
screen-api/src/main/java/com/moral/api/vo/WxMssVo.java 4 ●●● patch | view | raw | blame | history
screen-api/src/main/resources/application-qa.yml 4 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/AllocationMapper.xml 21 ●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/DeviceMapper.xml 2 ●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/OrganizationMapper.xml 35 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/mapper/ResponsibilityUnitMapper.xml 10 ●●●●● patch | view | raw | blame | history
screen-api/src/main/resources/word/尘负荷监测报告.docx patch | view | raw | blame | history
screen-common/src/main/java/com/moral/util/TokenUtils.java 11 ●●●● patch | view | raw | blame | history
screen-job/src/main/resources/application-cjl.yml 2 ●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java 3 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/pojo/dto/cruiser/CruiserListDTO.java 35 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java 110 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java 46 ●●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/ResponsibilityUnitServiceImpl.java 1 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/SysDictDataServiceImpl.java 1 ●●●● patch | view | raw | blame | history
screen-manage/src/main/java/com/moral/api/service/impl/SysDictTypeServiceImpl.java 1 ●●●● patch | view | raw | blame | history
screen-manage/src/main/resources/application-qa.yml 4 ●●●● patch | view | raw | blame | history
screen-manage/src/main/resources/mapper/HistorySecondCruiserMapper.xml 50 ●●●●● patch | view | raw | blame | history
screen-api/pom.xml
@@ -78,11 +78,31 @@
            <artifactId>jfreechart</artifactId>
            <version>1.5.0</version>
        </dependency>
        <!--  上面需要的依赖-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>com.deepoove</groupId>
            <artifactId>poi-tl</artifactId>
            <version>1.5.1</version>
            <version>1.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
screen-api/src/main/java/com/moral/api/config/Interceptor/SyncConfiguration.java
New file
@@ -0,0 +1,42 @@
package com.moral.api.config.Interceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
//@Configuration
@EnableAsync
public class SyncConfiguration {
    @Bean(name = "asyncPoolTaskExecutor")
    public ThreadPoolTaskExecutor executor() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        //核心线程数
        taskExecutor.setCorePoolSize(10);
        //线程池维护线程的最大数量,只有在缓冲队列满了之后才会申请超过核心线程数的线程
        taskExecutor.setMaxPoolSize(20);
        //缓存队列
        taskExecutor.setQueueCapacity(50);
        //许的空闲时间,当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
        taskExecutor.setKeepAliveSeconds(200);
        //异步方法内部线程名称
        taskExecutor.setThreadNamePrefix("async-");
        /**
         * 当线程池的任务缓存队列已满并且线程池中的线程数目达到maximumPoolSize,如果还有任务到来就会采取任务拒绝策略
         * 通常有以下四种策略:
         * ThreadPoolExecutor.AbortPolicy:丢弃任务并抛出RejectedExecutionException异常。
         * ThreadPoolExecutor.DiscardPolicy:也是丢弃任务,但是不抛出异常。
         * ThreadPoolExecutor.DiscardOldestPolicy:丢弃队列最前面的任务,然后重新尝试执行任务(重复此过程)
         * ThreadPoolExecutor.CallerRunsPolicy:重试添加当前的任务,自动重复调用 execute() 方法,直到成功
         */
        taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        taskExecutor.initialize();
        return taskExecutor;
    }
}
screen-api/src/main/java/com/moral/api/controller/AllocationController.java
@@ -6,16 +6,17 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.aspectj.apache.bcel.generic.RET;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.AllocationLog;
import com.moral.api.pojo.enums.SysDictTypeEnum;
import com.moral.api.pojo.ext.allocation.AllocationExt;
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.query.allocation.*;
import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.allocation.AllocationPageVo;
import com.moral.api.pojo.vo.allocation.AllocationVo;
import com.moral.api.utils.BeanConverts;
import com.moral.constant.PageResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,7 +24,6 @@
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
@@ -32,9 +32,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.moral.api.entity.Allocation;
import com.moral.api.entity.ResponsibilityUnit;
import com.moral.api.pojo.dto.allocation.AllocationUnitViewDto;
import com.moral.api.service.AllocationService;
import com.moral.api.utils.EasyExcelUtils;
import com.moral.api.utils.NoModelWriteData;
@@ -202,6 +201,23 @@
        }
    }
    @GetMapping("updataUnit")
    @ApiOperation("修改责任单位")
    public ResultMessage updataUnit(@RequestParam @ApiParam(value = "id",name = "主键id") Integer id,
                                    @RequestParam @ApiParam(value = "unitId",name = "责任主题Id") Integer unitId,
                                    @RequestParam @ApiParam(value = "polluteType",name = "污染分类Id") Integer polluteType){
        allocationService.updataUnit(id,unitId,polluteType);
        return ResultMessage.ok();
    }
    @GetMapping("getLog")
    @ApiOperation("修改记录")
    public ResultMessage getLog(@RequestParam @ApiParam(value = "allocationNum",name = "责任单号") String allocationNum){
        List<AllocationLog> log = allocationService.getLog(allocationNum);
        return ResultMessage.ok(log);
    }
}
screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java
@@ -6,6 +6,7 @@
import com.moral.api.pojo.query.app.AppAllocationFileCond;
import com.moral.api.pojo.query.app.AppAllocationPageCond;
import com.moral.api.pojo.vo.app.AppAllocationFindVo;
import com.moral.api.pojo.vo.app.AppAuthority;
import com.moral.constant.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -93,7 +94,7 @@
    @ApiOperation(value = "分享权限")
    public  ResultMessage  authority(@RequestParam @ApiParam(value = "allocationNum",name = "单号") String allocationNum,
                                     @RequestParam @ApiParam(value = "userId",name = "用户Id") Integer userId){
        boolean authority = allocationService.authority(allocationNum,userId);
        AppAuthority authority = allocationService.authority(allocationNum, userId);
        return ResultMessage.ok(authority);
    }
screen-api/src/main/java/com/moral/api/controller/AppUserController.java
@@ -18,9 +18,15 @@
import java.util.HashMap;
import java.util.Map;
import javax.validation.Valid;
import com.alibaba.fastjson.JSON;
import com.moral.api.entity.Allocation;
import com.moral.api.pojo.query.app.AppAllocationPushUserCond;
import com.moral.api.service.UserService;
import com.moral.api.utils.HttpClientUtil;
import com.moral.api.utils.WechatUtils;
import com.moral.api.vo.WxMssVo;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
@@ -65,31 +71,50 @@
        return ResultMessage.ok();
    }
    @GetMapping("pushOneUser")
    @PostMapping("pushOneUser")
    @ApiOperation(value = "小程序推送消息")
    public  ResultMessage pushOneUser(String openid){
        String body = push("oOCWi6yfVapaK25Jnkk7jKSbMLyw");
        return ResultMessage.ok(body);
    public  ResultMessage pushOneUser(@Valid @RequestBody Allocation appAllocationPushUserCond){
        userService.pushOneUser(appAllocationPushUserCond);
//        String body = push("oOCWi6-_hnzSvrMT8HX5D7Dz7tEA");
        return ResultMessage.ok();
    }
    public String push(String openid) {
        RestTemplate restTemplate = new RestTemplate();
        //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + HttpClientUtil.getAccessToken();
        //小程序订阅
        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + WechatUtils.getAccessToken();
//        String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=" + HttpClientUtil.getAccessToken();
//        String url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=" + HttpClientUtil.getAccessToken();
//        String url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + HttpClientUtil.getAccessToken();
          //小程序客服
//        String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + HttpClientUtil.getAccessToken();
        //拼接推送的模版
        WxMssVo wxMssVo = new WxMssVo();
        wxMssVo.setTouser(openid);//用户的openid(要发送给那个用户,通常这里应该动态传进来的)
        wxMssVo.setTemplate_id("sClgB85aEG1hgaiXpnJBopo5LJX6r91DUsyikOmUgv8");//订阅消息模板id
        wxMssVo.setPage("pages/index/index");
        wxMssVo.setTemplate_id("YNqUZ1MgMvwY3G-NENVbcmIBR5dUotSdnwcz96CWrho");//订阅消息模板id
        wxMssVo.setLang("zh_CN");
        wxMssVo.setMiniprogramState("formal");
//        wxMssVo.setPage("pages/index/index");
        Map<String, String> m = new HashMap<>(3);
        m.put("time2", "2023-10-23");
        m.put("thing3", "七星");
        m.put("thing7", "第一章第一节");
        m.put("character_string8", "第一章第一节");
        m.put("phrase10", "第一章第一节");
        wxMssVo.setData(m);
        Map<String, Object> m = new HashMap<>();
        HashMap<String, Object> map1 = new HashMap<>();
        HashMap<String, Object> map2 = new HashMap<>();
        HashMap<String, Object> map3 = new HashMap<>();
        HashMap<String, Object> map4 = new HashMap<>();
        map1.put("value","欧阳仑2");
        map2.put("value","ouyanglun");
        map3.put("value","巧克力1");
        map4.put("value","2023-10-16");
        m.put("thing18", map1);
        m.put("character_string1", map2);
        m.put("thing2", map3);
        m.put("date4", map4);
        wxMssVo.setData(JSON.toJSON(m));
        ResponseEntity<String> responseEntity =
                restTemplate.postForEntity(url, wxMssVo, String.class);
        return responseEntity.getBody();
screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -2,12 +2,13 @@
import cn.afterturn.easypoi.word.WordExportUtil;
import cn.hutool.poi.word.WordUtil;
import com.deepoove.poi.NiceXWPFDocument;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.MiniTableRenderData;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.data.TextRenderData;
import com.deepoove.poi.policy.HackLoopTableRenderPolicy;
import com.moral.api.entity.Dustld;
import com.moral.api.exception.BusinessException;
import com.moral.api.pojo.bo.ExcelBO;
import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO;
import com.moral.api.pojo.dust.DustForm;
@@ -24,7 +25,6 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.xmlbeans.impl.jam.provider.ResourcePath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@@ -236,23 +236,19 @@
     */
    @PostMapping("dailyDustlds")
    @Transactional
    public ResultMessage  dailyDustlds(@RequestBody Map<String,Object> params, HttpServletResponse response) throws IOException {
    public void dailyDustlds(@RequestBody Map<String,Object> params, HttpServletResponse response,HttpServletRequest request) throws IOException {
//        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("startTime") || !params.containsKey("endTime")){
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
            return;
        }
        System.out.println(CruiserController.class.getResource("/word/尘负荷监测报告.docx").getPath());
        URL resource = getClass().getResource("/word/尘负荷监测报告.docx");
        String path = resource.getPath();
        System.out.println(path);
        Map<String, Object> map = dustldService.dailyDustlds(params);
        if (ObjectUtils.isEmpty(map)){
            return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg());
            throw new BusinessException("未找到路段信息");
        }
        test(map,response);
        test(map,response,request);
        return ResultMessage.ok();
    }
@@ -315,56 +311,87 @@
    }
    public static void test( Map<String, Object> params,HttpServletResponse response) throws IOException {
        InputStream  inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx");
        XWPFDocument compile = null;
    public  void test( Map<String, Object> params,HttpServletResponse response,HttpServletRequest request) throws IOException {
        try {
            //InputStream  inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx");
            InputStream stream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx");
            //获取临时文件
            File file = new File("word/尘负荷监测报告.docx");
            //将读取到的类容存储到临时文件中,后面就可以用这个临时文件访问了
            FileUtils.copyInputStreamToFile(stream, file);
            //这个时候再去获取证书的文件路径 就可以正常获取了
            String filePath = file.getAbsolutePath();
            //第二步:创建数据,用于把我们模板中的{{}}包裹的变量替换掉,map中保存的key一定要和模板中的变量保持一致
            HashMap<String, Object> map = new HashMap<>();
            //设置单元格,表头
            RowRenderData header1 = RowRenderData.build(new TextRenderData("6495ED", "序号"), new TextRenderData("6495ED", "道路"),new TextRenderData("6495ED", "平均尘负荷(克/平方米)"));
            //RowRenderData header1 = RowRenderData.build(new TextRenderData("6495ED", "序号"), new TextRenderData("6495ED", "道路"),new TextRenderData("6495ED", "平均尘负荷(克/平方米)"));
            //设置表内容,如果在实际应用中,传入一个list集合或者数组,方可用foreach进行循环填充
            List<DustForm> list1 = (List<DustForm>) params.get("list1");
            ArrayList<Map<String, Object>> mapArrayList = (ArrayList<Map<String, Object>>) params.get("list3");
            List<Map<String, Object>> mapArrayList = (ArrayList<Map<String, Object>>) params.get("list3");
            ArrayList<RowRenderData> rsList1 = new ArrayList<>();
            ArrayList<RowRenderData> rsList3 = new ArrayList<>();
            List<Map> detailList = new ArrayList<>();
            for (int i = 0; i < list1.size(); i++) {
                DustForm dustForm = list1.get(i);
                RowRenderData row0 = RowRenderData.build(i+1+"",dustForm.getRoad(), dustForm.getValue()+"");
                rsList1.add(row0);
                Map maps = new HashMap();
                maps.put("table1", i+1);
                maps.put("table2", dustForm.getRoad());
                maps.put("table3", dustForm.getValue());
                detailList.add(maps);
            }
            List<Map> detailList2 = new ArrayList<>();
            Map maps = new HashMap();
           /* maps.put("table4", "");
            maps.put("table5", "");
            maps.put("table6", "");
            maps.put("table7", map.get("date1"));
            maps.put("table8", map.get("date2"));
            detailList2.add(maps);*/
            for (int i = 0; i < mapArrayList.size(); i++) {
                Map<String, Object> map1 = mapArrayList.get(i);
                RowRenderData row = RowRenderData.build(i + 1 + "", map1.get("road").toString(), map1.get("value1").toString(), map1.get("value2").toString(), map1.get("value3").toString());
                rsList3.add(row);
                maps = new HashMap();
                maps.put("time4", i+1);
                maps.put("time5", map1.get("road").toString());
                maps.put("time6", map1.get("value1").toString());
                maps.put("time7", map1.get("value2").toString());
                maps.put("time8", map1.get("value3").toString());
                detailList2.add(maps);
            }
            if (!ObjectUtils.isEmpty(mapArrayList)){
                map.put("table3", new MiniTableRenderData(rsList3));
            }
            map.put("table1", new MiniTableRenderData(header1, rsList1));
            String data = params.get("data").toString();
            map.put("data",data);
            map.put("time",params.get("time").toString());
            map.put("date1",params.get("date1").toString());
            map.put("date2",params.get("date2").toString());
            File docxFile = new File("尘负荷监测报告.docx");
            FileUtils.copyToFile(inputStream,docxFile);
            compile = WordExportUtil.exportWord07(docxFile.getPath(),map);
            compile.write(response.getOutputStream());
            HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy();
            Configure config = Configure.newBuilder().bind("detailList", policy).bind("detailList2", policy).build();
            XWPFTemplate compile = XWPFTemplate.compile(filePath,config).render(new HashMap<String, Object>(){{
                put("time",map.get("time"));
                put("data",map.get("data"));
                put("time1",map.get("date1").toString());
                put("time2",map.get("date2").toString());
                put("detailList", detailList);
                put("detailList2", detailList2);
            }});
            response.setContentType("multipart/form-data");
            // 设置文件名
            response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" );
            response.setCharacterEncoding("UTF-8");
            OutputStream out = response.getOutputStream();
            compile.write(out);
            out.flush();
            out.close();
            compile.close();
            inputStream.close();
        } catch (IOException e) {
            log.error ("导出失败,请联系网站管理员!", e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }finally {
            compile.close();
            inputStream.close();
        }
    }
screen-api/src/main/java/com/moral/api/entity/AllocationLog.java
New file
@@ -0,0 +1,67 @@
package com.moral.api.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
@Data
@EqualsAndHashCode(callSuper = false)
public class AllocationLog {
    private static final long serialVersionUID = 1L;
    /**
     * 序号
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 操作描述
     */
    private String content;
    /**
     * 操作人账号
     */
    private  String account;
    /**
     * 操作人姓名
     */
    private  String  userName;
    /**
     * 操作人员id
     */
    private Integer accountId;
    /**
     * Ip地址
     */
    private String ip;
    /**
     * 交办单号
     */
    private String allocationNum;
    private  String polluteType;
    /**
     * 操作时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
screen-api/src/main/java/com/moral/api/mapper/AllocationLogMapper.java
New file
@@ -0,0 +1,7 @@
package com.moral.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.entity.AllocationLog;
public interface AllocationLogMapper extends BaseMapper<AllocationLog> {
}
screen-api/src/main/java/com/moral/api/mapper/OrganizationMapper.java
@@ -2,6 +2,9 @@
import com.moral.api.entity.Organization;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <p>
@@ -13,4 +16,7 @@
 */
public interface OrganizationMapper extends BaseMapper<Organization> {
    List<Integer> orgIdList(@Param("organizationId") Integer organizationId);
    List<Integer> orgIdSpecialDevList(@Param("organizationId") Integer organizationId,@Param("mac") String mac);
}
screen-api/src/main/java/com/moral/api/mapper/ResponsibilityUnitMapper.java
@@ -22,4 +22,12 @@
     * 查询字典id
     */
    List<Integer> selectCodeList(@Param("code") String code,@Param("id") Integer id);
    /**
     * 查询字典类型名字
     * @param code
     * @param id
     * @return
     */
    String selectName(@Param("code") String code,@Param("id") Integer id);
}
screen-api/src/main/java/com/moral/api/pojo/enums/SysDictTypeEnum.java
@@ -41,6 +41,7 @@
    SYS_DEVICE("DEVICE","设备秒机数据"),
    SYS_AMEND("AMEND","立行立改修改数据"),
    ;
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationExt.java
@@ -1,5 +1,6 @@
package com.moral.api.pojo.ext.allocation;
import com.baomidou.mybatisplus.annotation.TableField;
import com.moral.api.entity.Allocation;
import com.moral.api.pojo.vo.approvetable.ApproveTableListVo;
import com.moral.api.pojo.vo.file.FileVo;
@@ -34,4 +35,16 @@
    @ApiModelProperty(value = "流程状态")
    private List<ApproveTableListVo> approveList;
    //主体单位名字
    @TableField(exist = false)
    private String unitName;
    //上报单位名字
    @TableField(exist = false)
    private String escalationUnitName;
    @TableField(exist = false)
    //污染类型名字
    private String polluteTypeName;
}
screen-api/src/main/java/com/moral/api/pojo/ext/allocation/AllocationPageExt.java
@@ -1,6 +1,7 @@
package com.moral.api.pojo.ext.allocation;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.moral.api.entity.Allocation;
import io.swagger.annotations.ApiModelProperty;
@@ -27,4 +28,11 @@
    @ApiModelProperty(value = "状态名字")
    private String stateName;
    @ApiModelProperty(value = "pc端修改权限标识")
    private String isCode;
    //上报单位名字
    private String escalationUnitName;
}
screen-api/src/main/java/com/moral/api/pojo/query/allocation/AllocationPageCond.java
@@ -25,13 +25,13 @@
public class AllocationPageCond implements Serializable{
    @ApiModelProperty(value = "责任单位id")
    private Integer unitId;
    private List<Integer> unitId;
    @ApiModelProperty(value = "污染分类id")
    private Integer polluteType;
    private List<Integer> polluteType;
    @ApiModelProperty(value = "流程状态")
    private Integer state;
    private List<Integer> state;
    @ApiModelProperty(value = "排查方式id")
    private Integer investigationType;
screen-api/src/main/java/com/moral/api/pojo/query/app/AppAllocationPushUserCond.java
New file
@@ -0,0 +1,49 @@
package com.moral.api.pojo.query.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
import javax.validation.constraints.NotNull;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="AppAllocationPushUserCond - 推送消息对象", description="AppAllocationPushUserCond - 推送消息对象")
public class AppAllocationPushUserCond {
    @ApiModelProperty(value = "上报时间")
    @NotNull(message = "上报时间不能为空!")
    private Date escalationTime;
    @ApiModelProperty(value = "责任单位id")
    @NotNull(message = "责任单位不能为空!")
    private Integer unitId;
    @ApiModelProperty(value = "上报单位id")
    @NotNull(message = "上报单位不能为空!")
    private Integer escalationUnitId;
    @ApiModelProperty(value = "状态")
    @NotNull(message = "状态不能为空!")
    private Integer state;
    /**
     *交办单号
     */
    @ApiModelProperty(value = "交办单号")
    @NotNull(message = "单号不能为空!")
    private String allocationNum;
}
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationPageVo.java
@@ -99,6 +99,9 @@
    @ApiModelProperty(value = "能否审批")
    private Integer isApprove;
    @ApiModelProperty(value = "pc端修改权限标识")
    private String isCode;
    public static AllocationPageVo convert(AllocationPageExt allocationPageExt) {
        AllocationPageVo allocationPageVo = BeanConverts.convert(allocationPageExt, AllocationPageVo.class);
        return allocationPageVo;
@@ -109,7 +112,7 @@
    }
    public Integer getResidueDay() {
        int day = this.changeDay;
        int day = Objects.isNull(this.changeDay)?0:this.changeDay;
        if(AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(state)){
            Date date = new Date();
            int days = DateUtils.getDays(escalationTime, date);
screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationVo.java
@@ -139,6 +139,13 @@
    @TableField(exist = false)
    private String time;
    @TableField(exist = false)
    private String unitName;
    @TableField(exist = false)
    private String escalationUnitName;
    @TableField(exist = false)
    private String polluteTypeName;
    public static AllocationVo convert(AllocationExt allocationExt) {
        AllocationVo allocationVo = BeanConverts.convert(allocationExt, AllocationVo.class);
screen-api/src/main/java/com/moral/api/pojo/vo/app/AppAllocationFindVo.java
@@ -2,6 +2,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.moral.api.pojo.enums.AllocationApproveEnum;
import com.moral.api.pojo.enums.ChangeEnum;
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.vo.allocation.AllocationPageVo;
import com.moral.api.utils.BeanConverts;
@@ -73,13 +74,18 @@
    @ApiModelProperty(value = "状态名字")
    private String stateName;
    //上报单位名字
    private String escalationUnitName;
    public Integer getResidueDay() {
        int day = this.changeDay;
        if(AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(state)){
            Date date = new Date();
            int days = DateUtils.getDays(escalationTime, date);
            return day-days;
       int day=0;
        if (this.changeType==ChangeEnum.DEADLINE.value){
             day = this.changeDay;
            if(AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(state)){
                Date date = new Date();
                int days = DateUtils.getDays(escalationTime, date);
                return day-days;
            }
        }
        return day;
    }
screen-api/src/main/java/com/moral/api/pojo/vo/app/AppAuthority.java
New file
@@ -0,0 +1,13 @@
package com.moral.api.pojo.vo.app;
import lombok.Data;
@Data
public class AppAuthority {
    //权限标识
    private  Integer code;
    //状态名字
    private  String  name;
}
screen-api/src/main/java/com/moral/api/service/AllocationService.java
@@ -7,18 +7,17 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.entity.Allocation;
import com.moral.api.entity.AllocationLog;
import com.moral.api.entity.ResponsibilityUnit;
import com.moral.api.pojo.ext.allocation.AllocationExt;
import com.moral.api.pojo.ext.allocation.AllocationListExt;
import com.moral.api.pojo.ext.allocation.AllocationPageExt;
import com.moral.api.pojo.query.allocation.*;
import com.moral.api.pojo.dto.allocation.AllocationUnitDto;
import com.moral.api.pojo.query.allocationextension.AllocationExtensionAddCond;
import com.moral.api.pojo.query.app.AppAllocationFileCond;
import com.moral.api.pojo.query.app.AppAllocationPageCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.allocation.AllocationPageVo;
import com.moral.api.pojo.vo.app.AppAllocationFindVo;
import com.moral.api.pojo.vo.app.AppAuthority;
public interface AllocationService extends IService<Allocation> {
@@ -133,8 +132,32 @@
     */
    void checkSmallRoutine(AllocationCheckCond checkCond);
    /**
     * 分享权限 1 可以看可以写  2.可以看不能写 3.都不能
     * @param allocationNum
     * @param userId
     * @return
     */
    AppAuthority authority(String allocationNum, Integer userId);
    boolean authority(String allocationNum,Integer userId);
    /**
     * 修改责任单位
     * @param id
     * @param unitId
     */
    void updataUnit(Integer id,Integer unitId,Integer polluteType);
    /**
     * 查看修改记录
     * @param allocationNum
     * @return
     */
    List<AllocationLog> getLog(String allocationNum);
    /**
     * 根据字典名称获取权限   空值无权,有值有权
     * @param code
     * @return
     */
    List<Integer> getUnitAuthority(String code);
}
screen-api/src/main/java/com/moral/api/service/OrganizationService.java
@@ -2,6 +2,7 @@
import com.moral.api.entity.Organization;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -34,6 +35,11 @@
    Organization getOrganizationById(Integer id);
    /**
     * 查询关联组织信息
     * @param organizationId
     * @return
     */
    List<Integer> orgIdList( Integer organizationId);
}
screen-api/src/main/java/com/moral/api/service/UserService.java
@@ -5,11 +5,12 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.Allocation;
import com.moral.api.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.moral.api.pojo.bo.UserBO;
import com.moral.api.pojo.query.AppUserCond;
import com.moral.api.pojo.query.app.AppAllocationPushUserCond;
/**
 * <p>
@@ -53,4 +54,7 @@
    boolean updateUserId(Integer userId);
    // 小程序推送
    void pushOneUser(Allocation appAllocationPushUserCond);
}
screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java
@@ -6,12 +6,15 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.config.Interceptor.UserHelper;
import com.moral.api.controller.LogController;
import com.moral.api.entity.*;
import com.moral.api.exception.BusinessException;
import com.moral.api.mapper.AllocationLogMapper;
import com.moral.api.mapper.AllocationMapper;
import com.moral.api.mapper.ResponsibilityUnitMapper;
import com.moral.api.mapper.SysDictDataMapper;
import com.moral.api.mapper.SysDictTypeMapper;
import com.moral.api.mapper.UserLogMapper;
import com.moral.api.mapper.UserMapper;
import com.moral.api.pojo.bean.BaseInvalidEntity;
import com.moral.api.pojo.dto.allocation.AllocationUnitViewDto;
@@ -25,11 +28,14 @@
import com.moral.api.pojo.query.app.AppAllocationPageCond;
import com.moral.api.pojo.vo.allocation.AllocationFindVo;
import com.moral.api.pojo.vo.app.AppAllocationFindVo;
import com.moral.api.pojo.vo.app.AppAuthority;
import com.moral.api.pojo.vo.user.QxUser;
import com.moral.api.service.*;
import com.moral.constant.Constants;
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import com.moral.util.WebUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
@@ -38,9 +44,13 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
@Service
@@ -70,6 +80,10 @@
    private ResponsibilityUnitService responsibilityUnitService;
    @Autowired
    private SysDictTypeService sysDictTypeService;
    @Autowired
    private UserService userService;
    @Autowired
    private AllocationLogMapper allocationLogMapper;
    /**
     * 根据字典类型获取字典数据
@@ -124,7 +138,7 @@
        //单号
        String allocationNum = "JBD-" + dateString + String.format("%04d", i);
        allocation.setAllocationNum(allocationNum);
        if(Objects.nonNull(allocationCond.getEscalationUnitId())&& escalationType(allocationCond.getEscalationUnitId())) {
        if(Objects.nonNull(allocationCond.getEscalationUnitId())&& !allocationCond.getEscalationUnitId().equals(allocationCond.getUnitId()) && escalationType(allocationCond.getEscalationUnitId())) {
            allocation.setEscalationType(AllocationEscalationTypeEnum.CHECK.getValue());
        }
        if(NEW_BUILT.equals(allocationCond.getState())) {
@@ -132,8 +146,10 @@
        }
        //获取新建图片
        allocationMapper.insert(allocation);
        //推送数据
        userService.pushOneUser(allocation);
        redisTemplate.opsForValue().set(RedisConstants.JBD_DATA,i);
        if(NEW_BUILT.equals(allocationCond.getState())) {
        if(NEW_BUILT.equals(allocationCond.getState())||AllocationApproveEnum.UNDER_RECTIFICATION.value.equals(allocationCond.getState())) {
            //添加流程数据
            ApproveTable approveTable = new ApproveTable();
            approveTable.setRelationId(allocation.getAllocationId());
@@ -206,32 +222,7 @@
            }
        }
//        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
//        Object unitId = userInfo.get("unitId");
//        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
//        Integer orgId = (Integer) orgInfo.get("id");
//        if (!ObjectUtils.isEmpty(map.get("unitId"))){
//            wrapper.in("unit_id",map.get("unitId").toString());
//        }else {
//            if (orgId!=24){
//                if (ObjectUtils.isEmpty(unitId)){
//                    return null;
//                }
//                ResponsibilityUnit responsibilityUnit1 = responsibilityUnitMapper.selectById(Integer.parseInt(unitId.toString()));
//                Integer areaCode = responsibilityUnit1.getAreaCode();
//                List<ResponsibilityUnit> responsibilityUnits = responsibilityUnitService.selectUnit(areaCode);
//                if (ObjectUtils.isEmpty(responsibilityUnits)){
//                    List<ResponsibilityUnit> responsibilityUnits1 = responsibilityUnitService.selectAreaUnit(areaCode);
//                    Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits1.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                    List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                    wrapper.in("unit_id",collect1);
//                }else {
//                    Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                    List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                    wrapper.in("unit_id",collect1);
//                }
//            }
//        }
        HashMap<String, Object> rsMap = new HashMap<>();
        ArrayList<Map<String, Object>> polluteArrayList = new ArrayList<>();
@@ -389,29 +380,7 @@
                }
            }
        }
//        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
//        Object unitId = userInfo.get("unitId");
//        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
//        Integer orgId = (Integer) orgInfo.get("id");
//
//        if (ObjectUtils.isEmpty(unitId)){
//            return null;
//        }
//        if (orgId!=24){
//            ResponsibilityUnit responsibilityUnit1 = responsibilityUnitMapper.selectById(Integer.parseInt(unitId.toString()));
//            Integer areaCode = responsibilityUnit1.getAreaCode();
//            List<ResponsibilityUnit> responsibilityUnits = responsibilityUnitService.selectUnit(areaCode);
//            if (ObjectUtils.isEmpty(responsibilityUnits)){
//                List<ResponsibilityUnit> responsibilityUnits1 = responsibilityUnitService.selectAreaUnit(areaCode);
//                Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits1.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                wrapper.in("unit_id",collect1);
//            }else {
//                Map<Integer, List<ResponsibilityUnit>> collect = responsibilityUnits.stream().collect(Collectors.groupingBy(o -> o.getUnitId()));
//                List<Integer> collect1 = collect.keySet().stream().collect(Collectors.toList());
//                wrapper.in("unit_id",collect1);
//            }
//        }
        ArrayList<Map<String, Object>> rsMap = new ArrayList<>();
        Object number1 = map.get("number");
@@ -480,6 +449,7 @@
    @Override
    public Page<AllocationPageExt> extPage(AllocationPageCond allocationPageCond) {
        List<Integer> unitAuthority = this.getUnitAuthority(SysDictTypeEnum.SYS_AMEND.value);
        List<Integer> unitList = unitResult();
        Integer codeId =  unitAreaCode();
        allocationPageCond.setUnitList(unitList);
@@ -491,6 +461,7 @@
                }else {
                    it.setIsApprove(0);
                }
                it.setIsCode(ObjectUtils.isEmpty(unitAuthority)?"2":"1");
            });
        }
        return page;
@@ -503,6 +474,9 @@
        allocationExt.setFileChangeList(fileTableService.list(id,FileTableEnum.ALLOCATION_RECTIFICATION.value));
        allocationExt.setFileApproveList(fileTableService.list(id,FileTableEnum.ALLOCATION_APPROVE.value));
        allocationExt.setApproveList(approveTableService.listAll(id, FileTableEnum.ALLOCATION_FOUNDATION.value));
        allocationExt.setUnitName(getUnitName(allocationExt.getUnitId()).getUnitName());
        allocationExt.setEscalationUnitName(getUnitName(allocationExt.getEscalationUnitId()).getUnitName());
        allocationExt.setPolluteTypeName(responsibilityUnitMapper.selectName(Constants.WU_RAN_LEI_XING,allocationExt.getPolluteType()));
        return allocationExt;
    }
@@ -526,6 +500,9 @@
        allocation.setState(changeCond.getState());
        allocation.setChangeTime(new Date());
        this.updateById(allocation);
        //推送数据
        Allocation allocation1 = this.getById(changeCond.getAllocationId());
        userService.pushOneUser(allocation1);
        //添加流程数据
        ApproveTable approveTable = new ApproveTable();
        approveTable.setRelationId(allocation.getAllocationId());
@@ -700,6 +677,8 @@
        Page<AllocationPageExt> extAppPage = this.baseMapper.extAppPage(allocationPageCond.getPage().convertPage(),allocationPageCond);
        extAppPage.getRecords().forEach(it->{
            Integer state = it.getState();
            //获取上报单位名字
            it.setEscalationUnitName(getUnitName(it.getEscalationUnitId()).getUnitName());
            if (state.equals(AllocationApproveEnum.DRAFT.value)||state.equals(AllocationApproveEnum.UNDER_RECTIFICATION.value)){
                if(integer==0||integer==1){
                    it.setStateName(AppAllocationStateEnum.TO_BE_PROCESSED.name);
@@ -787,9 +766,12 @@
        //添加流程数据
        ApproveTable approveTable = new ApproveTable();
        approveTable.setRelationId(allocation.getAllocationId());
        approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value);
       /* approveTable.setState(NEW_BUILT);
        approveTable.setStateName("新建");
        approveTableService.saveResult(approveTable);*/
        approveTable.setState(AllocationApproveEnum.UNDER_RECTIFICATION.value);
        approveTable.setStateName(AllocationApproveEnum.UNDER_RECTIFICATION.name);
        approveTable.setApproveModule(FileTableEnum.ALLOCATION_FOUNDATION.value);
        approveTableService.saveResult(approveTable);
        fileTableService.upDateResult(changeCond.getFileChangeList(),allocation.getAllocationId(), FileTableEnum.ALLOCATION_RECTIFICATION.value);
    }
@@ -835,30 +817,134 @@
    }
    @Override
    public boolean authority(String allocationNum,Integer userId) {
    public AppAuthority authority(String allocationNum,Integer userId) {
        //返回数据
        AppAuthority appAuthority = new AppAuthority();
        //获取用户信息
        QxUser user = UserHelper.getCurrentUser();
        //获取交办单信息
        LambdaQueryWrapper<Allocation> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Allocation::getAllocationNum,allocationNum);
        wrapper.eq(Allocation::getIsDel,0);
        wrapper.eq(Allocation::getIsInvalid,0);
        Allocation allocation = allocationMapper.selectOne(wrapper);
        List<Integer> userList = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_JBD.getValue(),user.getUserId());
        if(CollectionUtils.isNotEmpty(userList)){
            return true;
        }
        if(Objects.nonNull(user.getUnitId())){
            LambdaQueryWrapper<Allocation> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(Allocation::getAllocationNum,allocationNum);
            wrapper.eq(Allocation::getIsDel,0);
            wrapper.eq(Allocation::getIsInvalid,0);
            Allocation allocation = allocationMapper.selectOne(wrapper);
            if (allocation.getUnitId().equals(user.getUnitId())){
                return true;
            }
            String code = responsibilityUnitMapper.selectAreaCode(user.getUnitId());
            if(code.length()>6){
                return false;
            //可以看,可以填
            if (allocation.getState()>30){
                appAuthority.setCode(2);
                appAuthority.setName(AppAllocationStateEnum.COMPLETED.name);
            }else {
                return true;
                appAuthority.setCode(1);
                appAuthority.setName(AppAllocationStateEnum.COMPLETED.name);
            }
            return appAuthority;
        }
        if(Objects.nonNull(user.getUnitId())&&user.getUnitId()!=0){
            String code = responsibilityUnitMapper.selectAreaCode(user.getUnitId());
            if (code.length() > 6 && allocation.getUnitId().equals(user.getUnitId())) {
                if (allocation.getState().equals(AllocationApproveEnum.UNDER_RECTIFICATION.value)){
                    appAuthority.setCode(1);
                    appAuthority.setName(AppAllocationStateEnum.TO_BE_PROCESSED.name);
                    return appAuthority;
                }else if (allocation.getState().equals(AllocationApproveEnum.IN_APPROVAL.value)){
                    appAuthority.setCode(2);
                    appAuthority.setName(AppAllocationStateEnum.TO_BE_COMPLETED.name);
                    return appAuthority;
                }else {
                    appAuthority.setCode(2);
                    appAuthority.setName(AppAllocationStateEnum.COMPLETED.name);
                    return appAuthority;
                }
            } else if (code.length() <= 6){
                if (allocation.getState().equals(AllocationApproveEnum.IN_APPROVAL.value)){
                    appAuthority.setCode(1);
                    appAuthority.setName(AppAllocationStateEnum.TO_BE_PROCESSED.name);
                    return appAuthority;
                }else if (allocation.getState().equals(AllocationApproveEnum.UNDER_RECTIFICATION.value)){
                    appAuthority.setCode(2);
                    appAuthority.setName(AppAllocationStateEnum.TO_BE_COMPLETED.name);
                    return appAuthority;
                }else {
                    appAuthority.setCode(2);
                    appAuthority.setName(AppAllocationStateEnum.COMPLETED.name);
                    return appAuthority;
                }
            }
        }
        return true;
        //不能看,不能填
        appAuthority.setCode(3);
        appAuthority.setName("没有权限");
        return appAuthority;
    }
    /**
     * 修改责任单位
     *
     * @param id
     * @param unitId
     */
    @Override
    @Transactional
    public void updataUnit(Integer id, Integer unitId,Integer polluteType) {
        AllocationLog allocationLog = new AllocationLog();
        //获取用户信息
        QxUser user = UserHelper.getCurrentUser();
        Allocation allocation = allocationMapper.selectById(id);
        if (!ObjectUtils.isEmpty(unitId)){
            ResponsibilityUnit unitName1 = getUnitName(allocation.getUnitId());
            ResponsibilityUnit unitName2 = getUnitName(unitId);
            allocation.setUnitId(unitId);
            allocationLog.setContent(unitName1.getUnitName()+"----修改成----"+unitName2.getUnitName());
        }
        if (!ObjectUtils.isEmpty(polluteType)){
            SysDictData sysDictData1 = sysDictTypeService.listOne(Constants.WU_RAN_LEI_XING,allocation.getPolluteType().toString());
            SysDictData sysDictData2 = sysDictTypeService.listOne(Constants.WU_RAN_LEI_XING, polluteType.toString());
            allocation.setPolluteType(polluteType);
            allocationLog.setPolluteType(sysDictData1.getDataValue()+"----修改成----"+sysDictData2.getDataValue());
        }
        allocationMapper.updateById(allocation);
        //日志
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
        allocationLog.setAllocationNum(allocation.getAllocationNum());
        allocationLog.setIp(WebUtils.getIpAddr(request));
        allocationLog.setAccountId(user.getUserId());
        allocationLog.setAccount(user.getAccount());
        allocationLog.setUserName(user.getUserName());
        allocationLog.setCreateTime(new Date());
        allocationLogMapper.insert(allocationLog);
    }
    /**
     * 查看修改记录
     *
     * @param allocationNum
     * @return
     */
    @Override
    public List<AllocationLog> getLog(String allocationNum) {
        LambdaQueryWrapper<AllocationLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AllocationLog::getAllocationNum,allocationNum);
        wrapper.orderByAsc(AllocationLog::getCreateTime);
        List<AllocationLog> allocationLogs = allocationLogMapper.selectList(wrapper);
        return allocationLogs;
    }
    /**
     * 根据字典名称获取权限
     *
     * @param code
     * @return
     */
    @Override
    public List<Integer> getUnitAuthority(String code) {
        QxUser user = UserHelper.getCurrentUser();
        List<Integer> userList = responsibilityUnitMapper.selectCodeList(code,user.getUserId());
        return userList;
    }
    @Override
@@ -883,15 +969,15 @@
        if(CollectionUtils.isNotEmpty(userList)){
            return 1;
        }
        if(Objects.nonNull(user.getUnitId())){
        if(Objects.nonNull(user.getUnitId())&&user.getUnitId()!=0) {
            String code = responsibilityUnitMapper.selectAreaCode(user.getUnitId());
            if(code.length()>6){
            if (code.length() > 6) {
                return 0;
            }else {
            } else {
                return 2;
            }
        }
        return 1;
        return 0;
    }
    private boolean escalationType(Integer id){
        boolean f = false;
@@ -901,4 +987,11 @@
        }
        return f;
    }
    private ResponsibilityUnit getUnitName(Integer unitId){
        ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(unitId);
          return   responsibilityUnit;
    }
}
screen-api/src/main/java/com/moral/api/service/impl/DustldServiceImpl.java
@@ -1,7 +1,10 @@
package com.moral.api.service.impl;
import com.moral.api.exception.BusinessException;
import com.moral.api.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.stereotype.Service;
@@ -36,10 +39,6 @@
import com.moral.api.entity.Dustld;
import com.moral.api.entity.ManageCoordinate;
import com.moral.api.entity.MaxRoad;
import com.moral.api.mapper.DustldMapper;
import com.moral.api.mapper.HistorySecondCruiserMapper;
import com.moral.api.mapper.ManageCoordinateMapper;
import com.moral.api.mapper.MaxRoadMapper;
import com.moral.api.pojo.dto.historySecondCruiser.DustldDTO;
import com.moral.api.pojo.dust.DustForm;
import com.moral.api.pojo.dust.TimeForm;
@@ -270,6 +269,8 @@
    private ManageCoordinateMapper manageCoordinateMapper;
    @Autowired
    private MaxRoadMapper maxRoadMapper;
    @Autowired
    private OrganizationMapper organizationMapper;
    @Override
    @Transactional
@@ -278,6 +279,11 @@
        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
        Integer orgId = (Integer) orgInfo.get("id");
        String mac = params.get("mac").toString();
        List<Integer> orgList = organizationMapper.orgIdSpecialDevList(orgId,mac);
        if(CollectionUtils.isEmpty(orgList)){
            throw new BusinessException("该设备没有路段组织信息!");
        }
        String time1 = params.get("startTime").toString();
        String dateString1 = DateUtils.stringToDateString(time1, DateUtils.yyyy_MM_dd_HH_mm_ss_EN, DateUtils.yyyy_MM_dd_HH_mm_CN);
        String rsTime1 = dateString1.substring(5, 14);
@@ -286,7 +292,7 @@
        String rsTime2 = dateString2.substring(5, 14);
        HashMap<String, Object> rsMap = new HashMap<>();
        List<Map<String, Object>> dusts = historySecondCruiserMapper.getDusts(params);
        Map<String, List<DustldDTO>> collect = manageCoordinateMapper.CompareTo(orgId).stream().collect(Collectors.groupingBy(o -> o.getName()));
        Map<String, List<DustldDTO>> collect = manageCoordinateMapper.CompareTo(orgList.get(0)).stream().collect(Collectors.groupingBy(o -> o.getName()));
        if (ObjectUtils.isEmpty(dusts) || ObjectUtils.isEmpty(collect)){
            return null;
        }
@@ -384,9 +390,9 @@
                if (road.getName().equals(dustForm.getRoad())){
                    HashMap<String, Object> map = new HashMap<>();
                    map.put("road",road.getName());
                    map.put("value1",road.getData());
                    map.put("value2",dustForm.getValue());
                    map.put("value3",road.getData()-dustForm.getValue());
                    map.put("value1",String.format("%.2f",road.getData()));
                    map.put("value2",String.format("%.2f",dustForm.getValue()));
                    map.put("value3",String.format("%.2f",road.getData()-dustForm.getValue()));
                    list3.add(map);
                }
            }
screen-api/src/main/java/com/moral/api/service/impl/HistoryFiveMinutelyServiceImpl.java
@@ -39,6 +39,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -292,6 +293,7 @@
            }
        }
        String str = new DecimalFormat("#.######").format(Double.parseDouble(result.get("a21005").toString()));
        QueryFiveDataByMacVO queryFiveDataByMacVO = new QueryFiveDataByMacVO();
        queryFiveDataByMacVO.setName(device.getName());
        queryFiveDataByMacVO.setDataTime(datas.get("dataTime").toString());
@@ -299,7 +301,7 @@
        queryFiveDataByMacVO.setA34002(result.get("a34002").toString());
        queryFiveDataByMacVO.setA21026(result.get("a21026").toString());
        queryFiveDataByMacVO.setA21004(result.get("a21004").toString());
        queryFiveDataByMacVO.setA21005(result.get("a21005").toString());
        queryFiveDataByMacVO.setA21005(str);
        queryFiveDataByMacVO.setA05024(result.get("a05024").toString());
        queryFiveDataByMacVO.setA01008(result.get("a01008").toString());
        queryFiveDataByMacVO.setA01007(result.get("a01007").toString());
screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java
@@ -27,6 +27,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
 * <p>
@@ -59,28 +60,27 @@
    public List<Date> queryDate(Integer organizationId) {
        //构造查询条件
        QueryWrapper<HistorySecondUav> queryWrapper = new QueryWrapper<>();
        //List<Integer> childrenId = new ArrayList<>();
        List<Integer> children = organizationService.orgIdList(organizationId);
        //获取子组织id
        List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        /*List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        List<Integer> childrenId = new ArrayList<>();
        for (Organization child : children) {
            childrenId.add(child.getId());
        }
        childrenId.add(organizationId);
        queryWrapper.in("organization_id", childrenId);
        childrenId.add(organizationId);*/
        queryWrapper.in("organization_id", children);
        //设置查询时间范围为180天
        Date endDate = new Date();
        Date startDate = DateUtils.addDays(endDate, -180);
        queryWrapper.between("batch", startDate, endDate);
        //设置查询字段
        queryWrapper.select("DISTINCT batch");
        queryWrapper.select("DISTINCT DATE_FORMAT(batch,'%Y-%m-%d') batch ");
        queryWrapper.orderByDesc("batch");
        //查询结果
        List<HistorySecondUav> historySecondUavs = historySecondUavMapper.selectList(queryWrapper);
        //结果转为Date集合
        List<Date> result = new ArrayList<>();
        for (HistorySecondUav historySecondUav : historySecondUavs) {
            result.add(historySecondUav.getBatch());
        }
        List<Date> result = historySecondUavs.stream().map(HistorySecondUav::getBatch).collect(Collectors.toList());
        return result;
    }
@@ -94,12 +94,9 @@
        Date endDate = form.getEndDate();
        QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>();
        //获取子组织id
        List<Organization> children = organizationService.getChildrenOrganizationsById(organizationId);
        List<Integer> children = organizationService.orgIdList(organizationId);
        List<Integer> childrenId = new ArrayList<>();
        for (Organization child : children) {
            childrenId.add(child.getId());
        }
        childrenId.add(organizationId);
        childrenId.addAll(children);
        childrenId.addAll(integerList);
        wrapper.in("organization_id", childrenId);
        //查询根据batch查,因为可能会有跨天飞行的情况。
@@ -413,14 +410,19 @@
            Map<String, Object> data = JSON.parseObject(g.getValue(), Map.class);
            Map<String, Object> dataResult = new HashMap<>();
            dataResult = data;
            int a21026D =(int) Math.round(Double.parseDouble(data.get("a21026").toString()));
            if(a21026D>11){
            Double a34004 = Double.parseDouble(data.get("a34004").toString());
            Double a34002 = Double.parseDouble(data.get("a34002").toString());
            dataResult.put("a34002",Double.parseDouble(String.format("%.4f",a34004)));
            dataResult.put("a34004",Double.parseDouble(String.format("%.4f",a34002)));
           /* if(a21026D>11){
               // Integer digit = a21026D % 10;
                Integer digit = new Random().nextInt(5)+8;
                dataResult.put("a21026",Double.parseDouble(digit.toString()));
            }else {
                continue;
            }
            }*/
            historySecondUav.setId(g.getId());
            historySecondUav.setValue(JSONObject.toJSONString(dataResult));
            list.add(historySecondUav);
screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
@@ -71,4 +71,9 @@
            return;
        }
    }
    @Override
    public List<Integer> orgIdList(Integer organizationId) {
        return this.baseMapper.orgIdList(organizationId);
    }
}
screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
@@ -210,7 +210,7 @@
                    });
                }
            }else {
                BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Integer.parseInt(list.getDataValue())):BigDecimal.ZERO;
                BigDecimal dataValue = Objects.nonNull(list.getDataValue())?BigDecimal.valueOf(Double.parseDouble(list.getDataValue())):BigDecimal.ZERO;
                result.forEach(it->{
                    it.setAvgNum(it.getAvgNum().add(dataValue));
                });
@@ -224,8 +224,8 @@
    private BigDecimal numAvg(List<String> list , BigDecimal num){
        int nums = 1;
        for (int i=0;i<list.size();i=i+2){
            if(num.compareTo(BigDecimal.valueOf(Integer.parseInt(list.get(i))))>= 0 ){
                return num.add(BigDecimal.valueOf(Integer.parseInt(list.get(nums))));
            if(num.compareTo(BigDecimal.valueOf(Double.parseDouble(list.get(i))))>= 0 ){
                return num.add(BigDecimal.valueOf(Double.parseDouble(list.get(i+1))));
            }
            nums+=2;
        }
screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java
@@ -8,27 +8,38 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.config.Interceptor.UserHelper;
import com.moral.api.entity.*;
import com.moral.api.mapper.*;
import com.moral.api.pojo.bo.UserBO;
import com.moral.api.pojo.enums.AllocationApproveEnum;
import com.moral.api.pojo.enums.FileTableEnum;
import com.moral.api.pojo.enums.StateEnum;
import com.moral.api.pojo.enums.SysDictTypeEnum;
import com.moral.api.pojo.vo.file.FileVo;
import com.moral.api.pojo.vo.user.QxUser;
import com.moral.api.service.FileTableService;
import com.moral.api.service.ResponsibilityUnitService;
import com.moral.api.service.UserService;
import com.moral.api.utils.OperationLogUtils;
import com.moral.api.utils.StringUtils;
import com.moral.api.utils.WechatUtils;
import com.moral.api.vo.WxMssVo;
import com.moral.constant.Constants;
import com.moral.constant.ResponseCodeEnum;
import com.moral.util.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -69,6 +80,9 @@
    @Autowired
    private ResponsibilityUnitMapper responsibilityUnitMapper;
    @Autowired
    private ResponsibilityUnitService responsibilityUnitService;
    @Value("${AES.KEY}")
    private String AESKey;
@@ -103,6 +117,16 @@
        }
        ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(userBo.getUnitId());
        List<Integer> list = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_DEVICE.value, userBo.getId());
        result.put("userName", userBo.getUserName());
        result.put("unitId",userBo.getUnitId());
        result.put("userId", userBo.getId());
        result.put("account", userBo.getAccount());
        List<FileVo> listFile =  fileTableService.list(userBo.getId(), FileTableEnum.APP_ALLOCATION.value);
        result.put("file", CollectionUtils.isNotEmpty(listFile)?listFile.get(0):new FileVo());
        result.put("unName",Objects.nonNull(responsibilityUnit)&&Objects.nonNull(responsibilityUnit.getUnitName())?responsibilityUnit.getUnitName():"管理员登陆");
        result.put("device",ObjectUtils.isEmpty(list)? StateEnum.NOT_EFFECTIVE.value :StateEnum.TAKE_EFFECT.value);
        String userIdStr = new StringBuffer("00").append(userBo.getId().toString()).toString();
        String tokenResult = TokenUtils.getTokenById(userIdStr);
        //封装用户信息
        Map<String, Object> userInfo = new LinkedHashMap<>();
        userInfo.put("userId", userBo.getId());
@@ -117,19 +141,25 @@
        userInfo.put("isAdmin", userBo.getIsAdmin());
        userInfo.put("organizationId",userBo.getOrganizationId());
        userInfo.put("openid", openId);
        if(StringUtils.isNotEmpty(tokenResult)){
            result.put("token", tokenResult);
            result.put("code", ResponseCodeEnum.SUCCESS.getCode());
            result.put("msg", ResponseCodeEnum.SUCCESS.getMsg());
            sysLog("登陆了用户:" + userBo.getAccount()+" ;openId:"+openId,userBo);
            //添加openId到user表中
            User user = userMapper.selectById(userBo.getId());
            user.setOpenId(openId);
            userMapper.updateById(user);
            TokenUtils.getRefreshTokenApp(tokenResult,userInfo);
            return result;
        }
        try {
            //生成token,并存入redis
            String token = TokenUtils.getTokenApp(new StringBuffer("00").append(userBo.getId().toString()).toString(),userInfo);
            result.put("token", token);
            result.put("userName", userBo.getUserName());
            result.put("unitId",userBo.getUnitId());
            result.put("userId", userBo.getId());
            result.put("account", userBo.getAccount());
            List<FileVo> listFile =  fileTableService.list(userBo.getId(), FileTableEnum.APP_ALLOCATION.value);
            result.put("file", CollectionUtils.isNotEmpty(listFile)?listFile.get(0):new FileVo());
            result.put("unName",Objects.nonNull(responsibilityUnit)&&Objects.nonNull(responsibilityUnit.getUnitName())?responsibilityUnit.getUnitName():"管理员登陆");
            result.put("device",ObjectUtils.isEmpty(list)? StateEnum.NOT_EFFECTIVE.value :StateEnum.TAKE_EFFECT.value);
        } catch (Exception e) {
            log.error("token生成异常:" + e.getMessage());
            result.put("code", ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode());
@@ -178,7 +208,19 @@
//            String nickName = rawDataJson.getString("nickName");
//            String avatarUrl = rawDataJson.getString("avatarUrl");
        }
        String userIdStr = new StringBuffer("00").append(user.getId().toString()).toString();
        String tokenResult = TokenUtils.getTokenById(userIdStr);
        result.put("userName", user.getUserName());
        result.put("unitId",user.getUnitId());
        List<FileVo> listFile =  fileTableService.list(user.getId(), FileTableEnum.APP_ALLOCATION.value);
        result.put("file", CollectionUtils.isNotEmpty(listFile)?listFile.get(0):new FileVo());
        result.put("userId", user.getId());
        result.put("account", user.getAccount());
        ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(user.getUnitId());
        List<Integer> list = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_DEVICE.value, user.getId());
        result.put("device",ObjectUtils.isEmpty(list)? StateEnum.NOT_EFFECTIVE.value : StateEnum.TAKE_EFFECT.value);
        result.put("unName",Objects.nonNull(responsibilityUnit)&&Objects.nonNull(responsibilityUnit.getUnitName())?responsibilityUnit.getUnitName():"管理员登陆");
        result.put("openId",openid);
        Map<String, Object> userInfo = new LinkedHashMap<>();
        userInfo.put("userId", user.getId());
        userInfo.put("account", user.getAccount());
@@ -186,26 +228,24 @@
        userInfo.put("email", user.getEmail());
        userInfo.put("mobile", user.getMobile());
        userInfo.put("unitId",user.getUnitId());
//        userInfo.put("unName",user.getAreaName());
        userInfo.put("organizationId",user.getOrganizationId());
        userInfo.put("wechat", user.getWechat());
        userInfo.put("expireTime", DateUtils.dateToDateString(user.getExpireTime()));
        userInfo.put("isAdmin", user.getIsAdmin());
        ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(user.getUnitId());
        List<Integer> list = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_DEVICE.value, user.getId());
        if(StringUtils.isNotEmpty(tokenResult)){
            result.put("token", tokenResult);
            result.put("code", ResponseCodeEnum.SUCCESS.getCode());
            result.put("msg", ResponseCodeEnum.SUCCESS.getMsg());
            sysLog("登陆了用户:" + user.getAccount()+" ;openId:"+openid,user);
            TokenUtils.getRefreshTokenApp(tokenResult,userInfo);
            return result;
        }
        try {
            //生成token,并存入redis
            String token = TokenUtils.getTokenApp(new StringBuffer("00").append(user.getId().toString()).toString(),userInfo);
            result.put("token", token);
            result.put("userName", user.getUserName());
            result.put("unitId",user.getUnitId());
            List<FileVo> listFile =  fileTableService.list(user.getId(), FileTableEnum.APP_ALLOCATION.value);
            result.put("file", CollectionUtils.isNotEmpty(listFile)?listFile.get(0):new FileVo());
            result.put("userId", user.getId());
            result.put("account", user.getAccount());
            result.put("device",ObjectUtils.isEmpty(list)? StateEnum.NOT_EFFECTIVE.value : StateEnum.TAKE_EFFECT.value);
            result.put("unName",Objects.nonNull(responsibilityUnit)&&Objects.nonNull(responsibilityUnit.getUnitName())?responsibilityUnit.getUnitName():"管理员登陆");
            result.put("openId",openid);
        } catch (Exception e) {
            log.error("token生成异常:" + e.getMessage());
            result.put("code", ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode());
@@ -226,6 +266,74 @@
        sysLog(userId+"退出了小程序",user);
        return true;
    }
    /**
     * 小程序推送
     * @param appAllocationPushUserCond
     */
    @Override
    @Async("asyncPoolTaskExecutor")
    public void pushOneUser(Allocation appAllocationPushUserCond) {
        QxUser currentUser = UserHelper.getCurrentUser();
        ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(appAllocationPushUserCond.getUnitId());
        Integer areaCode = responsibilityUnit.getAreaCode();
        List<ResponsibilityUnit> responsibilityUnits = responsibilityUnitService.selectAreaUnit(areaCode.toString().length()>6?responsibilityUnit.getParentCode():responsibilityUnit.getAreaCode());
        //获取unitid
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getIsDelete,Constants.NOT_DELETE);
        Integer state = appAllocationPushUserCond.getState();
        if (state==20){
            wrapper.eq(User::getUnitId,appAllocationPushUserCond.getUnitId());
        }else {
            wrapper.eq(User::getUnitId,ObjectUtils.isEmpty(responsibilityUnits)?0:responsibilityUnits.get(0).getUnitId());
        }
        List<User> users = userMapper.selectList(wrapper);
        if (ObjectUtils.isEmpty(users)){
            return;
        }
        String dateString = DateUtils.dateToDateString(appAllocationPushUserCond.getEscalationTime(),"MM月dd日");
        //这里简单起见我们每次都获取最新的access_token(时间开发中,应该在access_token快过期时再重新获取)
        //小程序订阅
        String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + WechatUtils.getAccessToken();
        //发送消息
        for (User user : users) {
            if (user.getId().equals(currentUser.getUserId())){
                continue;
            }
            RestTemplate restTemplate = new RestTemplate();
            //拼接推送的模版
            WxMssVo wxMssVo = new WxMssVo();
            wxMssVo.setTouser(user.getOpenId());//用户的openid(要发送给那个用户,通常这里应该动态传进来的)
            wxMssVo.setTemplate_id("YNqUZ1MgMvwY3G-NENVbcmIBR5dUotSdnwcz96CWrho");//订阅消息模板id
            wxMssVo.setLang("zh_CN");
            wxMssVo.setMiniprogramState("formal");
            wxMssVo.setPage("pages/index/index");
            Map<String, Object> m = new HashMap<>();
            HashMap<String, Object> map1 = new HashMap<>();
            HashMap<String, Object> map2 = new HashMap<>();
            HashMap<String, Object> map3 = new HashMap<>();
            HashMap<String, Object> map4 = new HashMap<>();
            map1.put("value",responsibilityUnit.getUnitName()+dateString+"的交办单");
            map2.put("value",appAllocationPushUserCond.getAllocationNum());
            map3.put("value",state==30? AllocationApproveEnum.IN_APPROVAL.name:AllocationApproveEnum.UNDER_RECTIFICATION.name);
            map4.put("value",DateUtils.dateToDateString(new Date(),"yyyy年MM月dd日"));
            m.put("thing18", map1);
            m.put("character_string1", map2);
            m.put("thing2", map3);
            m.put("date4", map4);
            wxMssVo.setData(JSON.toJSON(m));
            ResponseEntity<String> responseEntity =
                    restTemplate.postForEntity(url, wxMssVo, String.class);
            String body = responseEntity.getBody();
            log.info("信息:"+body+"账号:"+user.getAccount()+"openID"+user.getOpenId());
        }
    }
    private void sysLog(String cont,User user){
        //日志
        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java
@@ -140,18 +140,4 @@
        return resultString;
    }
    public static String getAccessToken() {
        RestTemplate restTemplate = new RestTemplate();
        Map<String, String> params = new HashMap<>();
        params.put("APPID", "wx7c54942dfc87f4d8");  //
        params.put("APPSECRET", "5873a729c365b65ab42bb5fc82d2ed49");  //
        ResponseEntity<String> responseEntity = restTemplate.getForEntity(
                "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}", String.class, params);
        String body = responseEntity.getBody();
        JSONObject object = JSON.parseObject(body);
        String Access_Token = object.getString("access_token");
        String expires_in = object.getString("expires_in");
        System.out.println("有效时长expires_in:" + expires_in);
        return Access_Token;
    }
}
screen-api/src/main/java/com/moral/api/utils/WechatUtils.java
@@ -3,16 +3,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
@@ -20,7 +13,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.moral.api.service.UserLogService;
public class WechatUtils {
@@ -46,4 +39,18 @@
        return jsonObject;
    }
    public static String getAccessToken() {
        RestTemplate restTemplate = new RestTemplate();
        Map<String, String> params = new HashMap<>();
        params.put("APPID", APPID);  //
        params.put("APPSECRET", SECRET);  //
        ResponseEntity<String> responseEntity = restTemplate.getForEntity(
                "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}", String.class, params);
        String body = responseEntity.getBody();
        JSONObject object = JSON.parseObject(body);
        String Access_Token = object.getString("access_token");
//        String expires_in = object.getString("expires_in");
        return Access_Token;
    }
}
screen-api/src/main/java/com/moral/api/vo/WxMssVo.java
@@ -9,5 +9,7 @@
    private String touser;//用户openid
    private String template_id;//订阅消息模版id
    private String page = "pages/index/index";//默认跳到小程序首页
    private Map<String, String> data;//推送文字
    private Object data;//推送文字
    private  String miniprogramState;
    private  String lang;
}
screen-api/src/main/resources/application-qa.yml
@@ -21,7 +21,7 @@
  main:
    allow-bean-definition-overriding: true
  redis:
    host: r-bp1hez4g7rkqjswpaypd1.redis.rds.aliyuncs.com
    host: r-bp1hez4g7rkqjswpay158.redis.rds.aliyuncs.com
    port: 6379
    password: moral_123456
    timeout: 30000
@@ -38,7 +38,7 @@
        max-wait: 30000
        min-idle: 32
  tokenRedis:
    host: r-bp1hez4g7rkqjswpaypd1.redis.rds.aliyuncs.com
    host: r-bp1hez4g7rkqjswpay158.redis.rds.aliyuncs.com
    port: 6379
    password: moral_123456
    timeout: 30000
screen-api/src/main/resources/mapper/AllocationMapper.xml
@@ -67,14 +67,23 @@
        left join allocation_extension t1 on t1.allocation_id = allocation.allocation_id and t1.is_del =0 and t1.is_invalid = 0 and t1.state = 30
        <where>
            1 = 1 and allocation.is_del = 0
            <if test="allocation.unitId != null">
                and allocation.unit_id = #{allocation.unitId}
            <if test="allocation.unitId != null and allocation.unitId.size != 0">
                and allocation.unit_id in
                <foreach collection="allocation.unitId" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.polluteType != null and allocation.polluteType != 0">
                and allocation.pollute_type = #{allocation.polluteType}
            <if test="allocation.polluteType != null and allocation.polluteType.size != 0">
                and allocation.pollute_type in
                <foreach collection="allocation.polluteType" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.state != null and allocation.state != 0">
                and allocation.state = #{allocation.state}
            <if test="allocation.state != null and allocation.state.size != 0">
                and allocation.state in
                <foreach collection="allocation.state" item="id" index="index" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
            <if test="allocation.investigationType != null and allocation.investigationType != 0">
                and allocation.investigation_type = #{allocation.investigationType}
screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -199,7 +199,7 @@
        <if test="organizationId !=null">
            AND organization_id = #{organizationId}
        </if>
           and mac LIKE "%"#{mac}"%" AND is_delete = 0
           and mac LIKE "%"#{mac}"%" or `name` like "%"#{mac}"%" AND is_delete = 0
        union
        SELECT sd.id,sd.`name`,sd.mac,sd.special_type FROM special_device  as sd
        WHERE 1=1
screen-api/src/main/resources/mapper/OrganizationMapper.xml
@@ -26,4 +26,39 @@
        <result column="is_delete" property="isDelete"/>
    </resultMap>
    <select id="orgIdList" resultType="java.lang.Integer">
        SELECT id FROM (
                           SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                           UNION ALL
                           SELECT i.id, i.parent_id, i.name
                           FROM organization  i
                                    INNER JOIN (
                               SELECT * FROM (
                                                 SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                                                 UNION ALL
                                                 SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId}
                                             ) t1
                           ) t2 ON i.parent_id = t2.id
                           where i.is_delete = 0
                       ) t3
    </select>
    <select id="orgIdSpecialDevList" resultType="java.lang.Integer">
        select organization_id from special_device where organization_id in (
        SELECT id FROM (
                           SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                           UNION ALL
                           SELECT i.id, i.parent_id, i.name
                           FROM organization  i
                                    INNER JOIN (
                               SELECT * FROM (
                                                 SELECT id, parent_id, name FROM organization  WHERE id = #{organizationId}
                                                 UNION ALL
                                                 SELECT id, parent_id, name FROM organization WHERE parent_id = #{organizationId}
                                             ) t1
                           ) t2 ON i.parent_id = t2.id
                           where i.is_delete = 0
                       ) t3 ) and mac = #{mac} and is_delete = 0
    </select>
</mapper>
screen-api/src/main/resources/mapper/ResponsibilityUnitMapper.xml
@@ -42,4 +42,14 @@
        select area_code from responsibility_unit t where unit_id = #{id}
    </select>
    <select id="selectName" resultType="java.lang.String">
        select t1.dataValue from sys_dict_type t
                             left join sys_dict_data t1 on t1.dict_type_id = t.id
        where t.is_delete = 0 and t.name = #{code} and t1.dataKey = #{id} and t1.is_delete = 0
    </select>
</mapper>
screen-api/src/main/resources/word/???????.docx
Binary files differ
screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -86,7 +86,7 @@
            if (oldToken != null)
                redisTemplate.delete(oldToken);
            //新token写入到value中
            redisTemplate.opsForValue().set(token, userInfo);
            getRefreshTokenApp(token,userInfo);
            //redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
            //新token写入到Hash中
            redisTemplate.opsForHash().put("user_token", uid, token);
@@ -98,6 +98,9 @@
        }
    }
    public static void getRefreshTokenApp(String token, Object userInfo) {
        redisTemplate.opsForValue().set(token, userInfo);
    }
    /**
     * @Description: 校验token
@@ -197,7 +200,11 @@
     * @Date: 2021/5/21
     */
    public static String getTokenById(Integer id) {
         return (String)redisTemplate.opsForHash().get("user_token", String.valueOf(id));
         return (String) getTokenById(id.toString());
    }
    public static String getTokenById(String id) {
        return (String)redisTemplate.opsForHash().get("user_token", String.valueOf(id));
    }
screen-job/src/main/resources/application-cjl.yml
@@ -110,4 +110,4 @@
  date:
    changshu: P5DND7A0245358,P5DND7A0245364,P5DND7A0245413,P5DND7A0245355,P5DND7A0245416,P5DND7A0245426,P5DND7A0245398,P5DND7A0245441,P5DND7A0245429,P5DND7A0245435,P5DND7A0245372,P5DND7A0245397,P5DND7A0245415,P5DND7A0245411,P5DND7A0245407,P5DND7A0245418,P5DND7A0245430,P5DND7A0245493,P5DND7A0245414,P5DND7A0245366,P5DND7A0245442,P5DND7A0245386,P5DND7A0245431,P5DND7A0245394,P5DND7A0245380,P5DND7A0245420,P5DND7A0245440,P5DND7A0245432,P5DND7A0391974,P5DND7A0391989,P5DND7A0245481,P5DND7A0392001,P5DND7A0391991,P5DND7A0391978,P5DND7A0245499
  device:
    list: p5dnd7a0245499,p5dnd7a0391962
    list: p5dnd7a0245499,p5dnd7a0391962,HJS00002156B89
screen-manage/src/main/java/com/moral/api/mapper/HistorySecondCruiserMapper.java
@@ -6,6 +6,7 @@
import com.moral.api.entity.HistorySecondCruiser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moral.api.pojo.dto.cruiser.CruiserDTO;
import com.moral.api.pojo.dto.cruiser.CruiserListDTO;
/**
 * <p>
@@ -19,4 +20,6 @@
    List<CruiserDTO> getCruiserInfo(Map<String,Object> params);
    List<CruiserListDTO> cruiserList(Map<String,Object> params);
}
screen-manage/src/main/java/com/moral/api/pojo/dto/cruiser/CruiserListDTO.java
New file
@@ -0,0 +1,35 @@
package com.moral.api.pojo.dto.cruiser;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Objects;
@Data
public class CruiserListDTO {
    /**
     * 数据时间
     */
    private String time;
    /**
     * 纬度
     */
    private Double flyLat;
    /**
     * 经度
     */
    private Double flyLon;
    private Integer coordinateId;
    private Integer id;
    private Integer state;
}
screen-manage/src/main/java/com/moral/api/service/impl/HistorySecondCruiserServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.entity.HistorySecondCruiser;
import com.moral.api.entity.ManageCoordinateDetail;
import com.moral.api.entity.Sensor;
@@ -10,28 +11,20 @@
import com.moral.api.mapper.ManageCoordinateDetailMapper;
import com.moral.api.mapper.SpecialDeviceMapper;
import com.moral.api.pojo.dto.cruiser.CruiserDTO;
import com.moral.api.service.DeviceService;
import com.moral.api.pojo.dto.cruiser.CruiserListDTO;
import com.moral.api.service.HistorySecondCruiserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.api.service.SpecialDeviceService;
import com.moral.api.util.RoadUtils;
import com.moral.constant.Constants;
import com.moral.constant.RedisConstants;
import com.moral.util.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.sql.Wrapper;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -172,82 +165,41 @@
    @Override
    public Map<String, Object> getCruiserCompare(Map<String, Object> params) {
        HashMap<String,Object> rsMap = new HashMap<>();
        String mac = params.get("mac").toString();
        String time1 = params.get("time1").toString();
        List<CruiserListDTO> list = historySecondCruiserMapper.cruiserList(params);
        List<CruiserDTO> cruiserInfo = new ArrayList<>();
        ArrayList<ManageCoordinateDetail> rsList1 = new ArrayList<>();
        params.put("dateFormat", "%Y-%m-%d %H:%i:%s");
        List<ManageCoordinateDetail> manageCoordinateDetails = manageCoordinateDetailMapper.selectList(null);
        List<CruiserDTO> cruiserInfo = (List<CruiserDTO>) redisTemplate.opsForHash().get(RedisConstants.DATE_COORDINATE, mac + time1);
        if (ObjectUtils.isEmpty(cruiserInfo)){
            cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params);
            cruiserInfo = cruiserInfo.stream().distinct().collect(Collectors.toList());
            cruiserInfo.removeIf(o->{
                if (ObjectUtils.isEmpty(o.getFlyLon()) || ObjectUtils.isEmpty(o.getFlyLat())) {
                    return true;
                }
                double lon = o.getFlyLon();
                double lat = o.getFlyLat();
                double[] doubles = RoadUtils.transformWGS84ToBD09(lon, lat);
                Matcher matcher = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[0]);
                matcher.find();
                String s = matcher.group();
                Matcher matcher1 = Pattern.compile("\\d*\\.\\d{8}").matcher(""+doubles[1]);
                matcher1.find();
                String s1 = matcher1.group();
                o.setFlyLon(Double.parseDouble(s));
                o.setFlyLat(Double.parseDouble(s1));
                o.setData(lon+"_"+lat);
//            o.setFlyLon(doubles[0]);
//            o.setFlyLat(doubles[1]);
                if (lon < 70 || lon > 150 || lat < 20 || lat > 60) {
                    return true;
                }
                return false;
            });
            redisTemplate.opsForHash().put(RedisConstants.DATE_COORDINATE,mac+time1,cruiserInfo);
            //设置过期时间
            redisTemplate.opsForHash().getOperations().expire(RedisConstants.DATE_COORDINATE,6000, TimeUnit.SECONDS);
        }
//        List<CruiserDTO> cruiserInfo = historySecondCruiserMapper.getCruiserInfo(params);
        log.info(""+cruiserInfo.size());
        if (ObjectUtils.isEmpty(manageCoordinateDetails)){
            rsMap.put("rsData",cruiserInfo);
            rsMap.put("data",rsList1);
            return rsMap;
        }
        for (int i=cruiserInfo.size()-1;i>0;i--) {
            CruiserDTO cruiserDTO = cruiserInfo.get(i);
            String data = cruiserDTO.getData();
            String[] rs = data.split("_");
            String flyLon = rs[0];
            String flyLat = rs[1];
//            double lonDouble = Double.parseDouble(flyLon);
//            double latDouble = Double.parseDouble(flyLat);
            for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) {
                String latitude = manageCoordinateDetail.getLatitude().toString();
                String longitude = manageCoordinateDetail.getLongitude().toString();
//                double lonDouble1 = Double.parseDouble(longitude);
//                double latDouble1 = Double.parseDouble(latitude);
//                if (latDouble1==latDouble && lonDouble==lonDouble1){
                    if (flyLon.equals(longitude) && flyLat.equals(latitude)){
                    manageCoordinateDetail.setCode(data);
                    manageCoordinateDetail.setLongitude(cruiserDTO.getFlyLon());
                    manageCoordinateDetail.setLatitude(cruiserDTO.getFlyLat());
                    rsList1.add(manageCoordinateDetail);
                    cruiserInfo.remove(i);
                    break;
                }
        for(CruiserListDTO c : list){
            if (ObjectUtils.isEmpty(c.getFlyLon()) || ObjectUtils.isEmpty(c.getFlyLat())) {
                continue;
            }
            double[] doubles = RoadUtils.transformWGS84ToBD09(c.getFlyLon(), c.getFlyLat());
            if(doubles.length !=2){
                continue;
            }
            String date = new StringBuilder().append(c.getFlyLon()).append("_").append(c.getFlyLat()).toString();
            if(c.getState().equals(0)){
                CruiserDTO cruiserDTO = new CruiserDTO();
                cruiserDTO.setTime(c.getTime());
                cruiserDTO.setFlyLat(doubles[1]);
                cruiserDTO.setFlyLon(doubles[0]);
                cruiserDTO.setData(date);
                cruiserDTO.setState("1");
                cruiserInfo.add(cruiserDTO);
            }else {
                ManageCoordinateDetail detail = new ManageCoordinateDetail();
                detail.setId(c.getId());
                detail.setCoordinateId(c.getCoordinateId());
                detail.setLongitude(doubles[0]);
                detail.setLatitude(doubles[1]);
                detail.setState(c.getState().toString());
                detail.setCode(date);
                rsList1.add(detail);
            }
        }
        rsMap.put("rsData",cruiserInfo);
        rsMap.put("data",rsList1);
        rsMap.put("message","有"+cruiserInfo.size()+"个不在里面,"+"一共有"+(cruiserInfo.size()+rsList1.size())+"个");
        return rsMap;
    }
}
screen-manage/src/main/java/com/moral/api/service/impl/ManageCoordinateDetailServiceImpl.java
@@ -19,6 +19,7 @@
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -226,35 +227,24 @@
                log.info(j+"");
            }
        }else {
            for (int i=cruiserInfo.size()-1;i>0;i--) {
                CruiserDTO cruiserDTO = cruiserInfo.get(i);
                Double flyLat = cruiserDTO.getFlyLat();
                Double flyLon = cruiserDTO.getFlyLon();
                for (ManageCoordinateDetail manageCoordinateDetail : manageCoordinateDetails) {
                    String latitude = manageCoordinateDetail.getLatitude().toString();
                    String longitude = manageCoordinateDetail.getLongitude().toString();
//                    double lonDouble1 = Double.parseDouble(longitude);
//                    double latDouble1 = Double.parseDouble(latitude);
//                    if (lonDouble1==flyLon && flyLat==latDouble1 ){
                    if (longitude.equals(flyLon+"") && latitude.equals(flyLat+"")){
                        cruiserInfo.remove(i);
                        break;
                    }
                }
            }
            Map<String,Integer> map = new HashMap<>(manageCoordinateDetails.size()+50);
            manageCoordinateDetails.forEach(it->map.put(it.getLatitude()+"_"+it.getLongitude(),it.getId()));
            List<ManageCoordinateDetail> result = new ArrayList<>();
            for (CruiserDTO cruiserDTO : cruiserInfo) {
                Double flyLat = cruiserDTO.getFlyLat();
                Double flyLon = cruiserDTO.getFlyLon();
                ManageCoordinateDetail rsDTO = new ManageCoordinateDetail();
                rsDTO.setLatitude(flyLat);
                rsDTO.setLongitude(flyLon);
                rsDTO.setState("2");
                rsDTO.setCreateTime(new Date());
                rsDTO.setUpdateTime(new Date());
                rsDTO.setCoordinateId(coordinateId);
                manageCoordinateDetailMapper.insert(rsDTO);
                j++;
                log.info(j+"");
                String fly = cruiserDTO.getFlyLat()+"_"+cruiserDTO.getFlyLon();
               if(!map.containsKey(fly)){
                   ManageCoordinateDetail rsDTO = new ManageCoordinateDetail();
                   rsDTO.setLatitude(cruiserDTO.getFlyLat());
                   rsDTO.setLongitude(cruiserDTO.getFlyLon());
                   rsDTO.setState("2");
                   rsDTO.setCreateTime(new Date());
                   rsDTO.setUpdateTime(new Date());
                   rsDTO.setCoordinateId(coordinateId);
                   result.add(rsDTO);
               }
            }
            if(!CollectionUtils.isEmpty(result)){
                this.saveBatch(result);
            }
        }
        return 200;
screen-manage/src/main/java/com/moral/api/service/impl/ResponsibilityUnitServiceImpl.java
@@ -79,6 +79,7 @@
    public Map<String, Object> selectUnit(Map<String, Object> parameters) {
        QueryWrapper<ResponsibilityUnit> wrapper = new QueryWrapper<>();
        wrapper.eq("is_del",Constants.NOT_DELETE);
        wrapper.eq("is_invalid",0);
        int page = Integer.parseInt(parameters.get("page").toString());
        int size = Integer.parseInt(parameters.get("size").toString());
        Object parentName1 = parameters.get("parentCode");
screen-manage/src/main/java/com/moral/api/service/impl/SysDictDataServiceImpl.java
@@ -219,6 +219,7 @@
            QueryWrapper<SysDictData> wrapper = new QueryWrapper<>();
            wrapper.eq("is_delete", Constants.NOT_DELETE);
            wrapper.eq("dict_type_id", type.getId());
            wrapper.orderByAsc("id");
            List<SysDictData> datas = sysDictDataMapper.selectList(wrapper);
            result.put(type.getName(), datas);
        }
screen-manage/src/main/java/com/moral/api/service/impl/SysDictTypeServiceImpl.java
@@ -202,6 +202,7 @@
    private List<SysDictType> getAllDictTypeFromDB() {
        QueryWrapper<SysDictType> wrapper = new QueryWrapper<>();
        wrapper.eq("is_delete", Constants.NOT_DELETE);
        wrapper.orderByAsc("id");
        List<SysDictType> sysDictTypes = sysDictTypeMapper.selectList(wrapper);
        return sysDictTypes;
    }
screen-manage/src/main/resources/application-qa.yml
@@ -18,7 +18,7 @@
  application:
    name: screen-manage
  redis:
      host: r-bp1hez4g7rkqjswpaypd1.redis.rds.aliyuncs.com
      host: r-bp1hez4g7rkqjswpay158.redis.rds.aliyuncs.com
      port: 6379
      password: moral_123456
      timeout: 30000
@@ -35,7 +35,7 @@
          max-wait: 30000
          min-idle: 32
  tokenRedis:
    host: r-bp1hez4g7rkqjswpaypd1.redis.rds.aliyuncs.com
    host: r-bp1hez4g7rkqjswpay158.redis.rds.aliyuncs.com
    port: 6379
    password: moral_123456
    timeout: 30000
screen-manage/src/main/resources/mapper/HistorySecondCruiserMapper.xml
@@ -20,4 +20,54 @@
        order by time
    </select>
    <select id="cruiserList" resultType="com.moral.api.pojo.dto.cruiser.CruiserListDTO">
        WITH zb AS (
        SELECT
        DATE_FORMAT( `time`, '%Y-%m-%d %H:%i:%s' ) AS time,VALUE->> '$.flylat' AS flyLat,VALUE->> '$.flylon' AS flyLon
        FROM
        history_second_cruiser
        WHERE
        mac =  #{mac}
        AND `time` <![CDATA[>=]]> #{time1}
        AND `time` <![CDATA[<=]]> #{time2}
        ORDER BY
        time
        ),
        resultList AS (
        SELECT
        t1.time,
        t1.flyLat,
        t1.flyLon
        FROM
        zb t1
        INNER JOIN ( SELECT flyLon, flyLat, MAX( time ) AS max_time FROM zb GROUP BY flyLat, flyLon ) t2 ON t1.flyLon = t2.flyLon
        AND t1.flyLat = t2.flyLat
        AND t1.time = t2.max_time
        ),
        mx AS (
        SELECT t2.latitude,
            t2.longitude,
            t2.state,
            t2.coordinate_id ,max(t2.id) id
        FROM
        manage_coordinate t1
        LEFT JOIN manage_coordinate_detail t2 ON t1.coordinate_id = t2.coordinate_id
        LEFT JOIN special_device t3 ON t1.organization_id = t3.organization_id
        WHERE
        t1.is_del = 0
        AND t3.mac = #{mac} group by t2.latitude,
            t2.longitude,
            t2.state,
            t2.coordinate_id
        ) SELECT
        tt.time,
        tt.flyLat,
        tt.flyLon,
        COALESCE ( tt1.state, 0 ) AS state ,tt1.coordinate_id,tt1.id as id
        FROM
        resultList tt
        LEFT JOIN mx tt1 ON tt.flyLat = tt1.latitude
        AND tt.flyLon = tt1.longitude
    </select>
</mapper>