diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java index bb752eb..2ff6caf 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/TicketChartCell.java @@ -17,10 +17,14 @@ public class TicketChartCell { private String ticketName; @ApiModelProperty(value = "本月数量") private int ticketMon; + @ApiModelProperty(value = "本月合格数量") + private int ticketMonPassCount; @ApiModelProperty(value = "本月合格率") private double ticketMonPerc; @ApiModelProperty(value = "本年数量") private int ticketYear; + @ApiModelProperty(value = "本年合格数量") + private int ticketYearPassCount; @ApiModelProperty(value = "本年合格率") private double ticketYeaPercr; } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java index 7f55a09..71055ea 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/consumer/StandardWorkTicketConsumer.java @@ -45,7 +45,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume { //记录操作日志 WorkflowOperationLog regularWorkflowOperationLog = new WorkflowOperationLog(); - BeanUtils.copyProperties(response,regularWorkflowOperationLog); + BeanUtils.copyProperties(response, regularWorkflowOperationLog); if (ObjectUtils.isNotEmpty(regularWorkflowOperationLog)) { regularWorkflowOperationLog.setVariables(JSON.toJSONString(response.getVariables())); regularWorkflowOperationLog.setTakeId(response.getTaskId()); @@ -53,40 +53,29 @@ public class StandardWorkTicketConsumer implements IQueueConsume { regularWorkflowOperationLog.setIsOperationLog(true); regularWorkflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId()); log.info("正在记录操作日志WorkflowOperationLog.... :{}", regularWorkflowOperationLog); - workflowOperationLogService.save(regularWorkflowOperationLog); } + try { + WorkflowQueue ticker = new WorkflowQueue(); + ticker.setProcessDefinitionKey(taskDefinitionKey); + //判断执行具体的实现类 + ProcessService processService = + ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); + if (ObjectUtils.isNotEmpty(processService)) { + //执行业务方法 + try { + processService.calculate(response); + } catch (Exception e) { + e.printStackTrace(); + //todo 业务出错误 做补偿 + log.error("业务出错,StandardWorkTicketConsumer: {}", e.getMessage()); + log.error("业务出错,StandardWorkTicketConsumer: {} ", response); + regularWorkflowOperationLog.setIsOperationLog(false);//调用消费方抛出异常 - - WorkflowQueue ticker = new WorkflowQueue(); - ticker.setProcessDefinitionKey(taskDefinitionKey); - //判断执行具体的实现类 - ProcessService processService = - ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)).findFirst().orElse(null); - if (ObjectUtils.isNotEmpty(processService)) { - //执行业务方法 - try { - processService.calculate(response); - } catch (Exception e) { - e.printStackTrace(); - //todo 业务出错误 做补偿 - log.error("业务出错,StandardWorkTicketConsumer: {}", e.getMessage()); - log.error("业务出错,StandardWorkTicketConsumer: {} ", response); - WorkflowOperationLog workflowOperationLog = new WorkflowOperationLog(); - BeanUtils.copyProperties(response,workflowOperationLog); - if (ObjectUtils.isNotEmpty(workflowOperationLog)) { - regularWorkflowOperationLog.setVariables(JSON.toJSONString(response.getVariables())); - regularWorkflowOperationLog.setTakeId(response.getTaskId()); - regularWorkflowOperationLog.setTakeName(response.getTaskName()); - regularWorkflowOperationLog.setIsOperationLog(false); - regularWorkflowOperationLog.setProcessInstanceKey(response.getProcessInstanceId()); - log.info("正在保存到hzims_workflow_operation_log.... :{}", workflowOperationLog); - workflowOperationLogService.save(workflowOperationLog); } - } + } finally { + workflowOperationLogService.save(regularWorkflowOperationLog); } - - } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DealDutyRecFlowServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DealDutyRecFlowServiceImpl.java index 92abff0..03e4ec7 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DealDutyRecFlowServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DealDutyRecFlowServiceImpl.java @@ -57,9 +57,12 @@ public class DealDutyRecFlowServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("交接班v4消费流程执行中,param"+response); R dealtDutyRecFlow = iDutyRecClient.dealDutyRecFlow(response); if (!dealtDutyRecFlow.isSuccess()){ + log.error("消费交接班失败"+response); throw new ServiceException("执行交接班v4失败"); } + log.info("交接班v4消费流程结束,param"+response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java index 97a1266..23e2349 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/DefectProcessServiceImpl.java @@ -58,10 +58,12 @@ public class DefectProcessServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("消缺工作流程消费开始---param",response); R defect = defectClient.saveDefect(response); if (!defect.isSuccess()) { + log.error("消缺工作流程消费调取对应业务报错---param",response); throw new ServiceException("消缺工作流程出现异常呢"); - } + log.info("消缺工作消费流程结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java index 48d0154..6e28602 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MachineryTicketProcessServiceImpl.java @@ -61,10 +61,12 @@ public class MachineryTicketProcessServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("水力机械工作票消费流程开始---param",response); Boolean pending = ticketProcessService.findPending(response); if (!pending) { + log.error("水力机械工作票消费调用报错---param",response); throw new ServiceException("水力机械工作票流程出现异常呢"); - } + log.info("水力机械工作票消费流程结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java index 972e37b..d9fd8ff 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/MaintenanceProcessServiceImpl.java @@ -58,9 +58,12 @@ public class MaintenanceProcessServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("日常维护消费开始---param",response); Boolean pending = maintenanceFeignClient.findPending(response); if (!pending) { + log.error("日常维护消费报错---param",response); throw new ServiceException("日常维护业务流程出错呢"); } + log.info("日常维护消费结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java index 600e82d..170d403 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OneTicketProcessServiceImpl.java @@ -66,10 +66,12 @@ public class OneTicketProcessServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("工作票消费调用开始---param",response); Boolean pending = ticketProcessService.findPending(response); if (!pending) { + log.error("工作票消费调用异常---param",response); throw new ServiceException("工作票流程出现异常呢"); - } + log.info("工作票消费调用结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java index 608f866..f7cd785 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OperationTicketProcessServiceImpl.java @@ -62,9 +62,12 @@ public class OperationTicketProcessServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("操作票流程消费调用fein接口开始---param",response); Boolean pending = operationTicketFeignClient.findPending(response); if (!pending) { + log.info("操作票流程调用fein接口异常---param",response); throw new ServiceException("操作票流程出现异常呢"); } + log.info("操作票流程消费调用fein接口结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java index 57bc9e2..89ed0c4 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulPlanServiceImpl.java @@ -46,9 +46,12 @@ public class OverhaulPlanServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("检修计划调用fein消费开始---param",response); R defect = accessPlanV4Client.listener(response); if (!defect.isSuccess()) { + log.error("检修计划调用fein异常---param",response); throw new ServiceException("检修计划业务执行异常!"); } + log.info("检修计划调用fein结束---param",response); } } diff --git a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java index 3283052..bdfd199 100644 --- a/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java +++ b/hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/processflow/strategy/serviceimpl/OverhaulTaskServiceImpl.java @@ -47,10 +47,12 @@ public class OverhaulTaskServiceImpl extends ProcessAbstractService { */ @Override public void calculate(ProcessWorkFlowResponse response) { + log.info("检修计划调用fein接口消费开始---param",response); R defect = accessTaskV4Client.listener(response); if (!defect.isSuccess()) { + log.error("检修计划调用fein接口消费异常---param",response); throw new ServiceException("检修任务业务执行异常!"); - } + log.info("检修计划调用fein接口消费结束---param",response); } } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index e9e9d73..9bdfc9e 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -1515,28 +1515,28 @@ public class RealTargetServiceImpl implements RealTargetService { return; } // 有功功率单位 - String power = unitMap.get(device.getId()+HomePageConstant.CONCAT_P); + String power = unitMap.get(device.getEmCode().toUpperCase()+HomePageConstant.CONCAT_P); if(StringUtil.isNotBlank(power)){ realVo.setPowerUnit(power); } else { realVo.setPowerUnit("kW"); } // 无功功率 - String reactivePowerUnit = unitMap.get(device.getId()+HomePageConstant.CONCAT_Q); + String reactivePowerUnit = unitMap.get(device.getEmCode().toUpperCase()+HomePageConstant.CONCAT_Q); if(StringUtil.isNotBlank(reactivePowerUnit)){ realVo.setReactivePowerUnit(reactivePowerUnit); } else { realVo.setReactivePowerUnit("kVa r"); } // 定子电压单位 - String voltage = unitMap.get(device.getId()+HomePageConstant.CONCAT_UAB); + String voltage = unitMap.get(device.getEmCode().toUpperCase()+HomePageConstant.CONCAT_UAB); if(StringUtil.isNotBlank(voltage)){ realVo.setVoltageUnit(voltage); } else { realVo.setVoltageUnit("V"); } // 定子电流单位 - String current = unitMap.get(device.getId()+HomePageConstant.CONCAT_IA); + String current = unitMap.get(device.getEmCode().toUpperCase()+HomePageConstant.CONCAT_IA); if(StringUtil.isNotBlank(current)){ realVo.setCurrentUnit(current); } else { diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java index 629e2c6..a9789e4 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/station/impl/StationAttributeServiceImpl.java @@ -9,8 +9,7 @@ import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -31,6 +30,8 @@ public class StationAttributeServiceImpl extends BaseServiceImpl new TreeSet<>(Comparator.comparing(StationAttributeEntity::getAttributes))), ArrayList::new)) + .stream().collect(Collectors.toMap(StationAttributeEntity::getAttributes, StationAttributeEntity::getUnit)); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java index ebca68e..ea07538 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/DefectCheckServiceImpl.java @@ -274,7 +274,7 @@ public class DefectCheckServiceImpl extends BaseServiceImpl> analyzeDataByAnalyzeCode = searchClient.getAnalyzeDataByAnalyzeCode(analyzeDataCondition); if(!analyzeDataByAnalyzeCode.isSuccess()) { +// if(DataResultCode.ANALYZE_INSTANCE_UNDEFINE.getCode()==analyzeDataByAnalyzeCode.getCode()){ +// throw new ServiceException("找不到对应的分析实例,请检查好配置后重试!"); +// } throw new ServiceException("设备数据查询异常,请检查好配置后重试!"); } return analyzeDataByAnalyzeCode; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 4d5ec7e..f0e3942 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -106,6 +106,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ @@ -200,7 +201,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ eq(ImsDutyGroupPEntity::getGroupId, groupEntity.getId()); @@ -338,6 +339,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl { - throw new RuntimeException("更新交班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); - }); + if (ObjectUtil.isNotEmpty(headDutyMain)&&ObjectUtil.isNotEmpty(headDutyMain.getId())) { + Assert.isTrue(imsDutyMainService.updateById(headDutyMain), () -> { + throw new RuntimeException("更新交班状态失败,交班执行对象为:" + JSON.toJSONString(recDTO.getHeadDutyMainVo())); + }); + log.info("更新交班状态:"+carryDutyMain); + } // 更新接班值班 - Assert.isTrue(imsDutyMainService.updateById(carryDutyMain),() -> { - throw new RuntimeException("更新接班状态失败,交班执行对象为:"+ JSON.toJSONString(recDTO.getHeadDutyMainVo())); - }); + if (ObjectUtil.isNotEmpty(carryDutyMain)&&ObjectUtil.isNotEmpty(carryDutyMain.getId())) { + Assert.isTrue(imsDutyMainService.updateById(carryDutyMain), () -> { + throw new RuntimeException("更新接班状态失败,交班执行对象为:" + JSON.toJSONString(recDTO.getHeadDutyMainVo())); + }); + log.info("更新接班状态:"+carryDutyMain); + } // 更新交接班 - this.updateById(dutyRec); - return true; + if (ObjectUtil.isNotEmpty(dutyRec)&&ObjectUtil.isNotEmpty(dutyRec.getId())) { + return this.updateById(dutyRec); + }else { + log.error("更新交接班记录失败"+dutyRec.toString()); + return false; + } } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java index 7720bc9..6ce0cbd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AreaMonthReportController.java @@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import java.io.IOException; import java.net.URLEncoder; +import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -125,7 +126,7 @@ public class AreaMonthReportController extends BladeController { @ApiOperation("导出水电站月报") @GetMapping("/exportHydropowerStationMonthReport") public R exportHydropowerStationMonthReport(HttpServletResponse response, @ApiParam(value = "日期-年", required = true) Integer year,@ApiParam(value = "日期-月", required = true) Integer month, - @ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) { + @ApiParam(value = "站点Id", required = true) Long deptId,@ApiParam(value = "月报类型", required = true) Long type) throws ParseException { HashMap map = new HashMap<>(); if (Func.isEmpty(year)||Func.isEmpty(deptId)||Func.isEmpty(month)||year==0||deptId==0||month==0){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java index 14a7882..b31145b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAreaMonthReportService.java @@ -4,6 +4,7 @@ import com.hnac.hzims.operational.main.vo.AreaMonthReportVo; import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; +import java.text.ParseException; import java.util.HashMap; import java.util.List; @@ -18,5 +19,5 @@ public interface IAreaMonthReportService { R export(HttpServletResponse response, String date); - R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month,Long deptId,String name); + R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month,Long deptId,String name) throws ParseException; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java index baa6714..d3eb8c2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthReportServiceImpl.java @@ -201,7 +201,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { return R.data("success"); } @Override - public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId,String deptName) { + public R exportHydropowerStationMonthReport(HttpServletResponse response, HashMap map, Integer year, Integer month, Long deptId,String deptName) throws ParseException { R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); if (!deptByCurrentUser.isSuccess()||deptByCurrentUser.getData()==null){ return R.fail("用户权限查询失败"); @@ -219,9 +219,9 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List stationEntityList = stationService.list(Wrappers.lambdaQuery() .in(StationEntity::getRefDept, deptIds) .eq(StationEntity::getType, HomePageConstant.HYDROPOWER)); - stationEntityList=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(stationEntityList)) { - int commissionTime = stationEntityList.stream().map(s -> { + List stationEntityListByCommissionTime=Optional.ofNullable(stationEntityList).orElse(new ArrayList<>()).stream().filter(s->Func.isNotEmpty(s.getCommissionTime())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(stationEntityListByCommissionTime)) { + int commissionTime = stationEntityListByCommissionTime.stream().map(s -> { Duration dur = Duration.between(s.getCommissionTime(), LocalDateTime.now()); return (int) dur.toDays(); }).reduce(Integer::max).get(); @@ -236,10 +236,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { Integer yearBefore = year - 1; map.put("yearBefore", yearBefore); map.put("month", month); - Integer monthBefore = month - 1; + String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month); + String[] split = monStartMonBefore.split("-"); + Integer monthBefore = Integer.valueOf(split[1]); map.put("monthBefore", monthBefore); // map.put("date", date); - map.put("stationName", deptName); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日"); map.put("writeTime", simpleDateFormat.format(new Date())); @@ -262,7 +263,6 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 今年当月 String monthStart = TimeUtils.getMonthStart(year, month); String monthEndV2 = TimeUtils.getMonthEndV2(year, month); - List reals = (List) redisTemplate.opsForValue().get(load_hydropower_unit_real_key); List realsByDept = reals.stream().filter(s -> deptIds.contains(s.getDeptId())).collect(Collectors.toList()); // 装机容量占比数据组装 @@ -294,6 +294,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { //装机容量占比图 ImageEntity capacityProportionChart = JFreeUtil.pieChartByDouble("水电项目装机容量占比图", capacityProportionMap, 500, 400); map.put("capacityProportionChart", capacityProportionChart); + map.put("factoryComparisonChart", "---暂无数据---"); //各发电站发电量环比图+表格数据组装 List powerPercentageVoList = getMonPowerPercentageVos(year, month, deptList, deptIds, stationEntityList, stationIds, yearBefore, monthBefore); // getPowerData(deptList, yearStart, yearEnd, yearBeforeStart, yearBeforeEnd, monthStart, monthEnd, beforeMonthStart, beforeMonthEnd, monthStartBeforeYear, monthEndBeforeYear, devices, planYearData, powerPercentageVoList); @@ -315,14 +316,21 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { for (MonPowerPercentageVo monPowerPercentageVo : powerPercentageVoList) { HashMap power = new HashMap<>(); power.put("name", monPowerPercentageVo.getDeptName()); - power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MW"); - power.put("month",monPowerPercentageVo.getPowerMon()+"MW"); + power.put("monthBefore", monPowerPercentageVo.getPowerMonBefore()+"MkWh"); + power.put("month",monPowerPercentageVo.getPowerMon()+"MkWh"); powerMap.add(power); } map.put("power", powerMap); + String dateFormat=""; + if (month<10){ + dateFormat=year+"-"+"0"+month; + }else { + dateFormat=year+"-"+month; + } //表格总计 - List planYearAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year.toString()); - List planMonAll = planGenertionClient.getPlanGenerationByParam(null, Collections.singletonList(deptId.toString()), year + "-" + month); + List deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); + List planYearAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); + List planMonAll = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, dateFormat); getTabelSum(deptId, powerPercentageVoList, planYearAll, planMonAll, map); //发电情况统计表数据 ArrayList> list = new ArrayList<>(powerPercentageVoList.size()); @@ -335,7 +343,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { temp.put("year", String.valueOf(monPowerPercentageVo.getPowerYear())); temp.put("monPercentage", monPowerPercentageVo.getPowerMonPercentage() * 100 + "%"); temp.put("yearPercentage", monPowerPercentageVo.getPowerYearPercentage() * 100 + "%"); - temp.put("plan", monPowerPercentageVo.getPlanPercentage() * 100 + "%"); + temp.put("plan", monPowerPercentageVo.getPlanPercentage()+ "%"); list.add(temp); } map.put("powerGeneration", list); @@ -402,7 +410,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { //表格数据 HashMap temp = new HashMap<>(); temp.put("deptName", "总计"); - temp.put("checkLevel", "无等级"); + temp.put("checkLevel", ""); temp.put("findShortagesMon", "0"); temp.put("shortagesMon", "0"); temp.put("findShortagesYear", "0"); @@ -503,10 +511,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { int count = yearTicketCollect.size(); ticketChartCell.setTicketYear(count); List ticketIds = yearTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); + ticketChartCell.setTicketYearPassCount(0); R ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketYeaPercr(ticketYearPerc); + ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue()); } } if (CollectionUtils.isNotEmpty(monthTicketCollect)) { @@ -514,10 +524,13 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { int count = monthTicketCollect.size(); ticketChartCell.setTicketMon(count); List monthTicketIds = monthTicketCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); + //合格数量 R ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); + ticketChartCell.setTicketMonPassCount(0); if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketMonPerc(ticketMonthPerc); + ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue()); } } } @@ -536,9 +549,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { ticketChartCell.setTicketYear(count); List ticketIds = yearOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketPassCount = ticketInfoClient.getTicketPassByIds(ticketIds); + ticketChartCell.setTicketYearPassCount(0); if (ticketPassCount.isSuccess() && ticketPassCount.getData() != null && count != 0) { double ticketYearPerc = BigDecimal.valueOf(ticketPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketYeaPercr(ticketYearPerc); + ticketChartCell.setTicketYearPassCount(ticketPassCount.getData().intValue()); } } if (CollectionUtils.isNotEmpty(monthOperateCollect)) { @@ -547,9 +562,11 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { ticketChartCell.setTicketMon(count); List monthTicketIds = monthOperateCollect.stream().map(BaseEntity::getId).collect(Collectors.toList()); R ticketMonthPassCount = ticketInfoClient.getTicketPassByIds(monthTicketIds); + ticketChartCell.setTicketMonPassCount(0); if (ticketMonthPassCount.isSuccess() && ticketMonthPassCount.getData() != null && count != 0) { double ticketMonthPerc = BigDecimal.valueOf(ticketMonthPassCount.getData()).divide(BigDecimal.valueOf(count), 2, BigDecimal.ROUND_UP).doubleValue(); ticketChartCell.setTicketMonPerc(ticketMonthPerc); + ticketChartCell.setTicketMonPassCount(ticketMonthPassCount.getData().intValue()); } } } @@ -569,10 +586,20 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { sumCell.setTicketType(mapTicketChart.getKey()); sumCell.setTicketName(TicketConstants.TicketTypeNameEnum.getTicketNameByType(mapTicketChart.getKey())); List ticketChartValue = mapTicketChart.getValue(); - sumCell.setTicketMon(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum()); - sumCell.setTicketYear(ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum()); - sumCell.setTicketMonPerc(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketMonPerc).sum()); - sumCell.setTicketYeaPercr(ticketChartValue.stream().mapToDouble(TicketChartCell::getTicketYeaPercr).sum()); + int sumTicketMon = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMon).sum(); + sumCell.setTicketMon(sumTicketMon); + int sumTicketYear = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYear).sum(); + sumCell.setTicketYear(sumTicketYear); + int sumTicketMonPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketMonPassCount).sum(); + int sumTicketYearPass = ticketChartValue.stream().mapToInt(TicketChartCell::getTicketYearPassCount).sum(); + if (sumTicketMonPass>0&&sumTicketMon>0){ + BigDecimal monPassPerc = new BigDecimal(sumTicketMonPass).divide(new BigDecimal(sumTicketMon), 2, BigDecimal.ROUND_UP); + sumCell.setTicketMonPerc(monPassPerc.doubleValue()); + } + if (sumTicketYear>0&&sumTicketYearPass>0){ + BigDecimal yearPassPerc = new BigDecimal(sumTicketYearPass).divide(new BigDecimal(sumTicketYear), 2, BigDecimal.ROUND_UP); + sumCell.setTicketYeaPercr(yearPassPerc.doubleValue()); + } sumCollect.add(sumCell); } TicketChartVo ticketChartVo = new TicketChartVo(); @@ -621,6 +648,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { private List getMonPowerPercentageVos(Integer year, Integer month, List deptList, List deptIds, List stationEntityList, List stationIds, Integer yearBefore, Integer monthBefore) { List deptIdsString = deptIds.stream().map(String::valueOf).collect(Collectors.toList()); + //年计划发电量 List planYearData = planGenertionClient.getPlanGenerationByParam(null, deptIdsString, year.toString()); List powerPercentageVoList = new ArrayList<>(); //水电站,光伏站和带代运维数据近三年数据 @@ -629,7 +657,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { List listByYearBefore = TimeUtils.getListByYear(yearBefore); String monStart = TimeUtils.getMon(year, month); String monStartYearBefore = TimeUtils.getMon(yearBefore, month); - String monStartMonBefore = TimeUtils.getMon(year, monthBefore); + String monStartMonBefore = TimeUtils.getEarlyTime(yearBefore, month); +// String monStartMonBefore = TimeUtils.getMon(year, monthBefore); // 格式:站点-日期-发电量 for (Map.Entry> deviceMap : powerMapThree.entrySet()) { String deptNameByKey; @@ -649,31 +678,33 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { Double planGeneration = 0d; List planGenerationById = planYearData.stream().filter(s -> collect.get(0).getRefDept().equals(s.getStationDeptId())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(planGenerationById)) { - planGeneration = Double.valueOf(planGenerationById.get(0).getPlanGeneration()); + planGeneration = Double.valueOf(planGenerationById.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); } //当前机构近三年的数据 Map value = deviceMap.getValue(); //今年发电量 powerYear=value.entrySet().stream().filter(s->listByYear.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); //转换单位kwh-》万Kwh - powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerYear=powerYear.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerYearBefore=value.entrySet().stream().filter(s->listByYearBefore.contains(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerYearBefore=powerYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonth=value.entrySet().stream().filter(s->monStart.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonth=powerMonth.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonthBefore=value.entrySet().stream().filter(s->monStartMonBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonthBefore=powerMonthBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerMonthYearBefore=value.entrySet().stream().filter(s->monStartYearBefore.equals(s.getKey())).map(s->BigDecimal.valueOf(s.getValue())).reduce(BigDecimal.ZERO, BigDecimal::add); - powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP); + powerMonthYearBefore=powerMonthYearBefore.divide(new BigDecimal(10000),2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP).setScale(2,BigDecimal.ROUND_UP); powerVo.setPowerYear(powerYear.doubleValue()); powerVo.setPowerYearBefore(powerYearBefore.doubleValue()); BigDecimal yearPercentage = new BigDecimal(0); BigDecimal planPercentage = new BigDecimal(0); if (powerYearBefore.compareTo(BigDecimal.ZERO) != 0) { yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); + yearPercentage.setScale(2, BigDecimal.ROUND_UP); } if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); + planPercentage.setScale(2, BigDecimal.ROUND_UP); } powerVo.setPlanPercentage(planPercentage.doubleValue()); powerVo.setPowerYearPercentage(yearPercentage.doubleValue()); @@ -683,6 +714,7 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { BigDecimal monPercentage = new BigDecimal(0); if (powerMonthYearBefore.compareTo(BigDecimal.ZERO) != 0) { monPercentage = (powerMonth.subtract(powerMonthYearBefore)).divide(powerMonthYearBefore, 2, BigDecimal.ROUND_UP); + monPercentage.setScale(2, BigDecimal.ROUND_UP); } powerVo.setPowerMonPercentage(monPercentage.doubleValue()); powerPercentageVoList.add(powerVo); @@ -778,11 +810,12 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { private static void getTabelSum(Long deptId, List powerPercentageVoList, List planYearAll, List planMonAll, HashMap map) { Float planGeneration = 0f; if (Func.isNotEmpty(planYearAll)) { - planGeneration = planYearAll.get(0).getPlanGeneration(); + planGeneration =Double.valueOf(planYearAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ; } Float planMonGeneration = 0f; if (Func.isNotEmpty(planMonAll)) { - planMonGeneration = planMonAll.get(0).getPlanGeneration(); + planMonGeneration =Double.valueOf(planMonAll.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()).floatValue() ; +// planMonGeneration = planMonAll.get(0).getPlanGeneration(); } MonPowerPercentageVo powerVo = new MonPowerPercentageVo(); powerVo.setDeptId(deptId); @@ -803,7 +836,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { yearPercentage = (powerYear.subtract(powerYearBefore)).divide(powerYearBefore, 2, BigDecimal.ROUND_UP); } if (BigDecimal.valueOf(planGeneration).compareTo(BigDecimal.ZERO) != 0) { - planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration), 2, BigDecimal.ROUND_UP); + //因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100 + planPercentage = powerYear.divide(BigDecimal.valueOf(planGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP); // 年计划完成率 map.put("yearCompletionRate", planPercentage.toString()); } else { @@ -820,7 +854,8 @@ public class AreaMonthReportServiceImpl implements IAreaMonthReportService { // 项目月计划完成量 BigDecimal planMonPercentage = new BigDecimal(0); if (powerMonth.compareTo(BigDecimal.ZERO) != 0 && BigDecimal.valueOf(planMonGeneration).compareTo(BigDecimal.ZERO) != 0) { - planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration), 2, BigDecimal.ROUND_UP); + //因为计划发电量的单位是kwh,发电量已经转换为万kwh,再加上百分比转换所以需要乘以10000*100 + planMonPercentage = powerMonth.divide(BigDecimal.valueOf(planMonGeneration).divide(new BigDecimal(1000000)), 2, BigDecimal.ROUND_UP); } map.put("monCompletionRate", planMonPercentage); BigDecimal powerMonthBefore = powerPercentageVoList.stream() diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java index ecce2e3..2d5f9b3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HomePageServiceImpl.java @@ -972,7 +972,7 @@ public class HomePageServiceImpl implements IHomePageService { } int faInvestment = otherList.stream().mapToInt(OtherEntity::getFaQuantity).sum(); distributionNetworkVo.setFaInvestment(faInvestment); - double onlineRate = otherList.stream().mapToDouble(o-> Double.valueOf(o.getOnlineRate())).average().getAsDouble();; + double onlineRate = otherList.stream().mapToDouble(o-> Double.parseDouble(o.getOnlineRate())).average().getAsDouble(); if(Math.abs(onlineRate) <= 0){ distributionNetworkVo.setOnlineRate("0.0"); countDownLatch.countDown(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index adf3cb8..85f83fc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -1149,7 +1149,7 @@ public class HydropowerServiceImpl implements HydropowerService { long on = reals.stream().filter(real -> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId()) && real.getState()).count(); long sum = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).count(); if(Math.abs(sum) > 0){ - scale.setDeviceUse(BigDecimal.valueOf(on / sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); + scale.setDeviceUse(BigDecimal.valueOf(on / (double)sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); } } return scale; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java index 260894d..79c667d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java @@ -137,7 +137,7 @@ public class WindHomeServiceImpl implements WindHomeService { score.setPlanYear(yearPlans.stream().mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); // 年发电完成率 if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){ - score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); } // 月发电量 score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum()); @@ -145,10 +145,13 @@ public class WindHomeServiceImpl implements WindHomeService { score.setPlanMon(yearPlans.stream().filter(o->o.getDateTime().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(PlanGenerationEntity::getPlanGeneration).sum()); // 月发电量完成率 if(Math.abs(score.getGenerateMon()) > 0 && Math.abs(score.getPlanMon()) > 0){ - score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); + score.setCompleteMonRate(BigDecimal.valueOf(score.getGenerateMon() / score.getPlanMon() * 100).setScale(2, RoundingMode.HALF_UP).doubleValue()); } // 月平均风速 - score.setSpeedRate(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getSpeed).average().getAsDouble()); + OptionalDouble speed = winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getSpeed).average();; + if(speed.isPresent()){ + score.setSpeedRate(speed.getAsDouble()); + } // 月利用小时 score.setAvailableMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getAvailable).sum()); // 日发电量 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/MaintenanceController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/MaintenanceController.java index 1def60a..d504a91 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/MaintenanceController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/MaintenanceController.java @@ -55,11 +55,13 @@ public class MaintenanceController { @PostMapping("/findPending") @ApiOperation(value = "日常维护待处理") public Boolean findPending(@RequestBody ProcessWorkFlowResponse response){ + log.info("日常维护消费处理开始:findPending"); try { maintenanceService.findPending(response); return true; } catch (Exception e) { e.printStackTrace(); + log.error("param"+response+"报错信息"+e.toString()); throw new ServiceException("日常维护待处理:" + e.getMessage()); } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java index 32e1ffa..e10a281 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskCreateTask.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.maintenance.scheduled; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.hnac.hzims.message.dto.PlanMsgRecordDto; import com.hnac.hzims.message.entity.config.MessageTemplateEntity; import com.hnac.hzims.message.fegin.IMessageClient; @@ -10,11 +11,11 @@ import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.maintenance.entity.OperMaintenancePlanEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenancePlanMapper; +import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.MaintenanceService; import com.hnac.hzims.operational.maintenance.template.service.TemplateService; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskEntityVo; -import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.log.XxlJobLogger; @@ -29,6 +30,7 @@ import org.springblade.flow.core.feign.IFlowClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; @@ -70,6 +72,7 @@ public class MaintenanceTaskCreateTask { private final MaintenanceService maintenanceService; + private final IOperMaintenancePlanService maintenancePlanService; private final List templateService; @@ -79,7 +82,7 @@ public class MaintenanceTaskCreateTask { final static String REMIND_TASK_END_LIST = "hzims:operation:maintenance:remind:end:tasks"; @XxlJob(TASK_VALUE_MAINTENANCE_TASK_CREATE) - @Transactional +// @Transactional public ReturnT execute(String param) throws Exception { log.info(TASK_VALUE_MAINTENANCE_TASK_CREATE + " start...................................................................................."); Date startDate = StringUtil.isNotBlank(param) ? DateUtil.parse(param, DateUtil.PATTERN_DATE) : DateUtil.parse(DateUtil.formatDate(DateUtil.now()), DateUtil.PATTERN_DATE); @@ -97,9 +100,19 @@ public class MaintenanceTaskCreateTask { //生成日常巡检任务并插入数据库 for (int i = startIndex; i < endIndex; i++) { - this.generateTaskByPlan(planEntities.get(i),true); + Boolean aBoolean = this.generateTaskByPlan(planEntities.get(i), true); + //更新任务派发时间 + if (aBoolean) { + //当所有的任务生成后,才会更新计划的时间状态 + LambdaUpdateWrapper planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()); + planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, planEntities.get(i).getId()); + maintenancePlanService.update(planEntityLambdaUpdateWrapper); + log.info("更新任务派发"+planEntities.get(i)); + }else { + log.error("更新任务派发失败"+planEntities.get(i)); + } } - Thread.sleep(1000); page++; } while (page * size < planEntities.size()); @@ -113,19 +126,42 @@ public class MaintenanceTaskCreateTask { * @param planEntity * @return */ - public void generateTaskByPlan(OperMaintenancePlanEntity planEntity,Boolean flag) { + public Boolean generateTaskByPlan(OperMaintenancePlanEntity planEntity,Boolean flag) { + log.info("日常维护计划生成任务开始:param"+planEntity); OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(planEntity,OperMaintenanceTaskEntity.class); //拆分设备 每个设备生成一条任务 + List taskIds=new ArrayList<>(); if(StringUtil.isNotBlank(planEntity.getEmCode())){ List emCodeList = Arrays.asList(planEntity.getEmCode().split(",")); for(String emCode : emCodeList){ - taskEntity.setEmCode(emCode); - maintenanceService.fillTask(taskEntity,planEntity,flag); + //一旦有一条任务失败,则删除当前生成的任务,不更新当前的计划状态 + try { + taskEntity.setEmCode(emCode); + Long task = maintenanceService.fillTask(taskEntity, planEntity, flag); + if (ObjectUtil.isNotEmpty(task)){ + taskIds.add(task); + } + }catch (Exception e){ + log.error("日常维护任务生成失败:" + "emCode:" + emCode + "错误原因:" + e); + log.error("日常维护任务生成失败:" + "param:" + planEntity + "错误原因:" + e); + taskService.deleteTaskBatch(taskIds); + return false; + } } } else { - maintenanceService.fillTask(taskEntity,planEntity,flag); + try { + Long task = maintenanceService.fillTask(taskEntity, planEntity, flag); + if (ObjectUtil.isNotEmpty(task)) { + taskIds.add(task); + } + } catch (Exception e) { + log.error("日常维护任务生成失败:" + "param:" + planEntity + "错误原因:" + e); + taskService.deleteTaskBatch(taskIds); + return false; + } } + return true; } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java index d58df2a..3a09896 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/MaintenanceService.java @@ -38,5 +38,5 @@ public interface MaintenanceService { * @param taskEntity * @param finalPlanEntity */ - void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity,Boolean flag); + Long fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity,Boolean flag); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java index e93d73f..d8de898 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java @@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Lists; import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; @@ -38,10 +37,7 @@ import org.springblade.system.feign.ISysClient; import org.springframework.beans.BeanUtils; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.DefaultTransactionDefinition; import java.time.Instant; import java.time.LocalDate; @@ -49,7 +45,6 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -87,7 +82,7 @@ public class MaintenanceServiceImpl implements MaintenanceService { * @param ids */ @Override - @Transactional(rollbackFor = Exception.class) +// @Transactional(rollbackFor = Exception.class) public void createTask(List ids) { try { //获取日常维护计划 @@ -95,21 +90,26 @@ public class MaintenanceServiceImpl implements MaintenanceService { planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids); List planEntities = maintenancePlanService.list(planEntityLambdaQueryWrapper); //筛选当月没生成任务的计划 - List finalPlanEntities = planEntities.stream().filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) || !DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())).collect(Collectors.toList()); + List finalPlanEntities = planEntities.stream(). + filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) || + !DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())) + .collect(Collectors.toList()); if (CollectionUtil.isEmpty(finalPlanEntities)) { throw new ServiceException("所选计划当天已生成任务"); } for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) { // 通过计划生成任务 - this.createTaskByPlan(finalPlanEntity); - //更新任务派发时间 - LambdaUpdateWrapper planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()); - planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); - boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper); - if (!update) { - log.error("maintenance:generateTask 更新任务派发失败"); - throw new ServiceException("更新任务派发失败"); + Boolean taskByPlan = this.createTaskByPlan(finalPlanEntity); + if (taskByPlan) { + //更新任务派发时间 + LambdaUpdateWrapper planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>(); + planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()); + planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); + boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper); + if (!update) { + log.error("maintenance:generateTask 更新任务派发失败"); + throw new ServiceException("更新任务派发失败"); + } } } } catch (Exception e) { @@ -143,24 +143,26 @@ public class MaintenanceServiceImpl implements MaintenanceService { // standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo"); // standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class); } catch (Exception e) { - log.error("获取表单出现异常了~~~~"); + log.error("获取表单出现异常了~~~~"+response); throw new IllegalArgumentException(e.getMessage()); } - //1.查询日常维护信息 - Long id = NumberUtils.toLong(response.getBusinessKey()); - OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id); - if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) { - log.error("获取日常维护数据不存在"); - return; - } OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity(); BeanUtils.copyProperties(standardTicketInfoVo, entity); - entity.setId(id); + //1.查询日常维护信息 + //有Id才进行生成操作 + if (StringUtils.isNotBlank(response.getBusinessKey())) { + Long id = NumberUtils.toLong(response.getBusinessKey()); + OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id); + if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) { + log.error("获取日常维护数据不存在" + response); + return; + } + entity.setId(id); + //填充日常维护信息 saveOperMaintenanceTaskEntity(entity, response); entity.setProcessInstanceId(response.getProcessInstanceId()); taskService.updateById(entity); - //推送消息 if (response.getTaskId() != null) { // MessagePushRecordDto message = new MessagePushRecordDto(); @@ -225,8 +227,10 @@ public class MaintenanceServiceImpl implements MaintenanceService { } log.info("推送成功~"); } + } } catch (Exception e) { e.printStackTrace(); + log.error("日常维护消费异常:param"+response+"报错信息"+e); } } @@ -266,20 +270,40 @@ public class MaintenanceServiceImpl implements MaintenanceService { * * @param finalPlanEntity */ - private void createTaskByPlan(OperMaintenancePlanEntity finalPlanEntity) { + private Boolean createTaskByPlan(OperMaintenancePlanEntity finalPlanEntity) { OperMaintenanceTaskEntity taskEntity = BeanUtil.copy(finalPlanEntity, OperMaintenanceTaskEntity.class); //拆分设备 每个设备生成一条任务 + List taskIds = new ArrayList<>(); if (StringUtil.isNotBlank(finalPlanEntity.getEmCode())) { log.info("finalPlanEntity.getEmCode() : {}", finalPlanEntity.getEmCode()); String[] emCodeList = finalPlanEntity.getEmCode().split(","); for (String emCode : emCodeList) { - taskEntity.setEmCode(emCode); - this.fillTask(taskEntity, finalPlanEntity,false); + try { + taskEntity.setEmCode(emCode); + Long task = this.fillTask(taskEntity, finalPlanEntity, false); + if (ObjectUtil.isNotEmpty(task)) { + taskIds.add(task); + } + } catch (Exception e) { + log.error("日常维护任务生成失败:" + "emCode:" + emCode + "错误原因:" + e); + log.error("日常维护任务生成失败:" + "param:" + finalPlanEntity + "错误原因:" + e); + taskService.deleteTaskBatch(taskIds); + return false; + } } } else { - this.fillTask(taskEntity, finalPlanEntity,false); + try { + Long task = this.fillTask(taskEntity, finalPlanEntity, false); + if (ObjectUtil.isNotEmpty(task)) { + taskIds.add(task); + } + } catch (Exception e) { + log.error("日常维护任务生成失败:" + "param:" + finalPlanEntity + "错误原因:" + e); + taskService.deleteTaskBatch(taskIds); + return false; + } } - + return true; } @@ -290,7 +314,8 @@ public class MaintenanceServiceImpl implements MaintenanceService { * @param finalPlanEntity */ @Override - public void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity,Boolean flag) { +// @Transactional(rollbackFor = Exception.class) + public Long fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity, Boolean flag) { // DefaultTransactionDefinition = new DefaultTransactionDefinition(); // defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition); @@ -320,29 +345,31 @@ public class MaintenanceServiceImpl implements MaintenanceService { taskEntity.setDisposer(userId.replaceAll("\\^", ",")); } else { log.info("计划ID为:{}未查询到排班记录", finalPlanEntity.getId()); - LambdaUpdateWrapper planQueryWrapper = Wrappers.lambdaUpdate() - .set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()) - .eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); - maintenancePlanService.update(planQueryWrapper); - return; +// LambdaUpdateWrapper planQueryWrapper = Wrappers.lambdaUpdate() +// .set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()) +// .eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); +// maintenancePlanService.update(planQueryWrapper); + return null; } } taskService.save(taskEntity); // dataSourceTransactionManager.commit(transaction); +//等当前计划的所有任务生成后更新当前计划时间 +// LambdaUpdateWrapper planQueryWrapper = Wrappers.lambdaUpdate() +// .set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()) +// .eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); +// maintenancePlanService.update(planQueryWrapper); + executor.execute(() -> { + OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId()); + this.pushTaskMessage(maintenanceTask); + }); //启动流程 - String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity,flag); + String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity, flag); LambdaUpdateWrapper taskQueryWrapper = Wrappers.lambdaUpdate() .set(OperMaintenanceTaskEntity::getProcessInstanceId, processInstanceId) .eq(OperMaintenanceTaskEntity::getId, taskEntity.getId()); taskService.update(taskQueryWrapper); - LambdaUpdateWrapper planQueryWrapper = Wrappers.lambdaUpdate() - .set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()) - .eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); - maintenancePlanService.update(planQueryWrapper); - executor.execute(() -> { - OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId()); - this.pushTaskMessage(maintenanceTask); - }); + return taskEntity.getId(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index dab8118..14e4a1e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.RandomUtils; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -136,7 +137,9 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl list) { VoteChartVo voteChartVo = new VoteChartVo(); - List finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() == 3).map(s -> s.getId()).collect(Collectors.toList()); - List undoneIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() != 3).map(s -> s.getId()).collect(Collectors.toList()); + List finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> StringUtil.isNotBlank(s.getFlowTaskName())&&"结束".equals(s.getFlowTaskName())).map(BaseEntity::getId).collect(Collectors.toList()); + //没有流程名称或者流程名称不等于结束,都算未完成 + List undoneIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> StringUtil.isBlank(s.getFlowTaskName())||!"结束".equals(s.getFlowTaskName())).map(BaseEntity::getId).collect(Collectors.toList()); voteChartVo.setSumNum(list.size()); - voteChartVo.setSumIds(list.stream().map(s -> s.getId()).collect(Collectors.toList())); + voteChartVo.setSumIds(list.stream().map(BaseEntity::getId).collect(Collectors.toList())); voteChartVo.setFinishNum(finishIds.size()); voteChartVo.setFinishIds(finishIds); voteChartVo.setUndoneNum(undoneIds.size()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java index 58bf871..ddfd1f9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/TimeUtils.java @@ -112,7 +112,7 @@ public class TimeUtils { } public static List getListByYear(Integer year) { List monthList=new ArrayList<>(); - for (int i = 1; i <13; i++) { + for (int i = 0; i <12; i++) { // 创建一个Calendar对象 Calendar calendar = Calendar.getInstance(); // 设置年份 @@ -143,4 +143,24 @@ public class TimeUtils { String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ; return start; } + + + public static String getEarlyTime(Integer year, Integer month) { + // 创建一个Calendar对象 + Calendar calendar = Calendar.getInstance(); + // 设置年份 + calendar.set(Calendar.YEAR, year); + // 设置月份为1(即一月) + calendar.set(Calendar.MONTH, month-1); + // 设置日期为1 + calendar.set(Calendar.DATE, 1); + // 设置时间为0点0分0秒 + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.add(Calendar.MONTH, -1); + String start = DateUtil.format(calendar.getTime(), DateUtil.PATTERN_DATE) ; + return start; + } + } diff --git a/hzims-service/operational/src/main/resources/log/logback-dev.xml b/hzims-service/operational/src/main/resources/log/logback-dev.xml new file mode 100644 index 0000000..c67cdd9 --- /dev/null +++ b/hzims-service/operational/src/main/resources/log/logback-dev.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + + + + log/info.log + + + log/info/info-%d{yyyy-MM-dd_HH}.%i.log + + 240 + + 20MB + 10GB + true + + + ${log.pattern} + + + + INFO + ACCEPT + DENY + + + + + + log/error.log + + + log/error/error-%d{yyyy-MM-dd_HH}.%i.log + + 360 + + 20MB + 10GB + true + + + ${log.pattern} + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/resources/log/logback-prod.xml b/hzims-service/operational/src/main/resources/log/logback-prod.xml new file mode 100644 index 0000000..3083e23 --- /dev/null +++ b/hzims-service/operational/src/main/resources/log/logback-prod.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + + + + log/info.log + + + log/info/info-%d{yyyy-MM-dd_HH}.%i.log + + 240 + + 20MB + 10GB + true + + + ${log.pattern} + + + + INFO + ACCEPT + DENY + + + + + + log/error.log + + + log/error/error-%d{yyyy-MM-dd_HH}.%i.log + + 360 + + 20MB + 10GB + true + + + ${log.pattern} + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/resources/log/logback-test.xml b/hzims-service/operational/src/main/resources/log/logback-test.xml new file mode 100644 index 0000000..fb3de3c --- /dev/null +++ b/hzims-service/operational/src/main/resources/log/logback-test.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + + + + + + + + + log/error.log + + + log/error/error-%d{yyyy-MM-dd_HH}.%i.log + + 360 + + 20MB + 10GB + true + + + ${log.pattern} + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/resources/template/waterMonReport.docx b/hzims-service/operational/src/main/resources/template/waterMonReport.docx index f29b321..5b3dd55 100644 Binary files a/hzims-service/operational/src/main/resources/template/waterMonReport.docx and b/hzims-service/operational/src/main/resources/template/waterMonReport.docx differ diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/library/service/impl/TicketMatterGroupServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/library/service/impl/TicketMatterGroupServiceImpl.java index 68b1ecb..73dfbc8 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/library/service/impl/TicketMatterGroupServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/library/service/impl/TicketMatterGroupServiceImpl.java @@ -626,7 +626,7 @@ public class TicketMatterGroupServiceImpl extends BaseServiceImpl resultMap = OperationWordHelper.resultMap(workTicketInfoMap); - String workTicketStatus = this.getWorkTicketStatus(status); + String workTicketStatus =getWorkTicketStatus(status); String os = TicketConstant.OS_NAME; //Windows操作系统 if (os != null && os.toLowerCase().startsWith("windows")) { diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java index eee0811..44d27ce 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; -import com.hnac.hzims.message.dto.MessagePushRecordDto; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.feign.ProcessDictFeignService; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; @@ -59,7 +58,6 @@ import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -963,7 +961,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) { String type = measureEnum.getType(); if (tempIndex != Integer.valueOf(type)) { - index = 1; +// index = 1; tempIndex++; } log.info("获取安全措施的信息: {}", measureVO); @@ -984,7 +982,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { //验证工作措施是有有数据 this.isMatterLibraryList(workTicketInfoMap1); // 工作地点保留带电部位或注意事项 - this.matterLibraryListWithMap(workTicketInfoMap1); + matterLibraryListWithMap(workTicketInfoMap1); result.putAll(workTicketInfoMap1); } @@ -1025,12 +1023,13 @@ public class TicketProcessServiceImpl implements TicketProcessService { List ticketInfoDangers = workTicketVo.getTicketInfoDangers(); if (CollectionUtils.isNotEmpty(ticketInfoDangers)) { Map>> map = new HashMap<>(); - int index = 1; + int[] index = {1}; List> collect = ticketInfoDangers.stream().map(item -> { Map newItem = new HashMap<>(); - newItem.put("index", index); + newItem.put("index", index[0]); newItem.put("maintenance", item.getMaintenance() == null ? "\u00A0" : item.getMaintenance()); newItem.put("dangerousPoint", item.getDangerousPoint() == null ? "\u00A0" : item.getDangerousPoint()); + index[0]++; return newItem; }).collect(Collectors.toList()); @@ -1041,7 +1040,7 @@ public class TicketProcessServiceImpl implements TicketProcessService { WordMapUtils.newMapWithList("ticketInfoDangers", result, true, 4, "maintenance", "dangerousPoint"); //7. 是否包含 - this.isExists(result); + isExists(result); //8. 存入新的数据 this.addMapPut(result); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/OfflineTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/OfflineTicketServiceImpl.java index ec5c331..179898e 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/OfflineTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/OfflineTicketServiceImpl.java @@ -8,7 +8,6 @@ import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.ticket.constants.WorkTicketConstants; -import com.hnac.hzims.ticket.twoTicket.constant.TicketConstant; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketContentEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketFlowEntity; @@ -40,7 +39,6 @@ import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.List; -import java.util.Optional; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -61,7 +59,7 @@ public class OfflineTicketServiceImpl extends BaseServiceImpl