screen-api/pom.xml
@@ -34,6 +34,11 @@ <version>4.0.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>4.0.1</version> screen-api/src/main/java/com/moral/api/controller/AllocationController.java
@@ -20,11 +20,12 @@ import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -39,7 +40,9 @@ import com.moral.api.utils.NoModelWriteData; import com.moral.constant.Constants; import com.moral.constant.ResultMessage; import com.moral.util.DateUtils; import com.moral.util.WebUtils; import javax.validation.Valid; @@ -134,6 +137,7 @@ allocationVo.setFileChangeList(allocationext.getFileChangeList()); allocationVo.setFileApproveList(allocationext.getFileApproveList()); allocationVo.setApproveList(allocationext.getApproveList()); allocationVo.setTime(DateUtils.dateToDateString(allocationVo.getEscalationTime(), DateUtils.yyyy_MM_dd_CN)); return ResultMessage.ok(allocationVo); } @GetMapping("remove") screen-api/src/main/java/com/moral/api/controller/AppAllocationController.java
@@ -2,13 +2,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.moral.api.pojo.enums.AllocationApproveEnum; import com.moral.api.pojo.enums.AppAllocationStateEnum; import com.moral.api.pojo.ext.allocation.AllocationPageExt; import com.moral.api.pojo.query.app.AppAllocationFileCond; import com.moral.api.pojo.query.app.AppAllocationPageCond; import com.moral.api.pojo.vo.allocation.AllocationPageVo; import com.moral.api.pojo.vo.app.AppAllocationFindVo; import com.moral.constant.PageResult; import io.swagger.annotations.Api; @@ -92,4 +88,13 @@ return ResultMessage.ok(); } @GetMapping("authority") @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); return ResultMessage.ok(authority); } } screen-api/src/main/java/com/moral/api/controller/AppDevicController.java
New file @@ -0,0 +1,72 @@ package com.moral.api.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; import com.moral.api.entity.Device; import com.moral.api.entity.MonitorPoint; import com.moral.api.pojo.vo.device.AppDeviceVo; import com.moral.api.service.DeviceService; import com.moral.api.service.MonitorPointService; import com.moral.api.service.SpecialDeviceService; import com.moral.constant.ResultMessage; @Slf4j @Api(tags = {"小程序设备管理"}) @RestController @RequestMapping("/AppDevice") public class AppDevicController { @Autowired private MonitorPointService monitorPointService; @Autowired private DeviceService deviceService; @Autowired private SpecialDeviceService specialDeviceService; @GetMapping("selectOrganization") @ApiOperation(value = "小程序获取站点") public ResultMessage selectOrganization(){ List<MonitorPoint> monitorPoints = monitorPointService.getOrganizations(); return ResultMessage.ok(monitorPoints); } @GetMapping("selectDevice") @ApiOperation(value = "小程序获取设备") public ResultMessage selectDevice(@RequestParam @ApiParam(value = "monitorPointId",name = "站点ID") Integer monitorPointId){ List<Device> organizationDevice = deviceService.getOrganizationDevice(monitorPointId); return ResultMessage.ok(ObjectUtils.isEmpty(organizationDevice)?null:organizationDevice); } @GetMapping("fuzzySearch") @ApiOperation(value = "小程序模糊搜索") public ResultMessage fuzzySearch(@RequestParam @ApiParam(value = "mac",name = "设备mac号") String mac){ List<AppDeviceVo> devices = deviceService.getFuzzySearch(mac); return ResultMessage.ok(devices); } @GetMapping("specialDevice") @ApiOperation(value = "查询特殊设备") public ResultMessage selectSpecialDevice(){ List<AppDeviceVo> appDeviceVos = specialDeviceService.selectSpecialDevice(); return ResultMessage.ok(appDeviceVos); } } screen-api/src/main/java/com/moral/api/controller/AppUserController.java
@@ -5,19 +5,23 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import java.util.HashMap; import java.util.Map; import com.moral.api.service.UserService; import com.moral.api.utils.HttpClientUtil; import com.moral.api.vo.WxMssVo; import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; @@ -61,4 +65,34 @@ return ResultMessage.ok(); } @GetMapping("pushOneUser") @ApiOperation(value = "小程序推送消息") public ResultMessage pushOneUser(String openid){ String body = push("oOCWi6yfVapaK25Jnkk7jKSbMLyw"); return ResultMessage.ok(body); } 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(); //拼接推送的模版 WxMssVo wxMssVo = new WxMssVo(); wxMssVo.setTouser(openid);//用户的openid(要发送给那个用户,通常这里应该动态传进来的) wxMssVo.setTemplate_id("sClgB85aEG1hgaiXpnJBopo5LJX6r91DUsyikOmUgv8");//订阅消息模板id 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); ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, wxMssVo, String.class); return responseEntity.getBody(); } } screen-api/src/main/java/com/moral/api/controller/CruiserController.java
@@ -1,50 +1,15 @@ package com.moral.api.controller; 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.data.RowRenderData; import com.deepoove.poi.data.TextRenderData; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; import cn.afterturn.easypoi.word.WordExportUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URLEncoder; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.moral.api.entity.Dustld; import com.moral.api.pojo.bo.ExcelBO; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; import com.moral.api.pojo.dust.DustForm; import com.moral.api.pojo.vo.excel.DailyVo; import com.moral.api.service.DustldService; @@ -52,6 +17,32 @@ import com.moral.constant.ResponseCodeEnum; import com.moral.constant.ResultMessage; import com.moral.util.WebUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; 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; import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URL; import java.net.URLEncoder; import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.moral.api.controller.SysTestController.getPath; @@ -251,13 +242,16 @@ if (!params.containsKey("mac") || !params.containsKey("startTime") || !params.containsKey("endTime")){ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } 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()); } test(map,response); // return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(),ResponseCodeEnum.SUCCESS.getMsg(),map); return ResultMessage.ok(); } @@ -321,15 +315,10 @@ } public void test( Map<String, Object> params,HttpServletResponse response) throws IOException { // String path="D:\\尘负荷监测报告.docx"; String path = getPath("尘负荷监测报告.docx"); public static void test( Map<String, Object> params,HttpServletResponse response) throws IOException { InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx"); XWPFDocument compile = null; try { //获取当前模板的路径 File rootFile = new File(ResourceUtils.getURL("classpath:").getPath()); File file= new File(rootFile, path); //第一步:读取模板 XWPFTemplate compile = XWPFTemplate.compile(file.getPath()); //第二步:创建数据,用于把我们模板中的{{}}包裹的变量替换掉,map中保存的key一定要和模板中的变量保持一致 HashMap<String, Object> map = new HashMap<>(); //设置单元格,表头 @@ -362,19 +351,20 @@ map.put("time",params.get("time").toString()); map.put("date1",params.get("date1").toString()); map.put("date2",params.get("date2").toString()); // map.put("data",params.get("data").toString()); compile.render(map); // response.addHeader("Access-Contro1-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Origin","*");//允许所有请求跨域 response.setHeader("Access-Control-Allow-Methods", "*");//允许跨域的请求方法GET, POST, HEAD 等 response.setHeader("Access-Control-Allow-Headers", "*");//允许跨域的请求头 response.setHeader("Access-Control-Allow-Credentials", "true");//是否携带cooki File docxFile = new File("尘负荷监测报告.docx"); FileUtils.copyToFile(inputStream,docxFile); compile = WordExportUtil.exportWord07(docxFile.getPath(),map); compile.write(response.getOutputStream()); 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/controller/UAVController.java
@@ -88,6 +88,19 @@ return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS); } @PostMapping("getUavMore") public ResultMessage getUavMore(@RequestBody Map<String, Object> params){ //判断是否缺少参数 if (!params.containsKey("mac") || !params.containsKey("batch") || !params.containsKey("height1")|| !params.containsKey("uvasize")|| !params.containsKey("height2")) { return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); } List<UAVResultDTO> uavResultDTOS = uavService.getUav(params); if (ObjectUtils.isEmpty(uavResultDTOS)){ return new ResultMessage(ResponseCodeEnum.SENSOR_IS_NOT_EXIST,"null"); } return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS); } /** * @Description: 查询组织在哪天有无人机飞行,返回具体日期 @@ -138,4 +151,10 @@ return new ResultMessage(); } @GetMapping("UAVUpdateTest") public ResultMessage UAVUpdateTest( String batch){ historySecondUavService.UAVUpdateTest(batch); return new ResultMessage(); } } screen-api/src/main/java/com/moral/api/mapper/DeviceMapper.java
@@ -5,6 +5,7 @@ import com.moral.api.entity.Device; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.moral.api.pojo.vo.device.AppDeviceVo; import io.lettuce.core.dynamic.annotation.Param; /** @@ -34,4 +35,6 @@ List<String> deviceMacs(@Param("organizationId") int organizationId); List<AppDeviceVo> getDevices(@Param("mac") String mac,@Param("organizationId") Integer organizationId); } screen-api/src/main/java/com/moral/api/mapper/HistorySecondUavMapper.java
@@ -5,6 +5,7 @@ import com.moral.api.entity.HistorySecondUav; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.moral.api.pojo.dto.uav.UAVGetBD; import com.moral.api.pojo.dto.uav.UAVResultDTO; /** @@ -19,4 +20,6 @@ List<HistorySecondUav> reList(Map<String,Object> map); List<UAVGetBD> reListDetail(Map<String,Object> map); } screen-api/src/main/java/com/moral/api/mapper/MonitorPointMapper.java
@@ -1,5 +1,7 @@ package com.moral.api.mapper; import java.util.List; import com.moral.api.entity.MonitorPoint; import com.baomidou.mybatisplus.core.mapper.BaseMapper; @@ -13,4 +15,6 @@ */ public interface MonitorPointMapper extends BaseMapper<MonitorPoint> { List<Integer> getMonitorPointiId(Integer id); } screen-api/src/main/java/com/moral/api/mapper/SpecialDeviceMapper.java
@@ -1,7 +1,10 @@ package com.moral.api.mapper; import java.util.List; import com.moral.api.entity.SpecialDevice; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.moral.api.pojo.vo.device.AppDeviceVo; /** * <p> @@ -13,4 +16,6 @@ */ public interface SpecialDeviceMapper extends BaseMapper<SpecialDevice> { List<AppDeviceVo> selectSpecialDevice(Integer organizationId); } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVGetBD.java
@@ -21,4 +21,6 @@ private String value; private Double num; } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultDTO.java
@@ -1,6 +1,7 @@ package com.moral.api.pojo.dto.uav; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -40,24 +41,144 @@ private Double a21005; @ApiModelProperty(value = "未合并范围均值") private Double a21005CONotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21005CONotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21005CONotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21005COMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21005COMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21005COMergedLowest; private Double a21026; @ApiModelProperty(value = "未合并范围均值") private Double a21026SO2NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21026SO2NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21026SO2NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21026SO2MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21026SO2MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21026SO2MergedLowest; private Double a21004; @ApiModelProperty(value = "未合并范围均值") private Double a21004NO2NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a21004NO2NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a21004NO2NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a21004NO2MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a21004NO2MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a21004NO2MergedLowest; private Double a34002; @ApiModelProperty(value = "未合并范围均值") private Double a34002PM10NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a34002PM10NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a34002PM10NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a34002PM10MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a34002PM10MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a34002PM10MergedLowest; private Double a34004; @ApiModelProperty(value = "未合并范围均值") private Double a34004PM25NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a34004PM25NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a34004PM25NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a34004PM25MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a34004PM25MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a34004PM25MergedLowest; private Double a99054; @ApiModelProperty(value = "未合并范围均值") private Double a99054TVOCNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a99054TVOCNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a99054TVOCNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a99054TVOCMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a99054TVOCMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a99054TVOCMergedLowest; private Double a05024; @ApiModelProperty(value = "未合并范围均值") private Double a05024O3NotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a05024O3NotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a05024O3NotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a05024O3MergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a05024O3MergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a05024O3MergedLowest; private Double a01001; @ApiModelProperty(value = "未合并范围均值") private Double a01001TemNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01001TemNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01001TemNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01001TemMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01001TemMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01001TemMergedLowest; private Double a01002; @ApiModelProperty(value = "未合并范围均值") private Double a01002HumNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01002HumNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01002HumNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01002HumMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01002HumMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01002HumMergedLowest; private Double a01006; @ApiModelProperty(value = "未合并范围均值") private Double a01006PreNotMergedAvg; @ApiModelProperty(value = "未合并范围最高值") private Double a01006PreNotMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double a01006PreNotMergedLowest; @ApiModelProperty(value = "合并范围均值") private Double a01006PreMergeAvg; @ApiModelProperty(value = "合并范围最高值") private Double a01006PreMergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double a01006PreMergedLowest; } screen-api/src/main/java/com/moral/api/pojo/dto/uav/UAVResultListDTO.java
New file @@ -0,0 +1,34 @@ package com.moral.api.pojo.dto.uav; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.math.BigDecimal; import java.util.List; /** * @ClassName UAVResultListDTO * @Description TODO * @Author @cjl * @Date 2023-10-31 16:14 * @Version 1.0 */ @Data public class UAVResultListDTO { @ApiModelProperty(value = "无人机数据list") private List<UAVResultDTO> list; @ApiModelProperty(value = "未合并范围均值") private Double notMergedAvg; @ApiModelProperty(value = "合并范围均值") private Double mergeAvg; @ApiModelProperty(value = "未合并范围最高值") private Double notMergedHighest; @ApiModelProperty(value = "未合并范围最低值") private Double notMergedLowest; @ApiModelProperty(value = "合并范围最高值") private Double mergedHighest; @ApiModelProperty(value = "合并范围最低值") private Double mergedLowest; } screen-api/src/main/java/com/moral/api/pojo/enums/SysDictTypeEnum.java
@@ -38,6 +38,10 @@ *WIND */ WIND_FARM_SCOPE("WIND","风场范围"), SYS_DEVICE("DEVICE","设备秒机数据"), ; @EnumValue screen-api/src/main/java/com/moral/api/pojo/vo/allocation/AllocationVo.java
@@ -1,5 +1,6 @@ package com.moral.api.pojo.vo.allocation; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.moral.api.pojo.ext.allocation.AllocationExt; import com.moral.api.pojo.vo.approvetable.ApproveTableListVo; @@ -135,6 +136,9 @@ @ApiModelProperty(value = "流程状态") private List<ApproveTableListVo> approveList; @TableField(exist = false) private String time; public static AllocationVo convert(AllocationExt allocationExt) { AllocationVo allocationVo = BeanConverts.convert(allocationExt, AllocationVo.class); screen-api/src/main/java/com/moral/api/pojo/vo/device/AppDeviceVo.java
New file @@ -0,0 +1,46 @@ package com.moral.api.pojo.vo.device; import lombok.Data; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.fasterxml.jackson.annotation.JsonInclude; import com.moral.api.pojo.enums.InvestigationEnum; @Data @JsonInclude(JsonInclude.Include.NON_EMPTY) public class AppDeviceVo { private Integer id; private String name; private String mac; private String specialType; @TableField(exist = false) private String typeName; public String getTypeName() { String specialType = this.specialType; if (!ObjectUtils.isEmpty(specialType)){ if (specialType.equals("1")){ return InvestigationEnum.UAV.name; }else if (specialType.equals("0")){ return InvestigationEnum.TRAVELING_VEHICLE.name; } } return "站点"; } public String getSpecialType() { String specialType = this.specialType; if (ObjectUtils.isEmpty(specialType)){ return "3"; } return specialType; } } screen-api/src/main/java/com/moral/api/pojo/vo/device/OrganizationVO.java
New file @@ -0,0 +1,14 @@ package com.moral.api.pojo.vo.device; import lombok.Data; import java.io.Serializable; @Data public class OrganizationVO implements Serializable { private Integer id; private String name; } screen-api/src/main/java/com/moral/api/pojo/vo/user/QxUser.java
@@ -31,4 +31,9 @@ * 所属部门责任单位 */ private Integer unitId; /** * 组织id */ private Integer organizationId; } screen-api/src/main/java/com/moral/api/service/AllocationService.java
@@ -134,4 +134,7 @@ void checkSmallRoutine(AllocationCheckCond checkCond); boolean authority(String allocationNum,Integer userId); } screen-api/src/main/java/com/moral/api/service/DeviceService.java
@@ -2,6 +2,7 @@ import com.moral.api.entity.Device; import com.baomidou.mybatisplus.extension.service.IService; import com.moral.api.pojo.vo.device.AppDeviceVo; import java.util.List; import java.util.Map; @@ -51,4 +52,18 @@ */ Device getDeviceUnitAlramInforByMac(String mac); /** * 模糊查询 * @param mac * @return */ List<AppDeviceVo> getFuzzySearch(String mac); /** * 根据站点查询设备 * @param id * @return */ List<Device> getOrganizationDevice(Integer id); } screen-api/src/main/java/com/moral/api/service/HistorySecondUavService.java
@@ -48,4 +48,6 @@ boolean UAVTest(BigDecimal lat, BigDecimal lon, String batch); boolean UAVUpdateTest(String batch); } screen-api/src/main/java/com/moral/api/service/MonitorPointService.java
@@ -54,5 +54,12 @@ List<MonitoringStationDTO> listMonitoringStationDTO(Map<String, Object> params, int reportType, String startTime, String endTime); /** * 根据用户查询站点 * @return */ List<MonitorPoint> getOrganizations(); } screen-api/src/main/java/com/moral/api/service/OrganizationService.java
@@ -33,4 +33,7 @@ */ Organization getOrganizationById(Integer id); } screen-api/src/main/java/com/moral/api/service/SpecialDeviceService.java
@@ -10,6 +10,7 @@ import com.moral.api.entity.SpecialDevice; import com.baomidou.mybatisplus.extension.service.IService; import com.moral.api.pojo.bo.ExcelBO; import com.moral.api.pojo.vo.device.AppDeviceVo; import com.moral.api.pojo.vo.excel.DailyVo; /** @@ -53,7 +54,7 @@ //查询日报 List<ExcelBO> selectDaily(Map<String, Object> params); //查询所有特殊设备 List<AppDeviceVo> selectSpecialDevice(); } screen-api/src/main/java/com/moral/api/service/UAVService.java
@@ -5,9 +5,12 @@ import java.util.Map; import com.moral.api.pojo.dto.uav.UAVResultDTO; import com.moral.api.pojo.dto.uav.UAVResultListDTO; public interface UAVService { List<UAVResultDTO> getUav(Map<String, Object> params); UAVResultListDTO getUavMore(Map<String, Object> params); } screen-api/src/main/java/com/moral/api/service/impl/AllocationServiceImpl.java
@@ -12,6 +12,7 @@ import com.moral.api.mapper.ResponsibilityUnitMapper; import com.moral.api.mapper.SysDictDataMapper; import com.moral.api.mapper.SysDictTypeMapper; import com.moral.api.mapper.UserMapper; import com.moral.api.pojo.bean.BaseInvalidEntity; import com.moral.api.pojo.dto.allocation.AllocationUnitViewDto; import com.moral.api.pojo.enums.*; @@ -748,6 +749,8 @@ integerList.add(AllocationApproveEnum.IN_APPROVAL.value); integerList.add(AllocationApproveEnum.UNDER_RECTIFICATION.value); integerList.add(AllocationApproveEnum.DRAFT.value); }else if(type.equals(2)){ integerList.add(0); } } if(type.equals(3)){ @@ -832,6 +835,33 @@ } @Override public boolean authority(String allocationNum,Integer userId) { //获取用户信息 QxUser user = UserHelper.getCurrentUser(); 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; }else { return true; } } return true; } @Override public List<Integer> unitResult() { QxUser user = UserHelper.getCurrentUser(); Integer unitId = Objects.nonNull(user.getUnitId())?user.getUnitId():0; screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -2,7 +2,9 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.moral.api.config.Interceptor.UserHelper; import com.moral.api.config.mybatis.MybatisPlusConfig; import com.moral.api.entity.*; import com.moral.api.mapper.DeviceMapper; @@ -10,6 +12,8 @@ import com.moral.api.mapper.HistoryHourlyMapper; import com.moral.api.mapper.OrganizationUnitAlarmMapper; import com.moral.api.mapper.UnitConversionMapper; import com.moral.api.pojo.vo.device.AppDeviceVo; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.DeviceService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.moral.api.service.SensorService; @@ -495,6 +499,43 @@ return device; } /** * 模糊查询 * * @param mac * @return */ @Override public List<AppDeviceVo> getFuzzySearch(String mac) { QxUser user = UserHelper.getCurrentUser(); Integer organizationId = user.getOrganizationId(); // Integer organizationId = 24; List<AppDeviceVo> devices; if (organizationId!=24){ devices = deviceMapper.getDevices(mac,organizationId); }else { devices = deviceMapper.getDevices(mac,null); } return devices; } /** * 根据站点查询设备 * * @param id * @return */ @Override public List<Device> getOrganizationDevice(Integer id) { LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(Device::getMonitorPointId,id); wrapper.eq(Device::getIsDelete,Constants.NOT_DELETE); wrapper.orderByAsc(Device::getCreateTime); List<Device> devices = deviceMapper.selectList(wrapper); return devices; } private Device getDeviceUnitAlramInforByMacFromDb(String mac){ QueryWrapper<Device> wrapper = new QueryWrapper<>(); wrapper.eq("mac",mac); screen-api/src/main/java/com/moral/api/service/impl/HistorySecondUavServiceImpl.java
@@ -366,7 +366,7 @@ wrapper.select("value,mac,time,organization_id"); wrapper.orderByAsc("time"); List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); Date time =DateUtils.addDays(datas.get(2).getTime(),0); Date time = new Date(); //String bat = "2023-08-08 14:42:20"; for(HistorySecondUav g : datas){ HistorySecondUav historySecondUav = new HistorySecondUav(); @@ -399,4 +399,44 @@ this.saveBatch(list); return true; } @Override public boolean UAVUpdateTest(String batch) { List<HistorySecondUav> list = new ArrayList<>(); QueryWrapper<HistorySecondUav> wrapper = new QueryWrapper<>(); wrapper.eq("batch", batch); wrapper.select("id,value,mac,time,organization_id"); wrapper.orderByAsc("time"); List<HistorySecondUav> datas = historySecondUavMapper.selectList(wrapper); for(HistorySecondUav g : datas){ HistorySecondUav historySecondUav = new HistorySecondUav(); 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){ // 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); } this.updateBatchById(list); return true; } public static void main(String[] args) { for(int i = 0;i<10;i++){ //选定随机数的生成区间为7~15 //15-7=8 //8+1=9 int number = new Random().nextInt(5)+8; //随机数结果加上最初的首个数字 System.out.println(number); } } } screen-api/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java
@@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.moral.api.config.Interceptor.UserHelper; import com.moral.api.dto.MonitoringStationDTO; import com.moral.api.entity.*; import com.moral.api.mapper.DeviceMapper; @@ -10,6 +11,7 @@ import com.moral.api.mapper.MonitorPointMapper; import com.moral.api.mapper.SensorMapper; import com.moral.api.pojo.form.device.MonitorPointQueryForm; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.DeviceService; import com.moral.api.service.HistoryDailyService; import com.moral.api.service.HistoryHourlyService; @@ -24,6 +26,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import springfox.documentation.schema.Entry; import java.math.BigDecimal; @@ -518,6 +521,33 @@ return resultList; } /** * 根据用户查询站点 * * @return */ @Override public List<MonitorPoint> getOrganizations() { QueryWrapper<MonitorPoint> wrapper = new QueryWrapper<>(); wrapper.select("id","name"); QxUser user = UserHelper.getCurrentUser(); Integer organizationId = user.getOrganizationId(); List<Integer> monitorPointiIds = monitorPointMapper.getMonitorPointiId(organizationId); if (organizationId!=24){ wrapper.in("id",monitorPointiIds); } wrapper.eq("is_delete",Constants.NOT_DELETE); List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(wrapper); for (int i = 0; i < monitorPoints.size(); i++) { List<Device> organizationDevice = deviceService.getOrganizationDevice(monitorPoints.get(i).getId()); if (ObjectUtils.isEmpty(organizationDevice)){ monitorPoints.remove(i); i--; } } return monitorPoints; } private List<MonitoringStationDTO> resultList(List<HistoryDaily> historyDailyByMacAndTimeSlot){ List<MonitoringStationDTO> list = new ArrayList<>(); screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
@@ -1,8 +1,14 @@ package com.moral.api.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.moral.api.config.Interceptor.UserHelper; import com.moral.api.entity.MonitorPoint; import com.moral.api.entity.Organization; import com.moral.api.mapper.MonitorPointMapper; import com.moral.api.mapper.OrganizationMapper; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.DeviceService; import com.moral.api.service.MonitorPointService; import com.moral.api.service.OrganizationService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.moral.constant.Constants; @@ -28,6 +34,7 @@ OrganizationMapper organizationMapper; @Override public List<Organization> getChildrenOrganizationsById(Integer id) { List<Organization> childrenOrganization = new ArrayList<>(); @@ -41,6 +48,7 @@ } /** * @Description: 通过父组织查询下面所有的子组织放到children中 * @Param: [parentId, children] screen-api/src/main/java/com/moral/api/service/impl/SpecialDeviceServiceImpl.java
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.moral.api.config.Interceptor.UserHelper; import com.moral.api.entity.*; import com.moral.api.mapper.DailyMapper; import com.moral.api.mapper.HistorySecondCruiserMapper; @@ -14,7 +15,9 @@ import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultCountDTO; import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; import com.moral.api.pojo.enums.SysDictTypeEnum; import com.moral.api.pojo.vo.device.AppDeviceVo; import com.moral.api.pojo.vo.excel.DailyVo; import com.moral.api.pojo.vo.user.QxUser; import com.moral.api.service.OrganizationService; import com.moral.api.service.SpecialDeviceHistoryService; import com.moral.api.service.SpecialDeviceService; @@ -507,6 +510,20 @@ return excelBOS; } @Override public List<AppDeviceVo> selectSpecialDevice() { QxUser user = UserHelper.getCurrentUser(); Integer organizationId = user.getOrganizationId(); // Integer organizationId=71; List<AppDeviceVo> appDeviceVos; if (organizationId!=24){ appDeviceVos = specialDeviceMapper.selectSpecialDevice(organizationId); }else { appDeviceVos = specialDeviceMapper.selectSpecialDevice(null); } return appDeviceVos; } //计算平均值和最大值 private HashMap<String, Object> getStringObjectHashMap(List<Map<String, Object>> maps) { HashMap<String, Object> rsMap = new HashMap<>(); screen-api/src/main/java/com/moral/api/service/impl/UAVServiceImpl.java
@@ -1,8 +1,11 @@ package com.moral.api.service.impl; import com.moral.api.pojo.dto.uav.UAVResultListDTO; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; @@ -30,6 +33,76 @@ @Autowired private HistorySecondUavMapper historySecondUavMapper; @Override public UAVResultListDTO getUavMore(Map<String, Object> params) { UAVResultListDTO uavResultListDTO = new UAVResultListDTO(); String uvasize = params.get("uvasize").toString(); int size = Integer.parseInt(uvasize); //纬度 ArrayList<Double> flyLatList = new ArrayList<>(); //经度 ArrayList<Double> flyLonList = new ArrayList<>(); String type = params.get("type").toString(); params.put("type","$."+type); List<UAVGetBD> historySecondUavs = historySecondUavMapper.reListDetail(params); if (ObjectUtils.isEmpty(historySecondUavs)){ return null; } ArrayList<UAVGetBD> rsBDList = new ArrayList<>(); for (UAVGetBD historySecondUav : historySecondUavs) { UAVGetBD uavGetBD = new UAVGetBD(); //WGS84 转 百度坐标 double[] doubles = transformWGS84ToBD09(historySecondUav.getFlyLon(), historySecondUav.getFlyLat()); uavGetBD.setFlyLon(doubles[0]); uavGetBD.setFlyLat(doubles[1]); uavGetBD.setNum(historySecondUav.getNum()); rsBDList.add(uavGetBD); flyLatList.add(doubles[1]); flyLonList.add(doubles[0]); } //获取最大最小的经纬度 Double maxLat = Collections.max(flyLatList); Double maxLon = Collections.max(flyLonList); Double minLat = Collections.min(flyLatList); Double minLon = Collections.min(flyLonList); double distance1 = getDistance(maxLon, minLat, maxLon, maxLat); //计算经度的距离 double distance2 = getDistance(maxLon, minLat, minLon, minLat); ArrayList<UAVGteForDTO> list = new ArrayList<>(); String[] youshang = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, size); //右下2 String[] youxia = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(youshang[0]), Double.parseDouble(youshang[1]), size); //左下2 String[] zuoxia = calLocationByDistanceAndLocationAndDirection(180, minLon, maxLat, size); for (int i = 0; i <distance2 ; i+=size) { UAVGteForDTO dto1 = new UAVGteForDTO(); String[] strings2 = calLocationByDistanceAndLocationAndDirection(90, minLon, maxLat, i); String[] strings3 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youshang[0].toString()), Double.parseDouble(youshang[1].toString()), i); String[] strings4 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(youxia[0].toString()), Double.parseDouble(youxia[1].toString()), i); String[] strings5 = calLocationByDistanceAndLocationAndDirection(90, Double.parseDouble(zuoxia[0].toString()), Double.parseDouble(zuoxia[1].toString()), i); dto1.setLeftTop(strings2); dto1.setRightTop(strings3); dto1.setRightBottom(strings4); dto1.setLeftBottom(strings5); list.add(dto1); for (int j = 0; j < distance1; j+=size) { UAVGteForDTO dto2 = new UAVGteForDTO(); String[] strings6 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings2[0].toString()), Double.parseDouble(strings2[1].toString()), j); String[] strings7 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings3[0].toString()), Double.parseDouble(strings3[1].toString()), j); String[] strings8 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings4[0].toString()), Double.parseDouble(strings4[1].toString()), j); String[] strings9 = calLocationByDistanceAndLocationAndDirection(180, Double.parseDouble(strings5[0].toString()), Double.parseDouble(strings5[1].toString()), j); dto2.setLeftTop(strings6); dto2.setRightTop(strings7); dto2.setRightBottom(strings8); dto2.setLeftBottom(strings9); if (j!=0){ list.add(dto2); } } } return null; } @Override public List<UAVResultDTO> getUav(Map<String, Object> params) { @@ -169,6 +242,26 @@ rsMap.put(result,list1); } ArrayList<Double> TVOCArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> PM10ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> PM25ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> SOArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> NOArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> QYArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> COArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> WDArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> SHArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> O3ArrayListNotMergedSum = new ArrayList<>(); ArrayList<Double> TVOCArrayListMergedSum = new ArrayList<>(); ArrayList<Double> PM10ArrayListMergedSum = new ArrayList<>(); ArrayList<Double> PM25ArrayListMergedSum = new ArrayList<>(); ArrayList<Double> SOArrayListMergedSum = new ArrayList<>(); ArrayList<Double> NOArrayListMergedSum = new ArrayList<>(); ArrayList<Double> QYArrayListMergedSum = new ArrayList<>(); ArrayList<Double> COArrayListMergedSum = new ArrayList<>(); ArrayList<Double> WDArrayListMergedSum = new ArrayList<>(); ArrayList<Double> SHArrayListMergedSum = new ArrayList<>(); ArrayList<Double> O3ArrayListMergedSum = new ArrayList<>(); //计算区域类所有因子的平均数 ArrayList<UAVResultDTO> uavResultDTOS = new ArrayList<>(); Set<String> strings = rsMap.keySet(); @@ -194,53 +287,63 @@ Object a99054 = jsonObject.get("a99054"); if (!Objects.isNull(a99054)){ TVOCArrayList.add(Double.parseDouble(a99054.toString())); TVOCArrayListNotMergedSum.add(Double.parseDouble(a99054.toString())); } //pm2.5 Object a34004 = jsonObject.get("a34004"); if (!Objects.isNull(a34004)){ PM25ArrayList.add(Double.parseDouble(a34004.toString())); PM25ArrayListNotMergedSum.add(Double.parseDouble(a34004.toString())); } //二氧化硫 Object a21026 = jsonObject.get("a21026"); if (!Objects.isNull(a21026)){ SOArrayList.add(Double.parseDouble(a21026.toString())); SOArrayListNotMergedSum.add(Double.parseDouble(a21026.toString())); } //二氧化氮 Object a21004 = jsonObject.get("a21004"); if (!Objects.isNull(a21004)){ NOArrayList.add(Double.parseDouble(a21004.toString())); NOArrayListNotMergedSum.add(Double.parseDouble(a21004.toString())); } //气压 Object a01006 = jsonObject.get("a01006"); if (!Objects.isNull(a01006)){ QYArrayList.add(Double.parseDouble(a01006.toString())); QYArrayListNotMergedSum.add(Double.parseDouble(a01006.toString())); } //pm10 Object a34002 = jsonObject.get("a34002"); if (!Objects.isNull(a34002)){ PM10ArrayList.add(Double.parseDouble(a34002.toString())); PM10ArrayListNotMergedSum.add(Double.parseDouble(a34002.toString())); } //co Object a21005 = jsonObject.get("a21005"); if (!Objects.isNull(a21005)){ COArrayList.add(Double.parseDouble(a21005.toString())); COArrayListNotMergedSum.add(Double.parseDouble(a21005.toString())); } //湿度 Object a01002 = jsonObject.get("a01002"); if (!Objects.isNull(a01002)){ QYArrayList.add(Double.parseDouble(a01002.toString())); SHArrayList.add(Double.parseDouble(a01002.toString())); SHArrayListNotMergedSum.add(Double.parseDouble(a01002.toString())); } //温度 Object a01001 = jsonObject.get("a01001"); if (!Objects.isNull(a01001)){ QYArrayList.add(Double.parseDouble(a01001.toString())); WDArrayList.add(Double.parseDouble(a01001.toString())); WDArrayListNotMergedSum.add(Double.parseDouble(a01001.toString())); } //臭氧 Object a05024 = jsonObject.get("a05024"); if (!Objects.isNull(a05024)){ O3ArrayList.add(Double.parseDouble(a05024.toString())); O3ArrayListNotMergedSum.add(Double.parseDouble(a05024.toString())); } } @@ -295,14 +398,183 @@ dto.setA01001(WDDouble); dto.setA01002(SHDouble); dto.setA01006(QYDouble); TVOCArrayListMergedSum.add(TVODouble); COArrayListMergedSum.add(CODouble); NOArrayListMergedSum.add(NODouble); O3ArrayListMergedSum.add(O3Double); PM10ArrayListMergedSum.add(PM10Double); PM25ArrayListMergedSum.add(PM25Double); SOArrayListMergedSum.add(SODouble); WDArrayListMergedSum.add(WDDouble); SHArrayListMergedSum.add(SHDouble); QYArrayListMergedSum.add(QYDouble); String[] s = string.split("_"); dto.setFlyLat(Double.parseDouble(s[1])); dto.setFlyLon(Double.parseDouble(s[0])); uavResultDTOS.add(dto); } Double a21005CONotMergedAvg = resultDoubled(COArrayListNotMergedSum,1); Double a2100CO5NotMergedHighest= resultDoubled(COArrayListNotMergedSum,2); Double a2100CO5NotMergedLowest= resultDoubled(COArrayListNotMergedSum,3); Double a21005COMergeAvg = resultDoubled(COArrayListMergedSum,1); Double a21005COMergedHighest = resultDoubled(COArrayListMergedSum,2); Double a21005COMergedLowest = resultDoubled(COArrayListMergedSum,3); Double a21026SO2NotMergedAvg = resultDoubled(SOArrayListNotMergedSum,1); Double a21026SO2NotMergedHighest= resultDoubled(SOArrayListNotMergedSum,2); Double a21026SO2NotMergedLowest= resultDoubled(SOArrayListNotMergedSum,3); Double a21026SO2MergeAvg = resultDoubled(SOArrayListMergedSum,1); Double a21026SO2MergedHighest = resultDoubled(SOArrayListMergedSum,2); Double a21026SO2MergedLowest = resultDoubled(SOArrayListMergedSum,3); Double a21004NO2NotMergedAvg = resultDoubled(NOArrayListNotMergedSum,1); Double a21004NO2NotMergedHighest= resultDoubled(NOArrayListNotMergedSum,2); Double a21004NO2NotMergedLowest= resultDoubled(NOArrayListNotMergedSum,3); Double a21004NO2MergeAvg = resultDoubled(NOArrayListMergedSum,1); Double a21004NO2MergedHighest = resultDoubled(NOArrayListMergedSum,2); Double a21004NO2MergedLowest = resultDoubled(NOArrayListMergedSum,3); Double a34002PM10NotMergedAvg = resultDoubled(PM10ArrayListNotMergedSum,1); Double a34002PM10NotMergedHighest= resultDoubled(PM10ArrayListNotMergedSum,2); Double a34002PM10NotMergedLowest= resultDoubled(PM10ArrayListNotMergedSum,3); Double a34002PM10MergeAvg = resultDoubled(PM10ArrayListMergedSum,1); Double a34002PM10MergedHighest = resultDoubled(PM10ArrayListMergedSum,2); Double a34002PM10MergedLowest = resultDoubled(PM10ArrayListMergedSum,3); Double a34004PM25NotMergedAvg = resultDoubled(PM25ArrayListNotMergedSum,1); Double a34004PM25NotMergedHighest= resultDoubled(PM25ArrayListNotMergedSum,2); Double a34004PM25NotMergedLowest= resultDoubled(PM25ArrayListNotMergedSum,3); Double a34004PM25MergeAvg = resultDoubled(PM25ArrayListMergedSum,1); Double a34004PM25MergedHighest = resultDoubled(PM25ArrayListMergedSum,2); Double a34004PM25MergedLowest = resultDoubled(PM25ArrayListMergedSum,3); Double a99054TVOCNotMergedAvg = resultDoubled(TVOCArrayListNotMergedSum,1); Double a99054TVOCNotMergedHighest= resultDoubled(TVOCArrayListNotMergedSum,2); Double a99054TVOCNotMergedLowest= resultDoubled(TVOCArrayListNotMergedSum,3); Double a99054TVOCMergeAvg = resultDoubled(TVOCArrayListMergedSum,1); Double a99054TVOCMergedHighest = resultDoubled(TVOCArrayListMergedSum,2); Double a99054TVOCMergedLowest = resultDoubled(TVOCArrayListMergedSum,3); Double a05024O3NotMergedAvg = resultDoubled(O3ArrayListNotMergedSum,1); Double a05024O3NotMergedHighest= resultDoubled(O3ArrayListNotMergedSum,2); Double a05024O3NotMergedLowest= resultDoubled(O3ArrayListNotMergedSum,3); Double a05024O3MergeAvg = resultDoubled(O3ArrayListMergedSum,1); Double a05024O3MergedHighest = resultDoubled(O3ArrayListMergedSum,2); Double a05024O3MergedLowest = resultDoubled(O3ArrayListMergedSum,2); Double a01001TemNotMergedAvg = resultDoubled(WDArrayListNotMergedSum,1); Double a01001TemNotMergedHighest= resultDoubled(WDArrayListNotMergedSum,2); Double a01001TemNotMergedLowest= resultDoubled(WDArrayListNotMergedSum,3); Double a01001TemMergeAvg = resultDoubled(WDArrayListMergedSum,1); Double a01001TemMergedHighest = resultDoubled(WDArrayListMergedSum,2); Double a01001TemMergedLowest = resultDoubled(WDArrayListMergedSum,2); Double a01002HumNotMergedAvg = resultDoubled(SHArrayListNotMergedSum,1); Double a01002HumNotMergedHighest= resultDoubled(SHArrayListNotMergedSum,2); Double a01002HumNotMergedLowest= resultDoubled(SHArrayListNotMergedSum,3); Double a010022HumMergeAvg = resultDoubled(SHArrayListMergedSum,1); Double a01002HumMergedHighest = resultDoubled(SHArrayListMergedSum,2); Double a01002HumMergedLowest = resultDoubled(SHArrayListMergedSum,2); Double a01006PreNotMergedAvg = resultDoubled(QYArrayListNotMergedSum,1); Double a01006PreNotMergedHighest= resultDoubled(QYArrayListNotMergedSum,2); Double a01006PreNotMergedLowest= resultDoubled(QYArrayListNotMergedSum,3); Double a01006PreMergeAvg = resultDoubled(QYArrayListMergedSum,1); Double a01006PreMergedHighest = resultDoubled(QYArrayListMergedSum,2); Double a01006PreMergedLowest = resultDoubled(QYArrayListMergedSum,2); uavResultDTOS.forEach(it->{ it.setA21005CONotMergedAvg(a21005CONotMergedAvg); it.setA21005CONotMergedHighest(a2100CO5NotMergedHighest); it.setA21005CONotMergedLowest(a2100CO5NotMergedLowest); it.setA21005COMergeAvg(a21005COMergeAvg); it.setA21005COMergedHighest(a21005COMergedHighest); it.setA21005COMergedLowest(a21005COMergedLowest); it.setA21026SO2NotMergedAvg(a21026SO2NotMergedAvg); it.setA21026SO2NotMergedHighest(a21026SO2NotMergedHighest); it.setA21026SO2NotMergedLowest(a21026SO2NotMergedLowest); it.setA21026SO2MergeAvg(a21026SO2MergeAvg); it.setA21026SO2MergedHighest(a21026SO2MergedHighest); it.setA21026SO2MergedLowest(a21026SO2MergedLowest); it.setA21004NO2NotMergedAvg(a21004NO2NotMergedAvg); it.setA21004NO2NotMergedHighest(a21004NO2NotMergedHighest); it.setA21004NO2NotMergedLowest(a21004NO2NotMergedLowest); it.setA21004NO2MergeAvg(a21004NO2MergeAvg); it.setA21004NO2MergedHighest(a21004NO2MergedHighest); it.setA21004NO2MergedLowest(a21004NO2MergedLowest); it.setA34002PM10NotMergedAvg(a34002PM10NotMergedAvg); it.setA34002PM10NotMergedHighest(a34002PM10NotMergedHighest); it.setA34002PM10NotMergedLowest(a34002PM10NotMergedLowest); it.setA34002PM10MergeAvg(a34002PM10MergeAvg); it.setA34002PM10MergedHighest(a34002PM10MergedHighest); it.setA34002PM10MergedLowest(a34002PM10MergedLowest); it.setA34004PM25NotMergedAvg(a34004PM25NotMergedAvg); it.setA34004PM25NotMergedHighest(a34004PM25NotMergedHighest); it.setA34004PM25NotMergedLowest(a34004PM25NotMergedLowest); it.setA34004PM25MergeAvg(a34004PM25MergeAvg); it.setA34004PM25MergedHighest(a34004PM25MergedHighest); it.setA34004PM25MergedLowest(a34004PM25MergedLowest); it.setA99054TVOCNotMergedAvg(a99054TVOCNotMergedAvg); it.setA99054TVOCNotMergedHighest(a99054TVOCNotMergedHighest); it.setA99054TVOCNotMergedLowest(a99054TVOCNotMergedLowest); it.setA99054TVOCMergeAvg(a99054TVOCMergeAvg); it.setA99054TVOCMergedHighest(a99054TVOCMergedHighest); it.setA99054TVOCMergedLowest(a99054TVOCMergedLowest); it.setA05024O3NotMergedAvg(a05024O3NotMergedAvg); it.setA05024O3NotMergedHighest(a05024O3NotMergedHighest); it.setA05024O3NotMergedLowest(a05024O3NotMergedLowest); it.setA05024O3MergeAvg(a05024O3MergeAvg); it.setA05024O3MergedHighest(a05024O3MergedHighest); it.setA05024O3MergedLowest(a05024O3MergedLowest); it.setA01001TemNotMergedAvg(a01001TemNotMergedAvg); it.setA01001TemNotMergedHighest(a01001TemNotMergedHighest); it.setA01001TemNotMergedLowest(a01001TemNotMergedLowest); it.setA01001TemMergeAvg(a01001TemMergeAvg); it.setA01001TemMergedHighest(a01001TemMergedHighest); it.setA01001TemMergedLowest(a01001TemMergedLowest); it.setA01002HumNotMergedAvg(a01002HumNotMergedAvg); it.setA01002HumNotMergedHighest(a01002HumNotMergedHighest); it.setA01002HumNotMergedLowest(a01002HumNotMergedLowest); it.setA01002HumMergeAvg(a010022HumMergeAvg); it.setA01002HumMergedHighest(a01002HumMergedHighest); it.setA01002HumMergedLowest(a01002HumMergedLowest); it.setA01006PreNotMergedAvg(a01006PreNotMergedAvg); it.setA01006PreNotMergedHighest(a01006PreNotMergedHighest); it.setA01006PreNotMergedLowest(a01006PreNotMergedLowest); it.setA01006PreMergeAvg(a01006PreMergeAvg); it.setA01006PreMergedHighest(a01006PreMergedHighest); it.setA01006PreMergedLowest(a01006PreMergedLowest); }); return uavResultDTOS; } private Double resultDoubled(List<Double> doubles,int type){ if(CollectionUtils.isEmpty(doubles)){ return 0d; } double one = 0d; if(type == 1){ one = doubles.stream().mapToDouble(Double::doubleValue).average().getAsDouble(); }else if(type == 2){ one = doubles.stream().mapToDouble(Double::doubleValue).max().getAsDouble(); }else if(type == 3){ one = doubles.stream().mapToDouble(Double::doubleValue).min().getAsDouble(); } BigDecimal two = new BigDecimal(one); return two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); } private static final double EARTH_RADIUS = 6378137; screen-api/src/main/java/com/moral/api/service/impl/UserServiceImpl.java
@@ -12,6 +12,8 @@ import com.moral.api.mapper.*; import com.moral.api.pojo.bo.UserBO; 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.service.FileTableService; import com.moral.api.service.UserService; @@ -100,6 +102,7 @@ return result; } ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(userBo.getUnitId()); List<Integer> list = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_DEVICE.value, userBo.getId()); //封装用户信息 Map<String, Object> userInfo = new LinkedHashMap<>(); userInfo.put("userId", userBo.getId()); @@ -112,6 +115,7 @@ userInfo.put("wechat", userBo.getWechat()); userInfo.put("expireTime", DateUtils.dateToDateString(userBo.getExpireTime())); userInfo.put("isAdmin", userBo.getIsAdmin()); userInfo.put("organizationId",userBo.getOrganizationId()); userInfo.put("openid", openId); try { @@ -124,7 +128,8 @@ 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.getAreaName())?responsibilityUnit.getAreaName():"未选择责任单位"); 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()); @@ -151,7 +156,7 @@ // 3.接收微信接口服务 获取返回的参数 String openid = SessionKeyOpenId.getString("openid"); String sessionKey = SessionKeyOpenId.getString("session_key"); // String sessionKey = SessionKeyOpenId.getString("session_key"); // 4.校验签名 小程序发送的签名signature与服务器端生成的签名signature2 = sha1(rawData + sessionKey) // String signature2 = DigestUtils.sha1Hex(rawData + sessionKey); @@ -182,10 +187,12 @@ 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()); try { //生成token,并存入redis String token = TokenUtils.getTokenApp(new StringBuffer("00").append(user.getId().toString()).toString(),userInfo); @@ -196,7 +203,9 @@ result.put("file", CollectionUtils.isNotEmpty(listFile)?listFile.get(0):new FileVo()); result.put("userId", user.getId()); result.put("account", user.getAccount()); result.put("unName",Objects.nonNull(responsibilityUnit)&&Objects.nonNull(responsibilityUnit.getAreaName())?responsibilityUnit.getAreaName():"未选择责任单位"); 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()); screen-api/src/main/java/com/moral/api/utils/HttpClientUtil.java
@@ -12,13 +12,19 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class HttpClientUtil { @@ -133,4 +139,19 @@ 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
@@ -25,8 +25,8 @@ public class WechatUtils { public static final String APPID = "wx41f4c3c007545088"; public static final String SECRET = "9e1a328ad525dd169252a1cc5067a6f3"; public static final String APPID = "wxf95fb77e0b1f8c09"; public static final String SECRET = "acf3be9facf7f26bb8286c9b4eff93d0"; public static JSONObject getSessionKeyOrOpenId(String code) { screen-api/src/main/java/com/moral/api/vo/WxMssVo.java
New file @@ -0,0 +1,13 @@ package com.moral.api.vo; import lombok.Data; import java.util.Map; @Data public class WxMssVo { private String touser;//用户openid private String template_id;//订阅消息模版id private String page = "pages/index/index";//默认跳到小程序首页 private Map<String, String> data;//推送文字 } screen-api/src/main/resources/mapper/AllocationMapper.xml
@@ -95,7 +95,7 @@ and allocation.allocation_num LIKE CONCAT('%',#{allocation.allocationNum},'%') </if> <if test="allocation.unitList != null and allocation.unitList.size !=0"> and allocation.state in and allocation.unit_id in <foreach collection="allocation.unitList" item="id" index="index" open="(" close=")" separator=","> #{id} </foreach> screen-api/src/main/resources/mapper/DeviceMapper.xml
@@ -192,4 +192,20 @@ select mac from device where organization_id = #{organizationId} order by id desc </select> <select id="getDevices" resultType="com.moral.api.pojo.vo.device.AppDeviceVo"> SELECT d.id,d.`name`,d.mac,d.special_type FROM device as d where 1=1 <if test="organizationId !=null"> AND organization_id = #{organizationId} </if> and mac 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 <if test="organizationId !=null"> AND organization_id = #{organizationId} </if> and mac LIKE "%"#{mac}"%" AND is_delete = 0 </select> </mapper> screen-api/src/main/resources/mapper/HistorySecondUavMapper.xml
@@ -18,4 +18,12 @@ HAVING abs(`value`->>'$.flyhig') <![CDATA[>=]]> #{height1} and abs(`value`->>'$.flyhig') <![CDATA[<=]]> #{height2} </select> <select id="reListDetail" resultType="com.moral.api.pojo.dto.uav.UAVGetBD"> SELECT history_second_uav.time,value->>#{type} as num,value->>'$.flylon' as flyLon,value->>'$.flylat' as flyLat FROM history_second_uav WHERE mac = #{mac} AND batch = #{batch} HAVING abs(`value`->>'$.flyhig') <![CDATA[>=]]> #{height1} and abs(`value`->>'$.flyhig') <![CDATA[<=]]> #{height2} </select> </mapper> screen-api/src/main/resources/mapper/MonitorPointMapper.xml
@@ -19,4 +19,10 @@ <result column="desc" property="desc" /> </resultMap> <select id="getMonitorPointiId" resultType="java.lang.Integer"> select id from monitor_point where organization_id=#{id} and is_delete=0 </select> </mapper> screen-api/src/main/resources/mapper/SpecialDeviceMapper.xml
@@ -17,4 +17,13 @@ <result column="is_delete" property="isDelete"/> </resultMap> <select id="selectSpecialDevice" resultType="com.moral.api.pojo.vo.device.AppDeviceVo"> SELECT id,`name`,mac,special_type FROM special_device WHERE 1=1 <if test="organization_id !=null"> AND organization_id=#{organizationId} </if> AND is_delete =0 </select> </mapper> screen-job/src/main/java/com/moral/api/controller/PubController.java
@@ -44,6 +44,8 @@ private HistoryAqiService historyAqiService; @Autowired private HistoryHourlyService historyHourlyService; @Autowired private HistoryMonthlyService historyMonthlyService; @GetMapping("insertHistoryDaily") @ApiOperation(value = "天数据补录", notes = "天数据补录") @@ -106,6 +108,13 @@ return new ResultMessage(); } @GetMapping("insertHistoryMonthly") @ApiOperation(value = "月数据", notes = "月数据") public ResultMessage insertHistoryMonthly() { historyMonthlyService.insertHistoryMonthly(); return new ResultMessage(); } public static void main(String[] args) { String host = "https://pair.market.alicloudapi.com"; screen-job/src/main/resources/application-dev.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/service/impl/DeviceAdjustValueServiceImpl.java
@@ -330,6 +330,7 @@ QueryWrapper<DeviceAdjustValue> wrapper1 = new QueryWrapper<>(); wrapper1.eq("mac",adjustForm.getMac()); wrapper1.eq ("sensor_code",adjustForm.getCode()); wrapper1.eq("is_delete",0); Integer integer = deviceAdjustValueMapper.selectCount(wrapper1); if (integer==0){ deviceAdjustValue.setValue(adjustForm.getAgehou()); screen-manage/src/main/resources/application-dev.yml
@@ -127,6 +127,6 @@ foh3wi2ooghiCh5 result: device: list: p5dnd7a0245499,p5dnd7a0391962 list: p5dnd7a0245499,p5dnd7a0391962,HJS00002156B89 screen-manage/src/main/resources/mapper/DeviceAdjustValueMapper.xml
@@ -52,6 +52,7 @@ WHERE de.monitor_point_id = #{id} AND de.is_delete = 0 order by de.dev_num,de.id </select> </mapper>