Merge remote-tracking branch 'origin/dev' into cjl
9 files added
22 files modified
| | |
| | | import cn.hutool.poi.word.WordUtil; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.data.PictureRenderData; |
| | | 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.service.SpecialDeviceService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.DateUtils; |
| | | import com.moral.util.WebUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.apache.poi.xwpf.usermodel.XWPFDocument; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | 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; |
| | |
| | | return ObjectUtils.isEmpty(daily) ? ResultMessage.ok() : ResultMessage.ok(daily); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 下载走航车日报 |
| | | * @param id |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @GetMapping("loadDaily") |
| | | public ResultMessage loadDaily(Integer id){ |
| | | |
| | | DailyVo dailyVo = specialDeviceService.loadDaily(id); |
| | | if (dailyVo==null){ |
| | | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); |
| | | @PostMapping("loadDaily") |
| | | public void loadDaily( @RequestBody Map<String,Object> params,HttpServletResponse response) throws IOException { |
| | | List<Integer> ids = (List<Integer>) params.get("ids"); |
| | | List<DailyVo> dailyVos = specialDeviceService.loadDaily(ids); |
| | | if (ObjectUtils.isEmpty(dailyVos)){ |
| | | throw new BusinessException("未找到走航信息"); |
| | | } |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),dailyVo); |
| | | dailyDocx(dailyVos,response); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public void dailyDocx( List<DailyVo> dailyVos,HttpServletResponse response) throws IOException { |
| | | // String path = getPath(fileName); |
| | | //获取jar包所在目录 |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | | //在jar包所在目录下生成一个upload文件夹用来存储上传的图片 |
| | | String path = applicationHome.getSource().getParentFile().toString() + "\\static\\img"; |
| | | 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", "平均尘负荷(克/平方米)")); |
| | | |
| | | //设置表内容,如果在实际应用中,传入一个list集合或者数组,方可用foreach进行循环填充 |
| | | List<Map> detailList1 = new ArrayList<>(); |
| | | List<Map> detailList2 = new ArrayList<>(); |
| | | List<Map> detailList3 = new ArrayList<>(); |
| | | List<Map> detailList4 = new ArrayList<>(); |
| | | List<Map> detailList5 = new ArrayList<>(); |
| | | List<Map> detailList6 = new ArrayList<>(); |
| | | List<Map> detailList7 = new ArrayList<>(); |
| | | List<Map> detailList8 = new ArrayList<>(); |
| | | StringBuilder builder = new StringBuilder(); |
| | | List<Map> pic1 = new ArrayList<>(); |
| | | List<Map> pic2 = new ArrayList<>(); |
| | | List<Map> pic3 = new ArrayList<>(); |
| | | List<Map> pic4 = new ArrayList<>(); |
| | | List<Map> pic5 = new ArrayList<>(); |
| | | List<Map> pic6 = new ArrayList<>(); |
| | | List<Map> pic7 = new ArrayList<>(); |
| | | List<Map> pic8 = new ArrayList<>(); |
| | | |
| | | // picMap.put("urlImg", Pictures.ofUrl(str, PictureType.JPEG).size(width, height).create()); |
| | | // picMap.put("urlImg",new PictureRenderData(500, 500, "G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg")); |
| | | // picMap.put("urlImg1",new PictureRenderData(500, 500, "G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg")); |
| | | // picMap.put("urlImg", Pictures.ofUrl("G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg", PictureType.JPEG).size(500, 500).create()); |
| | | // picMap.put("urlImg1", Pictures.ofUrl("G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg", PictureType.JPEG).size(500, 500).create()); |
| | | int i =1; |
| | | for (DailyVo dailyVo : dailyVos) { |
| | | Map picMap1 = new HashMap(); |
| | | Map picMap2 = new HashMap(); |
| | | Map picMap3 = new HashMap(); |
| | | Map picMap4 = new HashMap(); |
| | | Map picMap5 = new HashMap(); |
| | | Map picMap6 = new HashMap(); |
| | | Map picMap7 = new HashMap(); |
| | | Map picMap8 = new HashMap(); |
| | | List<String> images = dailyVo.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | |
| | | picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(0))); |
| | | // picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | pic1.add(picMap1); |
| | | picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(1))); |
| | | // picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | pic2.add(picMap2); |
| | | picMap3.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(2))); |
| | | pic3.add(picMap3); |
| | | picMap4.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(3))); |
| | | pic4.add(picMap4); |
| | | picMap5.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(4))); |
| | | pic5.add(picMap5); |
| | | picMap6.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(5))); |
| | | pic6.add(picMap6); |
| | | picMap7.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(6))); |
| | | pic7.add(picMap7); |
| | | picMap8.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(7))); |
| | | pic8.add(picMap8); |
| | | i++; |
| | | } |
| | | detailList1.add(dailyVo.getCode()); |
| | | detailList2.add(dailyVo.getCode()); |
| | | detailList3.add(dailyVo.getCode()); |
| | | detailList4.add(dailyVo.getCode()); |
| | | detailList5.add(dailyVo.getCode()); |
| | | detailList6.add(dailyVo.getCode()); |
| | | detailList7.add(dailyVo.getCode()); |
| | | detailList8.add(dailyVo.getCode()); |
| | | builder.append("("+dailyVo.getCode().get("mac")+")白天对市重点区域(宝龙广场、盐城电厂为主)进行走航监测:常规7参数走航过程中PM2.5均值浓度为"+dailyVo.getCode().get("avgPm25")+"ug/m3;PM10均值浓度为"+dailyVo.getCode().get("avgPm10")+"ug/m3;NO2均值浓度为" |
| | | +dailyVo.getCode().get("avgNO2")+"ug/m3;CO均值浓度为"+dailyVo.getCode().get("avgCO")+"mg/m3;SO2均值浓度为"+dailyVo.getCode().get("avgSO2")+"ug/m3;O3均值浓度为"+dailyVo.getCode().get("avgO3")+"ug/m3,VOCs均值浓度"+dailyVo.getCode().get("avgVOC")+"mg/m3。"+"\n"+" "); |
| | | } |
| | | /* for (HashMap<String, Object> list : lists) { |
| | | detailList1.add(list); |
| | | detailList2.add(list); |
| | | detailList3.add(list); |
| | | detailList4.add(list); |
| | | detailList5.add(list); |
| | | detailList6.add(list); |
| | | detailList7.add(list); |
| | | detailList8.add(list); |
| | | builder.append("("+list.get("mac")+")白天对市重点区域(宝龙广场、盐城电厂为主)进行走航监测:常规7参数走航过程中PM2.5均值浓度为"+list.get("avgPm25")+"ug/m3;PM10均值浓度为"+list.get("avgPm10")+"ug/m3;NO2均值浓度为" |
| | | +list.get("avgNO2")+"ug/m3;CO均值浓度为"+list.get("avgCO")+"mg/m3;SO2均值浓度为"+list.get("avgSO2")+"ug/m3;O3均值浓度为"+list.get("avgO3")+"ug/m3,VOCs均值浓度"+list.get("avgVOC")+"mg/m3。"+"\n"+" "); |
| | | }*/ |
| | | /* List<Map> pic = new ArrayList<>(); |
| | | for (MultipartFile multipartFile : files) { |
| | | Map picMap = new HashMap(); |
| | | InputStream inputStream = multipartFile.getInputStream(); |
| | | picMap.put("urlImg", Pictures.ofStream(inputStream, PictureType.JPEG).size(500, 500).create()); |
| | | pic.add(picMap); |
| | | }*/ |
| | | |
| | | |
| | | String name = dailyVos.get(0).getName(); |
| | | String type = dailyVos.get(0).getType(); |
| | | map.put("code",builder); |
| | | map.put("time1",DateUtils.getCurCNDate()); |
| | | map.put("name",name); |
| | | map.put("type",type); |
| | | // map.put("pho",new PictureRenderData(100, 100, "G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg")); |
| | | // map.put("pho1",new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | |
| | | HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); |
| | | Configure config = Configure.newBuilder().bind("detailList1", policy).bind("detailList2", policy).bind("detailList3", policy).bind("detailList4", policy) |
| | | .bind("detailList5", policy).bind("detailList6", policy).bind("detailList7", policy).bind("detailList8", policy).build(); |
| | | XWPFTemplate compile = XWPFTemplate.compile(filePath,config).render(new HashMap<String, Object>(){{ |
| | | put("code",map.get("code")); |
| | | put("time1",map.get("time1")); |
| | | // put("pho", map.get("pho")); |
| | | // put("pho1", map.get("pho1")); |
| | | put("name",map.get("name")); |
| | | put("type",map.get("type")); |
| | | put("detailList1", detailList1); |
| | | put("detailList2", detailList2); |
| | | put("detailList3", detailList3); |
| | | put("detailList4", detailList4); |
| | | put("detailList5", detailList5); |
| | | put("detailList6", detailList6); |
| | | put("detailList7", detailList7); |
| | | put("detailList8", detailList8); |
| | | put("picList1", pic1); |
| | | put("picList2", pic2); |
| | | put("picList3", pic3); |
| | | put("picList4", pic4); |
| | | put("picList5", pic5); |
| | | put("picList6", pic6); |
| | | put("picList7", pic7); |
| | | put("picList8", pic8); |
| | | }}); |
| | | |
| | | |
| | | |
| | | |
| | | response.setContentType("multipart/form-data"); |
| | | // 设置文件名 |
| | | response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" ); |
| | | // response.setHeader("Content-Disposition", "attachment; filename=\"" + name+type+"监测报告" + "\""); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | //保存到本地 |
| | | /* File file1 = new File("G:\\test\\test2.docx"); |
| | | FileOutputStream out = new FileOutputStream(file1); |
| | | compile.write(out);*/ |
| | | //下载到线上 |
| | | OutputStream out = response.getOutputStream(); |
| | | compile.write(out); |
| | | out.flush(); |
| | | out.close(); |
| | | compile.close(); |
| | | } catch (IOException e) { |
| | | log.error ("导出失败,请联系网站管理员!", e); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.validation.Valid; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.dto.OnlineRatePageCond; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.vo.OnlineRateVo; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | @GetMapping("state") |
| | | @PostMapping("state") |
| | | @ApiOperation("当前在线率") |
| | | public ResultMessage state(Integer organizationId){ |
| | | Map<String, Object> start = deviceService.getStart(organizationId); |
| | | public ResultMessage state(@RequestBody Map<String, Object> params){ |
| | | if (!params.containsKey("macs")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<String> macs = (List<String>) params.get("macs"); |
| | | Map<String, Object> start = deviceService.getStart(macs); |
| | | return ResultMessage.ok(start); |
| | | } |
| | | } |
New file |
| | |
| | | package com.moral.api.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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 java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.HandDevice; |
| | | import com.moral.api.pojo.query.handdevice.HandDevicePageCond; |
| | | import com.moral.api.service.HandDeviceService; |
| | | import com.moral.api.utils.EasyExcelUtils; |
| | | import com.moral.api.utils.NoModelWriteData; |
| | | import com.moral.constant.PageResult; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HandDeviceController |
| | | * @date 2024.02.27 10:21 |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Api(tags = {"手持设备"}) |
| | | @RestController |
| | | @RequestMapping("/hand") |
| | | public class HandDeviceController { |
| | | |
| | | @Autowired |
| | | private HandDeviceService handDeviceService; |
| | | |
| | | @PostMapping("/page") |
| | | @ApiOperation("分页") |
| | | public ResultMessage page(@Valid @RequestBody HandDevicePageCond handDevicePageCond){ |
| | | Page<HandDevice> page = handDeviceService.page(handDevicePageCond); |
| | | PageResult<HandDevice> rsList = new PageResult<>(page); |
| | | rsList.setList(page.getRecords()); |
| | | return ResultMessage.ok(rsList); |
| | | } |
| | | |
| | | @GetMapping("/check") |
| | | @ApiOperation("查询手持设备") |
| | | public ResultMessage select(){ |
| | | List<Device> check = handDeviceService.check(); |
| | | return ResultMessage.ok(check); |
| | | } |
| | | |
| | | @GetMapping("/id") |
| | | @ApiOperation("根据mac查询设备") |
| | | public ResultMessage query(String mac){ |
| | | HandDevice handDevice = handDeviceService.query(mac); |
| | | return ResultMessage.ok(handDevice); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @ApiOperation("修改手持设备") |
| | | public ResultMessage update(@RequestBody HandDevice handDevice){ |
| | | HandDevice handDevice1 = handDeviceService.update(handDevice); |
| | | return ResultMessage.ok(handDevice1); |
| | | } |
| | | |
| | | @GetMapping("/details") |
| | | @ApiOperation("详情") |
| | | public ResultMessage details(String mac,String startTime,String endTime,String type){ |
| | | List<Map<String, Object>> details = handDeviceService.details(mac, startTime, endTime,type); |
| | | return ResultMessage.ok(details); |
| | | } |
| | | |
| | | @GetMapping("/unitExel") |
| | | @ApiOperation("导出") |
| | | public void exel(HttpServletResponse response, HttpServletRequest request){ |
| | | Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); |
| | | List<Map<String, Object>> details = handDeviceService.detailsExecl(params); |
| | | if (CollectionUtils.isEmpty(details)) { |
| | | return; |
| | | } |
| | | Map<String, Object> map = details.get(0); |
| | | List<String> list = new ArrayList<>(); |
| | | for (String key : map.keySet()) { |
| | | list.add(key); |
| | | } |
| | | String[] s2 = new String[list.size()]; |
| | | list.toArray(s2); |
| | | NoModelWriteData d = new NoModelWriteData(); |
| | | d.setFileName("数据导出"); |
| | | d.setHeadMap(s2); |
| | | d.setDataStrMap(s2); |
| | | d.setDataList(details); |
| | | try { |
| | | EasyExcelUtils easyExcelUtils = new EasyExcelUtils(); |
| | | easyExcelUtils.noModleWrite(d, response); |
| | | } catch (Exception e) { |
| | | int i = 0; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | List<Organization> organizations = organizationService.getOrganizationId(); |
| | | return ResultMessage.ok(ObjectUtils.isEmpty(organizations)?"0":organizations); |
| | | } |
| | | |
| | | |
| | | @GetMapping("queryDevices") |
| | | @ApiOperation("查询组织信息") |
| | | public ResultMessage queryDevices(){ |
| | | List<Organization> organizations = organizationService.queryDevices(); |
| | | return ResultMessage.ok(organizations); |
| | | } |
| | | } |
| | |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.pojo.query.PageCond; |
| | | |
| | |
| | | public class OnlineRatePageCond implements Serializable { |
| | | |
| | | |
| | | @ApiModelProperty(value = "组织id") |
| | | private Integer organizationId; |
| | | @ApiModelProperty(value = "设备集合") |
| | | private List<String> macs; |
| | | |
| | | // @ApiModelProperty(value = "分页参数") |
| | | // private PageCond page; |
New file |
| | |
| | | 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.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HandDevice |
| | | * @date 2024.02.27 09:46 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class HandDevice extends Model<HandDevice> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * mac号 |
| | | */ |
| | | private String mac; |
| | | |
| | | /** |
| | | * 设备地址 |
| | | */ |
| | | private String address; |
| | | |
| | | /** |
| | | * 经度 |
| | | */ |
| | | private Double longitude; |
| | | |
| | | /** |
| | | * 纬度 |
| | | */ |
| | | private Double latitude; |
| | | |
| | | /** |
| | | * 开始时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date startTime; |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date endTime; |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | private String createName; |
| | | /** |
| | | * 修改人 |
| | | */ |
| | | private String updateName; |
| | | |
| | | /** |
| | | * 是否删除 |
| | | */ |
| | | private String isDelete; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | private Date updateTime; |
| | | |
| | | private String state; |
| | | |
| | | |
| | | } |
| | |
| | | package com.moral.api.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import java.io.Serializable; |
| | | import com.moral.api.pojo.vo.monitorPoint.MonitorPointVos; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | |
| | | */ |
| | | private String isDelete; |
| | | |
| | | |
| | | /** |
| | | * 站点设备 |
| | | */ |
| | | @TableField(exist = false) |
| | | private List<MonitorPointVos> monitorPoint; |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.pojo.dto.dataDisplay.HeatMapDTO; |
| | | import com.moral.api.pojo.vo.device.AppDeviceVo; |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | import com.moral.api.vo.OnlineRateVo; |
| | | |
| | | import io.lettuce.core.dynamic.annotation.Param; |
| | |
| | | Page<OnlineRateVo> getPage(Page page, @Param("organizationId")Integer organizationId); |
| | | |
| | | //设备在线率不分页 |
| | | List<OnlineRateVo> getLists(@Param("organizationId")Integer organizationId,@Param("state")Integer state); |
| | | List<OnlineRateVo> getLists(List<String> macs,@Param("state")Integer state); |
| | | |
| | | List<DeviceVO> getListVo(Integer monitorPointId); |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.mapper; |
| | | |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.moral.api.entity.HandDevice; |
| | | import com.moral.api.pojo.query.handdevice.HandDevicePageCond; |
| | | |
| | | |
| | | public interface HandDeviceMapper extends BaseMapper<HandDevice> { |
| | | |
| | | |
| | | Page<HandDevice> Page(Page page, @Param("mac")String mac, |
| | | @Param("name")String name, |
| | | @Param("startTime")String startTime, |
| | | @Param("endTime")String endTime); |
| | | } |
| | |
| | | |
| | | import com.moral.api.entity.MonitorPoint; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.moral.api.pojo.vo.monitorPoint.MonitorPointVos; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | List<Integer> getMonitorPointiId(Integer id); |
| | | |
| | | List<MonitorPointVos> getMonitorPoint(Integer id); |
| | | } |
| | |
| | | @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") |
| | | private Date date; |
| | | |
| | | private String mac; |
| | | |
| | | private String type; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | SYS_AMEND("AMEND","立行立改修改数据"), |
| | | |
| | | SYS_HAND_DEVICE("HANDDEVICE","手持设备数据"), |
| | | |
| | | ; |
| | | |
| | | @EnumValue |
New file |
| | |
| | | package com.moral.api.pojo.query.handdevice; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | import com.moral.api.pojo.query.PageCond; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HandDevicePageCond |
| | | * @date 2024.02.27 10:40 |
| | | */ |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @ApiModel(value="HandDevice - 分页查询对象", description="HandDevice - 分页查询对象") |
| | | public class HandDevicePageCond implements Serializable { |
| | | |
| | | |
| | | @ApiModelProperty(value = "mac号") |
| | | private String mac; |
| | | |
| | | @ApiModelProperty(value = "分页参数") |
| | | private PageCond page; |
| | | |
| | | @ApiModelProperty(value = "开始时间") |
| | | private String startTime; |
| | | |
| | | @ApiModelProperty(value = "结束时间") |
| | | private String endTime; |
| | | |
| | | @ApiModelProperty(value = "设备名称") |
| | | private String name; |
| | | |
| | | } |
| | |
| | | |
| | | private List<String> images; |
| | | |
| | | |
| | | private String type; |
| | | |
| | | private String name; |
| | | |
| | | } |
New file |
| | |
| | | package com.moral.api.pojo.vo.monitorPoint; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName MonitorPointVos |
| | | * @date 2024.03.07 14:23 |
| | | */ |
| | | @Data |
| | | public class MonitorPointVos { |
| | | |
| | | private Integer id; |
| | | |
| | | private Integer organizationId; |
| | | |
| | | private String name; |
| | | |
| | | private Double longitude; |
| | | |
| | | private Double latitude; |
| | | |
| | | private String state; |
| | | |
| | | private Integer provinceCode; |
| | | |
| | | private Integer cityCode; |
| | | |
| | | private Integer areaCode; |
| | | |
| | | private String address; |
| | | |
| | | private List<DeviceVO> monitorPoint; |
| | | } |
| | |
| | | Map<String,Object> detail(String mac,String startTime,String endTime, String type); |
| | | |
| | | |
| | | |
| | | Map<String,Object> getStart(Integer organizationId); |
| | | /** |
| | | * 设备在线率 |
| | | * @param macs |
| | | * @return |
| | | */ |
| | | Map<String,Object> getStart(List<String> macs); |
| | | |
| | | |
| | | Map<String,Object> detailV1(String mac,String startTime,String endTime, String type); |
New file |
| | |
| | | package com.moral.api.service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import com.moral.api.entity.Device; |
| | | import com.moral.api.entity.HandDevice; |
| | | import com.moral.api.pojo.query.handdevice.HandDevicePageCond; |
| | | |
| | | public interface HandDeviceService extends IService<HandDevice> { |
| | | |
| | | /** |
| | | * 分页 |
| | | * @param handDevicePageCond |
| | | * @return |
| | | */ |
| | | Page<HandDevice> page(HandDevicePageCond handDevicePageCond); |
| | | |
| | | /** |
| | | * 查询手持设备 |
| | | * @return |
| | | */ |
| | | List<Device> check(); |
| | | |
| | | |
| | | /** |
| | | * 修改手持设备 |
| | | * @return |
| | | */ |
| | | HandDevice update(HandDevice handDevice); |
| | | |
| | | /** |
| | | * 根据mac查询 |
| | | * @param mac |
| | | * @return |
| | | */ |
| | | HandDevice query(String mac); |
| | | |
| | | /** |
| | | * 详情 |
| | | * @param mac |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | List<Map<String,Object>> details(String mac,String startTime,String endTime,String type); |
| | | |
| | | /** |
| | | * 导出 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | List<Map<String,Object>> detailsExecl(Map<String, Object> params); |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | QueryFiveDataByMacVO queryFiveDataByMac(String name,String chooseTime,String time); |
| | | |
| | | |
| | | /** |
| | | * @Description: 查询五分钟内某一mac的数据 |
| | | * @Param: [mac, startDate, endDate] |
| | | * @return: java.util.List<com.moral.api.entity.HistoryHourly> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/23 |
| | | */ |
| | | List<HistoryFiveMinutely> queryFiveMinutely(String mac, Date startDate, Date endDate); |
| | | |
| | | } |
| | |
| | | List<Organization> getOrganizationId(); |
| | | |
| | | |
| | | List<Organization> queryDevices(); |
| | | } |
| | |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.moral.api.entity.SpecialDevice; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | |
| | | ExcelBO getDaily(Map<String, Object> params, List<MultipartFile> files) throws ParseException; |
| | | |
| | | //下载走航车日报 |
| | | DailyVo loadDaily(Integer id); |
| | | List<DailyVo> loadDaily(List<Integer> ids); |
| | | |
| | | |
| | | //查询日报 |
| | |
| | | ArrayList<Integer> list = new ArrayList<>(); |
| | | list.add(id); |
| | | ArrayList<HeatMapDTO> rsHeatMap = new ArrayList<>(); |
| | | ArrayList<String> list1 = new ArrayList<>(); |
| | | /* ArrayList<String> list1 = new ArrayList<>(); |
| | | list1.add("腾鳌镇政府"); |
| | | list1.add("西四镇政府"); |
| | | list1.add("孤山镇政府"); |
| | | list1.add("英落镇政府"); |
| | | list1.add("马风镇朱红村"); |
| | | list1.add("马风镇朱红村");*/ |
| | | |
| | | if (form.equals("hour")){ //小时 |
| | | // String[] split = startTime.split("-"); |
| | |
| | | getHeatMap(heatMap,type); |
| | | rsHeatMap.addAll(heatMap); |
| | | } |
| | | for (int i = 0; i <6; i++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | if (i==0){ |
| | | heatMapDTO.setLat(40.590436); |
| | | heatMapDTO.setLng(122.861935); |
| | | heatMapDTO.setMac("1111"); |
| | | heatMapDTO.setName("1111"); |
| | | }else if (i==1){ |
| | | heatMapDTO.setLat(40.636617); |
| | | heatMapDTO.setLng(123.101544); |
| | | heatMapDTO.setMac("2222"); |
| | | heatMapDTO.setName("2222"); |
| | | }else if (i==2){ |
| | | heatMapDTO.setLat(40.890881); |
| | | heatMapDTO.setLng(122.910687); |
| | | heatMapDTO.setMac("3333"); |
| | | heatMapDTO.setName("3333"); |
| | | }else if (i==3){ |
| | | heatMapDTO.setLat(40.682129); |
| | | heatMapDTO.setLng(123.105836); |
| | | heatMapDTO.setMac("4444"); |
| | | heatMapDTO.setName("4444"); |
| | | }else if (i==4){ |
| | | heatMapDTO.setLat(40.890037); |
| | | heatMapDTO.setLng(123.021151); |
| | | heatMapDTO.setMac("5555"); |
| | | heatMapDTO.setName("5555"); |
| | | }else { |
| | | heatMapDTO.setLat(41.051333); |
| | | heatMapDTO.setLng(122.505864); |
| | | heatMapDTO.setMac("6666"); |
| | | heatMapDTO.setName("6666"); |
| | | if (id==71){ |
| | | for (int i = 0; i <6; i++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | if (i==0){ |
| | | heatMapDTO.setLat(40.590436); |
| | | heatMapDTO.setLng(122.861935); |
| | | heatMapDTO.setMac("1111"); |
| | | heatMapDTO.setName("1111"); |
| | | }else if (i==1){ |
| | | heatMapDTO.setLat(40.636617); |
| | | heatMapDTO.setLng(123.101544); |
| | | heatMapDTO.setMac("2222"); |
| | | heatMapDTO.setName("2222"); |
| | | }else if (i==2){ |
| | | heatMapDTO.setLat(40.890881); |
| | | heatMapDTO.setLng(122.910687); |
| | | heatMapDTO.setMac("3333"); |
| | | heatMapDTO.setName("3333"); |
| | | }else if (i==3){ |
| | | heatMapDTO.setLat(40.682129); |
| | | heatMapDTO.setLng(123.105836); |
| | | heatMapDTO.setMac("4444"); |
| | | heatMapDTO.setName("4444"); |
| | | }else if (i==4){ |
| | | heatMapDTO.setLat(40.890037); |
| | | heatMapDTO.setLng(123.021151); |
| | | heatMapDTO.setMac("5555"); |
| | | heatMapDTO.setName("5555"); |
| | | }else { |
| | | heatMapDTO.setLat(41.051333); |
| | | heatMapDTO.setLng(122.505864); |
| | | heatMapDTO.setMac("6666"); |
| | | heatMapDTO.setName("6666"); |
| | | } |
| | | rsHeatMap.add(heatMapDTO); |
| | | } |
| | | rsHeatMap.add(heatMapDTO); |
| | | } |
| | | |
| | | if (id==73){ |
| | | //亭湖区 |
| | | double lat =33.414538; |
| | | double lng =120.066616; |
| | | for (int i = 0; i <11 ; i++) { |
| | | for (int j = 0; j < 20; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat); |
| | | heatMapDTO.setLng(lng); |
| | | heatMapDTO.setName("1"); |
| | | heatMapDTO.setMac(i+"1"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng=lng+0.01; |
| | | if (j==19){ |
| | | lng=120.066616; |
| | | } |
| | | } |
| | | lat =lat-0.01; |
| | | } |
| | | //大丰区 |
| | | double lat1 =33.214555; |
| | | double lng1 =120.416805; |
| | | for (int i = 0; i < 11 ; i++) { |
| | | for (int j = 0; j < 10; j++) { |
| | | HeatMapDTO heatMapDTO = new HeatMapDTO(); |
| | | heatMapDTO.setCount(0.0); |
| | | heatMapDTO.setLat(lat1); |
| | | heatMapDTO.setLng(lng1); |
| | | heatMapDTO.setName("2"); |
| | | heatMapDTO.setMac(i+"2"+j); |
| | | rsHeatMap.add(heatMapDTO); |
| | | lng1=lng1+0.004; |
| | | if (j==9){ |
| | | lng1=120.416805; |
| | | } |
| | | } |
| | | lat1 =lat1-0.0022; |
| | | } |
| | | } |
| | | return distrinList(rsHeatMap); |
| | | } |
| | | |
| | |
| | | Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_mm_ss_EN); |
| | | List<String> tableNames = MybatisPLUSUtils.getTableNamesByWrapper(startDate, endDate, SeparateTableType.MONTH); |
| | | for (String mac:macs) { |
| | | /* for (String mac:macs) { |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("startDate",startDate); |
| | | mapParams.put("endDate",endDate); |
| | |
| | | historyHourlyMap.put("time",timeStr); |
| | | list.add(historyHourlyMap); |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | for (String mac:macs) { |
| | | Map<String, Object> mapParams = new HashMap<>(); |
| | | mapParams.put("startDate",startDate); |
| | | mapParams.put("endDate",endDate); |
| | | mapParams.put("mac",mac); |
| | | List<HistoryFiveMinutely> HistoryFiveMinutelys = FiveMinuteTableQuery(mapParams, tableNames); |
| | | HistoryFiveMinutelys = HistoryFiveMinutelys.stream().distinct().collect(Collectors.toList()); |
| | | List<HistoryFiveMinutely> distinctHistoryHourlies = new ArrayList<>(); |
| | | Map<String, Object> disMap = new HashMap<>(); |
| | | for (HistoryFiveMinutely historyFiveMinutely:HistoryFiveMinutelys) { |
| | | Date time = historyFiveMinutely.getTime(); |
| | | String timeStr = DateUtils.dateToDateString(time,DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | if (!disMap.containsKey(timeStr)){ |
| | | distinctHistoryHourlies.add(historyFiveMinutely); |
| | | disMap.put(timeStr,true); |
| | | } |
| | | } |
| | | for (HistoryFiveMinutely historyFiveMinutely:distinctHistoryHourlies) { |
| | | Map<String,Object> historyHourlyMap = new HashMap<>(); |
| | | historyHourlyMap.put("mac",mac); |
| | | JSONObject value= JSONObject.parseObject(historyFiveMinutely.getValue()); |
| | | Double sensorValue = Objects.nonNull(value)&&Objects.nonNull(value.get(sensorCode))?Double.parseDouble(value.get(sensorCode).toString()):0d; |
| | | historyHourlyMap.put(sensorCode,sensorValue); |
| | | Date time = historyFiveMinutely.getTime(); |
| | | String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | historyHourlyMap.put("time",timeStr); |
| | | list.add(historyHourlyMap); |
| | | } |
| | | } |
| | | Date middleDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | while (DateUtils.compareDateStr(endTime,DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_mm_EN),DateUtils.yyyy_MM_dd_HH_mm_EN)<=0){ |
| | | for (String mac:macs) { |
| | | boolean flag = true; |
| | | for (Map map:list) { |
| | | if (map.get("time").equals(DateUtils.dateToDateString(middleDate, DateUtils.yyyy_MM_dd_HH_mm_EN)) && map.get("mac").toString().equals(mac.toString())){ |
| | | flag = false; |
| | | } |
| | | } |
| | | if (flag){ |
| | | Map<String,Object> historyHourlyMap = new HashMap<>(); |
| | | historyHourlyMap.put("mac",mac); |
| | | historyHourlyMap.put(sensorCode,"0.0"); |
| | | historyHourlyMap.put("time",DateUtils.dateToDateString(middleDate,DateUtils.yyyy_MM_dd_HH_mm_EN)); |
| | | list.add(historyHourlyMap); |
| | | } |
| | | } |
| | | middleDate = DateUtils.getDateOfMin(middleDate,5); |
| | | } |
| | | } |
| | | for (Map map:list) { |
| | |
| | | long hour = (diff / nh)+1; //获取间隔几个小时 |
| | | |
| | | Map<String, List<OnlineRateVo>> collectList=new HashMap<>(); |
| | | List<OnlineRateVo> OnlineRateVoList = deviceMapper.getLists(onlineRatePageCond.getOrganizationId(),onlineRatePageCond.getState()); |
| | | // List<OnlineRateVo> OnlineRateVoList = deviceMapper.getLists(onlineRatePageCond.getOrganizationId(),onlineRatePageCond.getState()); |
| | | List<OnlineRateVo> OnlineRateVoList = deviceMapper.getLists(onlineRatePageCond.getMacs(),onlineRatePageCond.getState()); |
| | | if (!ObjectUtils.isEmpty(OnlineRateVoList)){ |
| | | |
| | | for (OnlineRateVo onlineRateVo : OnlineRateVoList) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,Object> getStart(Integer organizationId) { |
| | | public Map<String,Object> getStart(List<String> macs) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<OnlineRateVo> lists = deviceMapper.getLists(organizationId, null); |
| | | List<OnlineRateVo> lists = deviceMapper.getLists(macs, null); |
| | | if (!ObjectUtils.isEmpty(lists)){ |
| | | Map<String, List<OnlineRateVo>> collect = lists.stream().collect(Collectors.groupingBy(OnlineRateVo::getState)); |
| | | int size1 = lists.size(); |
New file |
| | |
| | | package com.moral.api.service.impl; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.Device; |
| | | import com.moral.api.entity.HandDevice; |
| | | import com.moral.api.entity.HistoryFiveMinutely; |
| | | import com.moral.api.entity.HistoryHourly; |
| | | import com.moral.api.entity.HistoryMinutely; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.HandDeviceMapper; |
| | | import com.moral.api.pojo.query.handdevice.HandDevicePageCond; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.service.DeviceService; |
| | | import com.moral.api.service.HandDeviceService; |
| | | import com.moral.api.service.HistoryFiveMinutelyService; |
| | | import com.moral.api.service.HistoryHourlyService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Description //todo |
| | | * |
| | | * @author swb |
| | | * @ClassName HandDeviceServiceImpl |
| | | * @date 2024.02.27 10:25 |
| | | */ |
| | | @Service |
| | | public class HandDeviceServiceImpl extends ServiceImpl<HandDeviceMapper, HandDevice> implements HandDeviceService { |
| | | |
| | | |
| | | @Autowired |
| | | private HandDeviceMapper handDeviceMapper; |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceMapper deviceMapper; |
| | | @Autowired |
| | | private HistoryHourlyService historyHourlyService; |
| | | |
| | | |
| | | @Autowired |
| | | private HistoryFiveMinutelyService historyFiveMinutelyService; |
| | | |
| | | /** |
| | | * 分页 |
| | | * |
| | | * @param handDevicePageCond |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Page<HandDevice> page(HandDevicePageCond handDevicePageCond) { |
| | | |
| | | Page<HandDevice> page = handDeviceMapper.Page(handDevicePageCond.getPage().convertPage(), |
| | | handDevicePageCond.getMac(), |
| | | handDevicePageCond.getName(), |
| | | handDevicePageCond.getStartTime(), |
| | | handDevicePageCond.getEndTime()); |
| | | return page; |
| | | } |
| | | |
| | | /** |
| | | * 查询手持设备 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Device> check() { |
| | | LambdaQueryWrapper<Device> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Device::getMac,Device::getName,Device::getId); |
| | | wrapper.eq(Device::getMonitorPointId,123); |
| | | wrapper.eq(Device::getIsDelete,Constants.NOT_DELETE); |
| | | wrapper.orderByAsc(Device::getCreateTime); |
| | | List<Device> devices = deviceMapper.selectList(wrapper); |
| | | return devices; |
| | | } |
| | | |
| | | /** |
| | | * 修改手持设备 |
| | | * |
| | | * @param handDevice |
| | | * @return |
| | | */ |
| | | @Override |
| | | public HandDevice update(HandDevice handDevice) { |
| | | QxUser currentUser = UserHelper.getCurrentUser(); |
| | | String state = handDevice.getState(); |
| | | if (state.equals("0")){ |
| | | HandDevice handDevice1 = getHand(handDevice); |
| | | handDevice1.setCreateName(currentUser.getUserName()); |
| | | handDeviceMapper.insert(handDevice1); |
| | | return handDevice1; |
| | | }else { |
| | | handDevice.setEndTime(new Date()); |
| | | handDevice.setState("0"); |
| | | handDevice.setUpdateName(currentUser.getUserName()); |
| | | handDeviceMapper.updateById(handDevice); |
| | | return handDevice; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public HandDevice query(String mac) { |
| | | QueryWrapper<HandDevice> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac",mac); |
| | | queryWrapper.orderByDesc("create_time"); |
| | | List<HandDevice> handDevices = handDeviceMapper.selectList(queryWrapper); |
| | | HandDevice handDevice; |
| | | if (ObjectUtils.isEmpty(handDevices)){ |
| | | handDevice = new HandDevice(); |
| | | Device deviceByMac = deviceService.getDeviceByMac(mac); |
| | | handDevice.setName(deviceByMac.getName()); |
| | | handDevice.setMac(deviceByMac.getMac()); |
| | | handDevice.setState("0"); |
| | | }else { |
| | | handDevice = handDevices.get(0); |
| | | } |
| | | return handDevice; |
| | | } |
| | | |
| | | /** |
| | | * 详情 |
| | | * |
| | | * @param mac |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> details(String mac, String startTime, String endTime,String type) { |
| | | Date startDate = DateUtils.getDate(startTime,DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | Date endDate = DateUtils.getDate(endTime,DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | List<Map<String, Object>> rsMap = new ArrayList<>(); |
| | | if (ObjectUtils.isEmpty(endTime)){ |
| | | endDate = new Date(); |
| | | |
| | | } |
| | | if (type.equals("hour")){ |
| | | List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate); |
| | | for (HistoryHourly historyHourly : valueByMacAndTime) { |
| | | String value = historyHourly.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | map.put("time",DateUtils.dateToDateString(historyHourly.getTime())); |
| | | map.put("a21001",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); |
| | | map.put("a21028",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); |
| | | rsMap.add(map); |
| | | } |
| | | }else if (type.equals("minute")){ |
| | | List<HistoryMinutely> historyMinutelys = historyHourlyService.getHistoryMinutely(mac, startDate, endDate); |
| | | for (HistoryMinutely historyMinutely : historyMinutelys) { |
| | | String value = historyMinutely.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | map.put("time",DateUtils.dateToDateString(historyMinutely.getTime())); |
| | | map.put("a21001",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); |
| | | map.put("a21028",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); |
| | | rsMap.add(map); |
| | | } |
| | | }else if (type.equals("minutely")){ |
| | | List<HistoryFiveMinutely> historyFiveMinutelies = historyFiveMinutelyService.queryFiveMinutely(mac, startDate, endDate); |
| | | for (HistoryFiveMinutely historyFiveMinutely : historyFiveMinutelies) { |
| | | String value = historyFiveMinutely.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | map.put("time",DateUtils.dateToDateString(historyFiveMinutely.getTime())); |
| | | map.put("a21001",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); |
| | | map.put("a21028",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); |
| | | map.put("a31001",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); |
| | | rsMap.add(map); |
| | | } |
| | | } |
| | | return rsMap; |
| | | } |
| | | |
| | | /** |
| | | * 导出 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> detailsExecl(Map<String, Object> params) { |
| | | String type = params.get("type").toString(); |
| | | String mac = params.get("mac").toString(); |
| | | Object endTime = params.get("endTime"); |
| | | Date startDate = DateUtils.getDate(params.get("startTime").toString(),DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | Date endDate; |
| | | List<Map<String, Object>> rsMap = new ArrayList<>(); |
| | | if (ObjectUtils.isEmpty(endTime)){ |
| | | endDate = new Date(); |
| | | }else { |
| | | endDate = DateUtils.getDate(endTime.toString(),DateUtils.yyyy_MM_dd_HH_mm_EN); |
| | | } |
| | | if (type.equals("hour")){ |
| | | List<HistoryHourly> valueByMacAndTime = historyHourlyService.getValueByMacAndTime(mac, startDate, endDate); |
| | | for (HistoryHourly historyHourly : valueByMacAndTime) { |
| | | LinkedHashMap<String, Object> map1 = new LinkedHashMap<>(); |
| | | String value = historyHourly.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | map1.put("时间",DateUtils.dateToDateString(historyHourly.getTime())); |
| | | map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); |
| | | map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); |
| | | map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); |
| | | map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); |
| | | map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); |
| | | map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); |
| | | map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); |
| | | map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); |
| | | map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); |
| | | map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); |
| | | map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); |
| | | map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); |
| | | rsMap.add(map1); |
| | | } |
| | | }else { |
| | | List<HistoryFiveMinutely> historyFiveMinutelies = historyFiveMinutelyService.queryFiveMinutely(mac, startDate, endDate); |
| | | for (HistoryFiveMinutely historyFiveMinutely : historyFiveMinutelies) { |
| | | LinkedHashMap<String, Object> map1 = new LinkedHashMap<>(); |
| | | String value = historyFiveMinutely.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | map1.put("时间",DateUtils.dateToDateString(historyFiveMinutely.getTime())); |
| | | map1.put("pm25",ObjectUtils.isEmpty(map.get("a34004"))?0:map.get("a34004")); |
| | | map1.put("pm10",ObjectUtils.isEmpty(map.get("a34002"))?0:map.get("a34002")); |
| | | map1.put("二氧化氮",ObjectUtils.isEmpty(map.get("a21004"))?0:map.get("a21004")); |
| | | map1.put("二氧化硫",ObjectUtils.isEmpty(map.get("a21026"))?0:map.get("a21026")); |
| | | map1.put("一氧化碳",ObjectUtils.isEmpty(map.get("a21005"))?0:map.get("a21005")); |
| | | map1.put("气压",ObjectUtils.isEmpty(map.get("a01006"))?0:map.get("a01006")); |
| | | map1.put("温度",ObjectUtils.isEmpty(map.get("a01001"))?0:map.get("a01001")); |
| | | map1.put("湿度",ObjectUtils.isEmpty(map.get("a01002"))?0:map.get("a01002")); |
| | | map1.put("tvoc",ObjectUtils.isEmpty(map.get("a99054"))?0:map.get("a99054")); |
| | | map1.put("甲醛",ObjectUtils.isEmpty(map.get("a31001"))?0:map.get("a31001")); |
| | | map1.put("硫化氢",ObjectUtils.isEmpty(map.get("a21028"))?0:map.get("a21028")); |
| | | map1.put("氨气",ObjectUtils.isEmpty(map.get("a21001"))?0:map.get("a21001")); |
| | | rsMap.add(map1); |
| | | } |
| | | } |
| | | return rsMap; |
| | | } |
| | | |
| | | |
| | | private HandDevice getHand(HandDevice handDevice){ |
| | | HandDevice rsHandDevice = new HandDevice(); |
| | | rsHandDevice.setName(handDevice.getName()); |
| | | rsHandDevice.setMac(handDevice.getMac()); |
| | | rsHandDevice.setAddress(handDevice.getAddress()); |
| | | rsHandDevice.setLatitude(handDevice.getLatitude()); |
| | | rsHandDevice.setLongitude(handDevice.getLongitude()); |
| | | rsHandDevice.setIsDelete(Constants.NOT_DELETE); |
| | | rsHandDevice.setStartTime(new Date()); |
| | | rsHandDevice.setUpdateTime(new Date()); |
| | | rsHandDevice.setCreateTime(new Date()); |
| | | rsHandDevice.setState("1"); |
| | | return rsHandDevice; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | return queryFiveDataByMacVO; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 查询五分钟内某一mac的数据 |
| | | * @Param: [mac, startDate, endDate] |
| | | * @return: java.util.List<com.moral.api.entity.HistoryHourly> |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/9/23 |
| | | */ |
| | | |
| | | @Override |
| | | public List<HistoryFiveMinutely> queryFiveMinutely(String mac, Date startDate, Date endDate) { |
| | | List<HistoryFiveMinutely> valueByMacAndTime = getValueByMacAndTime(mac, startDate, endDate); |
| | | return valueByMacAndTime; |
| | | } |
| | | |
| | | //对六参以及时间进行排序 |
| | | private Map<String, Object> orderSixParam(Map<String, Object> data) { |
| | | LinkedHashMap result = new LinkedHashMap(); |
| | |
| | | |
| | | 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.entity.MonitorPoint; |
| | | import com.moral.api.entity.Organization; |
| | | import com.moral.api.mapper.DeviceMapper; |
| | | import com.moral.api.mapper.MonitorPointMapper; |
| | | import com.moral.api.mapper.OrganizationMapper; |
| | | import com.moral.api.pojo.vo.user.QxUser; |
| | | import com.moral.api.pojo.vo.device.DeviceVO; |
| | | import com.moral.api.pojo.vo.monitorPoint.MonitorPointVos; |
| | | 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; |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | |
| | | @Autowired |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired |
| | | MonitorPointMapper monitorPointMapper; |
| | | |
| | | |
| | | @Autowired |
| | | DeviceMapper deviceMapper; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | return rsList; |
| | | } |
| | | |
| | | /** |
| | | * 查询组织信息 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Organization> queryDevices() { |
| | | Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo(); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization"); |
| | | Integer organizationId = (Integer) orgInfo.get("id"); |
| | | LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.select(Organization::getId,Organization::getAddress,Organization::getAreaName,Organization::getName); |
| | | wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE); |
| | | wrapper.orderByDesc(Organization::getCreateTime); |
| | | List<Organization> organizations; |
| | | if (organizationId==24){ |
| | | wrapper.eq(Organization::getParentId,organizationId); |
| | | organizations = organizationMapper.selectList(wrapper); |
| | | }else { |
| | | wrapper.eq(Organization::getId,organizationId); |
| | | organizations = organizationMapper.selectList(wrapper); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(organizations)){ |
| | | organizations.forEach(it ->{ |
| | | //查询站点 |
| | | // QueryWrapper<MonitorPoint> queryMonitorPointsWrapper = new QueryWrapper<>(); |
| | | // queryMonitorPointsWrapper.eq("organization_id", it.getId()); |
| | | // queryMonitorPointsWrapper.eq("is_delete", Constants.NOT_DELETE); |
| | | // List<MonitorPoint> monitorPoints = monitorPointMapper.selectList(queryMonitorPointsWrapper); |
| | | List<MonitorPointVos> monitorPoints = monitorPointMapper.getMonitorPoint(it.getId()); |
| | | //查询站点对应的设备 |
| | | for (MonitorPointVos monitorPoint : monitorPoints) { |
| | | // List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPoint.getId()); |
| | | List<DeviceVO> listVo = deviceMapper.getListVo(monitorPoint.getId()); |
| | | monitorPoint.setMonitorPoint(listVo); |
| | | } |
| | | it.setMonitorPoint(monitorPoints); |
| | | } ); |
| | | } |
| | | return organizations; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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; |
| | | import com.moral.api.mapper.SpecialDeviceMapper; |
| | | import com.moral.api.mapper.SysDictTypeMapper; |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserListDTO; |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultCountDTO; |
| | |
| | | import com.moral.api.service.SpecialDeviceHistoryService; |
| | | import com.moral.api.service.SpecialDeviceService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.SysAreaService; |
| | | import com.moral.api.service.SysDictTypeService; |
| | | import com.moral.constant.Constants; |
| | | |
| | |
| | | import com.moral.util.FileUtils; |
| | | import com.moral.util.GeodesyUtils; |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private SysAreaService sysAreaService; |
| | | |
| | | private final static Double dis = 50d; |
| | | |
| | |
| | | String type = params.get("type").toString(); |
| | | String code = params.get("code").toString(); |
| | | String area = params.get("area").toString(); |
| | | String mac = params.get("mac").toString(); |
| | | rsMap.put("area",area); |
| | | rsMap.put("mac",mac.substring(9)); |
| | | String value = JSON.toJSONString(rsMap); |
| | | |
| | | String mac = params.get("mac").toString(); |
| | | QueryWrapper<TbDaily> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("mac",mac); |
| | | queryWrapper.likeRight("time",time1.substring(0,10)); |
| | |
| | | |
| | | /** |
| | | * 下载走航车日报 |
| | | * @param id |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public DailyVo loadDaily(Integer id) { |
| | | ArrayList<String> rsList = new ArrayList<>(); |
| | | DailyVo dailyVo = new DailyVo(); |
| | | TbDaily tbDaily = dailyMapper.selectById(id); |
| | | if (tbDaily==null){ |
| | | return null; |
| | | public List<DailyVo> loadDaily(List<Integer> ids) { |
| | | ArrayList<DailyVo> dailyVos = new ArrayList<>(); |
| | | for (Integer id : ids) { |
| | | ArrayList<String> rsList = new ArrayList<>(); |
| | | DailyVo dailyVo = new DailyVo(); |
| | | TbDaily tbDaily = dailyMapper.selectById(id); |
| | | |
| | | SysArea areaByCode = sysAreaService.getAreaByCode(Integer.parseInt(tbDaily.getCode())); |
| | | if (tbDaily==null){ |
| | | continue; |
| | | } |
| | | String images = tbDaily.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | String[] split = images.split(","); |
| | | List<String> list1 = Arrays.asList(split); |
| | | dailyVo.setImages(list1); |
| | | }else { |
| | | dailyVo.setImages(rsList); |
| | | } |
| | | String value = tbDaily.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | List<String> list = (List<String>) map.get("time"); |
| | | String join = String.join("-", list); |
| | | map.put("time",join); |
| | | dailyVo.setCode(map); |
| | | dailyVo.setName(areaByCode.getAreaName()); |
| | | dailyVo.setType(tbDaily.getType().equals("car")?"走航车":"无人机"); |
| | | dailyVos.add(dailyVo); |
| | | } |
| | | String images = tbDaily.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | String[] split = images.split(","); |
| | | List<String> list1 = Arrays.asList(split); |
| | | dailyVo.setImages(list1); |
| | | }else { |
| | | dailyVo.setImages(rsList); |
| | | } |
| | | String value = tbDaily.getValue(); |
| | | Map map = JSON.parseObject(value, Map.class); |
| | | dailyVo.setCode(map); |
| | | return dailyVo; |
| | | return dailyVos; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | Object mac = params.get("mac"); |
| | | if (!ObjectUtils.isEmpty(mac)){ |
| | | String MAC = mac.toString(); |
| | | String[] split = mac.toString().split(","); |
| | | List<String> list = Arrays.asList(split); |
| | | List<String> macList = new ArrayList<>(new TreeSet<>(list)); |
| | | QueryWrapper<TbDaily> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("type",type).eq("code",code).eq("mac",MAC); |
| | | queryWrapper.eq("type",type).eq("code",code).in("mac",macList); |
| | | queryWrapper.between("time",startTime,endTime); |
| | | List<TbDaily> dailies = dailyMapper.selectList(queryWrapper); |
| | | for (TbDaily daily : dailies) { |
| | |
| | | result.put("msg", ResponseCodeEnum.ACCOUNT_IS_DELETE.getMsg()); |
| | | return result; |
| | | } |
| | | //手持设备权限 |
| | | List<Integer> handList = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_HAND_DEVICE.value, userBo.getId()); |
| | | result.put("handDevice",ObjectUtils.isEmpty(handList)? StateEnum.NOT_EFFECTIVE.value : StateEnum.TAKE_EFFECT.value); |
| | | //秒级数据权限 |
| | | ResponsibilityUnit responsibilityUnit = responsibilityUnitMapper.selectById(userBo.getUnitId()); |
| | | List<Integer> list = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_DEVICE.value, userBo.getId()); |
| | | result.put("userName", userBo.getUserName()); |
| | |
| | | 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()); |
| | | //手持设备秒级权限 |
| | | List<Integer> handList = responsibilityUnitMapper.selectCodeList(SysDictTypeEnum.SYS_HAND_DEVICE.value, user.getId()); |
| | | result.put("device",ObjectUtils.isEmpty(list)? StateEnum.NOT_EFFECTIVE.value : StateEnum.TAKE_EFFECT.value); |
| | | result.put("handDevice",ObjectUtils.isEmpty(handList)? 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<>(); |
| | |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | inner JOIN device_map_hierarchy as dm on d.id = dm.device_id |
| | | left JOIN device_map_hierarchy as dm on d.id = dm.device_id |
| | | <if test="tableName !=null"> |
| | | left join history_hourly${tableName} hd on hd.time = #{start} and d.mac = hd.mac |
| | | </if> |
| | |
| | | |
| | | |
| | | <select id="getLists" resultType="com.moral.api.vo.OnlineRateVo"> |
| | | select d.name,d.state,d.mac from device as d where organization_id=#{organizationId} and is_delete=0 |
| | | select d.name,d.state,d.mac from device as d where is_delete=0 |
| | | <if test="macs != null and macs.size !=0"> |
| | | and mac in |
| | | <foreach collection="macs" item="mac" index="index" open="(" close=")" separator=","> |
| | | #{mac} |
| | | </foreach> |
| | | </if> |
| | | <if test="state !=null and state == 0" > |
| | | and state=#{state} |
| | | </if> |
| | |
| | | and state<![CDATA[>=]]>#{state} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="getListVo" resultType="com.moral.api.pojo.vo.device.DeviceVO"> |
| | | select * from device where monitor_point_id=#{monitorPointId} and is_delete=0 |
| | | </select> |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HandDeviceMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HandDevice"> |
| | | <id column="id" property="id" /> |
| | | <result column="name" property="name" /> |
| | | <result column="mac" property="mac" /> |
| | | <result column="address" property="address" /> |
| | | <result column="longitude" property="longitude" /> |
| | | <result column="latitude" property="latitude" /> |
| | | <result column="start_time" property="startTime" /> |
| | | <result column="is_delete" property="isDelete" /> |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="create_name" property="createName" /> |
| | | <result column="update_name" property="updateName" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List"> |
| | | id,name,mac,address,longitude,latitude,start_time,is_delete,end_time,create_name,update_name,create_time,update_time |
| | | </sql> |
| | | <select id="Page" resultType="com.moral.api.entity.HandDevice"> |
| | | select |
| | | <include refid="Base_Column_List"/> |
| | | from hand_device |
| | | <where> |
| | | 1=1 and is_delete=0 |
| | | <if test="name != null and name != ''"> |
| | | and name = #{name} |
| | | </if> |
| | | <if test="mac != null and mac != ''"> |
| | | and mac = #{mac} |
| | | </if> |
| | | <if test="startTime != null and endTime == '' "> |
| | | and date(start_time) like CONCAT('%',#{startTime},'%') |
| | | </if> |
| | | <if test="endTime != '' and startTime != ''"> |
| | | and date(start_time) <![CDATA[>=]]> #{startTime} |
| | | and date(end_time) <![CDATA[<=]]> #{endTime} |
| | | </if> |
| | | </where> |
| | | order by start_time desc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | select id from monitor_point where organization_id=#{id} and is_delete=0 |
| | | </select> |
| | | |
| | | <select id="getMonitorPoint" resultType="com.moral.api.pojo.vo.monitorPoint.MonitorPointVos"> |
| | | select * from monitor_point where organization_id=#{id} and is_delete=0 |
| | | </select> |
| | | |
| | | |
| | | </mapper> |