diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java new file mode 100644 index 00000000..d899bb6b --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java @@ -0,0 +1,263 @@ +package com.zc.business.controller; + +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.zc.business.domain.DcDevice; +import com.zc.business.enums.UniversalEnum; +import com.zc.common.core.httpclient.exception.HttpException; +import io.swagger.v3.oas.annotations.Parameter; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.zc.business.domain.DcTrafficSurveyData; +import com.zc.business.service.IDcTrafficSurveyDataService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 一类交调数据Controller + * + * @author liuwenge + * @date 2024-10-29 + */ +@RestController +@RequestMapping("/trafficSurveyData/dcTrafficSurveyData") +public class DcTrafficSurveyDataController extends BaseController +{ + @Autowired + private IDcTrafficSurveyDataService dcTrafficSurveyDataService; + + @Resource + private DcDeviceController dcDeviceController; + + @Scheduled(cron = "0 5 * * * ?") + public void syncTrafficSectionData() throws HttpException, IOException { + + HashMap props = new HashMap<>(); + // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内 + props.put("terms[0].column", "timestamp$BTW"); + ArrayList dateList = new ArrayList<>(); + // 添加当前前一小时的开始和结束时间到列表,用于设定时间范围 + Date now = new Date(); + // 计算上一个小时的时间 + Date lastHourStart = DateUtil.beginOfHour(DateUtil.offsetHour(now, -1)); + Date lastHourEnd = DateUtil.endOfHour(DateUtil.offsetHour(now, -1)); + // 将上一个小时的开始和结束时间添加到列表 + dateList.add(DateUtil.format(lastHourStart, "yyyy-MM-dd HH:mm:ss")); + dateList.add(DateUtil.format(lastHourEnd, "yyyy-MM-dd HH:mm:ss")); + // 将日期列表以逗号分隔并设置为查询条件的值 + props.put("terms[0].value", String.join(UniversalEnum.COMMA.getValue(), dateList)); + props.put("paging", false); + props.put("sorts[0].order", "asc"); + props.put("sorts[0].name", "timestamp"); + + + List deviceList = dcTrafficSurveyDataService.selectDeviceList(); + String propertyId = "01"; //功能码 + + List batchData = new ArrayList<>(); + for (DcDevice dcDevice : deviceList) { + + Object data = JSON.parseObject(dcDeviceController.queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props).get("data").toString()).get("data"); + JSONArray dataArray = JSON.parseArray(data.toString()); + + Integer hezeTotal = 0; + Integer jinanTotal = 0; + for (Object o : dataArray) { + JSONObject jsonObject = JSON.parseObject(o.toString()); + JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString()); + hezeTotal += Integer.parseInt(formatValue.get("1").toString()); + jinanTotal += Integer.parseInt(formatValue.get("3").toString()); + } + + //菏泽方向数据 + DcTrafficSurveyData hezeData = new DcTrafficSurveyData(); + hezeData.setIotDeviceId(dcDevice.getIotDeviceId()); + hezeData.setStakeMark(dcDevice.getStakeMark()); + hezeData.setDirection("1"); + hezeData.setTimestamp(lastHourStart); + hezeData.setTrafficVolume(Long.valueOf(hezeTotal)); + batchData.add(hezeData); + //济南方向数据 + DcTrafficSurveyData jinanData = new DcTrafficSurveyData(); + jinanData.setIotDeviceId(dcDevice.getIotDeviceId()); + jinanData.setStakeMark(dcDevice.getStakeMark()); + jinanData.setDirection("3"); + jinanData.setTimestamp(lastHourStart); + jinanData.setTrafficVolume(Long.valueOf(jinanTotal)); + batchData.add(jinanData); + + } + + dcTrafficSurveyDataService.batchInsert(batchData); + + } + + /** + * 查询一类交调数据列表 + */ + @GetMapping("/list") + public AjaxResult list(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); + } + + /** + * 导出一类交调数据列表 + */ + @Log(title = "一类交调数据", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, DcTrafficSurveyData dcTrafficSurveyData) throws IOException { + AjaxResult ajaxResult = dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); + if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) { + Map data = (Map) ajaxResult.get("data"); + List> columnList = (List>) data.get("columnList"); + List> rowList = (List>) data.get("rowList"); + + XSSFWorkbook workbook = new XSSFWorkbook(); // 创建工作簿 + Sheet sheet = workbook.createSheet("一类交调站"); // 创建工作表 + + // 创建数据行样式 + CellStyle dataStyle = workbook.createCellStyle(); + dataStyle.setAlignment(HorizontalAlignment.CENTER); + dataStyle.setVerticalAlignment(VerticalAlignment.CENTER); + dataStyle.setBorderRight(BorderStyle.THIN); + dataStyle.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderLeft(BorderStyle.THIN); + dataStyle.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderTop(BorderStyle.THIN); + dataStyle.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + dataStyle.setBorderBottom(BorderStyle.THIN); + dataStyle.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = workbook.createFont(); + dataFont.setFontName(UniversalEnum.ARIAL.getValue()); + dataFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); + dataStyle.setFont(dataFont); + + // 创建表头样式 + CellStyle headerStyle = workbook.createCellStyle(); + headerStyle.cloneStyleFrom(dataStyle); + headerStyle.setAlignment(HorizontalAlignment.CENTER); + headerStyle.setVerticalAlignment(VerticalAlignment.CENTER); + headerStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = workbook.createFont(); + headerFont.setFontName(UniversalEnum.ARIAL.getValue()); + headerFont.setFontHeightInPoints((short) UniversalEnum.TEN.getNumber()); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + headerStyle.setFont(headerFont); + + // 添加表头 + Row row = sheet.createRow(UniversalEnum.ZERO.getNumber()); + Cell cell = row.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue("设备名称"); + cell.setCellStyle(headerStyle); + cell = row.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue("方向"); + cell.setCellStyle(headerStyle); + int i; + for (i = 0; i < columnList.size(); i++) { + cell = row.createCell(i + 2); + cell.setCellValue(columnList.get(i).get("label").toString()); + cell.setCellStyle(headerStyle);; + } + cell = row.createCell(i + 2); + cell.setCellValue("合计"); + cell.setCellStyle(headerStyle); + + + for (int j = 0; j < rowList.size(); j++) { + Row subHeaderRow = sheet.createRow(j+1); + cell = subHeaderRow.createCell(UniversalEnum.ZERO.getNumber()); + cell.setCellValue("一类交调站"+rowList.get(j).get("stakeMark").toString()); + cell.setCellStyle(dataStyle); + cell = subHeaderRow.createCell(UniversalEnum.ONE.getNumber()); + cell.setCellValue(rowList.get(j).get("direction").toString().equals("1") ? "济南方向" : "菏泽方向"); + cell.setCellStyle(dataStyle); + int k = 0; + for (k = 0; k < columnList.size(); k++) { + cell = subHeaderRow.createCell(k + 2); + cell.setCellValue(rowList.get(j).get(columnList.get(k).get("key")).toString()); + cell.setCellStyle(dataStyle);; + } + cell = subHeaderRow.createCell(k+2); + cell.setCellValue(rowList.get(j).get("total").toString()); + cell.setCellStyle(dataStyle); + } + + + // 写入文件 + try (ServletOutputStream outputStream = response.getOutputStream()){ + workbook.write(outputStream); + } finally { + workbook.close(); + } + + } + } + + /** + * 获取一类交调数据详细信息 + */ + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(dcTrafficSurveyDataService.selectDcTrafficSurveyDataById(id)); + } + + /** + * 新增一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody DcTrafficSurveyData dcTrafficSurveyData) + { + return toAjax(dcTrafficSurveyDataService.insertDcTrafficSurveyData(dcTrafficSurveyData)); + } + + /** + * 修改一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody DcTrafficSurveyData dcTrafficSurveyData) + { + return toAjax(dcTrafficSurveyDataService.updateDcTrafficSurveyData(dcTrafficSurveyData)); + } + + /** + * 删除一类交调数据 + */ + @Log(title = "一类交调数据", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(dcTrafficSurveyDataService.deleteDcTrafficSurveyDataByIds(ids)); + } +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java new file mode 100644 index 00000000..705dbdb0 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java @@ -0,0 +1,130 @@ +package com.zc.business.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 一类交调数据对象 dc_traffic_survey_data + * + * @author liuwenge + * @date 2024-10-29 + */ +public class DcTrafficSurveyData extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** $column.columnComment */ + private Long id; + + /** 物联设备主键 */ + @Excel(name = "物联设备主键") + private String iotDeviceId; + + /** 所在桩号 */ + @Excel(name = "所在桩号") + private String stakeMark; + + /** 方向1-上行,2-中,3-下行 */ + @Excel(name = "方向1-上行,2-中,3-下行") + private String direction; + + /** 采集时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "采集时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date timestamp; + + /** 车流量 */ + @Excel(name = "车流量") + private Long trafficVolume; + + private String type; + + private String times; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setIotDeviceId(String iotDeviceId) + { + this.iotDeviceId = iotDeviceId; + } + + public String getIotDeviceId() + { + return iotDeviceId; + } + public void setStakeMark(String stakeMark) + { + this.stakeMark = stakeMark; + } + + public String getStakeMark() + { + return stakeMark; + } + public void setDirection(String direction) + { + this.direction = direction; + } + + public String getDirection() + { + return direction; + } + public void setTimestamp(Date timestamp) + { + this.timestamp = timestamp; + } + + public Date getTimestamp() + { + return timestamp; + } + public void setTrafficVolume(Long trafficVolume) + { + this.trafficVolume = trafficVolume; + } + + public Long getTrafficVolume() + { + return trafficVolume; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getTimes() { + return times; + } + + public void setTimes(String times) { + this.times = times; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("iotDeviceId", getIotDeviceId()) + .append("stakeMark", getStakeMark()) + .append("direction", getDirection()) + .append("timestamp", getTimestamp()) + .append("trafficVolume", getTrafficVolume()) + .toString(); + } +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java new file mode 100644 index 00000000..0a94df6b --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java @@ -0,0 +1,71 @@ +package com.zc.business.mapper; + +import java.util.List; + +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcTrafficSurveyData; + +/** + * 一类交调数据Mapper接口 + * + * @author liuwenge + * @date 2024-10-29 + */ +public interface DcTrafficSurveyDataMapper +{ + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id); + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据集合 + */ + List selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); + + List selectDay(DcTrafficSurveyData dcTrafficSurveyData); + List selectMonth(DcTrafficSurveyData dcTrafficSurveyData); + List selectYear(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 删除一类交调数据 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + int deleteDcTrafficSurveyDataById(Long id); + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deleteDcTrafficSurveyDataByIds(Long[] ids); + + List selectDeviceList(); + + int batchInsert(List batchData); +} diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java new file mode 100644 index 00000000..78838bbc --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java @@ -0,0 +1,80 @@ +package com.zc.business.service; + +import java.util.List; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcDevice; +import com.zc.business.domain.DcTrafficSurveyData; + +/** + * 一类交调数据Service接口 + * + * @author liuwenge + * @date 2024-10-29 + */ +public interface IDcTrafficSurveyDataService +{ + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id); + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据集合 + */ + AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData); + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的一类交调数据主键集合 + * @return 结果 + */ + int deleteDcTrafficSurveyDataByIds(Long[] ids); + + /** + * 删除一类交调数据信息 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + int deleteDcTrafficSurveyDataById(Long id); + + /** + * 查询所有交调设备 + * + * @param + * @return 结果 + */ + List selectDeviceList(); + + /** + * 批量插入 + * + * @param batchData 一类交调数据 + * @return 结果 + */ + int batchInsert(List batchData); +} diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java new file mode 100644 index 00000000..c9a35c5f --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java @@ -0,0 +1,248 @@ +package com.zc.business.service.impl; + +import java.util.*; +import java.util.stream.Collectors; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcDevice; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.zc.business.mapper.DcTrafficSurveyDataMapper; +import com.zc.business.domain.DcTrafficSurveyData; +import com.zc.business.service.IDcTrafficSurveyDataService; + +/** + * 一类交调数据Service业务层处理 + * + * @author liuwenge + * @date 2024-10-29 + */ +@Service +public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataService +{ + @Autowired + private DcTrafficSurveyDataMapper dcTrafficSurveyDataMapper; + + /** + * 查询一类交调数据 + * + * @param id 一类交调数据主键 + * @return 一类交调数据 + */ + @Override + public DcTrafficSurveyData selectDcTrafficSurveyDataById(Long id) + { + return dcTrafficSurveyDataMapper.selectDcTrafficSurveyDataById(id); + } + + /** + * 查询一类交调数据列表 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 一类交调数据 + */ + @Override + public AjaxResult selectDcTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) + { + List> rowList = new ArrayList<>(); + List> columnList = getColumnList(dcTrafficSurveyData); + List dataList = new ArrayList<>(); + if (dcTrafficSurveyData.getType().equals("day")){ + dataList = dcTrafficSurveyDataMapper.selectDay(dcTrafficSurveyData); + } else if (dcTrafficSurveyData.getType().equals("month")){ + dataList = dcTrafficSurveyDataMapper.selectMonth(dcTrafficSurveyData); + } else if (dcTrafficSurveyData.getType().equals("year")){ + dataList = dcTrafficSurveyDataMapper.selectYear(dcTrafficSurveyData); + } + Map>>> groupedData = dataList.stream() + .collect(Collectors.groupingBy( + DcTrafficSurveyData::getIotDeviceId, // 第一级分组:按设备Id + Collectors.groupingBy(DcTrafficSurveyData::getDirection, // 第二级分组:按方向 + Collectors.groupingBy(DcTrafficSurveyData::getTimes) // 第三级分组:按时间 + ))); + List deviceList = dcTrafficSurveyDataMapper.selectDeviceList(); + + Map row = new HashMap<>(); + for (DcDevice dcDevice : deviceList) { + if (groupedData.containsKey(dcDevice.getIotDeviceId())){ + + Map>> directionData = groupedData.get(dcDevice.getIotDeviceId()); + //单个设备济南方向数据 + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","1"); + + if (directionData.containsKey("1")){ + Integer total = 0; + //单个设备济南方向分时数据 + Map> directionList = directionData.get("1"); + for (Map columnMap : columnList) { + if (directionList.containsKey(columnMap.get("key"))){ + List timeList = directionList.get(columnMap.get("key")); + row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + total += timeList.get(0).getTrafficVolume().intValue(); + } else { + row.put(columnMap.get("key"),0); + } + } + row.put("total",total); + } else { + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + row.put("total",0); + } + } + rowList.add(row); + + //单个设备菏泽方向数据 + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","3"); + if (directionData.containsKey("3")){ + Integer total = 0; + //单个设备菏泽方向分时数据 + Map> directionList = directionData.get("3"); + for (Map columnMap : columnList) { + if (directionList.containsKey(columnMap.get("key"))){ + List timeList = directionList.get(columnMap.get("key")); + row.put(columnMap.get("key"),timeList.get(0).getTrafficVolume()); + total += timeList.get(0).getTrafficVolume().intValue(); + } else { + row.put(columnMap.get("key"),0); + } + } + row.put("total",total); + } else { + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + row.put("total",0); + } + } + rowList.add(row); + } else { + row = new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","1"); + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + } + row.put("total",0); + rowList.add(row); + + row= new HashMap<>(); + row.put("stakeMark",dcDevice.getStakeMark()); + row.put("direction","3"); + for (Map columnMap : columnList) { + row.put(columnMap.get("key"),0); + } + row.put("total",0); + rowList.add(row); + } + } + Map result = new HashMap<>(); + result.put("rowList",rowList); + result.put("columnList",columnList); + return AjaxResult.success(result); + + } + + public List> getColumnList(DcTrafficSurveyData dcTrafficSurveyData){ + List> columnList = new ArrayList<>(); + Map column; + if (dcTrafficSurveyData.getType().equals("day")){ + for (int i = 0; i < 24; i++) { + column = new HashMap<>(); + column.put("label",i+"点"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } else if (dcTrafficSurveyData.getType().equals("month")){ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(dcTrafficSurveyData.getTimestamp()); + int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); // 获取这个月的最大天数 + for (int i = 1; i <= maxDay; i++) { + column = new HashMap<>(); + column.put("label",i+"日"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } else if (dcTrafficSurveyData.getType().equals("year")){ + for (int i = 1; i <= 12; i++) { + column = new HashMap<>(); + column.put("label",i+"月"); + column.put("key",String.valueOf(i)); + columnList.add(column); + } + } + return columnList; + } + /** + * 新增一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + @Override + public int insertDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataMapper.insertDcTrafficSurveyData(dcTrafficSurveyData); + } + + /** + * 修改一类交调数据 + * + * @param dcTrafficSurveyData 一类交调数据 + * @return 结果 + */ + @Override + public int updateDcTrafficSurveyData(DcTrafficSurveyData dcTrafficSurveyData) + { + return dcTrafficSurveyDataMapper.updateDcTrafficSurveyData(dcTrafficSurveyData); + } + + /** + * 批量删除一类交调数据 + * + * @param ids 需要删除的一类交调数据主键 + * @return 结果 + */ + @Override + public int deleteDcTrafficSurveyDataByIds(Long[] ids) + { + return dcTrafficSurveyDataMapper.deleteDcTrafficSurveyDataByIds(ids); + } + + /** + * 删除一类交调数据信息 + * + * @param id 一类交调数据主键 + * @return 结果 + */ + @Override + public int deleteDcTrafficSurveyDataById(Long id) + { + return dcTrafficSurveyDataMapper.deleteDcTrafficSurveyDataById(id); + } + + /** + * 查询所有交调设备 + * + * @param + * @return 结果 + */ + @Override + public List selectDeviceList(){ + return dcTrafficSurveyDataMapper.selectDeviceList(); + } + + /** + * 批量插入 + * + * @param batchData 一类交调数据 + * @return 结果 + */ + @Override + public int batchInsert(List batchData){ + return dcTrafficSurveyDataMapper.batchInsert(batchData); + } +} diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml new file mode 100644 index 00000000..0f550b30 --- /dev/null +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + select id, iot_device_id, stake_mark, direction, timestamp, traffic_volume from dc_traffic_survey_data + + + + + + + + + + + + insert into dc_traffic_survey_data + + iot_device_id, + stake_mark, + direction, + timestamp, + traffic_volume, + + + #{iotDeviceId}, + #{stakeMark}, + #{direction}, + #{timestamp}, + #{trafficVolume}, + + + + + insert into dc_traffic_survey_data + + iot_device_id, + stake_mark, + direction, + timestamp, + traffic_volume, + + + #{dcTrafficSurveyData.iotDeviceId}, + #{dcTrafficSurveyData.stakeMark}, + #{dcTrafficSurveyData.direction}, + #{dcTrafficSurveyData.timestamp}, + #{dcTrafficSurveyData.trafficVolume}, + + + + + + update dc_traffic_survey_data + + iot_device_id = #{iotDeviceId}, + stake_mark = #{stakeMark}, + direction = #{direction}, + timestamp = #{timestamp}, + traffic_volume = #{trafficVolume}, + + where id = #{id} + + + + delete from dc_traffic_survey_data where id = #{id} + + + + delete from dc_traffic_survey_data where id in + + #{id} + + + \ No newline at end of file