ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/resources/application-dev.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/resources/application-prod.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/resources/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
@@ -55,7 +55,7 @@ /** * 更新点位信息 * * @param point * @param pointList */ int updatePoint(@Param("point") YwPoint point); int updatePoint(List<YwPoint> pointList); } ycl-server/src/main/java/com/ycl/platform/service/impl/WorkOrderServiceImpl.java
@@ -28,7 +28,10 @@ import com.ycl.platform.wvp.WVPResult; import com.ycl.system.Result; import com.ycl.system.domain.SysConfig; import com.ycl.system.entity.SysDictData; import com.ycl.system.mapper.SysConfigMapper; import com.ycl.system.mapper.SysDictDataMapper; import com.ycl.system.mapper.SysDictTypeMapper; import com.ycl.system.model.LoginUser; import com.ycl.system.page.PageUtil; import com.ycl.utils.DateUtils; @@ -84,6 +87,7 @@ private final SysConfigMapper configMapper; private final ServerConfig serverConfig; private final ReportMapper reportMapper; private final SysDictDataMapper dictDataMapper; @Value("${rtsp.server:http://127.0.0.1:7788}") private String rtspServer; @@ -118,16 +122,31 @@ for (WorkOrder workOrder : workOrderList) { WorkOrder databaseWorkOrder = mapping.get(workOrder.getSerialNumber()); if (Objects.nonNull(databaseWorkOrder)) { List<WorkOrderErrorType> workOrderErrorTypeList = new LambdaQueryChainWrapper<>(workOrderErrorTypeMapper) .select(WorkOrderErrorType::getErrorName) .eq(WorkOrderErrorType::getWorkOrderNo, workOrder.getWorkOrderNo()) .list(); List<String> errorNameList = workOrderErrorTypeList.stream().map(WorkOrderErrorType::getErrorName).collect(Collectors.toList()); String errorType = databaseWorkOrder.getErrorType(); if (workOrder.getErrorType().equals(errorType)) { if (errorNameList.contains(errorType)) { // 如果,国标码、故障类型都一样,则跳过不处理 continue; } else { // 错误类型不一样,就更新错误类型,并且重置工单状态为待处理 errorType = errorType + "," + workOrder.getErrorType(); databaseWorkOrder.setErrorType(errorType); databaseWorkOrder.setStatus(WorkOrderStatusEnum.DISTRIBUTED); // 错误类型不一样,就新增一个错误类型,并且重置工单状态为待处理 List<SysDictData> errorTypeDictList = dictDataMapper.selectDictDataByType("error_type"); String finalErrorType = errorType; List<SysDictData> targetErrorTypes = errorTypeDictList.stream().filter(item -> finalErrorType.equals(item.getDictValue())).collect(Collectors.toList()); if (! CollectionUtils.isEmpty(targetErrorTypes)) { errorType = targetErrorTypes.get(0).getDictValue(); } WorkOrderErrorType workOrderErrorType = new WorkOrderErrorType(); workOrderErrorType.setWorkOrderNo(databaseWorkOrder.getWorkOrderNo()); Date now = new Date(); workOrderErrorType.setCreateTime(now); workOrderErrorType.setUpdateTime(now); workOrderErrorTypeMapper.insert(workOrderErrorType); databaseWorkOrder.setStatus(WorkOrderStatusEnum.DISTRIBUTED); databaseWorkOrder.setUpdateTime(now); baseMapper.updateById(databaseWorkOrder); updateNum++; @@ -142,11 +161,11 @@ } else { workOrder.setCreateTime(new Date()); workOrder.setUpdateTime(new Date()); // 如果报备过,使用最新报备的错误类型 Report report = reportMapper.checkPointReported(workOrder.getSerialNumber()); if (Objects.nonNull(report)) { workOrder.setErrorType(report.getErrorType()); } // // 如果报备过,使用最新报备的错误类型 // Report report = reportMapper.checkPointReported(workOrder.getSerialNumber()); // if (Objects.nonNull(report)) { // workOrder.setErrorType(report.getErrorType()); // } waitAddList.add(workOrder); } } ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -287,17 +287,6 @@ return point; }).collect(Collectors.toList()); this.waitAllFinishAndGetResult(pointList); // for (PointExport pointExport : dataList) { // YwPoint point = new YwPoint(); // point.setImportantCommandImageTag("是".equals(pointExport.getImportantCommandImageTagString())); // point.setProvinceTag("是".equals(pointExport.getProvinceTagString())); // point.setUnitId(Long.valueOf(unitId)); // point.setStartTime(startTime); // point.setEndTime(endTime); // point.setPointName(pointExport.getPointName()); // point.setSerialNumber(pointExport.getSerialNumber()); // this.baseMapper.updatePoint(point); // } } public void waitAllFinishAndGetResult(List<YwPoint> dataList) throws InterruptedException, ExecutionException { @@ -306,34 +295,18 @@ int start = 0; Date startTime = new Date(); while (true) { if (dataList.size() < start + 50) { if (dataList.size() < start + 100) { List<YwPoint> list = dataList.subList(start, dataList.size() - 1); Callable<Boolean> callable = new PointImportCallable(list, this.baseMapper); FutureTask<Boolean> futureTask = new FutureTask(callable); Thread thread = new Thread(futureTask); thread.start(); // 不能直接调用Future的get方法,否则就变成串行执行了,失去多线程意义 resultList.add(futureTask); this.baseMapper.updatePoint(list); break; } else { List<YwPoint> list = dataList.subList(start, start + 50); Callable<Boolean> callable = new PointImportCallable(list, this.baseMapper); FutureTask<Boolean> futureTask = new FutureTask(callable); Thread thread = new Thread(futureTask); thread.start(); // 不能直接调用Future的get方法,否则就变成串行执行了,失去多线程意义 resultList.add(futureTask); start += 50; List<YwPoint> list = dataList.subList(start, start + 100); this.baseMapper.updatePoint(list); start += 100; } } for (FutureTask<Boolean> futureTask : resultList) { data.add(futureTask.get()); } Date endTime = new Date(); log.error("总共耗时:" + (endTime.getTime() - startTime.getTime()) / 1000); if (data.stream().allMatch(item -> item == Boolean.TRUE)) { System.out.println("执行成功"); } log.error("总共耗时:" + (endTime.getTime() - startTime.getTime())); } } ycl-server/src/main/resources/application-dev.yml
@@ -36,7 +36,7 @@ spring: # 数据源配置 datasource: url: jdbc:mysql://101.35.247.188/zgyw?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true url: jdbc:mysql://101.35.247.188/zgyw?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowMultiQueries=true username: root password: ycl@202466 type: com.alibaba.druid.pool.DruidDataSource ycl-server/src/main/resources/application-prod.yml
@@ -36,7 +36,7 @@ spring: # 数据源配置 datasource: url: jdbc:mysql://51.92.65.72:3306/zgyw?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true url: jdbc:mysql://51.92.65.72:3306/zgyw?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowMultiQueries=true username: root password: zgyw@202488 type: com.alibaba.druid.pool.DruidDataSource ycl-server/src/main/resources/application.yml
@@ -68,7 +68,7 @@ logging: level: org.springframework: warn com.ycl : debug com.ycl : error # security配置 security: ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
@@ -109,15 +109,18 @@ </delete> <update id="updatePoint"> update t_yw_point <set> <if test="point.pointName != null and point.pointName != ''">point_name = #{point.pointName},</if> <foreach collection="pointList" separator=";" item="point"> UPDATE t_yw_point SET <if test="point.pointName != null and point.pointName != ''"> point_name = #{point.pointName}, </if> unit_id = #{point.unitId}, start_time = #{point.startTime}, end_time = #{point.endTime}, province_tag = #{point.provinceTag}, important_command_image_tag = #{point.importantCommandImageTag}, </set> important_command_image_tag = #{point.importantCommandImageTag} WHERE serial_number = #{point.serialNumber} </foreach> </update> </mapper>