Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 2 years ago
parent
commit
9da9b12d7d
  1. 1
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java
  2. 4
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java
  3. 52
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java
  4. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java
  5. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/DiagnoseFaultReq.java
  6. 39
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/scheduled/ThreadTask.java
  7. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java
  8. 58
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java
  9. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java
  10. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  11. 118
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java
  12. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.xml
  13. 26
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.xml
  14. 10
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java
  15. 23
      hzims-service/hzims-scheduled/src/main/resources/application.yml
  16. 0
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml
  17. 0
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml
  18. 21
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java
  19. 4
      hzims-service/operational/pom.xml
  20. 6
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java
  21. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  22. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java
  23. 45
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  24. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java
  25. 16
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  26. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java
  27. 10
      hzims-service/ticket/pom.xml
  28. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java
  29. 1
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java
  30. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java
  31. 21
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  32. 67
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketInfoDanger.java
  33. 32
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java
  34. 13
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/TicketInfoDangerMapper.java
  35. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/TicketInfoDangerMapper.xml
  36. 24
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketInfoDangerService.java
  37. 11
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java
  38. 37
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketInfoDangerServiceImpl.java
  39. 440
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  40. 12
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java
  41. 178
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java
  42. 84
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java
  43. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/dto/WorkTicketInfoDto.java
  44. 107
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java
  45. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketPrincipalChangeServiceImpl.java
  46. 2
      hzims-service/ticket/src/main/resources/application.yml
  47. BIN
      hzims-service/ticket/src/main/resources/template/secondary/动火工作票.docx
  48. BIN
      hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx
  49. BIN
      hzims-service/ticket/src/main/resources/template/secondary/工作票安全措施附页.docx
  50. BIN
      hzims-service/ticket/src/main/resources/template/secondary/有限空间监测记录单.docx
  51. BIN
      hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx
  52. BIN
      hzims-service/ticket/src/main/resources/template/第一种工作票.docx

1
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java

@ -102,6 +102,7 @@ public interface TicketConstants {
MECHANICAL_WORK("8","大隆水电站水力机械工作票模板"),
EMERGENCY_REPAIR("9","大隆水电站事故应急抢修单模板"),
NEW_FIRST_WORK("10","新电气第一种工作票模板"),
NEW_FIRST_WORK1("11","第一种工作票"),
;
@Getter
private String type;

4
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java

@ -19,7 +19,9 @@ public interface WorkTicketConstants {
TWO("2","matterLibraryListTwo"),
/**第三种安措**/
THREE("3","matterLibraryListThree"),
FOUR("4","matterLibraryListFour")
FOUR("4","matterLibraryListFour"),
Five("5","matterLibraryListFive"),
Flow("6","matterLibraryListFlow"),
;
@Getter
private String type;

52
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java

@ -403,14 +403,14 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
* 下一个审批人
*/
@ApiModelProperty("下一个审批人")
private Long nextStepOperator;
private String nextStepOperator;
/**
* 当前审批人
*/
@ApiModelProperty("当前审批人")
private Long stepOperator;
private String stepOperator;
/**
@ -427,4 +427,52 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private String flowTaskId;
/**
* 项目名称
*/
@ApiModelProperty("项目名称")
private String projectName;
/**
* 工作接收人
*/
@ApiModelProperty("工作接收人")
private String jobReceiver;
/**
* 工作接收人时间
*/
@ApiModelProperty("工作接收人时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime jobReceiverTime;
/**
* 安全隔离措施附页 (true,展示附件,false,不展示附件)
*/
@ApiModelProperty("安全隔离措施附页 (true,展示附件,false,不展示附件)")
private Boolean isSafety;
/**
* 危险点分析与预控措施票 (true,展示附件,false,不展示附件)
*/
@ApiModelProperty("危险点分析与预控措施票 (true,展示附件,false,不展示附件)")
private Boolean isHazard;
/**
* 动火工作票 (true,展示附件,false,不展示附件)
*/
@ApiModelProperty("动火工作票 (true,展示附件,false,不展示附件)")
private Boolean isRailway;
/**
*有限空间监测记录单(true,展示附件,false,不展示附件)
*/
@ApiModelProperty("有限空间监测记录单 (true,展示附件,false,不展示附件)")
private Boolean isLimited;
}

4
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/controller/FdpMonitorController.java

@ -22,7 +22,6 @@ import com.hnac.hzims.monitor.dto.FdpMonitorBindingDTO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeInstanceFieldVO;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.mp.support.Condition;
@ -274,7 +273,8 @@ public class FdpMonitorController extends BladeController {
@ApiOperationSupport(order = 180)
@ApiOperation(value = "获取实时、历史数据返回生成ID-旧版")
public R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO){
return service.getRealTimeHisData(taskDTO);
// return service.getRealTimeHisData(taskDTO);
return R.fail("此端口弃用,请访问新的接口");
}
@PostMapping("/updateFaultStateAll/getRealTimeHisDataNew")

3
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/request/DiagnoseFaultReq.java

@ -1,7 +1,6 @@
package com.hnac.hzims.fdp.request;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -24,7 +23,7 @@ public class DiagnoseFaultReq implements Serializable {
@ApiModelProperty(value = "故障可信度 人工诊断点击或者人工发现时,该故障的状态,发生为1,不发生为0。不确认发生或没发生时填入0-1之间的值。", required = true)
@JSONField(name = "confidence")
private Double status;
private Double confidence;
@ApiModelProperty("是否有效")
@JSONField(name = "is_deleted")

39
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/scheduled/ThreadTask.java

@ -13,7 +13,6 @@ import com.hnac.hzims.fdp.response.DiagnoseNextstepResp;
import com.hnac.hzims.fdp.service.IFdpFaultService;
import com.hnac.hzims.fdp.util.HttpRequestUtil;
import com.hnac.hzims.fdp.vo.FdpHttpResponseVo;
import com.hnac.hzims.fdp.vo.FdpRealTimeAndHisDataVo;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -50,13 +49,13 @@ public class ThreadTask {
//诊断
public static void fdpTask(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
public static void fdpTask(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, String key) {
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
//异步任务
updateFaultState(taskDTO, fdpFaultEntity, vo, key);
updateFaultState(taskDTO, fdpFaultEntity, key);
}
};
Thread thread = new Thread(runnable);
@ -84,6 +83,24 @@ public class ThreadTask {
// }
// }
//诊断
public static void fdpTaskNew(FdpTaskDTO taskDTO, FdpFaultEntity fdpFaultEntity, String key) {
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
//异步任务
updateFaultStateNew(taskDTO, fdpFaultEntity, key);
}
};
Thread thread = new Thread(runnable);
thread.start();
} catch (Exception e) {
log.error(e.getMessage(), e.toString());
}
}
// 声明对象
public static ThreadTask threadTask;
@ -102,20 +119,18 @@ public class ThreadTask {
/**
* 修改诊断状态
*
* @param vo
* @param key
*/
private static void updateFaultState(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
private static void updateFaultState(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, String key) {
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(vo);
// faultAllReq.setAutoData(vo);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());
@ -181,20 +196,18 @@ public class ThreadTask {
/**
* 修改诊断状态
*
* @param vo
* @param key
*/
private static void updateFaultStateNew(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, FdpRealTimeAndHisDataVo vo, String key) {
private static void updateFaultStateNew(FdpTaskDTO req, FdpFaultEntity fdpFaultEntity, String key) {
/**更新故障状态**/
DiagnoseFaultAllReq faultAllReq = new DiagnoseFaultAllReq();
faultAllReq.setAutoData(vo);
// faultAllReq.setAutoData(vo);
faultAllReq.setStationId(fdpFaultEntity.getStationId());
DiagnoseFaultReq diagnoseFaultReq = new DiagnoseFaultReq();
diagnoseFaultReq.setTaskId(req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());

3
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/IFdpMonitorService.java

@ -1,6 +1,5 @@
package com.hnac.hzims.fdp.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.fdp.dto.FdpMonitorDTO;
import com.hnac.hzims.fdp.dto.FdpMonitorExtendDTO;
@ -148,7 +147,7 @@ public interface IFdpMonitorService extends BaseService<FdpMonitorEntity> {
R updateFaultState(@RequestBody DiagnoseFaultReq diagnoseFaultReq);
R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO);
// R getRealTimeHisData(@RequestBody FdpTaskDTO taskDTO);
R getRealTimeHisDataNew(@RequestBody FdpTaskDTO taskDTO);

58
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpMonitorServiceImpl.java

@ -418,32 +418,32 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
}
}
@Override
public R getRealTimeHisData(FdpTaskDTO taskDTO) {
/**获取故障对象**/
LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1");
FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
if (ObjectUtil.isEmpty(fdpFaultEntity)) {
throw new ServiceException("获取对应故障对象失败");
}
/**获取实时、历史数据**/
FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//String key = UUID.randomUUID().toString();
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
String key = taskDTO.getId().toString();
//异步处理
ThreadTask.fdpTask(taskDTO, fdpFaultEntity, pushResp, key);
//获取数据成功-》 告知前端
Map<String, String> map = new HashMap<>();
map.put("id", key);
return R.data(map);
}
// @Override
// public R getRealTimeHisData(FdpTaskDTO taskDTO) {
// /**获取故障对象**/
// LambdaQueryWrapper<FdpFaultEntity> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(FdpFaultEntity::getFdpId, taskDTO.getFaultId()).last("limit 1");
// FdpFaultEntity fdpFaultEntity = fdpFaultService.getOne(wrapper);
// if (ObjectUtil.isEmpty(fdpFaultEntity)) {
// throw new ServiceException("获取对应故障对象失败");
// }
// /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//
//
// //String key = UUID.randomUUID().toString();
// boolean flag = fdpTaskService.save(taskDTO);
// if (!flag) {
// return R.fail("诊断任务保存失败");
// }
// String key = taskDTO.getId().toString();
// //异步处理
// ThreadTask.fdpTask(taskDTO, fdpFaultEntity, pushResp, key);
// //获取数据成功-》 告知前端
// Map<String, String> map = new HashMap<>();
// map.put("id", key);
// return R.data(map);
// }
@Override
public R getRealTimeHisDataNew(FdpTaskDTO taskDTO) {
@ -456,14 +456,14 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
}
// /**获取实时、历史数据**/
// FdpRealTimeAndHisDataVo pushResp = this.dataPushByPartition(fdpFaultEntity.getFdpPartition(), fdpFaultEntity.getCreateDept());
//String key = UUID.randomUUID().toString();
// String key = UUID.randomUUID().toString();
boolean flag = fdpTaskService.save(taskDTO);
if (!flag) {
return R.fail("诊断任务保存失败");
}
String key = taskDTO.getId().toString();
// //异步处理 20230426 此接口弃用
// ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, pushResp, key);
ThreadTask.fdpTaskNew(taskDTO, fdpFaultEntity, key);
//获取数据成功-》 告知前端
Map<String, String> map = new HashMap<>();
map.put("id", key);
@ -582,7 +582,7 @@ public class FdpMonitorServiceImpl extends BaseServiceImpl<FdpMonitorMapper, Fdp
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}", req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseFaultReq.setTenantId(fdpFaultEntity.getStationId());

8
hzims-service/equipment/src/main/java/com/hnac/hzims/fdp/service/impl/FdpTaskServiceImpl.java

@ -17,21 +17,15 @@ import com.hnac.hzims.operational.defect.feign.IOperPhenomenonClient;
import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author xiashandong
* @created 2021-05-25 17:32
@ -52,7 +46,7 @@ public class FdpTaskServiceImpl extends BaseServiceImpl<FdpTaskMapper, FdpTaskEn
diagnoseFaultReq.setTaskId(req.getId().toString());
log.info("存入taskId为:{}",req.getId().toString());
diagnoseFaultReq.setFaultId(req.getFaultId());
diagnoseFaultReq.setStatus(1.0);
diagnoseFaultReq.setConfidence(1.0);
diagnoseFaultReq.setLifeTime(1);
diagnoseFaultReq.setPriority(2);
diagnoseProxy.updateFaultState(diagnoseFaultReq);

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java

@ -18,7 +18,7 @@ import javax.annotation.Resource;
@EnableBladeFeign
@SpringCloudApplication
@MapperScan("com.hnac.hzims.scheduled.**.mapper.**")
@ComponentScan(basePackages = {"com.hnac.*","org.springblade.core.*"})
@ComponentScan(basePackages = {"com.hnac.*","org.springblade.core"})
@Resource
public class ScheduledApplication {
public static void main(String[] args) {

118
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/config/XxlJobConfig.java

@ -1,59 +1,59 @@
package com.hnac.hzims.scheduled.config;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2022/1/8 10:23
*/
@Slf4j
@Configuration
//指定任务Handler所在包路径
public class XxlJobConfig {
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
@Value("${xxl.job.executor.ip}")
private String ip;
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
log.info("====xxl-job config init====");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppName(appName);
xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
}
// package com.hnac.hzims.scheduled.config;
//
// import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
// import lombok.extern.slf4j.Slf4j;
// import org.springframework.beans.factory.annotation.Value;
// import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.ComponentScan;
// import org.springframework.context.annotation.Configuration;
//
// /**
// * @Author WL
// * @Version v1.0
// * @Serial 1.0
// * @Date 2022/1/8 10:23
// */
// @Slf4j
// @Configuration
// //指定任务Handler所在包路径
// public class XxlJobConfig {
//
//
// @Value("${xxl.job.admin.addresses}")
// private String adminAddresses;
//
// @Value("${xxl.job.executor.appname}")
// private String appName;
//
// @Value("${xxl.job.executor.ip}")
// private String ip;
//
// @Value("${xxl.job.executor.port}")
// private int port;
//
// @Value("${xxl.job.accessToken}")
// private String accessToken;
//
// @Value("${xxl.job.executor.logpath}")
// private String logPath;
//
// @Value("${xxl.job.executor.logretentiondays}")
// private int logRetentionDays;
//
//
// @Bean(initMethod = "start", destroyMethod = "destroy")
// public XxlJobSpringExecutor xxlJobExecutor() {
// log.info("====xxl-job config init====");
// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
// xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
// xxlJobSpringExecutor.setAppName(appName);
// xxlJobSpringExecutor.setIp(ip);
// xxlJobSpringExecutor.setPort(port);
// xxlJobSpringExecutor.setAccessToken(accessToken);
// xxlJobSpringExecutor.setLogPath(logPath);
// xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
// return xxlJobSpringExecutor;
// }
//
// }
//

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/HistoryAbnormalAlarmMapper.xml

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.HistoryAbnormalAlarmMapper">
<select id="getHistoryAbnormalAlarm" resultType="com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity">
select * from hzims_history_abnormal_alarm
where station_id = #{stationId}
and type = #{type}
and status = 0
</select>
</mapper>

26
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StationMapper.xml

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.StationMapper">
<select id="selectStationByType" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL and `TYPE` IS NOT NULL
<if test="serveType != null">
AND SERVE_TYPE = #{serveType}
</if>
<if test="stationType != null">
AND `TYPE` = #{stationType}
</if>
</select>
<select id="selectAll" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
select * from hzims_station where IS_DELETED = 0 and REF_DEPT IS NOT NULL AND REF_DOMAIN IS NOT NULL AND `TYPE` IS NOT NULL
</select>
<select id="selectStationByInCode" resultType="com.hnac.hzims.operational.station.entity.StationEntity">
SELECT * FROM hzims_station WHERE IS_DELETED = 0 and `CODE` IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper>

10
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ScheduledCreateTask.java

@ -31,7 +31,6 @@ public class ScheduledCreateTask {
* @return ReturnT<String>
*/
@XxlJob(LOAD_WATER_LEVEL)
//@Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterLevel(String param) throws Exception {
if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM");
@ -42,5 +41,14 @@ public class ScheduledCreateTask {
/**
* 水利-站点水位数据
* @return ReturnT<String>
*/
@XxlJob("cheshi")
public ReturnT<String> cheshi(String param) throws Exception {
System.out.println("执行呢方法");
return new ReturnT<>("SUCCESS");
}
}

23
hzims-service/hzims-scheduled/src/main/resources/application.yml

@ -36,23 +36,38 @@ spring:
# redis访问密码(默认为空)
password: 1qaz2WSX@redis
#xxl:
# job:
# accessToken: ''
# admin:
# addresses: http://192.168.1.3:7009/xxl-job-admin
# executor:
# appname: hzims-operational
# ip: 192.168.1.3
# logpath: /data/applogs/xxl-job/jobhandler
# logretentiondays: -1
# port: 28501
xxl:
job:
accessToken: ''
admin:
addresses: http://192.168.1.3:7009/xxl-job-admin
addresses: http://192.168.5.128:9080/xxl-job-admin
executor:
appname: hzims-operational
ip: 192.168.1.3
ip: 192.168.18.232
logpath: /data/applogs/xxl-job/jobhandler
logretentiondays: -1
port: 28501
#mybatis-plus配置
mybatis-plus:
mapper-locations: classpath:com/hnac/hzims/**/mapper/*Mapper.xml
mapper-locations: classpath*:/mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.hnac.hzims.**.entity
# typeAliasesPackage: com.hnac.hzims.**.entity
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#swagger扫描路径配置
swagger:

0
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/AbnormalAlarmMapper.xml → hzims-service/hzims-scheduled/src/main/resources/mapper/operation/AbnormalAlarmMapper.xml

0
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/StAlarmRecordMapper.xml → hzims-service/hzims-scheduled/src/main/resources/mapper/operation/StAlarmRecordMapper.xml

21
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/SmsMessageServiceImpl.java

@ -2,12 +2,11 @@ package com.hnac.hzims.message.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.api.client.util.Value;
import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.dto.PushDto;
import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.entity.MessagePushRecordEntity;
import com.hnac.hzims.message.log.aspect.SaveLog;
import com.hnac.hzims.message.service.IMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -19,6 +18,7 @@ import org.springblade.core.tool.utils.Func;
import org.springblade.resource.feign.ISmsClient;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* @author hx
@ -54,9 +54,16 @@ public class SmsMessageServiceImpl implements IMessageService {
request.getSmsParam(),
this.getAccountByPusher(Long.parseLong(request.getPusher()),request.getType())
);
Assert.isTrue(response.isSuccess(),() -> {
throw new ServiceException(response.getMsg());
});
return response.getData().isSuccess();
if(ObjectUtils.isEmpty(response.getData())) {
Assert.isTrue(response.isSuccess(), () -> {
throw new ServiceException(response.getMsg());
});
return response.isSuccess();
}else {
Assert.isTrue(response.getData().isSuccess(), () -> {
throw new ServiceException(response.getMsg());
});
return response.getData().isSuccess();
}
}
}

4
hzims-service/operational/pom.xml

@ -100,8 +100,8 @@
<!-- 月报统计图表导出-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.15</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>

6
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/AppHomeController.java

@ -31,7 +31,7 @@ public class AppHomeController extends BladeController {
@ApiLog
@ApiOperation("app首页-站点")
@GetMapping("/appStation")
@ApiOperationSupport(order = 11)
@ApiOperationSupport(order = 1)
public R<List<AppStationVo>> appStation(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(appService.appStation(deptId));
}
@ -39,7 +39,7 @@ public class AppHomeController extends BladeController {
@ApiLog
@ApiOperation("app首页-站点列表数据")
@GetMapping("/appStationList")
@ApiOperationSupport(order = 11)
@ApiOperationSupport(order = 2)
public R<List<AppStationAreaVo>> appStationList(@ApiParam(value = "机构ID") Long deptId) {
return R.data(appService.appStationList(deptId));
}
@ -47,7 +47,7 @@ public class AppHomeController extends BladeController {
@ApiLog
@ApiOperation("app首页-当班数据")
@GetMapping("/getDutyData")
@ApiOperationSupport(order = 11)
@ApiOperationSupport(order = 3)
public R<List<AppAreaDutyVo>> getDutyData(@ApiParam(value = "区域机构ID") Long deptId) {
return R.data(appService.getDutyData(deptId));
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java

@ -65,6 +65,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
@ -73,10 +74,12 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
po.setSignboardConditions(signboardConditions);
log.error("period_target_data_request {}",po);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return new ArrayList<>();
}
log.error("period_target_data_resp {}",result);
return result.getData().get(0).getList();
}
@ -99,6 +102,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java

@ -567,14 +567,17 @@ public class AppHomeServiceImpl implements IAppHomeService {
item.setClassMember(classMember);
}
/**
* 获取下一班组数据
* @param item
*
* @param id
*/
private void getNextDuty(AppAreaDutyVo item, Long id) {
DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id);
if(ObjectUtil.isEmpty(nextDuty)){
if(ObjectUtil.isEmpty(nextDuty) || ObjectUtil.isEmpty(nextDuty.getId())){
return;
}
item.setNextShift(nextDuty.getClassName());

45
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -118,6 +118,8 @@ public class HydropowerServiceImpl implements HydropowerService {
private final static String load_hydropower_unit_target_key = "hzims:operation:loadhydropowerunit:target:key";
private final static String loadwater_level_key = "hzims:operation:loadwater:level:key";
private final static String loadwater_group_key = "hzims:operation:group:key";
private final static int POOL_QUANTITY = 4;
private final static int DUTY_POOL_QUANTITY = 5;
@ -131,7 +133,7 @@ public class HydropowerServiceImpl implements HydropowerService {
public void loadHydropowerReal(String param) {
// 水电站站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
//.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
@ -189,7 +191,7 @@ public class HydropowerServiceImpl implements HydropowerService {
public void loadHydropowerTarget(String param) {
// 水电站站点
List<StationEntity> stations = stationService.list(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
//.eq(StationEntity::getServeType,HomePageConstant.HYDROPOWER_SERVETYPE)
.eq(StationEntity::getType,HomePageConstant.HYDROPOWER)
);
if(CollectionUtil.isEmpty(stations)){
@ -749,7 +751,12 @@ public class HydropowerServiceImpl implements HydropowerService {
if(CollectionUtil.isEmpty(realList)){
return 0.0;
}
return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum();
return realList.stream().filter(o->deptId.equals(o.getDeptId())).mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum();
}
/**
@ -1006,7 +1013,12 @@ public class HydropowerServiceImpl implements HydropowerService {
// 容量
kpi.setInstalledCapacity(reals.stream().mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum());
// 负荷
kpi.setLoad(reals.stream().mapToDouble(HydropowerUnitRealVo::getActivePower).sum());
kpi.setLoad(reals.stream().mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum());
// 容量利用率
if (Math.abs(kpi.getInstalledCapacity()) <= 0) {
kpi.setCapacityRate(0.0);
@ -1105,7 +1117,12 @@ public class HydropowerServiceImpl implements HydropowerService {
// 实时数据: 容量利用率、电站利用率
if(CollectionUtil.isNotEmpty(reals)){
// 实时功率
double use = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getActivePower).sum();
double use = reals.stream().filter(real->entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(o->{
if("MW".equalsIgnoreCase(o.getPowerUnit())){
return o.getActivePower() * 1000;
}
return o.getActivePower();
}).sum();
if(CollectionUtil.isNotEmpty(plans)){
// 装机容量
double capacity = reals.stream().filter(real-> entry.getValue().stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(real.getDeptId())).mapToDouble(HydropowerUnitRealVo::getInstalledCapacity).sum();
@ -1131,11 +1148,11 @@ public class HydropowerServiceImpl implements HydropowerService {
if(Math.abs(generate_sum) > 0){
return scales.stream().peek(scale-> scale.setAreaMakeUp(BigDecimal.valueOf(scale.getPowerYear() / generate_sum * 100).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue())).
filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0
&& Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0)
|| Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0)
.sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList());
}
return scales.stream().peek(scale-> scale.setAreaMakeUp(0.0)).filter(scale-> Math.abs(scale.getCapacityUse()) > 0 || Math.abs(scale.getAreaMakeUp()) > 0
&& Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0)
|| Math.abs(scale.getDeviceUse()) > 0 || Math.abs(scale.getGenerationRate()) > 0)
.sorted(Comparator.comparing(AreaScaleVo::getPowerYear).reversed()).collect(Collectors.toList());
}
@ -1219,6 +1236,10 @@ public class HydropowerServiceImpl implements HydropowerService {
*/
@Override
public List<HydropowerAreaVo> group(Long deptId) {
List<HydropowerAreaVo> gourps = (List<HydropowerAreaVo>) redisTemplate.opsForValue().get(loadwater_group_key + deptId);
if(CollectionUtil.isNotEmpty(gourps)){
return gourps;
}
Map<Dept,List<StationEntity>> areas = areaService.areaOrStaion(deptId,Collections.singletonList(HomePageConstant.HYDROPOWER));
if(MapUtils.isEmpty(areas)) {
return new ArrayList<>();
@ -1237,7 +1258,7 @@ public class HydropowerServiceImpl implements HydropowerService {
areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList())));
// 计划发电量
List<PlanGenerationEntity> plans = planGenertionClient.getPlanGenerationByParam(codes,null,String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));
return areas.entrySet().stream().map(entry->{
List<HydropowerAreaVo> hydropowerAreas = areas.entrySet().stream().map(entry->{
HydropowerAreaVo area = new HydropowerAreaVo();
area.setDeptId(entry.getKey().getId());
area.setDeptName(entry.getKey().getDeptName());
@ -1260,6 +1281,9 @@ public class HydropowerServiceImpl implements HydropowerService {
area.setStationTargets(this.stationTarget(entry.getValue(),reals,targets,plans));
return area;
}).sorted(Comparator.comparing(HydropowerAreaVo::getReality)).collect(Collectors.toList());
redisTemplate.opsForValue().set(loadwater_group_key,hydropowerAreas);
redisTemplate.expire(loadwater_group_key,5, TimeUnit.MINUTES);
return hydropowerAreas;
}
/**
@ -1630,6 +1654,9 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param item
*/
private void settingBase(DutyMainInfoVo duty, AppAreaDutyVo item) {
if(ObjectUtil.isEmpty(duty)){
return;
}
item.setShift(duty.getClassName());
item.setTeam(Optional.ofNullable(duty.getGroupName()).orElse("灵活排班"));
// 班组负责人
@ -1647,7 +1674,7 @@ public class HydropowerServiceImpl implements HydropowerService {
*/
private void getNextDuty(AppAreaDutyVo item, Long id) {
DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id);
if(ObjectUtil.isEmpty(nextDuty)){
if(ObjectUtil.isEmpty(nextDuty) || ObjectUtil.isEmpty(nextDuty.getId())){
return;
}
item.setNextShift(nextDuty.getClassName());

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java

@ -1352,9 +1352,9 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService {
}
return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{
PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo();
LocalDateTime time = LocalDateTime.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME));
LocalDateTime time = LocalDateTime.parse(DateUtil.format(DateUtil.parse(entry.getKey(), "yyyy-MM-dd HH:mm:ss.s"),DateUtil.PATTERN_DATETIME), DateUtil.DATETIME_FORMATTER);
target.setPeriod(String.valueOf(time.getHour()));
target.setValue((float) entry.getValue().stream().mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
target.setValue((float) entry.getValue().stream().filter(val -> !StringUtil.isEmpty(val.getVal())).mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum());
return target;
}).collect(Collectors.toList());
}

16
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java

@ -307,6 +307,7 @@ public class SideHustleServiceImpl implements ISideHustleService {
// 故障
List<OperPhenomenonEntity> operPhenomenonEntityList = operPhenomenonService.list(new QueryWrapper<OperPhenomenonEntity>() {{
in("EM_CODE", deviceCodeList);
ne("IS_DEFECT",DefectConstant.IsDefectStatusEnum.IS_DEFECT.getStatus());
ne("CONCLUSION_STATUS", DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus());
}});
List<String> faultList = operPhenomenonEntityList.stream().map(OperPhenomenonEntity::getEmCode).distinct().collect(Collectors.toList());
@ -343,20 +344,23 @@ public class SideHustleServiceImpl implements ISideHustleService {
return runDeviceList.stream().map(o ->{
Map<String,String> points = o.getPoint();
if(CollectionUtil.isEmpty(points)){
return "";
return "0";
}
String realId = points.get(HomePageConstant.JOINT_RELAY);
if(StringUtil.isBlank(realId)){
return "";
if(StringUtil.isEmpty(realId)){
return "0";
}
if(MapUtils.isEmpty(realMap)){
return "0";
}
String value = realMap.get(realId);
if(StringUtil.isBlank(value)){
return "";
if(StringUtil.isEmpty(value)){
return "0";
}
if (value.contains("1") || "1.0".equals(value)) {
return o.getEmCode();
}
return "";
return "0";
}).distinct().collect(Collectors.toList());
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WaterServiceImpl.java

@ -748,7 +748,7 @@ public class WaterServiceImpl implements IWaterService {
calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH));
String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00";
// 查询数据
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.HYDROPOWER_GENERATE_POWER);
List<AnalyseDataTaosVO> records = analyseDataService.periodTargetData(start,end,5,5,device.getEmCode(),HomePageConstant.ELECTRICITY_CONSUMPTION);
if(CollectionUtil.isEmpty(records)){
return new HashMap<>();
}

10
hzims-service/ticket/pom.xml

@ -275,11 +275,11 @@
<!-- </dependency>-->
<!--swagger-bootstrap-ui-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap-ui.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.xiaoymin</groupId>-->
<!-- <artifactId>swagger-bootstrap-ui</artifactId>-->
<!-- <version>${swagger-bootstrap-ui.version}</version>-->
<!-- </dependency>-->
</dependencies>
<repositories>

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java

@ -10,6 +10,5 @@ package com.hnac.hzims.ticket.processflow.constant;
*/
public class TicketProcessConstant {
// public final static String STARTEVENT = "startEvent1";
public final static String STARTEVENT = "workTicket";
public final static String STARTEVENT = "workTicketFlow";
}

1
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java

@ -48,6 +48,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume {
if (ObjectUtils.isNotEmpty(ticketService)) {
//执行业务方法
try {
response.setNum(1);
ticketService.calculate(response);
} catch (Exception e) {
e.printStackTrace();

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java

@ -50,4 +50,12 @@ public class ProcessWorkFlowResponse implements Serializable {
/**票据表单**/
private Object variables;
/**
* 根据handleType区分是用户还是候选组角色 标识 0是用户 1是角色
*/
private String handleType;
private Integer num;
}

21
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java

@ -16,12 +16,15 @@ import org.springblade.flow.core.vo.ComleteTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 工作票
*
* @Author WL
* @Version v1.0
* @Serial 1.0
@ -35,33 +38,31 @@ import java.util.Map;
public class TicketProcessController {
private final TicketProcessService ticketProcessService;
private final TicketProcessService ticketProcessService;
/**
* 启动流程
*
* @return
*/
@ApiOperation("启动流程")
@PostMapping("/startUp")
public R start(@RequestBody WorkTicketVo workTicketVo) {
ticketProcessService.startUp(workTicketVo);
return R.success("启动流程成功");
return R.success("申请开票成功");
}
/**
* 预览
* @param ticketType
* @param ticketId
*/
@GetMapping("/preview")
@ApiOperation(value = "预览")
@GetMapping("/newPreview")
@ApiOperation(value = "预览")
@ApiOperationSupport(order = 11)
public R preview(@RequestParam @ApiParam("票据类型") String ticketType, @RequestParam @ApiParam("票据ID") Long ticketId) {
String preview = ticketProcessService.preview(ticketType, ticketId);
return R.data(preview);
public void preview(@RequestParam(value = "ticketId", required = true) Long ticketId,
HttpServletResponse response) {
ticketProcessService.newPreview(ticketId, response);
}
}

67
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/TicketInfoDanger.java

@ -0,0 +1,67 @@
package com.hnac.hzims.ticket.twoTicket.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
*
* 工作票危险点分析及控制措施票
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/25 17:03
*/
@Data
@TableName("hzims_ticket_info_danger")
public class TicketInfoDanger {
/**
* 编号
*/
private Long id;
/**
* 工作票编号
*/
private Long ticketId;
/**
* 安全措施
*/
private String maintenance;
/**
* 危险点
*/
private String dangerousPoint;
/**
* 创建时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
/**
* 逻辑删除
*/
@TableLogic
@TableField("is_deleted")
private Boolean deleted;
}

32
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/entity/WorkTicketFinish.java

@ -26,7 +26,7 @@ import java.time.LocalDateTime;
@TableName("hzims_work_ticket_finish")
public class WorkTicketFinish implements Serializable {
private static final long serialVersionUID=1L;
private static final long serialVersionUID = 1L;
/**
* 编号
@ -99,7 +99,6 @@ public class WorkTicketFinish implements Serializable {
private Long principal;
/**
* 许可人
*/
@ -108,7 +107,6 @@ public class WorkTicketFinish implements Serializable {
private Long licensor;
/**
* 负责人工作结束时间
*/
@ -126,8 +124,7 @@ public class WorkTicketFinish implements Serializable {
/**
* 结束时间
*/
private LocalDateTime workEndTime;
private LocalDateTime workEndTime;
/**
@ -140,7 +137,30 @@ public class WorkTicketFinish implements Serializable {
* 交底内容
*/
@ApiModelProperty("交底内容")
private String tellContent;
private String tellContent;
/**
* 刀闸编号
*/
private String brakeNumber;
/**
* 监护人
*/
private Long guardian;
/**
* 监护人地点
*/
private String guardianPlace;
/**
* 其他事项
*/
private String otherItems;
}

13
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/TicketInfoDangerMapper.java

@ -0,0 +1,13 @@
package com.hnac.hzims.ticket.twoTicket.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/25 17:13
*/
public interface TicketInfoDangerMapper extends BaseMapper<TicketInfoDanger> {
}

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/TicketInfoDangerMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper">
</mapper>

24
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketInfoDangerService.java

@ -0,0 +1,24 @@
package com.hnac.hzims.ticket.twoTicket.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/25 17:15
*/
public interface TicketInfoDangerService extends IService<TicketInfoDanger> {
/**
* 根据工作票Id查询工作票危险点分析及控制措施票
* @param ticketId
* @return
*/
List<TicketInfoDanger> selectAllByTicket(Long ticketId);
}

11
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java

@ -3,6 +3,8 @@ package com.hnac.hzims.ticket.twoTicket.service;
import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import javax.servlet.http.HttpServletResponse;
/**
* 开票处理流程接口
* @Author dfy
@ -25,10 +27,11 @@ public interface TicketProcessService {
void findPending(ProcessWorkFlowResponse response);
/**
* 预览
* @param ticketType
* @param ticketId
* 预览
* @param response
* @return
*/
String preview(String ticketType, Long ticketId);
void newPreview(Long ticketId, HttpServletResponse response);
}

37
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketInfoDangerServiceImpl.java

@ -0,0 +1,37 @@
package com.hnac.hzims.ticket.twoTicket.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.mapper.TicketInfoDangerMapper;
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/25 17:15
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class TicketInfoDangerServiceImpl extends ServiceImpl<TicketInfoDangerMapper, TicketInfoDanger> implements TicketInfoDangerService {
/**
* 根据工作票Id查询工作票危险点分析及控制措施票
*
* @param ticketId
* @return
*/
@Override
public List<TicketInfoDanger> selectAllByTicket(Long ticketId) {
LambdaQueryWrapper<TicketInfoDanger> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TicketInfoDanger::getTicketId,ticketId);
return baseMapper.selectList(queryWrapper);
}
}

440
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -20,12 +20,15 @@ import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.constants.WorkTicketConstants;
import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker;
import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService;
import com.hnac.hzims.ticket.twoTicket.service.IWorkTicketFinishService;
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService;
import com.hnac.hzims.ticket.twoTicket.vo.process.FristWorkTicketVo;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import com.hnac.hzims.ticket.utils.MergeDocUtils;
import com.hnac.hzims.ticket.utils.PdfUtils;
import com.hnac.hzims.ticket.workTicket.entity.*;
import com.hnac.hzims.ticket.workTicket.service.*;
@ -34,6 +37,7 @@ import com.hnac.hzims.ticket.workTicket.service.impl.WorkTicketOperateTimeServic
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
@ -51,6 +55,9 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileOutputStream;
import java.time.LocalDateTime;
import java.util.*;
@ -100,7 +107,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private final IAccessTaskClient accessTaskClient;
private String newFirstWorkTicketFlowKey = "workTicket";
private String newFirstWorkTicketFlowKey = "workTicketFlow";
private final IStationClient stationClient;
@ -126,6 +133,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private String templatePath;
private final TicketInfoDangerService ticketInfoDangerService;
/**
* 启动开票流程
*
@ -137,28 +147,28 @@ public class TicketProcessServiceImpl implements TicketProcessService {
public void startUp(WorkTicketVo workTicketVo) {
log.info("执行 com.hnac.hzims.ticket.twoTicket.service.impl【startUp】 。。。方法");
if (workTicketVo.getWorkTicket().getSignage() == null) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
StationEntity stationEntity = new StationEntity();
stationEntity.setCode(workTicketVo.getWorkTicket().getSignageCode());
R<StationEntity> stationClientOne = stationClient.getOne(stationEntity);
if (!stationClientOne.isSuccess()) {
throw new IllegalArgumentException("根据条件获取唯一站点出错呢");
throw new IllegalArgumentException("站点编码不能为空");
}
StationEntity station = stationClientOne.getData();
if (station == null) {
throw new ServiceException("根据条件获取唯一站点暂无数据");
throw new ServiceException("站点编码不能为空");
}
log.info("前端查的站点编号 :{}", workTicketVo.getWorkTicket().getSignage());
log.info("后端查寻的站点编码 :{}", station.getSignage());
if (!workTicketVo.getWorkTicket().getSignage().equals(station.getSignage())) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
//获取站点编号
String signage = station.getSignage();
if (StringUtils.isBlank(signage) || signage.length() < 2) {
throw new ServiceException("站点标识-两票编码不能为空");
throw new ServiceException("站点编码不能为空");
}
signage = signage.length() == 2 ? station.getSignage() : station.getSignage().substring(0, 2);
@ -193,6 +203,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
@ -208,18 +219,40 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//2.流程处理
String businessKey = response.getBusinessKey();
WorkTicketInfoEntity workTicketInfo = firstWorkTicketService.getById(businessKey);
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
if (ObjectUtils.isEmpty(workTicketInfo)) {
log.error("获取工作票的数据为不存在");
int num = response.getNum();
while (true) {
if (num == 0) {
break;
}
try {
//睡眠2秒防止cpu飚高
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
log.info("进入重试机制 {}", response);
num--;
response.setNum(num);
findPending(response);
}
return;
}
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
try {
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicketInfo.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
} catch (Exception e) {
e.printStackTrace();
}
//更新安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
@ -258,9 +291,11 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelay.getId()) || ObjectUtils.isEmpty(workTicketDelayEntity)) {
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
}
}
@ -309,9 +344,11 @@ public class TicketProcessServiceImpl implements TicketProcessService {
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
if (workTicketPrincipalChange.getId() == null || ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else {
log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
}
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
@ -324,6 +361,18 @@ public class TicketProcessServiceImpl implements TicketProcessService {
e.printStackTrace();
}
//工作票危险点分析及控制措施票
try {
if (workTicketInfo.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
ticketInfoDangerService.saveBatch(ticketInfoDangers);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@ -335,23 +384,42 @@ public class TicketProcessServiceImpl implements TicketProcessService {
*/
private void saveWorkTicket(WorkTicketInfoEntity workTicket, ProcessWorkFlowResponse response) {
String taskId = response.getTaskId();
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
String nextStepOperator = response.getNextStepOperator();
//1.获取状态
Integer flowStatus = workTicket.getFlowStatus();
//2.根据流程获取描述信息
String description = getWorkTicketDescription(flowStatus);
String flowDescription = "";
//当前审批人
User user = UserCache.getUser(workTicket.getStepOperator());
Integer flowStatus = workTicket.getFlowStatus();
if (StringUtils.isNotEmpty(nextStepOperator)) {
if ("0".equals(response.getHandleType())) {
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null);
//下一个审批人
User stepUser = UserCache.getUser(taskUser);
flowDescription = "审批中,当前环节是".concat(description).concat(",当前审批人是").concat(user.getName()).concat(",下一个审批人是").concat(stepUser.getName()).concat("待审批");
workTicket.setNextStepOperator(taskUser);
} else {
flowDescription = "审批中,当前环节是".concat(description).concat(",审批人是").concat(user.getName());
if (taskUser != null) {
//下一个审批人
User stepUser = UserCache.getUser(taskUser);
if (stepUser != null) {
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(stepUser.getName()).concat("审批");
workTicket.setNextStepOperator(stepUser.getName());
}
}else {
workTicket.setNextStepOperator(null);
}
}
if ("1".equals(response.getHandleType())) {
log.info("获取角色信息" + response.getNextStepOperator());
//根据角色别名获取用户信息
try {
R<List<User>> roleAlias = userClient.relationUserListByRoleAlias(workTicket.getTenantId(), workTicket.getCreateDept(), response.getNextStepOperator());
String collect = roleAlias.getData().stream().map(item -> item.getName()).collect(Collectors.joining(","));
flowDescription = "审批中,当前环节是".concat(response.getTaskName()).concat(",待").concat(collect).concat("审批");
workTicket.setNextStepOperator(collect);
} catch (Exception e) {
e.printStackTrace();
log.error("R<List<User>> roleAlias = userClient.userListByRoleAlias(workTicket.getTenantId(), response.getNextStepOperator())");
log.error("获取用户信息失败");
workTicket.setNextStepOperator(null);
}
}
//如果taskId为空 或 flowStatus = 99
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) {
@ -359,17 +427,19 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicket.setFlowDescription(flowDescription);
workTicket.setFlowTaskId("");
workTicket.setFlowTaskName("结束");
workTicket.setNextStepOperator(-1L);
workTicket.setStepOperator(-1L);
workTicket.setNextStepOperator(null);
workTicket.setStepOperator(null);
} else {
workTicket.setFlowDescription(flowDescription);
workTicket.setFlowTaskId(taskId);
workTicket.setFlowTaskName(response.getTaskName());
}
//如果下一个审批人【nextStepOperator】是null设为-1
if (StringUtils.isEmpty(nextStepOperator)) {
workTicket.setNextStepOperator(-1L);
workTicket.setNextStepOperator(null);
}
System.out.println("workTicket = " + workTicket);
}
@ -383,8 +453,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
String value = null;
switch (flowStatus) {
case 1:
value = "签发人签发";
value = "许可人确认工作终结、工作票终结";
break;
case 2:
value = "运行人接收";
break;
@ -424,7 +495,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
*
* @param workTicketVo
*/
private void returnTicket(WorkTicketVo workTicketVo) {
public void returnTicket(WorkTicketVo workTicketVo) {
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
if (TicketConstants.TaskTypeEnum.JXRW.getType().equals(workTicket.getTaskType())) {
OperAccessTaskEntity taskEntity = new OperAccessTaskEntity();
@ -451,7 +522,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param newFirstWorkTicketFlowKey
* @param workTicketVo
*/
private void dealProcess(String newFirstWorkTicketFlowKey, WorkTicketVo workTicketVo) {
public void dealProcess(String newFirstWorkTicketFlowKey, WorkTicketVo workTicketVo) {
//若为线下工作票 则无需开启工作流
Integer status = WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus();
if (status.intValue() != workTicketVo.getWorkTicket().getFlowStatus().intValue()) {
@ -465,7 +536,6 @@ public class TicketProcessServiceImpl implements TicketProcessService {
if (!listR.isSuccess() || CollectionUtil.isEmpty(listR.getData())) {
throw new ServiceException("工作票签发人角色下未查询到相关人员");
}
log.info("获取签发人角色下的人员: {}", listR.getData());
Map<String, Object> params = new HashMap<>(4);
params.put("workTicketVo", workTicketVo);
@ -473,9 +543,15 @@ public class TicketProcessServiceImpl implements TicketProcessService {
workTicketVo.setIsState(true);
log.info("获取表单的数据: {}", workTicketVo);
R<BladeFlow> processInstanceContainNameByKey = flowClient.startProcessInstanceContainNameByKey(newFirstWorkTicketFlowKey, String.valueOf(workTicketVo.getWorkTicket().getId()), workTicketVo.getWorkTicket().getWorkContent(), params);
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getData() == null) {
throw new ServiceException("启动流程失败...");
log.info("processInstanceContainNameByKey.isSuccess() : {}", processInstanceContainNameByKey.isSuccess());
log.info("processInstanceContainNameByKey.getData() : {}", processInstanceContainNameByKey.getData());
log.info("BladeFlow processInstanceContainNameByKey:{}", processInstanceContainNameByKey);
if (!processInstanceContainNameByKey.isSuccess() && processInstanceContainNameByKey.getCode() == 500) {
log.error("processInstanceContainNameByKey {}", processInstanceContainNameByKey.getMsg());
throw new ServiceException("不好意思,您暂无权限...");
}
log.info("获取启动流程数据 : {}", processInstanceContainNameByKey);
}
@ -485,7 +561,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param workTicketContentDtoList
* @param workTicketInfoEntity
*/
private void saveWorkTicketContentDto(List<WorkTicketContentEntity> workTicketContentDtoList, WorkTicketInfoEntity workTicketInfoEntity) {
public void saveWorkTicketContentDto(List<WorkTicketContentEntity> workTicketContentDtoList, WorkTicketInfoEntity workTicketInfoEntity) {
if (CollectionUtils.isEmpty(workTicketContentDtoList)) {
return;
}
@ -508,7 +584,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param safetyMeasuresList
* @param workTicketInfoEntity
*/
private void saveSafetyMeasures(List<WorkTicketSafetyMeasureEntity> safetyMeasuresList, WorkTicketInfoEntity workTicketInfoEntity) {
public void saveSafetyMeasures(List<WorkTicketSafetyMeasureEntity> safetyMeasuresList, WorkTicketInfoEntity workTicketInfoEntity) {
if (CollectionUtil.isEmpty(safetyMeasuresList)) {
return;
}
@ -533,7 +609,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
* @param workTicket
* @return
*/
private WorkTicketInfoEntity saveWorkTicketInfo(WorkTicketInfoEntity workTicket) {
public WorkTicketInfoEntity saveWorkTicketInfo(WorkTicketInfoEntity workTicket) {
workTicket.setStatus(Func.isEmpty(workTicket.getPrincipal()) || Func.isEmpty(workTicket.getClassGroupMembers()) ? WorkTicketConstants.FirstWorkTicketStatusEnum.OFFLINE_OPERATE.getStatus() : WorkTicketConstants.FirstWorkTicketStatusEnum.SIGN.getStatus());
//班组成员名称
String byclassGroupMembers = getByClassGroupMembers(workTicket);
@ -542,9 +618,13 @@ public class TicketProcessServiceImpl implements TicketProcessService {
String principalName = getByPrincipal(workTicket);
workTicket.setPrincipalName(principalName);
workTicket.setFlowStatus(1);
workTicket.setStepOperator(AuthUtil.getUserId());
workTicket.setStepOperator(UserCache.getUser(AuthUtil.getUserId()).getName());
//唯一
workTicket.setCreateUser(AuthUtil.getUserId());
workTicket.setIsSafety(false);
workTicket.setIsHazard(false);
workTicket.setIsRailway(false);
workTicket.setIsLimited(false);
boolean isSave = firstWorkTicketService.save(workTicket);
if (!isSave) {
throw new IllegalArgumentException("保存工作对象错误");
@ -563,7 +643,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//班组成员
Long principal = workTicket.getPrincipal();
if (ObjectUtils.isNotEmpty(principal)) {
return UserCache.getUser(principal).getName();
User user = UserCache.getUser(principal);
return user == null ? null : user.getName();
}
return workTicket.getPrincipalManual();
}
@ -595,56 +676,110 @@ public class TicketProcessServiceImpl implements TicketProcessService {
/**
* 预览
* 预览
*
* @param ticketType
* @param ticketId
* @param response
* @return
*/
@SneakyThrows
@Override
public String preview(String ticketType, Long ticketId) {
public void newPreview(Long ticketId, HttpServletResponse response) {
String fileName = IdWorker.get32UUID() + ".docx";
// response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
response.setContentType("application/vnd.ms-excel;charset=utf-8");
// response.addHeader("Pargam", "no-cache");
// response.addHeader("Cache-Control", "no-cache");
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId);
//将查询的数据转换为map
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo);
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX;
log.info("工作票模板为:{}", fileName);
//创建新的map
for (Map.Entry<String, Object> stringObjectEntry : workTicketInfoMap.entrySet()) {
log.info("获取map : " + stringObjectEntry.getKey() + "=====>" + stringObjectEntry.getValue());
}
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
if ((workTicket.getIsSafety() == null && workTicket.getIsHazard() == null && workTicket.getIsLimited() == null && workTicket.getIsRailway() == null) || (workTicket.getIsSafety() == null || workTicket.getIsHazard() == null || workTicket.getIsLimited() == null || workTicket.getIsRailway() == null)) {
extractedWithWord(response, workTicketInfoMap);
return;
}
//如果4个多为false 或为空 附件不展示附件
if (!workTicket.getIsSafety() && !workTicket.getIsHazard() && !workTicket.getIsLimited() && !workTicket.getIsRailway()) {
extractedWithWord(response, workTicketInfoMap);
return;
}
List<File> docFileList = new ArrayList<>();
docFileList.add(new File("template/电气第一种工作票模版.docx"));
//安全隔离措施附页 (true,展示附件,false,不展示附件)
if (workTicket.getIsSafety()) {
setWorkTicketPrincipalChange(docFileList);
}
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
if (workTicket.getIsSafety()) {
setWorkTicketHazardPointChange(docFileList);
}
//动火工作票 (true,展示附件,false,不展示附件)
if (workTicket.getIsRailway()) {
setWorkTicketRailwayChange(docFileList);
}
//有限空间监测记录单(true,展示附件,false,不展示附件)
if (workTicket.getIsLimited()) {
setWorkTicketLimitedChange(docFileList);
}
MergeDocUtils.mergeDoc(docFileList, response);
}
/**
* 预览
*
* @param response
* @param workTicketInfoMap
* @throws Exception
*/
private static void extractedWithWord(HttpServletResponse response, Map<String, Object> workTicketInfoMap) throws Exception {
XWPFDocument doc = WordExportUtil.exportWord07("template/电气第一种工作票模版.docx", workTicketInfoMap);
FileOutputStream fos = null;
String name = null;
String os = System.getProperty("os.name");
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
log.info("当前系统版本是:{}", os);
name = "D:/导出excel/电气第一种工作票模版.docx";
fos = new FileOutputStream(name);
String name = "D:/导出excel/电气第一种工作票模版.docx";
FileOutputStream fos = new FileOutputStream(name);
doc.write(fos);
} else {
//其它操作系统
log.info("当前系统版本是:{}", os);
String prefix = IdWorker.get32UUID();
name = templatePath + prefix + ".docx";
fos = new FileOutputStream(name);
ServletOutputStream outputStream = response.getOutputStream();
doc.write(outputStream);
}
doc.write(fos);
fos.close();
return name;
}
//封装map 转换 excel导出
private Map<String, Object> convertMap(WorkTicketVo workTicketVo) {
Map<String, Object> result = new HashMap<>();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//1. 工作对象
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket, true);
//1. 工作对象
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMapResult(workTicket, result);
//安全隔离措施附页 (true,展示附件,false,不展示附件
this.getDataConversion(workTicketInfoMap, "isSafety", workTicketInfoMap.get("isSafety"));
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
this.getDataConversion(workTicketInfoMap, "isHazard", workTicketInfoMap.get("isHazard"));
//危险点分析与预控措施票 (true,展示附件,false,不展示附件)
this.getDataConversion(workTicketInfoMap, "isRailway", workTicketInfoMap.get("isRailway"));
//有限空间监测记录单(true,展示附件,false,不展示附件)
this.getDataConversion(workTicketInfoMap, "isLimited", workTicketInfoMap.get("isLimited"));
result.putAll(workTicketInfoMap);
//2. 安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
log.info("安全措施: {}", safetyMeasuresList);
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
Map<String, Object> workTicketInfoMap1 = new HashMap<>();
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType));
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> {
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) {
List<Map<String, Object>> mapList = new ArrayList<>();
int tempIndex = 1, index = 1;
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType());
@ -654,22 +789,66 @@ public class TicketProcessServiceImpl implements TicketProcessService {
index = 1;
tempIndex++;
}
log.info("获取安全措施的信息: {}", measureVO);
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true);
map.put("index", index);
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null);
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : "×";
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : "";
map.put("status", status);
mapList.add(map);
index++;
}
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList);
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), mapList);
} else {
workTicketInfoMap.put(measureEnum.getConvertAttributes(), new ArrayList<Map<String, String>>(1));
workTicketInfoMap1.put(measureEnum.getConvertAttributes(), new ArrayList<WorkTicketSafetyMeasureEntity>());
}
});
// 工作地点保留带电部位或注意事项
List<Map<String, Object>> matterLibraryListFive1 = workTicketInfoMap1.get("matterLibraryListFive") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFive");
List<Map<String, Object>> matterLibraryListFlow1 = workTicketInfoMap1.get("matterLibraryListFlow") == null ? new ArrayList<Map<String, Object>>() : (List<Map<String, Object>>) workTicketInfoMap1.get("matterLibraryListFlow");
System.out.println("matterLibraryListFive1 = " + matterLibraryListFive1);
System.out.println("matterLibraryListFlow1 = " + matterLibraryListFlow1);
if (matterLibraryListFive1 != null && matterLibraryListFlow1 != null) {
List<Map<String, Object>> matterLibraryListFive = matterLibraryListFive1;
// (4)补充工作地点保留带电部位和补充安全措施
List<Map<String, Object>> matterLibraryListFlow = matterLibraryListFlow1;
if (CollectionUtils.isNotEmpty(matterLibraryListFive) && CollectionUtils.isNotEmpty(matterLibraryListFlow)) {
if (matterLibraryListFive.size() < matterLibraryListFlow.size()) {
for (Map<String, Object> stringObjectMap : matterLibraryListFlow) {
matterLibraryListFive.add(new HashMap<>());
}
}
if (matterLibraryListFive.size() > matterLibraryListFlow.size()) {
for (Map<String, Object> stringObjectMap : matterLibraryListFive) {
matterLibraryListFlow.add(new HashMap<>());
}
}
workTicketInfoMap1.put("matterLibraryListFive", CollectionUtils.isEmpty(matterLibraryListFive) ? new ArrayList<>() : matterLibraryListFive);
workTicketInfoMap1.put("matterLibraryListFlow", CollectionUtils.isEmpty(matterLibraryListFlow) ? new ArrayList<>() : matterLibraryListFlow);
}
}
if (CollectionUtils.isEmpty(matterLibraryListFive1)) {
workTicketInfoMap1.put("matterLibraryListFive", new ArrayList<>());
}
if (CollectionUtils.isEmpty(matterLibraryListFlow1)) {
workTicketInfoMap1.put("matterLibraryListFlow", new ArrayList<>());
}
result.putAll(workTicketInfoMap1);
}
result.putAll(workTicketInfoMap);
//3. 工作票工作任务组
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
@ -678,26 +857,45 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//4. 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
log.info("工作票延期: {}", workTicketDelay);
if (ObjectUtils.isNotEmpty(workTicketDelay)) {
result.putAll(PdfUtils.objectToMap(workTicketDelay, true));
result.putAll(PdfUtils.objectToMapResult(workTicket, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketDelayEntity(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketDelayEntity(), result));
}
//5. 工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
log.info("工作结束: {}", workTicketFinish);
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
result.putAll(PdfUtils.objectToMap(workTicketFinish, true));
result.putAll(PdfUtils.objectToMapResult(workTicketFinish, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketFinish(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketFinish(), result));
}
//5. 工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) {
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange, true));
result.putAll(PdfUtils.objectToMapResult(workTicketPrincipalChange, result));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketPrincipalChangeEntity(), true));
result.putAll(PdfUtils.objectToMapResult(new WorkTicketPrincipalChangeEntity(), result));
}
//6. 工作票危险点分析及控制措施票
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
Map<String, List<Map<String, Object>>> map = new HashMap<>();
int index = 1;
List<Map<String, Object>> collect = ticketInfoDangers.stream().map(item -> {
Map<String, Object> newItem = new HashMap<>();
newItem.put("index", index);
newItem.put("maintenance", item.getMaintenance());
newItem.put("dangerousPoint", item.getDangerousPoint());
return newItem;
}).collect(Collectors.toList());
map.put("ticketInfoDangers", collect);
result.putAll(map);
}
return result;
}
@ -705,11 +903,101 @@ public class TicketProcessServiceImpl implements TicketProcessService {
/**
* 对象转map
*
* @param value
* @param result
* @return
*/
public Map<String, Object> getTicketObjectVo(Object value, Map<String, Object> result) {
String jsonString = JSON.toJSONString(value);
Map<String, Object> map = JSONObject.parseObject(jsonString, Map.class);
Map<String, Object> newMap = new HashMap<>();
for (Map.Entry<String, Object> stringObjectEntry : map.entrySet()) {
System.out.println("没转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
//如果包含直接跳过
if (result.containsKey(stringObjectEntry.getKey())) {
System.out.println("跳过key : " + stringObjectEntry.getKey());
continue;
}
Object newValue = stringObjectEntry.getValue();
if (newValue == null) {
newValue = "\u00A0";
}
newMap.put(stringObjectEntry.getKey(), newValue);
}
for (Map.Entry<String, Object> stringObjectEntry : newMap.entrySet()) {
System.out.println("数据转换的数据 " + stringObjectEntry.getKey() + "=" + stringObjectEntry.getValue());
}
return newMap;
}
/**
* 对象转map
*/
private static <T> Map<String, Object> parseObjectMap(T target, Class clas) {
return JSONObject.parseObject(JSONObject.toJSONString(target), Map.class);
}
/**
* 安全隔离措施附页
*/
@SneakyThrows
public void setWorkTicketPrincipalChange(List<File> docFileList) {
docFileList.add(new File("template/secondary/工作票安全措施附页.docx"));
}
/**
* 危险点分析与预控措施票
*/
@SneakyThrows
public void setWorkTicketHazardPointChange(List<File> docFileList) {
docFileList.add(new File("template/secondary/工作票危险点分析及控制措施票.docx"));
}
/**
* 动火工作票
*/
@SneakyThrows
public void setWorkTicketRailwayChange(List<File> docFileList) {
File file = new File("template/secondary/动火工作票.docx");
docFileList.add(file);
}
/**
* 有限空间监测记录单(true,展示附件,false,不展示附件)
*/
@SneakyThrows
public void setWorkTicketLimitedChange(List<File> docFileList) {
File file = new File("template/secondary/有限空间监测记录单.docx");
docFileList.add(file);
}
/**
* value true转 false转
*
* @param dataConversion
* @param key
* @param value
*/
public void getDataConversion(Map<String, Object> dataConversion, String key, Object value) {
String newValue = value == null ? (String) value : value.toString();
if (StringUtils.isNoneBlank(newValue)) {
dataConversion.put(key, BooleanUtils.toBoolean(newValue) ? "☑" : "□");
}
}
}

12
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java

@ -1,5 +1,6 @@
package com.hnac.hzims.ticket.twoTicket.vo.process;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.workTicket.entity.*;
import io.swagger.annotations.ApiModel;
@ -74,4 +75,15 @@ public class WorkTicketVo {
private Boolean isState = true;
private String ticketType;
/**
* 工作票危险点分析及控制措施票
*/
private List<TicketInfoDanger> ticketInfoDangers;
}

178
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/MergeDocUtils.java

@ -0,0 +1,178 @@
package com.hnac.hzims.ticket.utils;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/23 16:42
*/
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.BreakType;
import org.apache.poi.xwpf.usermodel.Document;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFPictureData;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBody;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.time.LocalDate;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 参数1:需要合并的word的文件对象list
* 参数2:合并之后word存储的全路径file对象
*/
public class MergeDocUtils {
/**
* word文档合并
* @param fileList 合并文档的路径
* @param response 新的word
* @throws Exception
*/
public static void mergeDoc(List<File> fileList, HttpServletResponse response)throws Exception {
OutputStream dest = response.getOutputStream();
ArrayList<XWPFDocument> documentList = new ArrayList<XWPFDocument>();
XWPFDocument doc = null;
for (int i = 0; i < fileList.size(); i++) {
FileInputStream in = new FileInputStream(fileList.get(i).getPath());
OPCPackage open = OPCPackage.open(in);
XWPFDocument document = new XWPFDocument(open);
documentList.add(document);
}
for (int i = 0; i < documentList.size(); i++) {
doc = documentList.get(0);
if (i == 0) {
//首页直接分页,不再插入首页文档内容
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
} else if (i == documentList.size() - 1) {
//尾页不再分页,直接插入最后文档内容
appendBody(doc, documentList.get(i));
} else {
documentList.get(i).createParagraph().createRun().addBreak(BreakType.PAGE);
appendBody(doc, documentList.get(i));
}
}
//输出合并之后的文件
doc.write(dest);
}
/**
* 图片文件追加
* @param src
* @param append
* @throws Exception
*/
public static void appendBody(XWPFDocument src, XWPFDocument append) throws Exception {
CTBody src1Body = src.getDocument().getBody();
CTBody src2Body = append.getDocument().getBody();
List<XWPFPictureData> allPictures = append.getAllPictures();
// 记录图片合并前及合并后的ID
Map<String, String> map = new HashMap();
for (XWPFPictureData picture : allPictures) {
String before = append.getRelationId(picture);
//将原文档中的图片加入到目标文档中
String after = src.addPictureData(picture.getData(), Document.PICTURE_TYPE_PNG);
map.put(before, after);
}
appendBody(src1Body, src2Body, map);
}
private static void appendBody(CTBody src, CTBody append, Map<String, String> map) throws Exception {
XmlOptions optionsOuter = new XmlOptions();
optionsOuter.setSaveOuter();
String appendString = append.xmlText(optionsOuter);
//去掉追加word内容中的 w:sectPr 标签,确保合成的word中只有一个 w:sectPr 标签对
//避免合成的word文档打开之后会提示有些内容读不出来,导致文件损坏
String rgex = "<[\\s]*?w:sectPr[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?w:sectPr[\\s]*?>";
appendString = appendString.replaceAll(rgex, "");
String srcString = src.xmlText();
String regex = regex(srcString, "w:sectPr");
// System.out.println(regex);
String prefix = srcString.substring(0, srcString.indexOf(">") + 1);
String mainPart = srcString.substring(srcString.indexOf(">") + 1, srcString.lastIndexOf("<"));
String sufix = srcString.substring(srcString.lastIndexOf("<"));
String addPart = appendString.substring(appendString.indexOf(">") + 1, appendString.lastIndexOf("<"));
if (map != null && !map.isEmpty()) {
//对xml字符串中图片ID进行替换
for (Map.Entry<String, String> set : map.entrySet()) {
addPart = addPart.replace(set.getKey(), set.getValue());
}
}
//将两个文档的xml内容进行拼接
CTBody makeBody = CTBody.Factory.parse(prefix + mainPart + addPart + sufix);
src.set(makeBody);
}
/**
* 获取指定标签中的内容
*
* @param xml
* @param label
* @return
*/
public static String regex(String xml, String label) {
String context = "";
// 正则表达式
String rgex = "<" + label + "[^>]*>((?:(?!<\\/" + label + ">)[\\s\\S])*)<\\/" + label + ">";
Pattern pattern = Pattern.compile(rgex);// 匹配的模式
Matcher m = pattern.matcher(xml);
// 匹配的有多个
List<String> list = new ArrayList<String>();
while (m.find()) {
int i = 1;
list.add(m.group(i));
i++;
}
if (list.size() > 0) {
// 输出内容自己定义
context = String.valueOf(list.size());
}
return context;
}
// public static void main(String[] args) throws Exception {
// //new一个list 模拟要合并的word对象集合
// List<File>docFileList = new ArrayList<>();
// docFileList.add(new File("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\电气第一种工作票模版.docx"));
// docFileList.add(new File("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\动火工作票.docx"));
//
// //合并之后doc存储路径 此处读的配置文件的存储路径 D:/pdfData/
// String docPath = "D:\\导出excel\\";
// //当前日期+UUID作为文件名防止重复
// String fileName = LocalDate.now() + "-" + UUID.randomUUID().toString().replaceAll("-", "");
// //合并之后doc存储路径
// String mergeDocUrl = docPath+fileName+".docx";
// //转成file对象
// File mergeDocFile = new File(mergeDocUrl);
//
// //合并doc
// MergeDocUtils.mergeDoc(docFileList,mergeDocFile);
//
// System.out.println("合并word成功");
//
// }
}

84
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java

@ -1,6 +1,7 @@
package com.hnac.hzims.ticket.utils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
import com.documents4j.job.LocalConverter;
@ -209,6 +210,89 @@ public class PdfUtils {
return result;
}
/**
* 对象转化为Map 并设置默认值
*
* @param obj
* @return
* @throws Exception
*/
public static Map<String, Object> objectToMapResult(Object obj, Map<String, Object> map) {
Map<String, Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
Class clazz = obj.getClass();
List<Field> fieldList = new ArrayList<>();
while (clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
fieldList.forEach(field -> {
field.setAccessible(true);
DefaultValue defaultValue = field.getAnnotation(DefaultValue.class);
Object value;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
throw new ServiceException("获取属性性出错");
}
//若为list则不处理
if (value instanceof List) {
return;
}
//若为时间格式则进行格式化
if (value instanceof LocalDateTime) {
value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
}
if (value instanceof Date) {
value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
}
if (map.containsKey(field.getName())) {
return;
}
//属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
if (ObjectUtil.isNotEmpty(defaultValue)) {
result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
} else {
if ("initialPrincipalName".equals(field.getName())
|| "principalChangeTime".equals(field.getName())
|| "principalName".equals(field.getName())
|| "jobReceiver".equals(field.getName())
|| "jobReceiverDateTime".equals(field.getName())
|| "watchPrincipalEndTime".equals(field.getName())
|| "licenseTime".equals(field.getName())
|| "licensorName".equals(field.getName())
|| "signerDateTime".equals(field.getName())
|| "classGroupName".equals(field.getName())
|| "code".equals(field.getName())
|| "signerName".equals(field.getName())
|| "watchPrincipalName".equals(field.getName()))
{
result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0 "));
} else if (
"groundNum".equals(field.getName()) ||
"dismantleNum".equals(field.getName()) ||
"retainNum".equals(field.getName())
) {
result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0 "));
} else {
//如果导出word为null会出现{{ ,value设置"\u00A0"
result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0"));
}
}
});
}
return result;
}
/**
* 读取本地pdf,这里设置的是预览
*/

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/dto/WorkTicketInfoDto.java

@ -60,4 +60,8 @@ public class WorkTicketInfoDto extends WorkTicketInfoEntity implements Serializa
@ApiModelProperty("机构编号集合")
private List<Long> deptIds;
@ApiModelProperty("创建人")
private String createUserName;
}

107
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient;
@ -24,8 +25,10 @@ import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo;
import com.hnac.hzims.ticket.aspect.AroundFlow;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.ticket.twoTicket.entity.TicketInfoDanger;
import com.hnac.hzims.ticket.twoTicket.entity.WorkTicketFinish;
import com.hnac.hzims.ticket.twoTicket.enums.FlowWorkTicketConstants;
import com.hnac.hzims.ticket.twoTicket.service.TicketInfoDangerService;
import com.hnac.hzims.ticket.twoTicket.service.impl.WorkTicketFinishServiceImpl;
import com.hnac.hzims.ticket.twoTicket.vo.process.WorkTicketVo;
import com.hnac.hzims.ticket.utils.ExcelUtil;
@ -104,6 +107,7 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
private final TicketInfoEvaluateService ticketInfoEvaluateService;
private final IWorkTicketContentService workTicketContentService;
private final WorkTicketFinishServiceImpl workTicketFinishService;
private final TicketInfoDangerService ticketInfoDangerService;
/** 生成两票编号锁 **/
private Lock lock = new ReentrantLock();
@ -237,14 +241,27 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
@Override
public R<IPage<WorkTicketInfoVO>> queryList(WorkTicketInfoDto req, Query query) {
LambdaQueryWrapper<WorkTicketInfoEntity> lqw = this.getQueryWrapper(req);
if(ObjectUtil.isNotEmpty(req.getCreateDept())) {
lqw.eq(WorkTicketInfoEntity::getCreateDept,req.getCreateDept());
if (ObjectUtil.isNotEmpty(req.getCreateDept())) {
lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept());
}
lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime);
IPage pages = super.page(Condition.getPage(query), lqw);
pages.setRecords(WorkTicketInfoWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
IPage<WorkTicketInfoEntity> pages = this.page(Condition.getPage(query), lqw);
//数据转换
IPage<WorkTicketInfoVO> workTicketInfoVOIPage = new Page<>(pages.getCurrent(), pages.getSize());
workTicketInfoVOIPage.setRecords(WorkTicketInfoWrapper.build().listVO(pages.getRecords()));
workTicketInfoVOIPage.setPages(pages.getPages());
workTicketInfoVOIPage.setTotal(pages.getTotal());
//获取创建人
workTicketInfoVOIPage.getRecords().forEach(item -> {
User user = UserCache.getUser(item.getCreateUser());
if (user != null) {
item.setCreateUserName(UserCache.getUser(item.getCreateUser()).getName());
}
});
return R.data(workTicketInfoVOIPage);
}
@Override
@ -940,20 +957,78 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
}
//赋值签发人
if (workTicketInfo.getSigner() != null){
workTicketInfo.setSignerName(UserCache.getUser(workTicketInfo.getSigner()).getName());
if (workTicketInfo.getSigner() != null) {
User user = UserCache.getUser(workTicketInfo.getSigner());
workTicketInfo.setSignerName(user == null ? null : user.getName());
}
if (workTicketInfo.getSigner() != null && workTicketInfo.getSignerName() == null) {
User user = UserCache.getUser(workTicketInfo.getSigner());
workTicketInfo.setSignerName(user == null ? null : user.getName());
}
//赋值许可人名称
if (workTicketInfo.getLicensor() != null){
workTicketInfo.setLicensorName(UserCache.getUser(workTicketInfo.getLicensor()).getName());
if (workTicketInfo.getLicensor() != null) {
User user = UserCache.getUser(workTicketInfo.getLicensor());
workTicketInfo.setLicensorName(user == null ? null : user.getName());
}
if (workTicketInfo.getLicensor() != null && workTicketInfo.getLicensorName() == null) {
User user = UserCache.getUser(workTicketInfo.getLicensor());
workTicketInfo.setLicensorName(user == null ? null : user.getName());
}
// 负责值班负责人
if (workTicketInfo.getWatchPrincipal() != null){
workTicketInfo.setWatchPrincipalName(UserCache.getUser(workTicketInfo.getWatchPrincipal()).getName());
if (workTicketInfo.getWatchPrincipal() != null) {
User user = UserCache.getUser(workTicketInfo.getWatchPrincipal());
workTicketInfo.setWatchPrincipalName(user == null ? null : user.getName());
}
if (workTicketInfo.getWatchPrincipal() != null && workTicketInfo.getWatchPrincipalName() == null) {
User user = UserCache.getUser(workTicketInfo.getWatchPrincipal());
workTicketInfo.setWatchPrincipalName(user == null ? null : user.getName());
}
StringBuilder sb = new StringBuilder();
String classGroupMembers = workTicketInfo.getClassGroupMembers();
if (StringUtils.isNoneBlank(classGroupMembers)) {
// System.out.println("获取classGroupMembers ==> " + classGroupMembers);
String[] split = classGroupMembers.split(",");
for (String classGroupMember : split) {
System.out.println(classGroupMember);
if (StringUtils.isNoneBlank(classGroupMember)) {
boolean matches = classGroupMember.matches("[0-9]+");
if (matches) {
User user = UserCache.getUser(Long.valueOf(classGroupMember));
String name = user == null ? null : user.getName();
if (StringUtils.isNotBlank(name)) {
sb.append(name).append(",");
}
}
}
}
//统计人数
if (workTicketInfo.getTotalPerson() == null) {
workTicketInfo.setTotalPerson(sb.toString().trim().split(",").length);
}
//成员信息
if (workTicketInfo.getClassGroupMembersName() == null) {
workTicketInfo.setClassGroupMembersName(sb.toString().endsWith(",") ?
sb.toString().substring(0, sb.length() - 1) : sb.toString());
}
}
//负责人名称
if (workTicketInfo.getPrincipalName() == null && workTicketInfo.getPrincipal() != null) {
User user = UserCache.getUser(workTicketInfo.getPrincipal());
workTicketInfo.setPrincipalName(user == null ? "" : user.getName());
}
workTicketVo.setWorkTicket(workTicketInfo);
//2. 安全措施数组
@ -995,13 +1070,13 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
workTicketPrincipalChangeService.selectByTicketId(ticketId);
if (ObjectUtils.isNotEmpty(workTicketPrincipalChangeEntity)) {
//原负责人
if (workTicketPrincipalChangeEntity.getInitialPrincipal() != null){
if (workTicketPrincipalChangeEntity.getInitialPrincipal() != null) {
workTicketPrincipalChangeEntity.setInitialPrincipalName(
UserCache.getUser(workTicketPrincipalChangeEntity.getInitialPrincipal()).getName()
);
}
//变更负责人
if (workTicketPrincipalChangeEntity.getChangePrincipal() != null){
if (workTicketPrincipalChangeEntity.getChangePrincipal() != null) {
workTicketPrincipalChangeEntity.setChangePrincipalName(
UserCache.getUser(workTicketPrincipalChangeEntity.getChangePrincipal()).getName()
);
@ -1010,6 +1085,12 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
workTicketVo.setWorkTicketPrincipalChange(workTicketPrincipalChangeEntity);
}
//7. 根据工作票Id查询工作票危险点分析及控制措施票
List<TicketInfoDanger> list = ticketInfoDangerService.selectAllByTicket(workTicketInfo.getId());
if (CollectionUtils.isNotEmpty(list)) {
workTicketVo.setTicketInfoDangers(list);
}
return workTicketVo;
}
}

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketPrincipalChangeServiceImpl.java

@ -101,7 +101,7 @@ public class WorkTicketPrincipalChangeServiceImpl extends BaseServiceImpl<WorkTi
queryWrapper.eq(WorkTicketPrincipalChangeEntity::getTicketId,ticketId);
queryWrapper.orderByDesc(BaseEntity::getCreateTime);
queryWrapper.last("limit 1");
return this.getOne(queryWrapper);
return this.list(queryWrapper).get(0);
}
/**

2
hzims-service/ticket/src/main/resources/application.yml

@ -5,6 +5,8 @@ mybatis-plus:
- classpath:/mapper/**/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.hnac.hzims.**.entity
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#swagger扫描路径配置
swagger:

BIN
hzims-service/ticket/src/main/resources/template/secondary/动火工作票.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/secondary/工作票危险点分析及控制措施票.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/secondary/工作票安全措施附页.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/secondary/有限空间监测记录单.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/电气第一种工作票模版.docx

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/第一种工作票.docx

Binary file not shown.
Loading…
Cancel
Save