Browse Source

# 风险隐患排查系统代码迁移

zhongwei
haungxing 11 months ago
parent
commit
05b0a78ffa
  1. 66
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/Constants.java
  2. 27
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDPlanDTO.java
  3. 22
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDTaskCheckItemDTO.java
  4. 33
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDTaskDTO.java
  5. 22
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/PlanCheckItemDTO.java
  6. 91
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDPlanEntity.java
  7. 84
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDTaskCheckItemEntity.java
  8. 83
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDTaskEntity.java
  9. 58
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/PlanCheckItemEntity.java
  10. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/schedule/XxlJobConstants.java
  11. 45
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDPlanVO.java
  12. 32
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDTaskCheckItemVO.java
  13. 44
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDTaskVO.java
  14. 22
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/PlanCheckItemVO.java
  15. 37
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDPlanWrapper.java
  16. 37
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDTaskCheckItemWrapper.java
  17. 39
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDTaskWrapper.java
  18. 26
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/PlanCheckItemWrapper.java
  19. 81
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerPlanController.java
  20. 79
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerTaskCheckItemController.java
  21. 72
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerTaskController.java
  22. 62
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/PlanCheckItemController.java
  23. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerPlanMapper.java
  24. 5
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerPlanMapper.xml
  25. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskCheckItemMapper.java
  26. 15
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskMapper.java
  27. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskMapper.xml
  28. 15
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/PlanCheckItemMapper.java
  29. 200
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/schedule/HiddenDangerPlanSchedule.java
  30. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerPlanService.java
  31. 16
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerTaskCheckItemService.java
  32. 32
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerTaskService.java
  33. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IPlanCheckItemService.java
  34. 73
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerPlanServiceImpl.java
  35. 57
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerTaskCheckItemService.java
  36. 128
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerTaskServiceImpl.java
  37. 53
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/PlanCheckItemServiceImpl.java

66
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/Constants.java

@ -0,0 +1,66 @@
package com.hnac.hzims.safeproduct.hiddenDanger;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springblade.core.log.exception.ServiceException;
import org.springframework.util.Assert;
import java.util.Arrays;
import java.util.Optional;
public interface Constants {
@AllArgsConstructor
enum PlanStatusEnum {
NOT_START(0,"未开始"),
HAVE(1,"进行中"),
STOPPED(2,"已停止")
;
@Getter
private final Integer status;
@Getter
private final String describe;
}
@AllArgsConstructor
enum TaskStatusEnum {
NOT_START(0,"未开始"),
HAVE(1,"进行中"),
FINISH(2,"已完成"),
NON_FINISH(3,"未完成")
;
@Getter
private Integer status;
@Getter
private String describe;
}
@AllArgsConstructor
enum CycleEnum {
/**一天一次**/
CYCLE_ONE("1",1,"day"),
/**一周一次**/
CYCLE_TWO("2",1,"week"),
/**一月一次**/
CYCLE_THREE("3",1,"month"),
/**一季一次**/
CYCLE_FOUR("4",1,"quarter"),
/**一年一次**/
CYCLE_FIVE("5",1,"year")
;
@Getter
private String cycle;
@Getter
private int days;
@Getter
private String cycleType;
public static CycleEnum getCycleEnumByCycle(String cycle) {
Optional<CycleEnum> cycleEnum = Arrays.stream(CycleEnum.class.getEnumConstants()).filter(e -> cycle.equals(e.getCycle())).findFirst();
Assert.isTrue(cycleEnum.isPresent(),() -> {
throw new ServiceException("未找到对应的周期");
});
return cycleEnum.get();
}
}
}

27
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDPlanDTO.java

@ -0,0 +1,27 @@
package com.hnac.hzims.safeproduct.hiddenDanger.dto;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName HDPlanDTO
* @description:
* @author: hx
* @create: 2023-09-19 11:29
* @Version 4.0
**/
@EqualsAndHashCode
@ApiModel("隐患排查计划DTO")
@Data
public class HDPlanDTO extends HDPlanEntity implements Serializable {
@ApiModelProperty("隐患排查计划排查项列表")
List<PlanCheckItemDTO> checkItemDTOS;
}

22
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDTaskCheckItemDTO.java

@ -0,0 +1,22 @@
package com.hnac.hzims.safeproduct.hiddenDanger.dto;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @ClassName HDTaskCheckItemDTO
* @description:
* @author: hx
* @create: 2023-09-19 20:26
* @Version 4.0
**/
@EqualsAndHashCode
@Data
@ApiModel("隐患任务排查项DTO")
public class HDTaskCheckItemDTO extends HDTaskCheckItemEntity implements Serializable {
}

33
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/HDTaskDTO.java

@ -0,0 +1,33 @@
package com.hnac.hzims.safeproduct.hiddenDanger.dto;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @ClassName HDTaskDTO
* @description:
* @author: hx
* @create: 2023-09-19 15:57
* @Version 4.0
**/
@ApiModel("隐患排查任务DTO")
@Data
@EqualsAndHashCode
public class HDTaskDTO extends HDTaskEntity implements Serializable {
@ApiModelProperty("年月")
private String yearMonth;
@ApiModelProperty("开始时间")
private LocalDateTime taskStartTime;
@ApiModelProperty("结束时间")
private LocalDateTime taskEndTime;
}

22
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/dto/PlanCheckItemDTO.java

@ -0,0 +1,22 @@
package com.hnac.hzims.safeproduct.hiddenDanger.dto;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @ClassName PlanCheckItemDTO
* @description:
* @author: hx
* @create: 2023-10-07 14:01
* @Version 4.0
**/
@Data
@ApiModel("隐患排查计划排查项DTO")
@EqualsAndHashCode
public class PlanCheckItemDTO extends PlanCheckItemEntity implements Serializable {
}

91
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDPlanEntity.java

@ -0,0 +1,91 @@
package com.hnac.hzims.safeproduct.hiddenDanger.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* @ClassName HDPlanEntity
* @description:
* @author: hx
* @create: 2023-09-19 10:51
* @Version 4.0
**/
@Data
@ApiModel("隐患计划")
@EqualsAndHashCode
@TableName("hzims_hidden_danger_plan")
public class HDPlanEntity extends TenantEntity implements Serializable {
@ApiModelProperty(value = "计划名称",required = true)
@QueryField(condition = SqlCondition.LIKE)
@NotNull
private String planName;
@ApiModelProperty(value = "站点编号",required = true)
@QueryField(condition = SqlCondition.LIKE)
@NotNull
private String stationCode;
@ApiModelProperty(value = "排查类型,字典:hd_check_type",required = true)
@QueryField(condition = SqlCondition.EQUAL)
private String checkType;
@JsonFormat(pattern = DateUtil.PATTERN_DATE)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
@ApiModelProperty(value = "排查日期(开始日期)",required = true)
@QueryField(condition = SqlCondition.EQUAL)
private LocalDate checkStartDate;
@JsonFormat(pattern = DateUtil.PATTERN_DATE)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
@ApiModelProperty(value = "排查日期(结束日期)",required = true)
@QueryField(condition = SqlCondition.EQUAL)
private LocalDate checkEndDate;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查周期,字典:hd_check_cycle")
private String cycle;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查风险点ID")
private Long categoryId;
@QueryField(condition = SqlCondition.LIKE)
@ApiModelProperty(value = "排查风险点名称")
private String categoryName;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "计划类型:1为定时计划,2为临时计划,字典:hd_plan_type")
private String planType;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "是否启用:0为停用,1为启用")
private Boolean enable;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查人员ID")
private Long checkUserId;
/**计划近期生成任务最后时间**/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private LocalDateTime lastGenerateTaskTime;
/**下一次任务生成时间**/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private LocalDateTime nextGenerateTaskTime;
}

84
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDTaskCheckItemEntity.java

@ -0,0 +1,84 @@
package com.hnac.hzims.safeproduct.hiddenDanger.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @ClassName HDTaskCheckItemEntity
* @description:
* @author: hx
* @create: 2023-09-19 20:06
* @Version 4.0
**/
@Data
@ApiModel("隐患任务排查项")
@EqualsAndHashCode
@TableName("hzims_hidden_danger_task_item")
public class HDTaskCheckItemEntity extends TenantEntity implements Serializable {
@ApiModelProperty("隐患排查任务ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long taskId;
@ApiModelProperty("风险点ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long categoryId;
@ApiModelProperty("风险点名称")
@QueryField(condition = SqlCondition.LIKE)
private String categoryName;
@ApiModelProperty("风险点类型")
@QueryField(condition = SqlCondition.EQUAL)
private String riskType;
@ApiModelProperty("检查项ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long checkItemId;
@ApiModelProperty("检查项")
@QueryField(condition = SqlCondition.LIKE)
private String checkItemName;
@ApiModelProperty("区域/位置ID")
private String areaId;
@ApiModelProperty("区域/位置")
private String areaName;
@ApiModelProperty("上传附件")
private String attachment;
@ApiModelProperty("排查备注")
private String remark;
@ApiModelProperty(value = "事故诱因")
@QueryField(condition = SqlCondition.LIKE)
private String accidentIncentive;
@ApiModelProperty(value = "导致后果")
@QueryField(condition = SqlCondition.LIKE)
private String causeConsequence;
@ApiModelProperty("排查人ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long checkUserId;
@ApiModelProperty("排查时间")
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime checkTime;
}

83
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/HDTaskEntity.java

@ -0,0 +1,83 @@
package com.hnac.hzims.safeproduct.hiddenDanger.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @ClassName HDTaskEntity
* @description:
* @author: hx
* @create: 2023-09-19 15:32
* @Version 4.0
**/
@Data
@ApiModel("隐患任务")
@EqualsAndHashCode
@TableName("hzims_hidden_danger_task")
public class HDTaskEntity extends TenantEntity implements Serializable {
@ApiModelProperty(value = "隐患排查计划ID",required = true)
private Long planId;
@ApiModelProperty(value = "隐患排查计划名称",required = true)
@QueryField(condition = SqlCondition.LIKE)
private String planName;
@ApiModelProperty(value = "站点编号",required = true)
@QueryField(condition = SqlCondition.LIKE)
@NotNull
private String stationCode;
@ApiModelProperty("风险点类别")
private Integer categoryType;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查风险点ID")
private Long categoryId;
@QueryField(condition = SqlCondition.LIKE)
@ApiModelProperty(value = "排查风险点名称")
private String categoryName;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "计划类型:1为定时计划,2为临时计划,字典:hd_plan_type")
private String planType;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查周期,字典:hd_check_cycle")
private String cycle;
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@ApiModelProperty(value = "开始时间",required = true)
@QueryField(condition = SqlCondition.EQUAL)
private LocalDateTime startTime;
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@ApiModelProperty(value = "结束时间",required = true)
@QueryField(condition = SqlCondition.EQUAL)
private LocalDateTime endTime;
@ApiModelProperty("流程ID")
@QueryField(condition = SqlCondition.EQUAL)
private String processInstanceId;
@QueryField(condition = SqlCondition.EQUAL)
@ApiModelProperty(value = "排查人员ID")
private Long checkUserId;
}

58
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/entity/PlanCheckItemEntity.java

@ -0,0 +1,58 @@
package com.hnac.hzims.safeproduct.hiddenDanger.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
@ApiModel("计划风险排查项")
@Data
@EqualsAndHashCode
@TableName("hzims_hidden_danger_plan_item")
public class PlanCheckItemEntity extends TenantEntity implements Serializable {
@ApiModelProperty("隐患排查任务ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long planId;
@ApiModelProperty("区域/位置ID")
private String areaId;
@ApiModelProperty("区域/位置")
private String areaName;
@ApiModelProperty("风险点ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long categoryId;
@ApiModelProperty("风险点名称")
@QueryField(condition = SqlCondition.LIKE)
private String categoryName;
@ApiModelProperty("风险点类型")
@QueryField(condition = SqlCondition.EQUAL)
private String riskType;
@ApiModelProperty("检查项ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long checkItemId;
@ApiModelProperty("检查项")
@QueryField(condition = SqlCondition.LIKE)
private String checkItemName;
@ApiModelProperty(value = "事故诱因")
@QueryField(condition = SqlCondition.LIKE)
private String accidentIncentive;
@ApiModelProperty(value = "导致后果")
@QueryField(condition = SqlCondition.LIKE)
private String causeConsequence;
}

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/schedule/XxlJobConstants.java

@ -0,0 +1,8 @@
package com.hnac.hzims.safeproduct.hiddenDanger.schedule;
public interface XxlJobConstants {
/**根据隐患排查计划生成任务**/
String GENERATE_HD_TASK_BY_PLAN = "generateHDTaskByPlan";
}

45
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDPlanVO.java

@ -0,0 +1,45 @@
package com.hnac.hzims.safeproduct.hiddenDanger.vo;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName HDPlanVO
* @description:
* @author: hx
* @create: 2023-09-19 11:31
* @Version 4.0
**/
@Data
@Api("隐患排查计划VO")
@EqualsAndHashCode
public class HDPlanVO extends HDPlanEntity implements Serializable {
@ApiModelProperty("创建人名称")
private String creatorName;
@ApiModelProperty("更新人名称")
private String updateUserName;
@ApiModelProperty("排查类型名称")
private String checkTypeName;
@ApiModelProperty("排查周期名称")
private String cycleName;
@ApiModelProperty("计划类型名称")
private String planTypeName;
@ApiModelProperty("排查人名称")
private String checkUserName;
@ApiModelProperty("隐患排查计划排查项列表")
List<PlanCheckItemVO> checkItemVOS;
}

32
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDTaskCheckItemVO.java

@ -0,0 +1,32 @@
package com.hnac.hzims.safeproduct.hiddenDanger.vo;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @ClassName HDTaskCheckItemVO
* @description:
* @author: hx
* @create: 2023-09-19 20:27
* @Version 4.0
**/
@EqualsAndHashCode
@Data
@ApiModel("隐患任务排查项VO")
public class HDTaskCheckItemVO extends HDTaskCheckItemEntity implements Serializable {
@ApiModelProperty("创建人名称")
private String creatorName;
@ApiModelProperty("更新人名称")
private String updateUserName;
@ApiModelProperty("排查人名称")
private String checkUserName;
}

44
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/HDTaskVO.java

@ -0,0 +1,44 @@
package com.hnac.hzims.safeproduct.hiddenDanger.vo;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName HDTaskVO
* @description:
* @author: hx
* @create: 2023-09-19 15:58
* @Version 4.0
**/
@ApiModel("隐患排查任务VO")
@Data
@EqualsAndHashCode
public class HDTaskVO extends HDTaskEntity implements Serializable {
@ApiModelProperty("创建人名称")
private String creatorName;
@ApiModelProperty("更新人名称")
private String updateUserName;
@ApiModelProperty("排查周期名称")
private String cycleName;
@ApiModelProperty("计划类型名称")
private String planTypeName;
@ApiModelProperty("排查人名称")
private String checkUserName;
@ApiModelProperty("是否异常")
private Boolean isAbnormal = false;
@ApiModelProperty("隐患任务排查项列表")
private List<HDTaskCheckItemVO> checkItemVOList;
}

22
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/vo/PlanCheckItemVO.java

@ -0,0 +1,22 @@
package com.hnac.hzims.safeproduct.hiddenDanger.vo;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @ClassName PlanCheckItemVO
* @description:
* @author: hx
* @create: 2023-10-07 14:01
* @Version 4.0
**/
@Data
@ApiModel("隐患排查计划排查项VO")
@EqualsAndHashCode
public class PlanCheckItemVO extends PlanCheckItemEntity implements Serializable {
}

37
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDPlanWrapper.java

@ -0,0 +1,37 @@
package com.hnac.hzims.safeproduct.hiddenDanger.wrapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDPlanVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.cache.DictCache;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import java.util.Optional;
/**
* @ClassName HDPlanWrapper
* @description:
* @author: hx
* @create: 2023-09-19 13:50
* @Version 4.0
**/
public class HDPlanWrapper extends BaseEntityWrapper<HDPlanEntity, HDPlanVO> {
public static HDPlanWrapper build() {
return new HDPlanWrapper();
}
@Override
public HDPlanVO entityVO(HDPlanEntity entity) {
HDPlanVO planVO = BeanUtil.copy(entity,HDPlanVO.class);
planVO.setCreatorName(Optional.ofNullable(entity.getCreateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
planVO.setUpdateUserName(Optional.ofNullable(entity.getUpdateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
planVO.setCheckUserName(Optional.ofNullable(entity.getCheckUserId()).map(UserCache::getUser).map(User::getName).orElse(null));
planVO.setCheckTypeName(Optional.ofNullable(entity.getCheckType()).map(dictKey -> DictCache.getValue("hd_check_type",dictKey)).orElse(null));
planVO.setCycleName(Optional.ofNullable(entity.getCycle()).map(dictKey -> DictCache.getValue("hd_check_cycle",dictKey)).orElse(null));
planVO.setPlanTypeName(Optional.ofNullable(entity.getPlanType()).map(dictKey -> DictCache.getValue("hd_plan_type",dictKey)).orElse(null));
return planVO;
}
}

37
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDTaskCheckItemWrapper.java

@ -0,0 +1,37 @@
package com.hnac.hzims.safeproduct.hiddenDanger.wrapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskCheckItemVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import java.util.Optional;
/**
* @ClassName HDTaskCheckItemWrapper
* @description:
* @author: hx
* @create: 2023-09-19 20:28
* @Version 4.0
**/
public class HDTaskCheckItemWrapper extends BaseEntityWrapper<HDTaskCheckItemEntity, HDTaskCheckItemVO> {
public static HDTaskCheckItemWrapper build() {
return new HDTaskCheckItemWrapper();
}
@Override
public HDTaskCheckItemVO entityVO(HDTaskCheckItemEntity entity) {
HDTaskCheckItemVO checkItemVO = BeanUtil.copy(entity,HDTaskCheckItemVO.class);
checkItemVO.setCreatorName(Optional.ofNullable(entity.getCreateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
checkItemVO.setUpdateUserName(Optional.ofNullable(entity.getUpdateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
if(entity.getCheckUserId()!=null) {
checkItemVO.setCheckUserName(UserCache.getUser(entity.getCheckUserId()).getName());
}
return checkItemVO;
}
}

39
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/HDTaskWrapper.java

@ -0,0 +1,39 @@
package com.hnac.hzims.safeproduct.hiddenDanger.wrapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.system.cache.DictCache;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import java.util.Optional;
/**
* @ClassName HDTaskWrapper
* @description:
* @author: hx
* @create: 2023-09-19 15:59
* @Version 4.0
**/
public class HDTaskWrapper extends BaseEntityWrapper<HDTaskEntity, HDTaskVO> {
public static HDTaskWrapper build() {
return new HDTaskWrapper();
}
@Override
public HDTaskVO entityVO(HDTaskEntity entity) {
if(entity == null){
return null;
}
HDTaskVO taskVO = BeanUtil.copy(entity,HDTaskVO.class);
taskVO.setCreatorName(Optional.ofNullable(entity.getCreateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
taskVO.setUpdateUserName(Optional.ofNullable(entity.getUpdateUser()).map(UserCache::getUser).map(User::getName).orElse(null));
taskVO.setCheckUserName(Optional.ofNullable(entity.getCheckUserId()).map(UserCache::getUser).map(User::getName).orElse(null));
taskVO.setCycleName(Optional.ofNullable(entity.getCycle()).map(dictKey -> DictCache.getValue("hd_check_cycle",dictKey)).orElse(null));
taskVO.setPlanTypeName(Optional.ofNullable(entity.getPlanType()).map(dictKey -> DictCache.getValue("hd_plan_type",dictKey)).orElse(null));
return taskVO;
}
}

26
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/wrapper/PlanCheckItemWrapper.java

@ -0,0 +1,26 @@
package com.hnac.hzims.safeproduct.hiddenDanger.wrapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.PlanCheckItemVO;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
/**
* @ClassName PlanCheckItemWrapper
* @description:
* @author: hx
* @create: 2023-10-07 14:05
* @Version 4.0
**/
public class PlanCheckItemWrapper extends BaseEntityWrapper<PlanCheckItemEntity, PlanCheckItemVO> {
public static PlanCheckItemWrapper build() {
return new PlanCheckItemWrapper();
}
@Override
public PlanCheckItemVO entityVO(PlanCheckItemEntity entity) {
PlanCheckItemVO vo = BeanUtil.copy(entity,PlanCheckItemVO.class);
return vo;
}
}

81
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerPlanController.java

@ -0,0 +1,81 @@
package com.hnac.hzims.safeproduct.hiddenDanger.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDPlanDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.schedule.HiddenDangerPlanSchedule;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerPlanService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDPlanVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.HDPlanWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
/**
* @ClassName HDPlanController
* @description:
* @author: hx
* @create: 2023-09-19 11:34
* @Version 4.0
**/
@RestController
@RequestMapping("/hiddenDanger/plan")
@Api(value = "隐患计划管理",tags = "隐患计划管理")
@AllArgsConstructor
public class HiddenDangerPlanController extends BladeController implements Serializable {
private final IHiddenDangerPlanService hdPlanService;
private final HiddenDangerPlanSchedule planSchedule;
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<HDPlanVO>> page(HDPlanDTO request, Query query) {
LambdaQueryWrapper<HDPlanEntity> queryWrapper = Condition.getQueryWrapper(HDPlanEntity.class, BeanUtil.copy(request, HDPlanEntity.class));
queryWrapper.orderByDesc(HDPlanEntity::getCreateTime);
IPage page = hdPlanService.page(Condition.getPage(query),queryWrapper);
page.setRecords(HDPlanWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@GetMapping("/detail/{id}")
@ApiOperation("查询详情")
@ApiOperationSupport(order = 2)
public R<HDPlanVO> detail(@PathVariable @ApiParam("主键ID") Long id) {
return R.data(hdPlanService.detail(id));
}
@PutMapping("/updateById")
@ApiOperation("根据ID编辑隐患排查计划")
@ApiOperationSupport(order = 3)
public R updateById(@RequestBody HDPlanDTO request) {
return R.status(hdPlanService.doUpdate(request));
}
@PostMapping("/save")
@ApiOperation("新增隐患排查计划")
@ApiOperationSupport(order = 4)
public R save(@RequestBody HDPlanDTO request) {
return R.status(hdPlanService.doSave(request));
}
@PostMapping("/generateTask")
@ApiOperation("生成隐患排查任务")
@ApiOperationSupport(order = 5)
public R generateTask() {
planSchedule.generateTask(null);
return R.success("操作成功!");
}
}

79
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerTaskCheckItemController.java

@ -0,0 +1,79 @@
package com.hnac.hzims.safeproduct.hiddenDanger.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskCheckItemVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.HDTaskCheckItemWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.web.bind.annotation.*;
/**
* @ClassName HDTaskCheckItemController
* @description:
* @author: hx
* @create: 2023-09-19 20:39
* @Version 4.0
**/
@RestController
@RequestMapping("/hiddenDanger/task/checkItem")
@Api(value = "隐患任务排查项管理",tags = "隐患任务排查项管理")
@AllArgsConstructor
public class HiddenDangerTaskCheckItemController extends BladeController {
private final IHiddenDangerTaskCheckItemService hdTaskCheckItemService;
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<HDTaskCheckItemVO>> page(HDTaskCheckItemDTO request, Query query) {
LambdaQueryWrapper<HDTaskCheckItemEntity> queryWrapper = Condition.getQueryWrapper(HDTaskCheckItemEntity.class, BeanUtil.copy(request, HDTaskCheckItemEntity.class));
queryWrapper.orderByAsc(HDTaskCheckItemEntity::getAreaName).orderByAsc(HDTaskCheckItemEntity::getCategoryName).orderByAsc(HDTaskCheckItemEntity::getCheckItemName);
IPage page = hdTaskCheckItemService.page(Condition.getPage(query),queryWrapper);
page.setRecords(HDTaskCheckItemWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@GetMapping("/detail/{id}")
@ApiOperation("查询详情")
@ApiOperationSupport(order = 2)
public R<HDTaskCheckItemVO> detail(@PathVariable @ApiParam("主键ID") Long id) {
HDTaskCheckItemEntity Task = hdTaskCheckItemService.getById(id);
return R.data(HDTaskCheckItemWrapper.build().entityVO(Task));
}
@PutMapping("/updateById")
@ApiOperation("根据ID编辑隐患排查计划")
@ApiOperationSupport(order = 3)
public R updateById(@RequestBody HDTaskCheckItemDTO request) {
HDTaskCheckItemEntity Task = BeanUtil.copy(request, HDTaskCheckItemEntity.class);
return R.status(hdTaskCheckItemService.updateById(Task));
}
@PostMapping("/save")
@ApiOperation("新增隐患排查计划")
@ApiOperationSupport(order = 4)
public R save(@RequestBody HDTaskCheckItemDTO request) {
HDTaskCheckItemEntity Task = BeanUtil.copy(request, HDTaskCheckItemEntity.class);
return R.status(hdTaskCheckItemService.save(Task));
}
@PostMapping("/troubleshooting")
@ApiOperation("执行排查项")
@ApiOperationSupport(order = 5)
public R troubleshooting(@RequestBody HDTaskCheckItemDTO req) {
return R.status(hdTaskCheckItemService.troubleshooting(req));
}
}

72
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/HiddenDangerTaskController.java

@ -0,0 +1,72 @@
package com.hnac.hzims.safeproduct.hiddenDanger.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
/**
* @ClassName HDTaskController
* @description:
* @author: hx
* @create: 2023-09-19 16:03
* @Version 4.0
**/
@RestController
@RequestMapping("/hiddenDanger/task")
@Api(value = "隐患任务管理",tags = "隐患任务管理")
@AllArgsConstructor
public class HiddenDangerTaskController extends BladeController implements Serializable {
private final IHiddenDangerTaskService hdTaskService;
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<HDTaskVO>> page(HDTaskDTO request, Query query) {
return R.data(hdTaskService.page(request,query));
}
@GetMapping("/detail/{id}")
@ApiOperation("查询详情")
@ApiOperationSupport(order = 2)
public R<HDTaskVO> detail(@PathVariable @ApiParam("主键ID") Long id) {
return R.data(hdTaskService.detail(id));
}
@PutMapping("/updateById")
@ApiOperation("根据ID编辑隐患排查计划")
@ApiOperationSupport(order = 3)
public R updateById(@RequestBody HDTaskDTO request) {
HDTaskEntity Task = BeanUtil.copy(request, HDTaskEntity.class);
return R.status(hdTaskService.updateById(Task));
}
@PostMapping("/save")
@ApiOperation("新增隐患排查计划")
@ApiOperationSupport(order = 4)
public R save(@RequestBody HDTaskDTO request) {
HDTaskEntity Task = BeanUtil.copy(request, HDTaskEntity.class);
return R.status(hdTaskService.save(Task));
}
@GetMapping("/finishTask")
@ApiOperation("完成隐患排查任务")
@ApiOperationSupport(order = 5)
public R finishTask(@RequestParam @ApiParam("任务ID") Long taskId) {
return R.status(hdTaskService.finishTask(taskId));
}
}

62
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/controller/PlanCheckItemController.java

@ -0,0 +1,62 @@
package com.hnac.hzims.safeproduct.hiddenDanger.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.PlanCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IPlanCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.PlanCheckItemVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.PlanCheckItemWrapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.web.bind.annotation.*;
@RestController
@AllArgsConstructor
@RequestMapping("/hdPlan/checkItem")
public class PlanCheckItemController extends BladeController {
private final IPlanCheckItemService planCheckItemService;
@GetMapping("/page")
@ApiOperation("分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<PlanCheckItemVO>> page(PlanCheckItemDTO request, Query query) {
LambdaQueryWrapper<PlanCheckItemEntity> queryWrapper = Condition.getQueryWrapper(PlanCheckItemEntity.class, BeanUtil.copy(request, PlanCheckItemEntity.class));
queryWrapper.orderByAsc(PlanCheckItemEntity::getAreaName).orderByAsc(PlanCheckItemEntity::getCategoryName).orderByAsc(PlanCheckItemEntity::getCheckItemName);
IPage page = planCheckItemService.page(Condition.getPage(query),queryWrapper);
page.setRecords(PlanCheckItemWrapper.build().listVO(page.getRecords()));
return R.data(page);
}
@GetMapping("/detail/{id}")
@ApiOperation("查询详情")
@ApiOperationSupport(order = 2)
public R<PlanCheckItemVO> detail(@PathVariable @ApiParam("主键ID") Long id) {
return R.data(PlanCheckItemWrapper.build().entityVO(planCheckItemService.getById(id)));
}
@PutMapping("/updateById")
@ApiOperation("根据ID编辑隐患排查计划")
@ApiOperationSupport(order = 3)
public R updateById(@RequestBody PlanCheckItemDTO request) {
PlanCheckItemEntity Task = BeanUtil.copy(request, PlanCheckItemEntity.class);
return R.status(planCheckItemService.updateById(Task));
}
@PostMapping("/save")
@ApiOperation("新增隐患排查计划")
@ApiOperationSupport(order = 4)
public R save(@RequestBody PlanCheckItemDTO request) {
PlanCheckItemEntity Task = BeanUtil.copy(request, PlanCheckItemEntity.class);
return R.status(planCheckItemService.save(Task));
}
}

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerPlanMapper.java

@ -0,0 +1,8 @@
package com.hnac.hzims.safeproduct.hiddenDanger.mapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
public interface HiddenDangerPlanMapper extends UserDataScopeBaseMapper<HDPlanEntity> {
}

5
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerPlanMapper.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.safeproduct.hiddenDanger.mapper.HiddenDangerPlanMapper">
</mapper>

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskCheckItemMapper.java

@ -0,0 +1,8 @@
package com.hnac.hzims.safeproduct.hiddenDanger.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
public interface HiddenDangerTaskCheckItemMapper extends BaseMapper<HDTaskCheckItemEntity> {
}

15
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskMapper.java

@ -0,0 +1,15 @@
package com.hnac.hzims.safeproduct.hiddenDanger.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.statistic.vo.RiskDangerAccidentMonthCountVO;
import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
public interface HiddenDangerTaskMapper extends UserDataScopeBaseMapper<HDTaskEntity> {
List<RiskDangerAccidentMonthCountVO> getDangerMonthTrend(@Param("ew") QueryWrapper ew);
}

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/HiddenDangerTaskMapper.xml

@ -0,0 +1,13 @@
<?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.safeproduct.hiddenDanger.mapper.HiddenDangerTaskMapper">
<select id="getDangerMonthTrend" resultType="com.hnac.hzims.safeproduct.statistic.vo.RiskDangerAccidentMonthCountVO">
select DATE_FORMAT(start_time,'%Y-%m') yearAndMonth,count(*) dangerCount
from hzims_hidden_danger_task
where 1=1
<if test="ew!=null and ew.sqlSegment!=null and ew.sqlSegment != ''">
and ${ew.sqlSegment}
</if>
group by DATE_FORMAT(start_time,'%Y-%m')
</select>
</mapper>

15
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/mapper/PlanCheckItemMapper.java

@ -0,0 +1,15 @@
package com.hnac.hzims.safeproduct.hiddenDanger.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
/**
* @ClassName PlanCheckItemMapper
* @description:
* @author: hx
* @create: 2023-10-07 14:34
* @Version 4.0
**/
public interface PlanCheckItemMapper extends BaseMapper<PlanCheckItemEntity> {
}

200
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/schedule/HiddenDangerPlanSchedule.java

@ -0,0 +1,200 @@
package com.hnac.hzims.safeproduct.hiddenDanger.schedule;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.hnac.hzims.safeproduct.hiddenDanger.Constants;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerPlanService;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskService;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IPlanCheckItemService;
import com.hnac.hzims.safeproduct.risk.entity.HazardCategory;
import com.hnac.hzims.safeproduct.risk.service.HazardCategoryService;
import com.hnac.hzims.safeproduct.risk.service.HazardSourceService;
import com.hnac.hzims.safeproduct.risk.service.IRiskCheckService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.*;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import static com.hnac.hzims.safeproduct.hiddenDanger.schedule.XxlJobConstants.GENERATE_HD_TASK_BY_PLAN;
/**
* @ClassName HDPlanSchedule
* @description:
* @author: hx
* @create: 2023-09-19 16:10
* @Version 4.0
**/
@Component
@AllArgsConstructor
@Slf4j
public class HiddenDangerPlanSchedule {
private final IHiddenDangerPlanService hdPlanService;
private final IHiddenDangerTaskService hdTaskService;
private final IRiskCheckService riskCheckService;
private final HazardSourceService hazardSourceService;
private final IHiddenDangerTaskCheckItemService taskCheckItemService;
private final IPlanCheckItemService planCheckItemService;
private final HazardCategoryService hazardCategoryService;
/**
* 生成任务
* @param params 生成任务日期
* @return 工作流ID
*/
@XxlJob(GENERATE_HD_TASK_BY_PLAN)
public ReturnT generateTask(String params) {
LocalDate currentDate = StringUtil.isNoneBlank(params) ? LocalDate.parse(params, DateUtil.DATE_FORMATTER) : LocalDate.now();
// 处理未开始的计划
// this.dealNonStartPlan(currentDate);
// 将结束日期在当前日期之前的计划置为已停止
this.stopHDPlan(currentDate);
// 查找出当天有任务生成的计划
List<HDPlanEntity> generateTaskPlans = this.getGenerateTaskPlanList(currentDate);
if(CollectionUtil.isEmpty(generateTaskPlans)) {
return ReturnT.SUCCESS;
}
// 生成任务
this.generateTask(generateTaskPlans,currentDate);
generateTaskPlans.forEach(plan -> {
plan.setLastGenerateTaskTime(LocalDateTime.now());
Constants.CycleEnum cycleEnumByCycle = Constants.CycleEnum.getCycleEnumByCycle(plan.getCycle());
plan.setNextGenerateTaskTime(HiddenDangerPlanSchedule.plusDateTime(LocalDateTime.of(currentDate,LocalTime.MIN),cycleEnumByCycle.getCycleType(),cycleEnumByCycle.getDays()));
plan.setStatus(Constants.PlanStatusEnum.HAVE.getStatus());
});
hdPlanService.updateBatchById(generateTaskPlans);
return ReturnT.SUCCESS;
}
/**
* 处理未开始计划
* @param currentDate
*/
public void dealNonStartPlan(LocalDate currentDate) {
LambdaUpdateWrapper<HDPlanEntity> queryWrapper = Wrappers.<HDPlanEntity>lambdaUpdate()
.set(HDPlanEntity::getStatus,Constants.PlanStatusEnum.HAVE.getStatus())
.le(HDPlanEntity::getCheckStartDate,currentDate)
.ge(HDPlanEntity::getCheckEndDate,currentDate)
.eq(HDPlanEntity::getEnable,true)
.eq(HDPlanEntity::getStatus,Constants.PlanStatusEnum.NOT_START.getStatus());
hdPlanService.update(queryWrapper);
}
/**
* 变更已结束的隐患计划的状态
* @param currentDate 日期
*/
private void stopHDPlan(LocalDate currentDate) {
LambdaUpdateWrapper<HDPlanEntity> queryWrapper = Wrappers.<HDPlanEntity>lambdaUpdate()
.set(HDPlanEntity::getStatus, Constants.PlanStatusEnum.STOPPED.getStatus())
.eq(HDPlanEntity::getEnable,true)
.lt(HDPlanEntity::getCheckEndDate, currentDate);
hdPlanService.update(queryWrapper);
}
/**
* 获取待生成任务的计划
* @param currentDate 日期
* @return 待生成任务的计划
*/
private List<HDPlanEntity> getGenerateTaskPlanList(LocalDate currentDate) {
List<HDPlanEntity> result = Lists.newArrayList();
// 未生成任务的计划
List<HDPlanEntity> noTaskPlanList = hdPlanService.list(Wrappers.<HDPlanEntity>lambdaQuery()
.eq(HDPlanEntity::getStatus, Constants.PlanStatusEnum.NOT_START.getStatus())
.eq(HDPlanEntity::getEnable,true)
);
if(CollectionUtil.isNotEmpty(noTaskPlanList)) {
result.addAll(noTaskPlanList);
}
// 已经生成过任务的计划
List<HDPlanEntity> existTaskPlanList = hdPlanService.list(Wrappers.<HDPlanEntity>lambdaQuery()
.eq(HDPlanEntity::getStatus, Constants.PlanStatusEnum.HAVE.getStatus())
.eq(HDPlanEntity::getNextGenerateTaskTime,LocalDateTime.of(currentDate,LocalTime.MIN))
.eq(HDPlanEntity::getEnable,true)
);
if(CollectionUtil.isNotEmpty(existTaskPlanList)) {
result.addAll(existTaskPlanList);
}
return result;
}
/**
* 生成任务
* @param planList 计划列表
*/
private void generateTask(List<HDPlanEntity> planList,LocalDate currentDate) {
List<HDTaskEntity> taskList = planList.stream().map(plan -> BeanUtil.copy(plan, HDTaskEntity.class)).peek(task -> {
task.setPlanId(task.getId());
task.setId(null);
task.setCreateTime(null);
task.setUpdateTime(null);
// 设置计划开始结束时间
task.setStartTime(LocalDateTime.of(currentDate, LocalTime.MIN));
task.setCategoryType(Optional.ofNullable(hazardCategoryService.getById(task.getCategoryId())).map(HazardCategory::getCategory).orElse(null));
Constants.CycleEnum cycleEnumByCycle = Constants.CycleEnum.getCycleEnumByCycle(task.getCycle());
task.setEndTime(HiddenDangerPlanSchedule.plusDateTime(LocalDateTime.of(currentDate,LocalTime.MIN),cycleEnumByCycle.getCycleType(),cycleEnumByCycle.getDays()));
task.setStatus(Constants.TaskStatusEnum.HAVE.getStatus());
}).collect(Collectors.toList());
hdTaskService.saveBatch(taskList);
// 保存隐患任务的风险排查项
List<HDTaskCheckItemEntity> riskCheckEntityList = Lists.newArrayList();
taskList.forEach(task -> {
List<PlanCheckItemEntity> planCheckItemList = planCheckItemService.list(Wrappers.<PlanCheckItemEntity>lambdaQuery().eq(PlanCheckItemEntity::getPlanId, task.getPlanId()));
List<HDTaskCheckItemEntity> checkItemList = planCheckItemList.stream().map(check -> {
HDTaskCheckItemEntity taskCheckItem = BeanUtil.copy(check, HDTaskCheckItemEntity.class);
taskCheckItem.setId(null);
taskCheckItem.setCreateTime(null);
taskCheckItem.setUpdateTime(null);
taskCheckItem.setStatus(null);
taskCheckItem.setTaskId(task.getId());
taskCheckItem.setCreateUser(task.getCreateUser());
taskCheckItem.setUpdateUser(task.getUpdateUser());
taskCheckItem.setCreateDept(task.getCreateDept());
return taskCheckItem;
}).collect(Collectors.toList());
riskCheckEntityList.addAll(checkItemList);
});
taskCheckItemService.saveBatch(riskCheckEntityList);
taskCheckItemService.update(Wrappers.<HDTaskCheckItemEntity>lambdaUpdate().set(HDTaskCheckItemEntity::getStatus,null).in(HDTaskCheckItemEntity::getId,riskCheckEntityList.stream().map(HDTaskCheckItemEntity::getId).filter(Func::isNotEmpty).collect(Collectors.toList())));
}
/**
* 计算时间
* @param date 时间
* @param dateType 时间类型
* @param nums 数量
* @return 计算后的时间
*/
public static LocalDateTime plusDateTime(LocalDateTime date,String dateType,int nums) {
switch(dateType) {
case com.hnac.hzims.common.utils.DateUtil.YEAR:
return date.plusYears(nums);
case com.hnac.hzims.common.utils.DateUtil.QUARTER:
return date.plusMonths(nums*4);
case com.hnac.hzims.common.utils.DateUtil.MONTH:
return date.plusMonths(nums);
case com.hnac.hzims.common.utils.DateUtil.WEEK:
return date.plusDays(nums*7);
case com.hnac.hzims.common.utils.DateUtil.DAY:
return date.plusDays(nums);
default:
return date;
}
}
}

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerPlanService.java

@ -0,0 +1,16 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDPlanDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDPlanVO;
import org.springblade.core.mp.base.BaseService;
public interface IHiddenDangerPlanService extends BaseService<HDPlanEntity> {
Boolean doSave(HDPlanDTO planDTO);
Boolean doUpdate(HDPlanDTO planDTO);
HDPlanVO detail(Long id);
}

16
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerTaskCheckItemService.java

@ -0,0 +1,16 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskCheckItemVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface IHiddenDangerTaskCheckItemService extends BaseService<HDTaskCheckItemEntity> {
List<HDTaskCheckItemVO> getList(HDTaskCheckItemDTO req);
Boolean troubleshooting(HDTaskCheckItemDTO req);
}

32
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IHiddenDangerTaskService.java

@ -0,0 +1,32 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskVO;
import com.hnac.hzims.safeproduct.statistic.vo.RiskDangerAccidentMonthCountVO;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import java.util.List;
/**
* @ClassName IHDTaskService
* @description:
* @author: hx
* @create: 2023-09-19 16:04
* @Version 4.0
**/
public interface IHiddenDangerTaskService extends BaseService<HDTaskEntity> {
List<HDTaskVO> list(HDTaskDTO req);
List<RiskDangerAccidentMonthCountVO> getMonthTaskCount(HDTaskDTO req);
HDTaskVO detail(Long id);
IPage<HDTaskVO> page(HDTaskDTO request, Query query);
Boolean finishTask(Long taskId);
}

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/IPlanCheckItemService.java

@ -0,0 +1,13 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.PlanCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
public interface IPlanCheckItemService extends BaseService<PlanCheckItemEntity> {
Boolean doSaveOrUpdateBatch(List<PlanCheckItemDTO> itemList);
}

73
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerPlanServiceImpl.java

@ -0,0 +1,73 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.safeproduct.hiddenDanger.Constants;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDPlanDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDPlanEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.mapper.HiddenDangerPlanMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerPlanService;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IPlanCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDPlanVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.PlanCheckItemWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
@Slf4j
public class HiddenDangerPlanServiceImpl extends BaseServiceImpl<HiddenDangerPlanMapper, HDPlanEntity> implements IHiddenDangerPlanService {
private final IPlanCheckItemService planCheckItemService;
/**
* 保存隐患排查计划
* @param planDTO 隐患排查计划
* @return 保存结果
*/
@Override
public Boolean doSave(HDPlanDTO planDTO) {
planDTO.setStatus(Constants.PlanStatusEnum.NOT_START.getStatus());
HDPlanEntity plan = BeanUtil.copy(planDTO, HDPlanEntity.class);
if(this.save(plan)) {
if(CollectionUtil.isNotEmpty(planDTO.getCheckItemDTOS())) {
return planCheckItemService.doSaveOrUpdateBatch(planDTO.getCheckItemDTOS().stream().peek(d -> d.setPlanId(plan.getId())).collect(Collectors.toList()));
}
return true;
}
return false;
}
/**
* 编辑隐患排查计划
* @param planDTO 隐患排查计划
* @return 执行结果
*/
@Override
public Boolean doUpdate(HDPlanDTO planDTO) {
HDPlanEntity plan = BeanUtil.copy(planDTO, HDPlanEntity.class);
if(this.updateById(plan)) {
if(CollectionUtil.isNotEmpty(planDTO.getCheckItemDTOS())) {
return planCheckItemService.doSaveOrUpdateBatch(planDTO.getCheckItemDTOS().stream().peek(d -> d.setPlanId(plan.getId())).collect(Collectors.toList()));
}
return true;
}
return false;
}
@Override
public HDPlanVO detail(Long id) {
HDPlanEntity plan = this.getById(id);
HDPlanVO planVO = BeanUtil.copy(plan, HDPlanVO.class);
List<PlanCheckItemEntity> checkItemList = planCheckItemService.list(Wrappers.<PlanCheckItemEntity>lambdaQuery().eq(PlanCheckItemEntity::getPlanId, id));
planVO.setCheckItemVOS(PlanCheckItemWrapper.build().listVO(checkItemList));
return planVO;
}
}

57
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerTaskCheckItemService.java

@ -0,0 +1,57 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.mapper.HiddenDangerTaskCheckItemMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskCheckItemVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.HDTaskCheckItemWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
* @ClassName HDTaskCheckItemService
* @description:
* @author: hx
* @create: 2023-09-19 20:37
* @Version 4.0
**/
@Service
@AllArgsConstructor
@Slf4j
public class HiddenDangerTaskCheckItemService extends BaseServiceImpl<HiddenDangerTaskCheckItemMapper, HDTaskCheckItemEntity> implements IHiddenDangerTaskCheckItemService {
@Override
public List<HDTaskCheckItemVO> getList(HDTaskCheckItemDTO req) {
LambdaQueryWrapper<HDTaskCheckItemEntity> queryWrapper = Condition.getQueryWrapper(HDTaskCheckItemEntity.class, req);
List<HDTaskCheckItemEntity> checkItemEntityList = this.list(queryWrapper);
return HDTaskCheckItemWrapper.build().listVO(checkItemEntityList);
}
/**
* 执行排查项
* @param req 执行排查项结果
* @return 结果
*/
@Override
public Boolean troubleshooting(HDTaskCheckItemDTO req) {
LambdaUpdateWrapper<HDTaskCheckItemEntity> lambdaUpdateWrapper = Wrappers.<HDTaskCheckItemEntity>lambdaUpdate()
.set(HDTaskCheckItemEntity::getCheckUserId, AuthUtil.getUserId())
.set(HDTaskCheckItemEntity::getCheckTime, LocalDateTime.now())
.set(HDTaskCheckItemEntity::getStatus, req.getStatus())
.set(HDTaskCheckItemEntity::getRemark, req.getRemark())
.set(HDTaskCheckItemEntity::getAttachment,req.getAttachment())
.eq(HDTaskCheckItemEntity::getId, req.getId());
return this.update(lambdaUpdateWrapper);
}
}

128
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/HiddenDangerTaskServiceImpl.java

@ -0,0 +1,128 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.hiddenDanger.Constants;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.HDTaskDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.HDTaskEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.mapper.HiddenDangerTaskMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskCheckItemService;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IHiddenDangerTaskService;
import com.hnac.hzims.safeproduct.hiddenDanger.vo.HDTaskVO;
import com.hnac.hzims.safeproduct.hiddenDanger.wrapper.HDTaskWrapper;
import com.hnac.hzims.safeproduct.statistic.vo.RiskDangerAccidentMonthCountVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName HDTaskServiceImpl
* @description:
* @author: hx
* @create: 2023-09-19 16:05
* @Version 4.0
**/
@Service
@AllArgsConstructor
@Slf4j
public class HiddenDangerTaskServiceImpl extends BaseServiceImpl<HiddenDangerTaskMapper, HDTaskEntity> implements IHiddenDangerTaskService {
private final IHiddenDangerTaskCheckItemService taskCheckItemService;
/**
* 隐患排查任务列表查询
* @param req 筛选条件
* @return 任务列表
*/
@Override
public List<HDTaskVO> list(HDTaskDTO req) {
return HDTaskWrapper.build().listVO(this.list(this.getQueryWrapper(req)));
}
@Override
public List<RiskDangerAccidentMonthCountVO> getMonthTaskCount(HDTaskDTO req) {
return this.baseMapper.getDangerMonthTrend(this.getQueryWrapper(req));
}
@Override
public HDTaskVO detail(Long id) {
HDTaskEntity task = this.getById(id);
HDTaskVO taskVO = HDTaskWrapper.build().entityVO(task);
HDTaskCheckItemDTO itemDTO = new HDTaskCheckItemDTO();
itemDTO.setTaskId(id);
taskVO.setCheckItemVOList(taskCheckItemService.getList(itemDTO));
return taskVO;
}
@Override
public IPage<HDTaskVO> page(HDTaskDTO request, Query query) {
LambdaQueryWrapper<HDTaskEntity> queryWrapper = Condition.getQueryWrapper(HDTaskEntity.class, BeanUtil.copy(request, HDTaskEntity.class));
queryWrapper.orderByDesc(HDTaskEntity::getCreateTime);
IPage page = this.page(Condition.getPage(query),queryWrapper);
page.setRecords(HDTaskWrapper.build().listVO(page.getRecords()));
if(CollectionUtil.isNotEmpty(page.getRecords())) {
List<Long> taskIdList = (List<Long>) page.getRecords().stream().map(t -> ((HDTaskVO) t).getId()).collect(Collectors.toList());
List<HDTaskCheckItemEntity> abnormalItem = taskCheckItemService.list(Wrappers.<HDTaskCheckItemEntity>lambdaQuery()
.eq(HDTaskCheckItemEntity::getStatus, 0)
.in(HDTaskCheckItemEntity::getTaskId, taskIdList)
);
List<Long> abnormalTaskId = abnormalItem.stream().map(HDTaskCheckItemEntity::getTaskId).distinct().collect(Collectors.toList());
page.getRecords().stream().filter(t -> abnormalTaskId.contains(((HDTaskVO) t).getId())).forEach(t -> ((HDTaskVO) t).setIsAbnormal(true));
}
return page;
}
/**
* 完成隐患排查任务
* @param taskId 任务ID
* @return 执行结果
*/
@Override
public Boolean finishTask(Long taskId) {
List<HDTaskCheckItemEntity> unfinishItemList = taskCheckItemService.list(
Wrappers.<HDTaskCheckItemEntity>lambdaQuery().eq(HDTaskCheckItemEntity::getTaskId, taskId)
.isNull(HDTaskCheckItemEntity::getCheckTime)
);
Assert.isTrue(CollectionUtil.isEmpty(unfinishItemList),() -> {
throw new ServiceException("存在未完成的排查项:" +unfinishItemList.stream().map(HDTaskCheckItemEntity::getCheckItemName).collect(Collectors.joining(","))+ ",任务无法提交!");
});
return this.update(
Wrappers.<HDTaskEntity>lambdaUpdate()
.set(HDTaskEntity::getStatus, Constants.TaskStatusEnum.FINISH.getStatus())
.eq(HDTaskEntity::getId,taskId)
);
}
private QueryWrapper getQueryWrapper(HDTaskDTO req) {
QueryWrapper<HDTaskEntity> queryWrapper = Wrappers.query();
if(StringUtil.isNotBlank(req.getStationCode())) {
queryWrapper.eq("station_code",req.getStationCode());
}
if(StringUtil.isNotBlank(req.getYearMonth())) {
queryWrapper.eq("DATE_FORMAT(start_time,'%Y-%m')",req.getYearMonth());
}
if(ObjectUtil.isNotEmpty(req.getTaskStartTime())) {
queryWrapper.ge("start_time",req.getTaskStartTime());
}
if(ObjectUtil.isNotEmpty(req.getTaskEndTime())) {
queryWrapper.le("start_time",req.getTaskEndTime());
}
return queryWrapper;
}
}

53
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hiddenDanger/service/impl/PlanCheckItemServiceImpl.java

@ -0,0 +1,53 @@
package com.hnac.hzims.safeproduct.hiddenDanger.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.safeproduct.hiddenDanger.dto.PlanCheckItemDTO;
import com.hnac.hzims.safeproduct.hiddenDanger.entity.PlanCheckItemEntity;
import com.hnac.hzims.safeproduct.hiddenDanger.mapper.PlanCheckItemMapper;
import com.hnac.hzims.safeproduct.hiddenDanger.service.IPlanCheckItemService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
import java.util.stream.Collectors;
/**
* @ClassName PlanCheckItemServiceImpl
* @description:
* @author: hx
* @create: 2023-10-07 14:35
* @Version 4.0
**/
@Service
@AllArgsConstructor
@Slf4j
public class PlanCheckItemServiceImpl extends BaseServiceImpl<PlanCheckItemMapper, PlanCheckItemEntity> implements IPlanCheckItemService {
/**
* 保存/编辑计划排查项
* @param itemList 排查项列表
* @return
*/
@Override
public Boolean doSaveOrUpdateBatch(List<PlanCheckItemDTO> itemList) {
Assert.isTrue(!itemList.stream().map(PlanCheckItemDTO::getPlanId).anyMatch(Func::isEmpty),() -> {
throw new ServiceException("保存计划排查项是必须包含计划ID");
});
List<Long> idList = itemList.stream().map(PlanCheckItemDTO::getId).filter(Func::isNotEmpty).distinct().collect(Collectors.toList());
LambdaQueryWrapper<PlanCheckItemEntity> wrapper = Wrappers.<PlanCheckItemEntity>lambdaQuery().select(PlanCheckItemEntity::getId)
.eq(PlanCheckItemEntity::getPlanId, itemList.get(0).getPlanId())
.notIn(CollectionUtil.isNotEmpty(idList),PlanCheckItemEntity::getId, idList);
List<Long> removeIdList = this.listObjs(wrapper, Func::toLong);
this.deleteLogic(removeIdList);
return this.saveOrUpdateBatch(JSONArray.parseArray(JSON.toJSONString(itemList),PlanCheckItemEntity.class));
}
}
Loading…
Cancel
Save