diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java index 6c61fa9a..4a42e0a3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java @@ -2,15 +2,33 @@ package com.ruoyi.common.utils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.regex.Pattern; /** - * @Description 桩号计算工具 + * @Description 桩号工具 * * @author liuwenge * @date 2024/1/17 14:43 */ public class StakeMarkUtils { + /** + * @Description 桩号格式校验 + * + * 正确格式: K060+010 + * @author liuwenge + * @date 2024/3/22 20:05 + * @param stakeMark + * @return boolean + */ + public static boolean checkStakeMark(String stakeMark){ + if (StringUtils.isEmpty(stakeMark)){ + return false; + } + Pattern pattern = Pattern.compile("^K\\d{3}\\+\\d{3}$"); + return pattern.matcher(stakeMark).matches(); + } + /** * @Description 桩号转公里数 * @@ -20,12 +38,13 @@ public class StakeMarkUtils { * @return 公里数:123.123 */ public static String formatKilometre(String stakeMark){ - if (StringUtils.isEmpty(stakeMark)){ + if (!checkStakeMark(stakeMark)){ return ""; } - return stakeMark.toLowerCase().replace("k","").replace("+","."); + return stakeMark.replace("K","").replace("+","."); } + /** * @Description 桩号转米 * @@ -34,11 +53,18 @@ public class StakeMarkUtils { * @param stakeMark 桩号:"K123+123" * @return 公里数:123123 */ + public static Long formatMetreLong(String stakeMark){ + if (!checkStakeMark(stakeMark)){ + return null; + } + return Long.valueOf(stakeMark.replace("K","").replace("+","")); + } + public static String formatMetre(String stakeMark){ - if (StringUtils.isEmpty(stakeMark)){ + if (!checkStakeMark(stakeMark)){ return ""; } - return stakeMark.toLowerCase().replace("k","").replace("+",""); + return stakeMark.replace("K","").replace("+",""); } /** @@ -51,11 +77,11 @@ public class StakeMarkUtils { * @return java.math.BigDecimal 距离 */ public static BigDecimal getKilometre(String startStakeMark, String endStakeMark){ - if (StringUtils.isEmpty(startStakeMark) || StringUtils.isEmpty(endStakeMark)){ + if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){ return BigDecimal.ZERO; } - String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); - String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); + String start = startStakeMark.replace("K","").replace("+","."); + String end = endStakeMark.replace("K","").replace("+","."); BigDecimal startKilometre = new BigDecimal(start); BigDecimal endKilometre = new BigDecimal(end); if (startKilometre.compareTo(endKilometre) > 0){ @@ -75,11 +101,11 @@ public class StakeMarkUtils { * @return java.math.BigDecimal 距离 */ public static BigDecimal getMetre(String startStakeMark, String endStakeMark){ - if (StringUtils.isEmpty(startStakeMark) || StringUtils.isEmpty(endStakeMark)){ + if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){ return BigDecimal.ZERO; } - String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); - String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); + String start = startStakeMark.replace("K","").replace("+","."); + String end = endStakeMark.replace("K","").replace("+","."); BigDecimal startKilometre = new BigDecimal(start); BigDecimal endKilometre = new BigDecimal(end); if (startKilometre.compareTo(endKilometre) > 0){ diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 9d288e65..046648e7 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -69,7 +69,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override public boolean matches(HttpServletRequest request) { // 获取请求的IP - String requestIP = request.getRemoteAddr(); + String requestIP = request.getHeader("X-Forwarded-For"); // 将配置文件中的IP字符串分割为数组 String[] ips = allowedIPs.split(","); // 检查请求的IP是否在允许的IP数组中 diff --git a/zc-business/pom.xml b/zc-business/pom.xml index c0017e0b..6b870a73 100644 --- a/zc-business/pom.xml +++ b/zc-business/pom.xml @@ -47,6 +47,31 @@ com.ruoyi ruoyi-system + + + org.apache.poi + poi-ooxml + 4.1.2 + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 + + + org.apache.poi + poi + 4.1.2 + + + + + com.deepoove + poi-tl + 1.9.1 + + com.zc 1.0.0 diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java index 1163548e..d6b84c89 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java @@ -126,6 +126,15 @@ public class DcEmergencyPlansController extends BaseController { return AjaxResult.success(dcEmergencyPlansService.executionEventConfirmation(dcEventAnDcEmergencyPlans)); } + /** + * 根据事件id-查询预案事件关联表 + */ + @ApiOperation("根据事件id-查询预案事件关联表") + @GetMapping("/event/assoc/{id}") + public AjaxResult eventConfirm(@PathVariable("id") String id) { + return AjaxResult.success(dcEmergencyPlansService.selectEventPlanAssocByEventId(id)); + } + /** * 感知事件确定 */ diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java index 028532e5..f7dcbe6d 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEventController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEventController.java @@ -162,4 +162,6 @@ public class DcEventController extends BaseController Map map = dcEventService.selectCount(); return map; } + + } diff --git a/zc-business/src/main/java/com/zc/business/controller/DcMeteorologicalDetectorController.java b/zc-business/src/main/java/com/zc/business/controller/DcMeteorologicalDetectorController.java new file mode 100644 index 00000000..7fcfdea9 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/DcMeteorologicalDetectorController.java @@ -0,0 +1,42 @@ +package com.zc.business.controller; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.page.TableDataInfo; +import com.zc.business.domain.DcEvent; +import com.zc.business.domain.DcMeteorologicalDetectorData; +import com.zc.business.service.IDcEventService; +import com.zc.business.service.IDcMeteorologicalDetectorDataService; +import com.zc.business.service.impl.DcMeteorologicalDetectorDataServiceImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * + */ +@Api(tags = "气象设备") +@RestController +@RequestMapping("/dc/system/meteorologicalDetector") +public class DcMeteorologicalDetectorController extends BaseController { + @Autowired + private IDcMeteorologicalDetectorDataService dcMeteorologicalDetectorDataService; + + @ApiOperation("统计气象设备信息列表") + @GetMapping("/{deviceName}") + public TableDataInfo list(@PathVariable("deviceName") String deviceName) + { + List> list = dcMeteorologicalDetectorDataService.selectStatistics(deviceName); + return getDataTable(list); + } + @ApiOperation("统计气象设备当天最新信息列表") + @GetMapping("/listLatest") + public TableDataInfo listAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) + { + List list = dcMeteorologicalDetectorDataService.selectlistAll(dcMeteorologicalDetectorData); + return getDataTable(list); + } +} diff --git a/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java b/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java index 12b3a390..ee7a0f91 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; +import java.io.IOException; import java.util.List; /** @@ -112,4 +113,10 @@ public class DcStakeMarkController extends BaseController { return toAjax(dcStakeMarkService.removeStakeMark(ids)); } + @ApiOperation("根据json文件路径导入桩号") + @PostMapping("importStakeMarkByJsonFilePath") + public AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException { + return dcStakeMarkService.importJsonStakeMark(filePath, direction); + } + } diff --git a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java index 800a725a..29c9a7c9 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java @@ -55,7 +55,7 @@ public class DcWarningController extends BaseController @PreAuthorize("@ss.hasPermi('business:warning:export')") @Log(title = "预警信息", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, DcWarning dcWarning) + public void export(HttpServletResponse response,@RequestBody DcWarning dcWarning) { List list = dcWarningService.export(dcWarning); ExcelUtil util = new ExcelUtil<>(DcWarning.class); diff --git a/zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java b/zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java index 0663a021..cd286852 100644 --- a/zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java +++ b/zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java @@ -14,6 +14,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -32,6 +33,7 @@ import java.util.Objects; */ @Api(tags = "非机预警接口") @RestController +@Component @RequestMapping("/nonAutomaticWarning") public class NonAutomaticWarningController extends BaseController { diff --git a/zc-business/src/main/java/com/zc/business/controller/StatusController.java b/zc-business/src/main/java/com/zc/business/controller/StatusController.java index 52b65fbd..0bbc786a 100644 --- a/zc-business/src/main/java/com/zc/business/controller/StatusController.java +++ b/zc-business/src/main/java/com/zc/business/controller/StatusController.java @@ -1,8 +1,10 @@ package com.zc.business.controller; +import com.github.pagehelper.util.StringUtil; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; @@ -15,6 +17,7 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; @@ -31,6 +34,10 @@ public class StatusController extends BaseController { private StatusService statusService; @Autowired private DcDeviceServiceImpl dcDeviceService; + @Resource + private RedisCache redisCache; + + private static final String ORDERRULE = "orderRule";//排序策略key //设备列表 @ApiOperation("设备状态列表按时间和类型") @@ -86,7 +93,7 @@ public class StatusController extends BaseController { Map mapSort=new TreeMap<>(); for (Map.Entry> entry : mapTime.entrySet()) { List groupItems = entry.getValue(); - long count = groupItems.stream().filter(iteam -> iteam.getDeviceStatus() == "1").count(); + long count = groupItems.stream().filter(iteam -> Objects.equals(iteam.getDeviceStatus(), "1")).count(); String onlineRate=String.format("%.2f%%", (double) count / groupItems.size() * 100); mapSort.put(entry.getKey(),onlineRate); } @@ -95,6 +102,16 @@ public class StatusController extends BaseController { } + //按时间划分设备柱状图 + @ApiOperation("更新缓存规则") + @GetMapping ("/rule") + public AjaxResult setRule(String rule) + { + redisCache.setCacheSetValue(ORDERRULE,rule); + return AjaxResult.success(); + } + + @ApiOperation("根据设备Id查询折线图数据") @GetMapping("/deviceStatusList/{deviceId}") public AjaxResult getDeviceStatusList(@PathVariable Long deviceId) { @@ -251,11 +268,11 @@ public class StatusController extends BaseController { Integer lastKey = Collections.max(ipMap.keySet()); List lastEntry = ipMap.get(lastKey); Map> typeMap = lastEntry.stream().filter(iteam -> iteam.getType() != null).collect(Collectors.groupingBy(Status::getType)); - Map> subMap = new HashMap<>(); + Map> subMap = new HashMap<>(); itemTypeMap.forEach((key, value) -> { - Map maps = new HashMap<>(); + Map maps = new HashMap<>(); List groupItems = typeMap.get(key); if (groupItems == null) { //丢包率 @@ -317,7 +334,7 @@ public class StatusController extends BaseController { // // } //} - Map maps=new HashMap<>(); + Map maps=new HashMap<>(); double lostRate = lastEntry.stream() .mapToDouble(Status -> Double.parseDouble(Status.getLostRate().replace("%", ""))) // 去掉%,并转换为double .average().getAsDouble(); @@ -337,7 +354,19 @@ public class StatusController extends BaseController { //总数 maps.put("sum",String.valueOf(list.size())); subMap.put("全部设备",maps); - +// Map ruleMap=new HashMap<>(); +// String orderRule=redisCache.getCacheObject(ORDERRULE); +// if(StringUtil.isNotEmpty(orderRule)){ +// ruleMap.put("rule",orderRule); +// subMap.put("排序规则",ruleMap); +// }else{ +// String[] rules = {"全部设备","高清网络枪型固定摄像机","高清网络球形摄像机","桥下高清网络球形摄像机","360°全景摄像机","180°全景摄像机", +// "门架式可变信息标志","雨棚可变信息标志","站前悬臂式可变信息标志","气象检测器","路段语音广播系统","护栏碰撞预警系统","毫米波雷达", +// "合流区预警系统","激光疲劳唤醒","一类交通量调查站","智能行车诱导系统"}; +// orderRule= Arrays.toString(rules); +// ruleMap.put("rule",orderRule); +// subMap.put("排序规则",ruleMap); +// } return AjaxResult.success(subMap); } diff --git a/zc-business/src/main/java/com/zc/business/controller/WordController.java b/zc-business/src/main/java/com/zc/business/controller/WordController.java new file mode 100644 index 00000000..b2879914 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/controller/WordController.java @@ -0,0 +1,1050 @@ +package com.zc.business.controller; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.mapper.DcTrafficIncidentsMapper; +import com.zc.business.utils.PoiUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.xwpf.usermodel.*; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; + +import static com.zc.business.utils.PoiUtil.*; + +/** + * @Description 通行情况快报 + * + * @author liuwenge + * @date 2024/3/26 11:13 + */ +@Api(tags = "通行情况快报") +@RestController +@RequestMapping("/business/word") +public class WordController { + + @Autowired + private WeatherForecastController weatherForecastController; + @Autowired + private DcTrafficIncidentsMapper dcTrafficIncidentsMapper; + + + @PostMapping("/trafficSituationReport") + @ApiOperation("导出通行情况快报") + public void trafficSituationReport(HttpServletResponse response){ + try { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String date = df.format(new Date()); + String outputPath = RuoYiConfig.getDownloadPath() +"/济菏高速公路通行情况快报" + date + ".docx"; + // 读取Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/wordTemplate.docx"); + XWPFDocument newDoc = new XWPFDocument(inputStream); + + // 创建并插入带超链接的目录 + insertTOC(newDoc); + + + //换页 + XWPFParagraph breakPara = newDoc.createParagraph(); + breakPara.setAlignment(ParagraphAlignment.CENTER); + CTP ctP = breakPara.getCTP(); + CTR ctr = ctP.addNewR(); + CTBr ctBr = ctr.addNewBr(); + ctBr.setType(STBrType.PAGE); + + + + PoiUtil.createHeading1(newDoc,"总体情况"); + /** 天气情况统计 */ + weather(newDoc); + /** 交通管制情况 */ + trafficControl(newDoc); + /** 交通事故 */ + trafficAccident(newDoc); + /** 出入口车流量 */ + trafficFlow(newDoc); + + + + PoiUtil.createHeading1(newDoc,"收费站运行情况"); + /** 封闭原因统计 */ + trafficControlReasons(newDoc); + /** 封闭数量统计 */ + closedQuantity(newDoc); + PoiUtil.createHeading1(newDoc,"交通事故情况"); + /** 交通事故统计 */ + accidentType(newDoc); + + + PoiUtil.createHeading1(newDoc,"拥堵情况"); + /** 拥堵地点 */ + congestionLocation(newDoc); + /** 拥堵时长 */ + congestionDuration(newDoc); + /** 拥堵长度 */ + congestionMileage(newDoc); + + + + // 保存新生成的Word文件 +// FileOutputStream out = new FileOutputStream(outputPath); +// out.close(); + + // 不保存直接返回文件流 + newDoc.write(response.getOutputStream()); + + + // 关闭文档 + newDoc.close(); + System.out.println("生成通行情况快报成功!"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * @Description 天气情况统计 + * + * @author liuwenge + * @date 2024/3/26 15:39 + * @param + * @return void + */ + + public void weather(XWPFDocument doc) { + + PoiUtil.createHeading2(doc,"天气情况统计"); + + XWPFTable table = doc.createTable(9, 25); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + AjaxResult ajaxResult = weatherForecastController.hourlyWeather(); + if (ajaxResult.get("code").equals(200)) { + Map>> data = (Map>>) ajaxResult.get("data"); + data.keySet().forEach(key ->{ + if ("hourlyWeather1".equals(key)){ + setTableFonts(table.getRow(1).getCell(0), "长清区"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + OffsetDateTime offsetDateTime = OffsetDateTime.parse(weatherList.get(i).get("fxTime").toString()); + setTableFonts(table.getRow(0).getCell(i+1),offsetDateTime.format(DateTimeFormatter.ofPattern("dd日HH时"))); + setTableFonts(table.getRow(1).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather2".equals(key)){ + setTableFonts(table.getRow(2).getCell(0), "平阴县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(2).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather3".equals(key)){ + setTableFonts(table.getRow(3).getCell(0), "东平县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(3).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather4".equals(key)){ + setTableFonts(table.getRow(4).getCell(0), "汶上县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(4).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather5".equals(key)){ + setTableFonts(table.getRow(5).getCell(0), "梁山县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(5).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather6".equals(key)){ + setTableFonts(table.getRow(6).getCell(0), "嘉祥县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(6).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather7".equals(key)){ + setTableFonts(table.getRow(7).getCell(0), "巨野县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(7).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } else if ("hourlyWeather8".equals(key)){ + setTableFonts(table.getRow(8).getCell(0), "郓城县"); + List> weatherList = data.get(key); + for (int i = 0; i < weatherList.size(); i++) { + setTableFonts(table.getRow(8).getCell(i+1), weatherList.get(i).get("text").toString()); + } + } + }); + } + + //换行 + createLineBreak(doc); + + + } + + + /** + * @Description 交通管制情况 + * + * @author liuwenge + * @date 2024/3/26 17:36 + * @param doc + * @return void + */ + public void trafficControl(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "交通管制情况"); + + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + Calendar calendar = Calendar.getInstance(); + //将天至1 + calendar.set(Calendar.DAY_OF_MONTH, 1); + //将小时至0 + calendar.set(Calendar.HOUR_OF_DAY, 0); + //将分钟至0 + calendar.set(Calendar.MINUTE, 0); + //将秒至0 + calendar.set(Calendar.SECOND,0); + //将毫秒至0 + calendar.set(Calendar.MILLISECOND, 0); + //获得当前月第一天 + Date date = calendar.getTime(); + String startDate = dateFormat.format(date); + String endDate = dateFormat.format(new Date()); + + + List> tollStationAnalysisList = dcTrafficIncidentsMapper.selectTollStationAnalysisByFacility(null,startDate,endDate); + if (tollStationAnalysisList != null && tollStationAnalysisList.size() > 0) { + + XWPFTable table = doc.createTable(11, 4); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(1), "封闭"); + setTableFonts(table.getRow(0).getCell(2), "限行"); + setTableFonts(table.getRow(0).getCell(3), "间隔放行"); + + //excel + for (int i = 0; i < tollStationAnalysisList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), tollStationAnalysisList.get(i).get("facilityName").toString()); + setTableFonts(table.getRow(i+1).getCell(1), tollStationAnalysisList.get(i).get("facilityClose").toString()); + setTableFonts(table.getRow(i+1).getCell(2), tollStationAnalysisList.get(i).get("facilityRestriction").toString()); + setTableFonts(table.getRow(i+1).getCell(3), tollStationAnalysisList.get(i).get("facilityInterval").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(0); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"封闭","限行","间隔放行"}; + //分类信息 + for (int i = 0; i < tollStationAnalysisList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(tollStationAnalysisList.get(i).get("facilityName").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(tollStationAnalysisList.get(i).get("facilityClose").toString())); + sheet.getRow(i+1).getCell(2).setCellValue(Long.parseLong(tollStationAnalysisList.get(i).get("facilityRestriction").toString())); + sheet.getRow(i+1).getCell(3).setCellValue(Long.parseLong(tollStationAnalysisList.get(i).get("facilityInterval").toString())); + + } + PoiUtil.wordExportChar(chart, "交通管制情况", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + + } + + //换行 + createLineBreak(doc); + + + List> trafficControlAnalysisList = dcTrafficIncidentsMapper.selectTrafficControlAnalysis(startDate,endDate); + if (trafficControlAnalysisList != null && trafficControlAnalysisList.size() > 0) { + + XWPFTable table = doc.createTable(7, 4); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(1), "封闭"); + setTableFonts(table.getRow(0).getCell(2), "限行"); + setTableFonts(table.getRow(0).getCell(3), "间隔放行"); + + //excel + for (int i = 0; i < trafficControlAnalysisList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), trafficControlAnalysisList.get(i).get("controlCauseName").toString()); + setTableFonts(table.getRow(i+1).getCell(1), trafficControlAnalysisList.get(i).get("facilityClose").toString()); + setTableFonts(table.getRow(i+1).getCell(2), trafficControlAnalysisList.get(i).get("facilityRestriction").toString()); + setTableFonts(table.getRow(i+1).getCell(3), trafficControlAnalysisList.get(i).get("facilityInterval").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(0); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + //系列信息 + String[] singleBarSeriesNames = {"封闭","限行","间隔放行"}; + //分类信息 + for (int i = 0; i < trafficControlAnalysisList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(trafficControlAnalysisList.get(i).get("controlCauseName").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(trafficControlAnalysisList.get(i).get("facilityClose").toString())); + sheet.getRow(i+1).getCell(2).setCellValue(Long.parseLong(trafficControlAnalysisList.get(i).get("facilityRestriction").toString())); + sheet.getRow(i+1).getCell(3).setCellValue(Long.parseLong(trafficControlAnalysisList.get(i).get("facilityInterval").toString())); + } + for (int i = sheet.getLastRowNum(); i > trafficControlAnalysisList.size();i--){ + sheet.removeRow(sheet.getRow(i)); + } + + PoiUtil.wordExportChar(chart, "交通管制情况", singleBarSeriesNames,sheet ); + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + + } + + //换行 + createLineBreak(doc); + + } + + + /** + * @Description 交通事故 + * + * @author liuwenge + * @date 2024/3/27 20:06 + * @param doc + * @return void + */ + public void trafficAccident(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "交通事故"); + + + List> trafficAccidentList = dcTrafficIncidentsMapper.selectTrafficAccidentAnalysis(); + if (trafficAccidentList != null && trafficAccidentList.size() > 0) { + + XWPFTable table = doc.createTable(2, 4); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + + //表格插入总数 + setTableFonts(table.getRow(0).getCell(0), "事故数量"); + Long allNum = 0L; + for (Map map : trafficAccidentList) { + allNum += Long.parseLong(map.get("num").toString()); + } + setTableFonts(table.getRow(1).getCell(0), allNum.toString()); + + //excel + for (int i = 0; i < trafficAccidentList.size(); i++){ + setTableFonts(table.getRow(0).getCell(i+1), trafficAccidentList.get(i).get("eventStateLabel").toString()); + setTableFonts(table.getRow(1).getCell(i+1), trafficAccidentList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(1); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < trafficAccidentList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(trafficAccidentList.get(i).get("eventStateLabel").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(trafficAccidentList.get(i).get("num").toString())); + + } + for (int i = sheet.getLastRowNum(); i > trafficAccidentList.size();i--){ + sheet.removeRow(sheet.getRow(i)); + } + PoiUtil.wordExportChar(chart, "交通事故", singleBarSeriesNames,sheet ); + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + + } + + //换行 + createLineBreak(doc); + + + + } + + + /** + * @Description 出入口车流量 + * + * @author liuwenge + * @date 2024/3/28 9:14 + * @param doc + * @return void + */ + public void trafficFlow(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "出入口车流量"); + + + List> trafficFlowList = new ArrayList<>(); + Map trafficFlow = new HashMap<>(); + trafficFlow.put("label","入口"); + trafficFlow.put("num","0"); + trafficFlowList.add(trafficFlow); + + trafficFlow = new HashMap<>(); + trafficFlow.put("label","出口"); + trafficFlow.put("num","0"); + trafficFlowList.add(trafficFlow); + + if (trafficFlowList != null && trafficFlowList.size() > 0) { + + XWPFTable table = doc.createTable(2, 3); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + + //表格插入总数 + setTableFonts(table.getRow(0).getCell(0), "合计"); + Long allNum = 0L; + for (Map map : trafficFlowList) { + allNum += Long.parseLong(map.get("num").toString()); + } + setTableFonts(table.getRow(1).getCell(0), allNum.toString()); + + //excel + for (int i = 0; i < trafficFlowList.size(); i++){ + setTableFonts(table.getRow(0).getCell(i+1), trafficFlowList.get(i).get("label").toString()); + setTableFonts(table.getRow(1).getCell(i+1), trafficFlowList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(1); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < trafficFlowList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(trafficFlowList.get(i).get("label").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(trafficFlowList.get(i).get("num").toString())); + + } + for (int i = sheet.getLastRowNum(); i > trafficFlowList.size();i--){ + sheet.removeRow(sheet.getRow(i)); + } + PoiUtil.wordExportChar(chart, "出入口车流量", singleBarSeriesNames,sheet ); + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + + } + + //换行 + createLineBreak(doc); + + + } + + + /** + * @Description 封闭原因统计 + * + * @author liuwenge + * @date 2024/3/28 11:29 + * @param doc + * @return void + */ + public void trafficControlReasons(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "封闭原因统计"); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + //将天至1 + calendar.set(Calendar.DAY_OF_MONTH, 1); + //将小时至0 + calendar.set(Calendar.HOUR_OF_DAY, 0); + //将分钟至0 + calendar.set(Calendar.MINUTE, 0); + //将秒至0 + calendar.set(Calendar.SECOND,0); + //将毫秒至0 + calendar.set(Calendar.MILLISECOND, 0); + //获得当前月第一天 + Date date = calendar.getTime(); + String startDate = dateFormat.format(date); + String endDate = dateFormat.format(new Date()); + + + //封闭 + List> closeList = dcTrafficIncidentsMapper.selectTrafficControlReasons("1",startDate,endDate); + //限行 + List> restrictionList = dcTrafficIncidentsMapper.selectTrafficControlReasons("2",startDate,endDate); + + + + if (closeList != null && closeList.size() > 0 && restrictionList != null && restrictionList.size() > 0 ) { + + XWPFTable table = doc.createTable(13, 3); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(1), "封闭"); + setTableFonts(table.getRow(0).getCell(2), "限行"); + + //excel + for (int i = 0; i < closeList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), closeList.get(i).get("causeTypeName").toString()); + setTableFonts(table.getRow(i+1).getCell(1), closeList.get(i).get("num").toString()); + setTableFonts(table.getRow(i+1).getCell(2), restrictionList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(2); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"封闭","限行"}; + //分类信息 + for (int i = 0; i < closeList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(closeList.get(i).get("causeTypeName").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(closeList.get(i).get("num").toString())); + sheet.getRow(i+1).getCell(2).setCellValue(Long.parseLong(restrictionList.get(i).get("num").toString())); + + } + PoiUtil.wordExportChar(chart, "封闭原因统计", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + } + + + /** + * @Description 封闭数量统计 + * + * @author liuwenge + * @date 2024/3/28 11:29 + * @param doc + * @return void + */ + public void closedQuantity(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "封闭数量统计"); + + List> closedQuantityList = dcTrafficIncidentsMapper.selectClosedQuantity(); + + if (closedQuantityList != null && closedQuantityList.size() > 0) { + + XWPFTable table = doc.createTable(25, 2); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(0), "时间"); + setTableFonts(table.getRow(0).getCell(1), "数量"); + + //excel + for (int i = 0; i < closedQuantityList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), closedQuantityList.get(i).get("hours").toString()); + setTableFonts(table.getRow(i+1).getCell(1), closedQuantityList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(3); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < closedQuantityList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(closedQuantityList.get(i).get("hours").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(closedQuantityList.get(i).get("num").toString())); + + } + PoiUtil.wordExportChar(chart, "封闭数量统计", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + } + + + /** + * @Description 事故类型统计 + * + * @author liuwenge + * @date 2024/3/28 11:29 + * @param doc + * @return void + */ + public void accidentType(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "事故类型统计"); + + List> accidentTypeList = dcTrafficIncidentsMapper.selectAccidentTypeStatistics(); + + if (accidentTypeList != null && accidentTypeList.size() > 0) { + + XWPFTable table = doc.createTable(6, 2); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(0), "事故类型"); + setTableFonts(table.getRow(0).getCell(1), "数量"); + + //excel + for (int i = 0; i < accidentTypeList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), accidentTypeList.get(i).get("eventSubclassName").toString()); + setTableFonts(table.getRow(i+1).getCell(1), accidentTypeList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate2.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(0); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < accidentTypeList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(accidentTypeList.get(i).get("eventSubclassName").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(accidentTypeList.get(i).get("num").toString())); + + } + PoiUtil.wordExportChar(chart, "事故类型统计", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + + List> trafficAccidentsList = dcTrafficIncidentsMapper.selectTrafficAccidents(); + + if (trafficAccidentsList != null && trafficAccidentsList.size() > 0) { + + XWPFTable table = doc.createTable(25, 2); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(0), "时间"); + setTableFonts(table.getRow(0).getCell(1), "数量"); + + //excel + for (int i = 0; i < trafficAccidentsList.size(); i++){ + setTableFonts(table.getRow(i+1).getCell(0), trafficAccidentsList.get(i).get("hours").toString()); + setTableFonts(table.getRow(i+1).getCell(1), trafficAccidentsList.get(i).get("num").toString()); + } + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(3); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < trafficAccidentsList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(trafficAccidentsList.get(i).get("hours").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(trafficAccidentsList.get(i).get("num").toString())); + + } + PoiUtil.wordExportChar(chart, "事故时间统计", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + } + + + + + /** + * @Description 拥堵地点 + * + * @author liuwenge + * @date 2024/3/28 16:56 + * @param doc + * @return void + */ + public void congestionLocation(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "拥堵地点"); + + List> congestionLocationList = dcTrafficIncidentsMapper.selectCongestionLocation(); + + if (congestionLocationList != null && congestionLocationList.size() > 0) { + + XWPFTable table = doc.createTable(2, 5); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + //表格插入总数 + setTableFonts(table.getRow(0).getCell(0), "合计"); + Long allNum = 0L; + for (Map map : congestionLocationList) { + allNum += Long.parseLong(map.get("num").toString()); + } + setTableFonts(table.getRow(1).getCell(0), allNum.toString()); + + //excel + for (int i = 0; i < congestionLocationList.size(); i++){ + setTableFonts(table.getRow(0).getCell(i+1), congestionLocationList.get(i).get("eventSubclassLabel").toString()); + setTableFonts(table.getRow(1).getCell(i+1), congestionLocationList.get(i).get("num").toString()); + } + + + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(1); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < congestionLocationList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(congestionLocationList.get(i).get("eventSubclassLabel").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(congestionLocationList.get(i).get("num").toString())); + + } + for (int i = sheet.getLastRowNum(); i > congestionLocationList.size();i--){ + sheet.removeRow(sheet.getRow(i)); + } + PoiUtil.wordExportChar(chart, "拥堵地点", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + } + + /** + * @Description 拥堵时长 + * + * @author liuwenge + * @date 2024/3/28 17:27 + * @param doc + * @return void + */ + public void congestionDuration(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "拥堵时长"); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Calendar calendar = Calendar.getInstance(); + //将天至1 + calendar.set(Calendar.DAY_OF_MONTH, 1); + //将小时至0 + calendar.set(Calendar.HOUR_OF_DAY, 0); + //将分钟至0 + calendar.set(Calendar.MINUTE, 0); + //将秒至0 + calendar.set(Calendar.SECOND,0); + //将毫秒至0 + calendar.set(Calendar.MILLISECOND, 0); + //获得当前月第一天 + Date date = calendar.getTime(); + String startDate = dateFormat.format(date); + String endDate = dateFormat.format(new Date()); + + List> congestionDurationList = dcTrafficIncidentsMapper.selectCongestionDuration(startDate,endDate); + + if (congestionDurationList != null && congestionDurationList.size() > 0) { + + XWPFTable table = doc.createTable(2, 1); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(0), "合计"); + setTableFonts(table.getRow(1).getCell(0), congestionDurationList.get(0).get("minuteTime").toString()); + } + + //换行 + createLineBreak(doc); + } + + /** + * @Description 拥堵长度 + * + * @author liuwenge + * @date 2024/3/28 19:31 + * @param doc + * @return void + */ + public void congestionMileage(XWPFDocument doc) { + PoiUtil.createHeading2(doc, "拥堵长度"); + + List> congestionMileageList = dcTrafficIncidentsMapper.selectCongestionMileage(); + + if (congestionMileageList != null && congestionMileageList.size() > 0) { + + XWPFTable table = doc.createTable(2, 6); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + //表格插入总数 + setTableFonts(table.getRow(0).getCell(0), "合计"); + Long allNum = 0L; + for (Map map : congestionMileageList) { + allNum += Long.parseLong(map.get("num").toString()); + } + setTableFonts(table.getRow(1).getCell(0), allNum.toString()); + + //excel + for (int i = 0; i < congestionMileageList.size(); i++){ + setTableFonts(table.getRow(0).getCell(i+1), congestionMileageList.get(i).get("mileageType").toString()); + setTableFonts(table.getRow(1).getCell(i+1), congestionMileageList.get(i).get("num").toString()); + } + + + try { + + + // 复制Word模板 + InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("wordTemplate/chartTemplate.docx"); + XWPFDocument copiedTemplate = new XWPFDocument(inputStream); + + //获取word中所有图表对象 + List charts = copiedTemplate.getCharts(); + XWPFChart chart = charts.get(1); + XSSFWorkbook workbook = chart.getWorkbook(); + XSSFSheet sheet = workbook.getSheetAt(0); + + //系列信息 + String[] singleBarSeriesNames = {"数量"}; + //分类信息 + for (int i = 0; i < congestionMileageList.size(); i++){ + sheet.getRow(i+1).getCell(0).setCellValue(congestionMileageList.get(i).get("mileageType").toString()); + sheet.getRow(i+1).getCell(1).setCellValue(Long.parseLong(congestionMileageList.get(i).get("num").toString())); + + } + for (int i = sheet.getLastRowNum(); i > congestionMileageList.size();i--){ + sheet.removeRow(sheet.getRow(i)); + } + PoiUtil.wordExportChar(chart, "拥堵长度", singleBarSeriesNames,sheet ); + + + // 追加到同一个Word文档中 + mergeChart(chart,doc); +// PoiUtil.mergeDoc(copiedTemplate, doc); + + + // 关闭复制的模板文档 + copiedTemplate.close(); + + } catch (Exception e){ + e.printStackTrace(); + } + } + + //换行 + createLineBreak(doc); + } + +} diff --git a/zc-business/src/main/java/com/zc/business/domain/DcMeteorologicalDetectorData.java b/zc-business/src/main/java/com/zc/business/domain/DcMeteorologicalDetectorData.java index 627f5f12..2910e341 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcMeteorologicalDetectorData.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcMeteorologicalDetectorData.java @@ -1,5 +1,11 @@ package com.zc.business.domain; +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -11,231 +17,123 @@ import com.ruoyi.common.core.domain.BaseEntity; * @author ruoyi * @date 2024-02-01 */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiModel("气象检测器数据对象") public class DcMeteorologicalDetectorData extends BaseEntity { private static final long serialVersionUID = 1L; - + @ApiModelProperty("主键") /** 主键 */ private Long id; /** 物联设备id */ + @ApiModelProperty("物联设备id") @Excel(name = "物联设备id") private String iotDeviceId; /** 降雨量毫米 */ + @ApiModelProperty("降雨量毫米") + @Excel(name = "降雨量毫米") private String rainfall; /** 能见度类型 */ + @ApiModelProperty("能见度类型 4 表示能见度良好3表示阴霾 2表示雾 1表示浓雾") @Excel(name = "能见度类型") private String visibilityType; - /** 能见度 */ + @ApiModelProperty("能见度") @Excel(name = "能见度") private String visibility; /** 路面温度 */ + @ApiModelProperty("路面温度") + @Excel(name = "路面温度") private String remoteRoadSurfaceTemperature; /** 气压 */ + @ApiModelProperty("大气压力 单位hPa") + @Excel(name = "气压") private String atmosphericPressure; /** 降水类型 */ + @ApiModelProperty("降水类型 0=无降;1=雨;2=雪;3=毛毛雨;4=雨夹雪") + @Excel(name = "降水类型") private String precipitationType; /** 湿滑系数 */ + @ApiModelProperty("湿滑系数") + @Excel(name = "湿滑系数") private String wetSlipperyCoefficient; /** 气温 */ + @ApiModelProperty("气温") + @Excel(name = "气温") private String temperature; /** 湿度 */ @Excel(name = "湿度") - private String humidity; + @ApiModelProperty("湿度") + private String humidity; /** 风向 */ + @ApiModelProperty("风向") + @Excel(name = "风向") private String windDirection; + /** 风速 */ + @ApiModelProperty("风速 单位m/s") + @Excel(name = "风速") private String windSpeed; /** 路面状态 */ + @ApiModelProperty("路面状态 00=干燥,01=潮湿,02=积水,03=结冰,04=积雪,05=冰水混合物,06=泥泞") + @Excel(name = "路面状态") private String remoteRoadSurfaceStatus; /** 水膜厚度 */ + @ApiModelProperty("水膜厚度 单位mm") @Excel(name = "水膜厚度") private String waterFilmIceSnowValue; + @Excel(name = "设备名称") + @ApiModelProperty("设备名称") + + private String deviceName; + + @Excel(name = "桩号") + @ApiModelProperty("桩号") + private String stakeMark; + @ApiModelProperty("方向") + + @Excel(name = "方向") + private String direction; + @ApiModelProperty("状态") + @TableField(exist = false) + private String deviceState; +// "rainfall": 0, +// "visibility": "05.000", +// "remoteRoadSurfaceTemperature": 11.5, +// "atmosphericPressure:": 1008.8, +// "precipitationType": 0, +// "wetSlipperyCoefficient": 80, +// "temperature": 12.6, +// "humidity": 63.4, +// "windDirection": 358, +// "windSpeed": 1.5, +// "remoteRoadSurfaceStatus": "01", +// "visibilityType": 4, +// "waterFilmIceSnowValue": 0 - - - - - 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 setRainfall(String rainfall) - { - this.rainfall = rainfall; - } - - public String getRainfall() - { - return rainfall; - } - public void setVisibilityType(String visibilityType) - { - this.visibilityType = visibilityType; - } - - public String getVisibilityType() - { - return visibilityType; - } - public void setVisibility(String visibility) - { - this.visibility = visibility; - } - - public String getVisibility() - { - return visibility; - } - public void setAtmosphericPressure(String atmosphericPressure) - { - this.atmosphericPressure = atmosphericPressure; - } - - public String getAtmosphericPressure() - { - return atmosphericPressure; - } - public void setTemperature(String temperature) - { - this.temperature = temperature; - } - - public String getTemperature() - { - return temperature; - } - public void setHumidity(String humidity) - { - this.humidity = humidity; - } - - public String getHumidity() - { - return humidity; - } - public void setWindDirection(String windDirection) - { - this.windDirection = windDirection; - } - - public String getWindDirection() - { - return windDirection; - } - public void setWindSpeed(String windSpeed) - { - this.windSpeed = windSpeed; - } - - public String getWindSpeed() - { - return windSpeed; - } - - public void setPrecipitationType(String precipitationType) - { - this.precipitationType = precipitationType; - } - - public String getPrecipitationType() - { - return precipitationType; - } - public void setWetSlipperyCoefficient(String wetSlipperyCoefficient) - { - this.wetSlipperyCoefficient = wetSlipperyCoefficient; - } - - public String getWetSlipperyCoefficient() - { - return wetSlipperyCoefficient; - } - - public void setRemoteRoadSurfaceTemperature(String remoteRoadSurfaceTemperature) - { - this.remoteRoadSurfaceTemperature = remoteRoadSurfaceTemperature; - } - - public String getRemoteRoadSurfaceTemperature() - { - return remoteRoadSurfaceTemperature; - } - public void setRemoteRoadSurfaceStatus(String remoteRoadSurfaceStatus) - { - this.remoteRoadSurfaceStatus = remoteRoadSurfaceStatus; - } - - public String getRemoteRoadSurfaceStatus() - { - return remoteRoadSurfaceStatus; - } - - public void setWaterFilmIceSnowValue(String waterFilmIceSnowValue) - { - this.waterFilmIceSnowValue = waterFilmIceSnowValue; - } - - public String getWaterFilmIceSnowValue() - { - return waterFilmIceSnowValue; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("iotDeviceId", getIotDeviceId()) - .append("rainfall", getRainfall()) - .append("visibilityType", getVisibilityType()) - .append("visibility", getVisibility()) - .append("atmosphericPressure", getAtmosphericPressure()) - .append("temperature", getTemperature()) - .append("humidity", getHumidity()) - .append("windDirection", getWindDirection()) - .append("windSpeed", getWindSpeed()) - .append("precipitationType", getPrecipitationType()) - .append("wetSlipperyCoefficient", getWetSlipperyCoefficient()) - .append("remoteRoadSurfaceTemperature", getRemoteRoadSurfaceTemperature()) - .append("remoteRoadSurfaceStatus", getRemoteRoadSurfaceStatus()) - .append("waterFilmIceSnowValue", getWaterFilmIceSnowValue()) - .toString(); - } } diff --git a/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java b/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java index 123c57cd..8370ee64 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcStakeMark.java @@ -29,5 +29,7 @@ public class DcStakeMark { private Date updateTime; @ApiModelProperty("所属辖区") private Long sectionId; + @ApiModelProperty("桩号里程") + private Long mileage; } diff --git a/zc-business/src/main/java/com/zc/business/domain/Status.java b/zc-business/src/main/java/com/zc/business/domain/Status.java index 0ab2a5a6..5e7c74e7 100644 --- a/zc-business/src/main/java/com/zc/business/domain/Status.java +++ b/zc-business/src/main/java/com/zc/business/domain/Status.java @@ -125,7 +125,7 @@ public class Status { private Long deviceId; @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern ="yyyy-MM-dd HH:mm:ss") - @Excel(name = "监测时间", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "监测时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private LocalDateTime time; public String getSuccessRate() { @@ -208,7 +208,7 @@ public class Status { this.deviceId = deviceId; } - @Excel(name = "型号") + // @Excel(name = "型号") private String model; diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java index 7788b60e..ebbb2f0a 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcMeteorologicalDetectorDataMapper.java @@ -1,6 +1,8 @@ package com.zc.business.mapper; import java.util.List; +import java.util.Map; + import com.zc.business.domain.DcMeteorologicalDetectorData; import com.zc.business.domain.MdDeviceData; @@ -59,4 +61,8 @@ public interface DcMeteorologicalDetectorDataMapper * @return 结果 */ int deleteDcMeteorologicalDetectorDataByIds(Long[] ids); +//统计 + List> selectStatistics(String deviceName); + + List selectlistAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java index 448050c3..bc949499 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcStakeMarkMapper.java @@ -1,14 +1,21 @@ package com.zc.business.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.zc.business.domain.DcDevice; import com.zc.business.domain.DcStakeMark; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 桩号Mapper接口 * - * @author zhaoxianglong + * @author */ @Mapper public interface DcStakeMarkMapper extends BaseMapper { + + + boolean batchInsert(List dcStakeMarkList); + } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java index d01d8a09..dfaf12ee 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java @@ -236,4 +236,97 @@ public interface DcTrafficIncidentsMapper { */ List> selectEventTypeAnalysis(@Param("direction") String direction,@Param("type") String type,@Param("startTime") String startTime); + /** + * @Description 交通管制情况 + * + * @author liuwenge + * @date 2024/3/27 18:32 + * @param startTime + * @param endTime + * @return java.util.List> + */ + List> selectTrafficControlAnalysis(@Param("startTime") String startTime,@Param("endTime") String endTime); + + /** + * @Description 交通事故统计 + * + * @author liuwenge + * @date 2024/3/27 20:04 + * @param + * @return java.util.List> + */ + List> selectTrafficAccidentAnalysis(); + + /** + * @Description 封闭原因统计 + * + * @author liuwenge + * @date 2024/3/28 14:47 + * @param controlType + * @param startTime + * @param endTime + * @return java.util.List> + */ + List> selectTrafficControlReasons(@Param("controlType") String controlType,@Param("startTime") String startTime,@Param("endTime") String endTime); + + + /** + * @Description 封闭数量统计 + * + * @author liuwenge + * @date 2024/3/28 14:51 + * @param + * @return java.util.List> + */ + List> selectClosedQuantity(); + + /** + * @Description 事故类型统计--当月按类型 + * + * @author liuwenge + * @date 2024/3/28 15:19 + * @param + * @return java.util.List> + */ + List> selectAccidentTypeStatistics(); + + /** + * @Description 事故类型统计--当天按小时 + * + * @author liuwenge + * @date 2024/3/28 16:28 + * @param + * @return java.util.List> + */ + List> selectTrafficAccidents(); + + /** + * @Description 拥堵地点 + * + * @author liuwenge + * @date 2024/3/28 16:55 + * @param + * @return java.util.List> + */ + List> selectCongestionLocation(); + + /** + * @Description 拥堵时长 + * + * @author liuwenge + * @date 2024/3/28 17:23 + * @param + * @return java.util.List> + */ + List> selectCongestionDuration(@Param("startTime") String startTime,@Param("endTime") String endTime); + + /** + * @Description 拥堵长度 + * + * @author liuwenge + * @date 2024/3/28 19:30 + * @return java.util.List> + */ + List> selectCongestionMileage(); + } diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index 23ac63f9..ec36ba9f 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java @@ -378,16 +378,20 @@ public class DeviceMessageHandler { String direction = ""; if (Objects.equals(location, "0")) { dcWarning.setDirection("1"); - direction = "上行右侧"; + dcWarning.setLane("0"); + direction = "菏泽方向右侧护栏"; } else if (Objects.equals(location, "1")) { dcWarning.setDirection("1"); - direction = "上行左侧"; + dcWarning.setLane("1"); + direction = "菏泽方向左侧护栏"; } else if (Objects.equals(location, "10")) { dcWarning.setDirection("0"); - direction = "下行右侧"; + dcWarning.setLane("0"); + direction = "济南方向右侧护栏"; } else if (Objects.equals(location, "11")) { dcWarning.setDirection("0"); - direction = "下行左侧"; + dcWarning.setLane("1"); + direction = "济南方向左侧护栏"; } String eventType = ""; @@ -423,8 +427,11 @@ public class DeviceMessageHandler { dcWarning.setStakeMark(dcDevices.get(0).getStakeMark()); dcWarning.setWarningType(9); + dcWarning.setWarningSubclass("4"); + dcWarning.setWarningState(1); dcWarning.setCreateTime(new Date()); - dcWarning.setWarningTitle("护栏碰撞上报事件:区域号为" + areaCode + "在" + timeOfFireAlarming + direction + "发生" + eventType + "事件"); + dcWarning.setDirection("护栏碰撞上报事件:区域号为" + areaCode + "在20" + timeOfFireAlarming + direction + "发生" + eventType + "事件"); + dcWarning.setWarningTitle("护栏碰撞在20" + timeOfFireAlarming + direction + "发生" + eventType + "事件"); dcWarning.setOtherConfig(dataJsonObject.toJSONString()); dcWarningService.insertDcWarning(dcWarning); } @@ -438,7 +445,25 @@ public class DeviceMessageHandler { */ private void weatherDetectorMessageHandle(JSONObject msg) { - DcMeteorologicalDetectorData meteorologicalDetectorData = (DcMeteorologicalDetectorData) msg.get("properties"); + // DcMeteorologicalDetectorData meteorologicalDetectorData = (DcMeteorologicalDetectorData) msg.get("properties"); + JSONObject jsonObject = (JSONObject) msg.get("properties"); + DcMeteorologicalDetectorData meteorologicalDetectorData = jsonObject.toJavaObject(DcMeteorologicalDetectorData.class); + + + JSONObject jsonObjectHeaders = (JSONObject)msg.get("headers"); + String parts = jsonObjectHeaders.getString("deviceName"); + String[] strings = parts.split("-"); + String deviceName = strings[0]; + String stakeMark = strings[1]; + String direction = strings[2]; + + //设备名称 + meteorologicalDetectorData.setDeviceName(deviceName); + //位置 + meteorologicalDetectorData.setStakeMark(stakeMark); + //方向 + meteorologicalDetectorData.setDirection(direction); + meteorologicalDetectorData.setIotDeviceId(msg.get("deviceId").toString()); meteorologicalDetectorDataService.insertDcMeteorologicalDetectorData(meteorologicalDetectorData); diff --git a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java index 2ecea0a2..de8faf8e 100644 --- a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java +++ b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java @@ -65,6 +65,14 @@ public interface DcEmergencyPlansService { */ JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); + /** + * 根据事件id-查询预案事件关联表 + * + * @param eventId 事件id + * @return 结果 + */ + EventPlanAssoc selectEventPlanAssocByEventId(String eventId); + /** * 感知事件确定 * diff --git a/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java index 4832955c..929f5b67 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcMeteorologicalDetectorDataService.java @@ -1,6 +1,8 @@ package com.zc.business.service; import java.util.List; +import java.util.Map; + import com.zc.business.domain.DcMeteorologicalDetectorData; import com.zc.business.domain.MdDeviceData; @@ -59,4 +61,8 @@ public interface IDcMeteorologicalDetectorDataService * @return 结果 */ int deleteDcMeteorologicalDetectorDataById(Long id); +//统计当天 没小时温度 + List> selectStatistics(String deviceName); + + List selectlistAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java b/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java index 8390bd34..0131c4d2 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java @@ -2,8 +2,10 @@ package com.zc.business.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcStakeMark; +import java.io.IOException; import java.util.List; /** @@ -60,4 +62,13 @@ public interface IDcStakeMarkService extends IService { * @return 设备信息 */ DcStakeMark getStakeMark(String id); + + + /** + * 导入桩号 + * + * @param filePath json文件路径 + * @return + */ + AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java index c570691e..e837c5ea 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java @@ -30,6 +30,7 @@ import javax.annotation.Resource; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.CountDownLatch; import java.util.stream.Collectors; @Service @@ -225,12 +226,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { */ public Map> getBoardTemplate(List dcDevices) { Map> map = new HashMap<>(); + CountDownLatch latch = new CountDownLatch(dcDevices.size()); dcDevices.forEach(dcDevice -> { threadPoolTaskExecutor.execute(() -> { try { - if (StringUtils.isEmpty(dcDevice.getIotDeviceId())) { - return; - } + if (StringUtils.isNotEmpty(dcDevice.getIotDeviceId())){ AjaxResult ajaxResult = dcDeviceController.getDeviceRealtimeProperty(dcDevice.getIotDeviceId(), "3A", new HashMap<>()); if (ajaxResult.get("code").equals(200)) { JSONObject properties = JSON.parseObject(JSON.parseObject(ajaxResult.get("data").toString()).get("3A").toString()); @@ -263,12 +263,19 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { }); map.put(dcDevice.getDeviceName(), list); } + } } catch (Exception e) { e.printStackTrace(); + } finally { + latch.countDown(); // 确保在异常情况下也能减少CountDownLatch计数 } }); }); - + try { + latch.await(); // 等待所有线程执行完毕 + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } return map; } @@ -301,7 +308,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } else if (searchRule.equals(2)) { // 事件上游最近 - if (direction.equals("1")) { + if (direction.equals("菏泽方向")) { // 上行 取最大的几个 start.add("55"); start.add("379"); @@ -341,7 +348,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } else if (searchRule.equals(3)) { // 事件下游最近 - if (direction.equals("1")) { + if (direction.equals("菏泽方向")) { // 上行 取最大的几个 start.add(markArray[0]); start.add(markArray[1]); @@ -417,6 +424,18 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { return executionConfirmation(dcEventAnDcEmergencyPlans, dcEvent.getStakeMark(), direction, id); } + /** + * 根据事件id-查询预案事件关联表 + * @param eventId 事件id + * @return + */ + @Override + public EventPlanAssoc selectEventPlanAssocByEventId(String eventId) { + EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); + eventPlanAssoc.setEventId(eventId); + return eventPlanAssocMapper.selectByEventId(eventPlanAssoc); + } + /** * 感知事件-情报板自动生成 * @@ -577,17 +596,24 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); // 事件编号 eventPlanAssoc.setEventId(id); - + EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); // 区分是执行操作 还是 恢复操作 - if (dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { - // 事件预案编号 + if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && StringUtils.isEmpty(selectEventPlanAssoc.getId())) { + // 首次执行操作 eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId()); eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", "")); eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); - } else { - EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); + } + else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { + // 多次执行操作 + selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); + selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); + eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); + } + else { + // 恢复操作 未执行的事件不能进行恢复操作 selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", "")); selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); @@ -613,7 +639,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { iotDeviceId = device.getIotDeviceId(); HashMap props = new HashMap<>(); try { - if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE)) { + if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE.toString())) { // 行车诱导 functionId = DeviceFunctionIdConstants.DRIVING_GUIDANCE; // 控制模式 1-手动 2-自动 3-万年历 @@ -638,7 +664,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } - else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) { if (operationType == 1) { // 执行操作 @@ -714,7 +740,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } } - else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING.toString())) { // 路段广播 JSONObject params = new JSONObject(); params.put("name", "task-event"); @@ -735,7 +761,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } - else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) { // 激光疲劳唤醒 functionId = otherConfig.get("state").toString(); diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java index 56ed60eb..dd5d6468 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java @@ -1,9 +1,12 @@ package com.zc.business.service.impl; import java.util.List; +import java.util.Map; import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.SecurityUtils; import com.zc.business.domain.DcDevice; import com.zc.business.domain.MdDeviceData; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +27,7 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica @Autowired private DcMeteorologicalDetectorDataMapper dcMeteorologicalDetectorDataMapper; + /** * 查询气象检测器数据 * @@ -57,6 +61,7 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica @Override public int insertDcMeteorologicalDetectorData(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) { + dcMeteorologicalDetectorData.setCreateTime(DateUtils.getNowDate()); return dcMeteorologicalDetectorDataMapper.insertDcMeteorologicalDetectorData(dcMeteorologicalDetectorData); } @@ -95,4 +100,14 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica { return dcMeteorologicalDetectorDataMapper.deleteDcMeteorologicalDetectorDataById(id); } + + @Override + public List> selectStatistics(String deviceName) { + return dcMeteorologicalDetectorDataMapper.selectStatistics(deviceName); + } + + @Override + public List selectlistAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) { + return dcMeteorologicalDetectorDataMapper.selectlistAll(dcMeteorologicalDetectorData); + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java index 3dacb227..ae0d23b4 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java @@ -1,19 +1,26 @@ package com.zc.business.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.PageUtils; +import com.ruoyi.common.utils.StakeMarkUtils; +import com.zc.business.domain.DcRoadSection; import com.zc.business.domain.DcStakeMark; +import com.zc.business.mapper.DcRoadSectionMapper; import com.zc.business.mapper.DcStakeMarkMapper; import com.zc.business.service.IDcStakeMarkService; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import javax.annotation.Resource; +import java.io.*; +import java.util.*; +import java.util.regex.Pattern; /** * 桩号Service业务层处理 @@ -23,6 +30,10 @@ import java.util.Objects; @Service public class DcStakeMarkServiceImpl extends ServiceImpl implements IDcStakeMarkService { + @Resource + private DcStakeMarkMapper dcStakeMarkMapper; + @Resource + private DcRoadSectionMapper dcRoadSectionMapper; public LambdaQueryWrapper stakeMarkQueryWrapper(DcStakeMark dcStakeMark) { @@ -125,5 +136,84 @@ public class DcStakeMarkServiceImpl extends ServiceImpl> map = JSON.parseObject(jsonStr, new TypeReference>>() {}); + List stakeMarkList = new ArrayList<>(); + + List dcRoadSectionList = dcRoadSectionMapper.selectDcRoadSectionList(null); + + //桩号格式校验 + List errorKey = new ArrayList<>(); + map.keySet().forEach(key ->{ + if (!StakeMarkUtils.checkStakeMark(key)){ + errorKey.add(key); + } + DcStakeMark dcStakeMark = new DcStakeMark(); + dcStakeMark.setStakeMark(key); + + dcStakeMark.setLongitude(map.get(key).containsKey("lng") ? map.get(key).get("lng").toString() : ""); + dcStakeMark.setLatitude(map.get(key).containsKey("lat") ? map.get(key).get("lat").toString() : ""); + dcStakeMark.setDirection(direction); + + Long sectionId = getRoadSection(dcRoadSectionList,key); + dcStakeMark.setSectionId(sectionId); + dcStakeMark.setMileage(StakeMarkUtils.formatMetreLong(key)); + stakeMarkList.add(dcStakeMark); + }); + + if (errorKey.size() > 0){ + return AjaxResult.error("桩号格式错误",errorKey); + } + Date databaseStart = new Date(); + Long time = databaseStart.getTime() - methodStart.getTime(); + System.out.println("处理数据用时---------------------------------->" + time); + dcStakeMarkMapper.batchInsert(stakeMarkList); + + Long endTime = new Date().getTime() - databaseStart.getTime(); + System.out.println("导入数据库用时--------------------------------->" + endTime); + return AjaxResult.success(); + } + + private Long getRoadSection(List roadSectionList,String stakeMark){ + + if (roadSectionList == null || roadSectionList.size() < 1){ + return null; + } + Long metre = StakeMarkUtils.formatMetreLong(stakeMark); + for (DcRoadSection dcRoadSection : roadSectionList) { + Long startStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getStartStakeMark()); + Long endStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getEndStakeMark()); + if (metre >= startStakeMark && metre < endStakeMark){ + return dcRoadSection.getId(); + } + } + + return null; + + } + } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index 65648daf..0ad11a12 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -93,7 +93,138 @@ public class DcWarningServiceImpl implements IDcWarningService //设置事件Id UUID无下划线格式32 String uuid = IdUtils.fastSimpleUUID(); dcWarning.setId(uuid); - return dcWarningMapper.insertDcWarning(dcWarning); + if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null|| + StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){ + return 0; + } + String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略 + Map redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据 + if (redisWarningStrategy==null||redisWarningStrategy.size()==0){//如果缓存为空,查询数据重新加入缓存 + Map redisMap = new HashMap<>(); + List dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据 + for (DcWaringStrategy waringStrategy : dcWaringStrategies) { + String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString() + + waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key + JSONObject jsonObject = new JSONObject(); + jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式 + jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟 + jsonObject.put("priority", waringStrategy.getPriority());//优先级 + redisMap.put(key, jsonObject); + } + redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中 + redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置 + } + String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource(). + toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型) + String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值) + HashMap redisValueOne = redisWarningStrategy.get(redisKye+"1");//查看传入的事件类型是否配置策略1(优先级策略) + if(redisValueOne!=null){//执行策略1(暂时未定义,定义后开发) + return dcWarningMapper.insertDcWarning(dcWarning);//未定义直接走新增; + } + HashMap redisValueTwo = redisWarningStrategy.get(redisKye+"2");//查看传入的事件类型是否配置策略2(延迟策略) + if (redisValueOne==null&&redisValueTwo!=null){ //执行策略2,执行到这里说明1不存在或者1未满足过滤条件 + String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长 + if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间 + int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + return 1;//结束 + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis + redisCache.deleteObject(WARNINGDATA+key); + dcWarningMapper.insertDcWarning(dcWarning); + String id = dcWarning.getId(); + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES); + return 1; + } + String otherConfig=""; + if (map.get("otherConfig")!=null){ + otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息 + } + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成新的json + JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo); + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间 + if (integer==0){ + return 0; + } + return 1; + } + HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略) + if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件 + String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长 + if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间 + int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + return 1;//结束 + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis + redisCache.deleteObject(WARNINGDATA+key); + dcWarningMapper.insertDcWarning(dcWarning); + String id = dcWarning.getId(); + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES); + return 1; + } + String otherConfig=""; + otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + if (integer==0){ + return 0; + } + return 1; + } + HashMap redisValueFour = redisWarningStrategy.get(redisKye+"4");//查看传入的事件类型是否配置策略3(自动结束策略) + if (redisValueOne==null&&redisValueTwo==null&&redisValueThree==null&&redisValueFour!=null){ //执行策略4,执行到这里说明1不存在或者2、3不存在或者1未满足过滤条件 + if (dataId==null){//如果不存在直接加入数据库,加入缓存 + int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库 + if (insertDcWarning==0){ + return 0; + } + String id = dcWarning.getId();//取出加入后的id作为value + redisCache.setCacheObject(WARNINGDATA+key,id,24,TimeUnit.HOURS);//加入缓存,防止redis数据累计,这里也要设置过期时间,设置为24小时 + return 1;//结束 + } + //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置 + HashMap map = dcWarningMapper.selectDcWarningById(dataId); + if (map==null){//redis中有id但是数据库中没有这条数据,那就删除这条redis数据,新数据加入到数据库,并加入到redis + redisCache.deleteObject(WARNINGDATA+key); + dcWarningMapper.insertDcWarning(dcWarning); + String id = dcWarning.getId(); + redisCache.setCacheObject(WARNINGDATA+key,id); + return 1; + } + String otherConfig=""; + otherConfig = map.get("otherConfig").toString();//取出原id的配置信息 + String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息 + JSONObject jsonObjectOne = new JSONObject(otherConfig); + JSONObject jsonObjectTwo = new JSONObject(otherConfigString); + JSONObject jsonObject = new DcWarningServiceImpl().mergeJsonObjects(jsonObjectOne, jsonObjectTwo);//合成新的json + Integer integer = dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString());//修改数据库配置 + redisCache.deleteObject(WARNINGDATA + key);//删除redis存储的数据 + if (integer==0){ + return 0; + } + return 1; + } + return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库; } @@ -170,13 +301,14 @@ public class DcWarningServiceImpl implements IDcWarningService } HashMap redisValueThree = redisWarningStrategy.get(redisKye+"3");//查看传入的事件类型是否配置策略3(时间窗口策略) if (redisValueOne==null&&redisValueTwo==null&&redisValueThree!=null){ //执行策略3,执行到这里说明1不存在或者2不存在或者1未满足过滤条件 - if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间(30分钟) + String strategyTime = redisValueThree.get("strategyTime").toString();//策略时长 + if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的过期时间 int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库 if (insertDcWarning==0){ return 0; } String id = dcWarning.getId();//取出加入后的id作为value - redisCache.setCacheObject(WARNINGDATA+key,id,30,TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟) return 1;//结束 } //redis存在数据,取出redis的id找对对应事件的配置,合成事件配置 @@ -185,7 +317,7 @@ public class DcWarningServiceImpl implements IDcWarningService redisCache.deleteObject(WARNINGDATA+key); dcWarningMapper.insertDcWarning(dcWarning); String id = dcWarning.getId(); - redisCache.setCacheObject(WARNINGDATA+key,id,30,TimeUnit.MINUTES); + redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES); return 1; } String otherConfig=""; diff --git a/zc-business/src/main/java/com/zc/business/utils/PoiUtil.java b/zc-business/src/main/java/com/zc/business/utils/PoiUtil.java new file mode 100644 index 00000000..e799f2ef --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/utils/PoiUtil.java @@ -0,0 +1,369 @@ +package com.zc.business.utils; + +import com.aliyuncs.utils.IOUtils; +import com.google.common.base.Strings; +import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xddf.usermodel.chart.XDDFChartData; +import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; +import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; +import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xwpf.usermodel.*; +import org.apache.xmlbeans.XmlOptions; +import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea; +import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; +import org.springframework.util.StringUtils; + +import java.io.*; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author : LCheng + * @date : 2020-12-10 10:03 + * description : poi工具 + */ +public class PoiUtil { + + public static int headingCount1 = 1; + public static int headingCount2 = 1; + + /** + * 根据word模板导出 针对图表(柱状图,折线图,饼图等)的处理 + * + * @param docChart 图表对象 + * @param title 图表标题 + * @param seriesNames 系列名称数组 + * @return {@link XWPFChart} + * @author LCheng + * @date 2020/12/10 11:08 + */ + public static XWPFChart wordExportChar(XWPFChart docChart, String title, String[] seriesNames, XSSFSheet sheet) { + //获取图表数据对象 + XDDFChartData chartData = docChart.getChartSeries().get(0); + + //word图表均对应一个内置的excel,用于保存图表对应的数据 + //excel中 第一列第二行开始的数据为分类信息 + //CellRangeAddress(1, categories.size(), 0, 0) 四个参数依次为 起始行 截止行 起始列 截止列。 + //根据分类信息的范围创建分类信息的数据源 + XDDFDataSource catDataSource = XDDFDataSourcesFactory.fromStringCellRange(sheet, new CellRangeAddress(1,sheet.getLastRowNum(),0,0)); + //更新数据 + for (int i = 0; i < seriesNames.length; i++) { + //excel中各系列对应的数据的范围 + //根据数据的范围创建值的数据源 + XDDFNumericalDataSource valDataSource = XDDFDataSourcesFactory.fromNumericCellRange(sheet, new CellRangeAddress(1,sheet.getLastRowNum(),i+1,i+1)); + //获取图表系列的数据对象 + XDDFChartData.Series series = chartData.getSeries().get(i); + //替换系列数据对象中的分类和值 + series.replaceData(catDataSource, valDataSource); + //修改系列数据对象中的标题 + CellReference cellReference = docChart.setSheetTitle(seriesNames[i], 1); + series.setTitle(seriesNames[i], cellReference); + } + //更新图表数据对象 + docChart.plot(chartData); + //图表整体的标题 传空值则不替换标题 + if (!Strings.isNullOrEmpty(title)) { + docChart.setTitleText(title); + docChart.setTitleOverlay(false); + } + return docChart; + } + + /** + * 合并docx文件 + * @param srcDocxs 需要合并的目标docx文件 + * @param destDocx 合并后的docx输出文件 + */ + public static void mergeDoc(XWPFDocument srcDocxs, XWPFDocument destDocx) { + + + try { + + //获取目标文件的CTDocument1对象 + CTDocument1 ctDocument1 = srcDocxs.getDocument(); + //获取第一个目标文件的CTBody对象 + CTBody src1Body = ctDocument1.getBody(); + + + //获取目标文件中的图表 + List relations = srcDocxs.getCharts(); + //判断是否有图表,没有图表的话,追加到之前的目标文件后面 + if (relations.size() <= 0) { + CTBody src2Body = srcDocxs.getDocument().getBody(); + //获取目标文件中的图片 + List allPictures = srcDocxs.getAllPictures(); + // 记录图片合并前及合并后的ID + Map map = new HashMap(); + //遍历图片 + for (XWPFPictureData picture : allPictures) { + String before = srcDocxs.getRelationId(picture); + //将原文档中的图片加入到目标文档中 + String after = destDocx.addPictureData(picture.getData(), Document.PICTURE_TYPE_PNG); + map.put(before, after); + } + //将当前文件的内容追加到之前的目标文件中 + appendBody(src1Body, src2Body,map); + } + //遍历图表, + for (XWPFChart chart1 : relations) { + //是否是word中自带图表 + if (chart1 instanceof XWPFChart) { // 如果是图表元素 + XWPFChart chart = destDocx.createChart(5774310, 3076575); + CTPlotArea plotArea = chart1.getCTChart().getPlotArea(); + chart.getCTChart().setPlotArea(plotArea); + chart.getCTChart().setLegend(chart1.getCTChart().getLegend()); + } + } + //关闭流 + srcDocxs.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + /** + * 合并chart + * @param chart 需要合并的目标chart + * @param destDocx 合并后的docx输出文件 + */ + public static void mergeChart(XWPFChart chart, XWPFDocument destDocx) { + try { + + XWPFChart docxChart = destDocx.createChart(5774310, 3076575); + CTPlotArea plotArea = chart.getCTChart().getPlotArea(); + docxChart.getCTChart().setPlotArea(plotArea); + docxChart.getCTChart().setLegend(chart.getCTChart().getLegend()); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 插入换行符 + * @param destDocx 合并后的docx输出文件 + */ + public static void createLineBreak(XWPFDocument destDocx) { + try { + + XWPFParagraph paragraph = destDocx.createParagraph(); + XWPFRun run = paragraph.createRun(); + run.addBreak(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + /** + * 合并文档内容 + * + * @param src 目标文档 + * @param append 要合并的文档 + * @throws Exception + */ + private static void appendBody(CTBody src, CTBody append,Map map) throws Exception { + XmlOptions optionsOuter = new XmlOptions(); + optionsOuter.setSaveOuter(); + //获取目标文件的字符内容 + String srcString = src.xmlText(); + //获取目标文件字符的开头 + String prefix = srcString.substring(0, srcString.indexOf(">") + 1); + //获取目标文件字符的内容 + String mainPart = srcString.substring(srcString.indexOf(">") + 1, + srcString.lastIndexOf("<")); + //获取目标文件字符的结尾 + String sufix = srcString.substring(srcString.lastIndexOf("<")); + //获取需要追加的文件 + String appendString = append.xmlText(optionsOuter); + //获取需要追加的文件内容(除去头和尾) + String addPart = appendString.substring(appendString.indexOf(">") + 1, + appendString.lastIndexOf("<")); + if (map != null && !map.isEmpty()) { + //对xml字符串中图片ID进行替换 + for (Map.Entry set : map.entrySet()) { + addPart = addPart.replace(set.getKey(), set.getValue()); + } + } + //将获取到的文件内容合并成为新的CTBody + CTBody makeBody = CTBody.Factory.parse(prefix + mainPart + addPart + + sufix); + //将新的CTBody重新设置到目标文件中 + src.set(makeBody); + } + + public static XWPFParagraph createHeading(XWPFDocument doc, String title) { + //段落 + XWPFParagraph paragraph = doc.createParagraph(); + XWPFRun run = paragraph.createRun(); + run.setText(title); +// run.setColor("696969"); + run.setFontSize(18); + run.setBold(true);//标题加粗 + return paragraph; + } + + /** + * 创建标题1 + * + * @param doc + * @param title + */ + public static void createHeading1(XWPFDocument doc, String title) { + //段落 + XWPFParagraph paragraph = doc.createParagraph(); + XWPFRun run = paragraph.createRun(); + run.setText(title); +// run.setColor("696969"); + run.setFontSize(16); + run.setBold(true);//标题加粗 + paragraph.setStyle("Heading1"); + } + + /** + * 创建标题2 + * + * @param doc + * @param title + */ + public static void createHeading2(XWPFDocument doc, String title) { + XWPFParagraph paragraph = doc.createParagraph(); + XWPFRun run = paragraph.createRun(); + run.setText(title); + run.setFontSize(14); + run.setBold(true);//标题加粗 + paragraph.setStyle("Heading2"); + } + + public static void createTable(XWPFDocument doc) { + XWPFTable table = doc.createTable(3, 3); + //列宽自动分割 + CTTblWidth infoTableWidth = table.getCTTbl().addNewTblPr().addNewTblW(); + infoTableWidth.setType(STTblWidth.DXA); + infoTableWidth.setW(BigInteger.valueOf(9072)); + + setTableFonts(table.getRow(0).getCell(0), "编号"); + setTableFonts(table.getRow(0).getCell(1), "问题"); + setTableFonts(table.getRow(0).getCell(2), "应答"); + setTableFonts(table.getRow(1).getCell(0), "1"); + setTableFonts(table.getRow(1).getCell(1), "陈述日期"); + setTableFonts(table.getRow(1).getCell(2), "2017年02月17日"); + setTableFonts(table.getRow(2).getCell(0), "2"); + setTableFonts(table.getRow(2).getCell(1), "PICS序列号"); + setTableFonts(table.getRow(2).getCell(2), "121313132131"); + + } + + // word跨列合并单元格 + public static void mergeCellsHorizontal(XWPFTable table, int row, int fromCell, int toCell) { + for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) { + XWPFTableCell cell = table.getRow(row).getCell(cellIndex); + if (cellIndex == fromCell) { + // The first merged cell is set with RESTART merge value + cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART); + } else { + // Cells which join (merge) the first one, are set with CONTINUE + cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE); + } + } + } + + // word跨行并单元格 + public static void mergeCellsVertically(XWPFTable table, int col, int fromRow, int toRow) { + for (int rowIndex = fromRow; rowIndex <= toRow; rowIndex++) { + XWPFTableCell cell = table.getRow(rowIndex).getCell(col); + if (rowIndex == fromRow) { + // The first merged cell is set with RESTART merge value + cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.RESTART); + } else { + // Cells which join (merge) the first one, are set with CONTINUE + cell.getCTTc().addNewTcPr().addNewVMerge().setVal(STMerge.CONTINUE); + } + } + } + + /** + * 设置表格中字体 + * + * @param cell + * @param cellText + */ + public static void setTableFonts(XWPFTableCell cell, String cellText) { + CTP ctp = CTP.Factory.newInstance(); + XWPFParagraph p = new XWPFParagraph(ctp, cell); + p.setAlignment(ParagraphAlignment.CENTER); + XWPFRun run = p.createRun(); + run.setFontSize(8); + run.setText(cellText); + CTRPr rpr = run.getCTR().isSetRPr() ? run.getCTR().getRPr() : run.getCTR().addNewRPr(); + CTFonts fonts = rpr.isSetRFonts() ? rpr.getRFonts() : rpr.addNewRFonts(); + fonts.setAscii("仿宋"); + fonts.setEastAsia("仿宋"); + fonts.setHAnsi("仿宋"); + cell.setParagraph(p); + } + + /** + * 添加描述信息 + * + * @param doc + * @param description + */ + public static void addDescription(XWPFDocument doc, String description) { + if (StringUtils.isEmpty(description)) { + return; + } + XWPFParagraph title = doc.createParagraph(); + XWPFRun run = title.createRun(); + run.setText(description); + run.setBold(true); + title.setAlignment(ParagraphAlignment.CENTER); + } + + /** + * 创建目录 + * 创建并插入带超链接的目录 + * @param document + */ + public static void insertTOC2(XWPFDocument document) { + // 定义 TOC 字段属性 + CTSimpleField tocField = CTSimpleField.Factory.newInstance(); + tocField.setInstr("TOC \\h \\z \\t \"Heading1,Heading2\""); // 包含 Heading1 和 Heading2 样式的目录 + + // 创建包含 TOC 字段的段落 + XWPFParagraph tocPara = document.createParagraph(); + tocPara.getCTP().addNewFldSimple().set(tocField); + + // 更新文档字段以计算目录 + document.enforceUpdateFields(); + } + + /** + * 创建目录 + * 创建并插入带超链接的目录 + * @param document + */ + public static void insertTOC(XWPFDocument document) { + // 创建目录所在的段落 + XWPFParagraph tocPara = document.createParagraph(); + + + // 添加 TOC 域代码 + String tocFieldCode = "TOC \\o \"1-3\" \\h \\z \\u"; + CTSimpleField tocField = tocPara.getCTP().addNewFldSimple(); + tocField.setInstr(tocFieldCode); + tocField.setDirty(STOnOff.TRUE); + } +} + diff --git a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml index 88e7f843..df208d4b 100644 --- a/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml @@ -4,59 +4,57 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - - - - - - - + + + + + + + + + + - - select id, iot_device_id, rainfall, visibility_type, visibility, road_surface_status, atmospheric_pressure, temperature, humidity, wind_direction, wind_speed, freezing_point_temperature, salinity_value, road_surface_temperature, water_film_thickness, precipitation_type, wet_slippery_coefficient, sensor_temperature, remote_road_surface_temperature, remote_road_surface_status, sub_surface_temperature, water_film_ice_snow_value,create_time from dc_meteorological_detector_data + select id, iot_device_id, rainfall, visibility_type, visibility, atmospheric_pressure, temperature, humidity, wind_direction, wind_speed, precipitation_type, wet_slippery_coefficient,remote_road_surface_temperature, remote_road_surface_status, water_film_ice_snow_value,create_time,stake_mark,device_name,direction from dc_meteorological_detector_data - and iot_device_id = #{iotDeviceId} + and direction = #{direction} + and stake_mark = #{stakeMark} + and device_name = #{deviceName} and rainfall = #{rainfall} and visibility_type = #{visibilityType} and visibility = #{visibility} - and road_surface_status = #{roadSurfaceStatus} and atmospheric_pressure = #{atmosphericPressure} and temperature = #{temperature} and humidity = #{humidity} and wind_direction = #{windDirection} and wind_speed = #{windSpeed} - and freezing_point_temperature = #{freezingPointTemperature} - and salinity_value = #{salinityValue} - and road_surface_temperature = #{roadSurfaceTemperature} - and water_film_thickness = #{waterFilmThickness} and precipitation_type = #{precipitationType} and wet_slippery_coefficient = #{wetSlipperyCoefficient} - and sensor_temperature = #{sensorTemperature} and remote_road_surface_temperature = #{remoteRoadSurfaceTemperature} and remote_road_surface_status = #{remoteRoadSurfaceStatus} - and sub_surface_temperature = #{subSurfaceTemperature} and water_film_ice_snow_value = #{waterFilmIceSnowValue} @@ -66,81 +64,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + insert into dc_meteorological_detector_data iot_device_id, + direction, + stake_mark, + device_name, rainfall, visibility_type, visibility, - road_surface_status, atmospheric_pressure, temperature, humidity, wind_direction, wind_speed, - freezing_point_temperature, - salinity_value, - road_surface_temperature, - water_film_thickness, precipitation_type, wet_slippery_coefficient, - sensor_temperature, remote_road_surface_temperature, remote_road_surface_status, - sub_surface_temperature, water_film_ice_snow_value, create_time #{iotDeviceId}, + #{direction}, + #{stakeMark}, + #{deviceName}, #{rainfall}, #{visibilityType}, #{visibility}, - #{roadSurfaceStatus}, #{atmosphericPressure}, #{temperature}, #{humidity}, #{windDirection}, #{windSpeed}, - #{freezingPointTemperature}, - #{salinityValue}, - #{roadSurfaceTemperature}, - #{waterFilmThickness}, #{precipitationType}, #{wetSlipperyCoefficient}, - #{sensorTemperature}, #{remoteRoadSurfaceTemperature}, #{remoteRoadSurfaceStatus}, - #{subSurfaceTemperature}, #{waterFilmIceSnowValue}, - current_date + CURRENT_TIMESTAMP - + update dc_meteorological_detector_data iot_device_id = #{iotDeviceId}, + iot_device_id = #{direction}, + device_name = #{deviceName}, + stake_mark = #{stakeMark}, rainfall = #{rainfall}, visibility_type = #{visibilityType}, visibility = #{visibility}, - road_surface_status = #{roadSurfaceStatus}, atmospheric_pressure = #{atmosphericPressure}, temperature = #{temperature}, humidity = #{humidity}, wind_direction = #{windDirection}, wind_speed = #{windSpeed}, - freezing_point_temperature = #{freezingPointTemperature}, - salinity_value = #{salinityValue}, - road_surface_temperature = #{roadSurfaceTemperature}, - water_film_thickness = #{waterFilmThickness}, precipitation_type = #{precipitationType}, wet_slippery_coefficient = #{wetSlipperyCoefficient}, - sensor_temperature = #{sensorTemperature}, remote_road_surface_temperature = #{remoteRoadSurfaceTemperature}, remote_road_surface_status = #{remoteRoadSurfaceStatus}, - sub_surface_temperature = #{subSurfaceTemperature}, water_film_ice_snow_value = #{waterFilmIceSnowValue}, where id = #{id} @@ -156,4 +142,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + \ No newline at end of file diff --git a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml index 3b372a0b..db76147b 100644 --- a/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml @@ -38,7 +38,8 @@ left JOIN dc_stake_mark AS mark ON mark.stake_mark=warning.stake_mark and mark.direction=warning.direction left join dc_facility as facility on facility.stake_mark=warning.stake_mark - warning.warning_source !=6 + and warning.warning_source !=6 + and warning.warning_source = #{warningSource} and warning.warning_state = #{warningState} and warning.warning_type = #{warningType} and warning.warning_subclass = #{warningSubclass} @@ -451,7 +452,7 @@ SELECT '2-1' AS warning_subclass, '行人' AS subclass UNION ALL SELECT '6-4' AS warning_subclass, '抛洒物' AS subclass UNION ALL SELECT '5-6' AS warning_subclass, '变道' AS subclass UNION ALL - SELECT '99-1' AS warning_subclass, '机占非' AS subclass UNION ALL + SELECT '99-1' AS warning_subclass, '其它' AS subclass UNION ALL SELECT '6-3' AS warning_subclass, '路障' AS subclass UNION ALL SELECT '7-1' AS warning_subclass, '施工' AS subclass UNION ALL SELECT '4-10' AS warning_subclass, '停车' AS subclass UNION ALL diff --git a/zc-business/src/main/resources/mapper/business/DcStakeMarkMapper.xml b/zc-business/src/main/resources/mapper/business/DcStakeMarkMapper.xml new file mode 100644 index 00000000..62cb4d6d --- /dev/null +++ b/zc-business/src/main/resources/mapper/business/DcStakeMarkMapper.xml @@ -0,0 +1,41 @@ + + + + + + + + insert into dc_stake_mark + + stake_mark, + longitude, + latitude, + direction, + section_id, + mileage, + create_time, + + + #{dcStakeMark.stakeMark}, + #{dcStakeMark.longitude}, + #{dcStakeMark.latitude}, + #{dcStakeMark.direction}, + #{dcStakeMark.sectionId}, + #{dcStakeMark.mileage}, + now(), + + ON DUPLICATE KEY UPDATE + + stake_mark = #{dcStakeMark.stakeMark}, + longitude = #{dcStakeMark.longitude}, + latitude = #{dcStakeMark.latitude}, + direction = #{dcStakeMark.direction}, + section_id = #{dcStakeMark.sectionId}, + mileage = #{dcStakeMark.mileage}, + update_time = now(), + + + + diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml index 46746935..ce150537 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml @@ -398,4 +398,233 @@ group by event_subclass) t3 on t1.eventSubclass = t3.event_subclass + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml index 21aff783..9aa85077 100644 --- a/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcWarningMapper.xml @@ -70,15 +70,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -162,7 +182,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update dc_warning set other_config=#{otherConfig} where id=#{id} + update dc_warning set other_config=#{otherConfig},update_time=now() where id=#{id} diff --git a/zc-business/src/main/resources/mapper/business/StatusMapper.xml b/zc-business/src/main/resources/mapper/business/StatusMapper.xml index 9cf01288..388f6b57 100644 --- a/zc-business/src/main/resources/mapper/business/StatusMapper.xml +++ b/zc-business/src/main/resources/mapper/business/StatusMapper.xml @@ -96,9 +96,9 @@ ELSE '双向' END AS direction, CASE - WHEN s.device_status = 1 THEN '正常' - WHEN s.device_status = 0 THEN '异常' - ELSE '双向' + WHEN s.device_status = 1 THEN '在线' + WHEN s.device_status = 0 THEN '离线' + ELSE '设备未接入' END AS device_status from dc_device d LEFT JOIN status s on (s.device_id = d.id) diff --git a/zc-business/src/main/resources/wordTemplate/chartTemplate.docx b/zc-business/src/main/resources/wordTemplate/chartTemplate.docx new file mode 100644 index 00000000..2f9a8f65 Binary files /dev/null and b/zc-business/src/main/resources/wordTemplate/chartTemplate.docx differ diff --git a/zc-business/src/main/resources/wordTemplate/chartTemplate2.docx b/zc-business/src/main/resources/wordTemplate/chartTemplate2.docx new file mode 100644 index 00000000..c0a398ea Binary files /dev/null and b/zc-business/src/main/resources/wordTemplate/chartTemplate2.docx differ diff --git a/zc-business/src/main/resources/wordTemplate/wordTemplate.docx b/zc-business/src/main/resources/wordTemplate/wordTemplate.docx new file mode 100644 index 00000000..5c48a30b Binary files /dev/null and b/zc-business/src/main/resources/wordTemplate/wordTemplate.docx differ