diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java index fba3124..7a5cbe2 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/entity/OperDefectEntity.java @@ -104,9 +104,11 @@ public class OperDefectEntity extends TenantEntity { /** * 区域Id */ + @TableField(exist = false) private String areaId; /** * 年月 */ + @TableField(exist = false) private YearMonth yearMonth; } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageSmsClient.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageSmsClient.java index 0296932..be6eca0 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageSmsClient.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageSmsClient.java @@ -4,6 +4,8 @@ package com.hnac.hzims.message.fegin; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.req.SmsReq; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IPushMsgClient.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IPushMsgClient.java index 7fe7ccc..4f780ef 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IPushMsgClient.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IPushMsgClient.java @@ -7,6 +7,8 @@ import com.hnac.hzims.message.dto.SmsPushDto; import com.hnac.hzims.message.dto.WsPushDto; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatTypeVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatTypeVo.java index 6ef7e4c..c7fc6a1 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatTypeVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatTypeVo.java @@ -27,7 +27,6 @@ public class PushStatTypeVo { */ private String businessClassifyName; - /** * 业务分类统计 */ diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatVo.java index 340629c..8c2b335 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/PushStatVo.java @@ -29,15 +29,12 @@ public class PushStatVo { */ private Integer status; - - /** * 状态名称 */ private String statusName; - /** * 统计数量 */ diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java new file mode 100644 index 0000000..9e7f665 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/CheckCompanyFeignClient.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.safeproduct.Constants; +import com.hnac.hzims.safeproduct.areamonthly.feign.fallback.CheckCompanyFeignClientFallback; +import com.hnac.hzims.safeproduct.areamonthly.feign.fallback.SafeproductFeignClientFallback; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 19:35 + */ +@FeignClient(value = Constants.APP_NAME, fallback = CheckCompanyFeignClientFallback.class) +public interface CheckCompanyFeignClient { + + /** + * 查询安全检查 + * + * @param req + * @param query + * @return + */ + @GetMapping("/CheckCompany/list") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页", notes = "查询条件:startDate,endDate,status") + R> list(CheckCompanyEntity req, Query query); + + + /** + * 详情 + * @param id + * @return + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 40) + @ApiOperation(value = "详情", notes = "传入id") + public R detail(@RequestParam Long id); +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java new file mode 100644 index 0000000..1781d1b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeEquipmentTrialFeignClient.java @@ -0,0 +1,35 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.safeproduct.Constants; +import com.hnac.hzims.safeproduct.areamonthly.feign.fallback.CheckCompanyFeignClientFallback; +import com.hnac.hzims.safeproduct.areamonthly.feign.fallback.SafeEquipmentTrialFeignClientFallback; +import com.hnac.hzims.safeproduct.areamonthly.vo.SafeEquipmentTrialVO; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 19:50 + */ +@FeignClient(value = Constants.APP_NAME, fallback = SafeEquipmentTrialFeignClientFallback.class) +public interface SafeEquipmentTrialFeignClient { + + + /** + * 分页 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页", notes = "查询条件:createDept,fileName,startTime,endTime") + public R> list(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query) ; + +} + diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java new file mode 100644 index 0000000..a12b162 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/SafeproductFeignClient.java @@ -0,0 +1,48 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.safeproduct.Constants; +import com.hnac.hzims.safeproduct.areamonthly.feign.fallback.SafeproductFeignClientFallback; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckMonthVo; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import io.swagger.annotations.ApiOperation; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 18:06 + */ +@FeignClient(value = Constants.APP_NAME, fallback = SafeproductFeignClientFallback.class) +public interface SafeproductFeignClient { + + /** + * 分页查询安全生产会议次数 + */ + @GetMapping("/checkMonth/listconferenceScope/{page}/{size}") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页", notes = "查询条件:month,status,createDept") + public R> listconferenceScope(@PathVariable Long page, @PathVariable Long size, CheckMonthEntity req); + + + /** + * 详情 + */ + @GetMapping("/checkMonth/detail") + @ApiOperationSupport(order = 40) + @ApiOperation(value = "详情", notes = "传入id") + public R detail(@RequestParam Long id); + + + +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/CheckCompanyFeignClientFallback.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/CheckCompanyFeignClientFallback.java new file mode 100644 index 0000000..b756639 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/CheckCompanyFeignClientFallback.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign.fallback; + +import com.hnac.hzims.safeproduct.areamonthly.feign.CheckCompanyFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 19:35 + */ +@Service +public class CheckCompanyFeignClientFallback implements CheckCompanyFeignClient { + /** + * 查询安全检查 + * + * @param req + * @param query + * @return + */ + @Override + public R> list(CheckCompanyEntity req, Query query) { + return R.fail("远程调用失败"); + } + + /** + * 详情 + * + * @param id + * @return + */ + @Override + public R detail(Long id) { + return null; + } +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeEquipmentTrialFeignClientFallback.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeEquipmentTrialFeignClientFallback.java new file mode 100644 index 0000000..d0ae375 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeEquipmentTrialFeignClientFallback.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign.fallback; + +import com.hnac.hzims.safeproduct.areamonthly.feign.SafeEquipmentTrialFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.vo.SafeEquipmentTrialVO; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 19:50 + */ +@Service +public class SafeEquipmentTrialFeignClientFallback implements SafeEquipmentTrialFeignClient { + + /** + * 分页 + * + * @param safeEquipmentTrialDTO + * @param query + */ + @Override + public R> list(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query) { + return R.fail("远程调用失败"); + } +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeproductFeignClientFallback.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeproductFeignClientFallback.java new file mode 100644 index 0000000..b5c22c9 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/feign/fallback/SafeproductFeignClientFallback.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.safeproduct.areamonthly.feign.fallback; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.safeproduct.areamonthly.feign.SafeproductFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckMonthVo; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import org.springblade.core.mp.support.BladePage; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 18:07 + */ +@Service +public class SafeproductFeignClientFallback implements SafeproductFeignClient { + /** + * 分页查询安全生产会议次数 + * + * @param page + * @param size + * @param req + */ + @Override + public R> listconferenceScope(Long page, Long size, CheckMonthEntity req) { + return R.fail("远程调用失败"); + } + + /** + * 详情 + * + * @param id + */ + @Override + public R detail(Long id) { + return R.fail("远程调用失败"); + } +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckCompanyVo.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckCompanyVo.java new file mode 100644 index 0000000..b925505 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckCompanyVo.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.safeproduct.areamonthly.vo; + +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; +import java.util.Map; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 19:22 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CheckCompanyVo extends CheckCompanyEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("创建人名称") + private String createUserName; + + @ApiModelProperty("状态文本值") + private String statusText; + + @ApiModelProperty(value = "检查项实例") + List> items; +// +// @ApiModelProperty(value = "检查项实例") +// List> list; +} \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckMonthVo.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckMonthVo.java new file mode 100644 index 0000000..9a04af7 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/CheckMonthVo.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.safeproduct.areamonthly.vo; + +import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 18:09 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CheckMonthVo extends CheckMonthEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty("创建人名称") + private String createUserName; + + @ApiModelProperty("部门名称") + private String deptName; + + @ApiModelProperty("状态文本值") + private String statusText; + + @ApiModelProperty(value = "检查项实例") + List items; +} + diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/SafeEquipmentTrialVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/SafeEquipmentTrialVO.java new file mode 100644 index 0000000..983fe83 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/areamonthly/vo/SafeEquipmentTrialVO.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.areamonthly.vo; + +import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/12 20:04 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class SafeEquipmentTrialVO extends SafeEquipmentTrialEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("创建人名称") + private String createUserName; +} + diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/SafeEquipmentTrialDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/SafeEquipmentTrialDTO.java index f460f6e..2e6e07f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/SafeEquipmentTrialDTO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/SafeEquipmentTrialDTO.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; +import java.time.YearMonth; import java.util.List; @@ -36,4 +37,13 @@ public class SafeEquipmentTrialDTO extends SafeEquipmentTrialEntity { @ApiModelProperty("创建部门集合") private List deptList; + + + @ApiModelProperty(value = "区域id") + private String areaId; + + + + @ApiModelProperty(value = "年月") + private YearMonth yearMonth; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckCompanyEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckCompanyEntity.java index 11b83e0..93582aa 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckCompanyEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckCompanyEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzims.safeproduct.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -11,6 +12,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDateTime; +import java.time.YearMonth; /** * Created by Sam Huang 2022/5/6 8:16 @@ -47,4 +49,15 @@ public class CheckCompanyEntity extends TenantEntity implements Serializable { @ApiModelProperty(value = "检查机构") private String orgId; + + @TableField(exist = false) + @ApiModelProperty(value = "区域id") + private String areaId; + + + + @TableField(exist = false) + @ApiModelProperty(value = "年月") + private YearMonth yearMonth; + } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java index 60d4019..c91da19 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/CheckMonthEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzims.safeproduct.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.NullSerializer; @@ -10,6 +11,7 @@ import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; import java.io.Serializable; +import java.time.YearMonth; /** * Created by Sam Huang 2022/5/6 8:16 @@ -32,4 +34,27 @@ public class CheckMonthEntity extends TenantEntity implements Serializable { @ApiModelProperty(value = "核查建议") private String suggest; + + /** + * 区域Id + */ + @TableField(exist = false) + @ApiModelProperty(value = "区域Id") + private String areaId; + + + /** + * 年月 + */ + @TableField(exist = false) + private YearMonth yearMonth; + + + + @TableField(exist = false) + private String itemName; + + + + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java index de23097..c317ec1 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java @@ -36,4 +36,11 @@ public interface MessagePushRecordMapper extends UserDataScopeBaseMapper pushStat(@Param("vo") MessagePushRecordEntityVo vo); + + /** + * 查询出状态信息 + * @return + */ + List selectByStatus(); + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml index a9fe853..0412c8c 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml @@ -5,28 +5,26 @@ - - - - - + + + + + - - - select PUSHER_NAME pusherName, - BUSINESS_CLASSIFY businessClassify, - count(1) count + select PUSHER_NAME pusherName, + BUSINESS_CLASSIFY businessClassify, + count(1) count from hzims_message_push_record IS_DELETED = 0 and - STATION_CODE = #{vo.stationCode} + DEPT_ID = #{vo.stationCode} and @@ -80,11 +78,10 @@ - - + @@ -93,13 +90,13 @@ + + \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index 4455f42..d98330d 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.common.utils.CacheUtil; @@ -56,71 +57,70 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl { - throw new ServiceException("发送消息失败!"); - }); - // 更新推送状态以及推送时间 - LambdaUpdateWrapper luw = Wrappers.lambdaUpdate() - .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) - .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) - .eq(MessagePushRecordEntity::getId, id); - return this.update(luw); - } + @Override + public Boolean send(Long id) { + MessagePushRecordEntity record = this.getById(id); + IMessageService messageSend = MessageFactory.getMessageSend(record.getType()); + Boolean result = messageSend.send(record); + Assert.isTrue(result, () -> { + throw new ServiceException("发送消息失败!"); + }); + // 更新推送状态以及推送时间 + LambdaUpdateWrapper luw = Wrappers.lambdaUpdate().set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()).set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS).eq(MessagePushRecordEntity::getId, id); + return this.update(luw); + } - /** @Author hx + /** + * @return java.lang.Boolean 推送解雇 + * @Author hx * @Description 保存并推送消息 * @Date 2023/4/12 10:23 * @Param [request] 消息记录 - * @return java.lang.Boolean 推送解雇 **/ - @Override - @Transactional(rollbackFor = Exception.class) - public Boolean saveAndSend(MessagePushRecordEntity request) { + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean saveAndSend(MessagePushRecordEntity request) { LocalDateTime now = LocalDateTime.now(); - if(MessageConstants.IMMEDIATELY.equals(request.getPushType())) { + if (MessageConstants.IMMEDIATELY.equals(request.getPushType())) { request.setPlanTime(now); request.setPushTime(now); // 立即推送消息 - if(this.save(request) && Func.isNotEmpty(request.getId())) { + if (this.save(request) && Func.isNotEmpty(request.getId())) { return this.send(request.getId()); } throw new ServiceException("保存消息失败!"); - } - else if(MessageConstants.PLAN.equals(request.getPushType())) { + } else if (MessageConstants.PLAN.equals(request.getPushType())) { return this.save(request); - } - else { + } else { throw new ServiceException("推送类型只能为即时推送或计划推送"); } } - /** - * 获取 QueryWrapper - * @param request 查询条件 - * @return QueryWrapper - */ - private LambdaQueryWrapper getQueryWrapper(MessagePushRecordEntity request) { - LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda(); - if(Func.isNotEmpty(request.getStartTime())) { - lambda.ge(MessagePushRecordEntity::getPushTime,request.getStartTime()); - } - if(Func.isNotEmpty(request.getEndTime())) { - lambda.le(MessagePushRecordEntity::getPushTime,request.getEndTime()); - } - lambda.orderByDesc(MessagePushRecordEntity::getPushTime); - return lambda; - } + /** + * 获取 QueryWrapper + * + * @param request 查询条件 + * @return QueryWrapper + */ + private LambdaQueryWrapper getQueryWrapper(MessagePushRecordEntity request) { + LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda(); + if (Func.isNotEmpty(request.getStartTime())) { + lambda.ge(MessagePushRecordEntity::getPushTime, request.getStartTime()); + } + if (Func.isNotEmpty(request.getEndTime())) { + lambda.le(MessagePushRecordEntity::getPushTime, request.getEndTime()); + } + lambda.orderByDesc(MessagePushRecordEntity::getPushTime); + return lambda; + } + /** * 短信推送统计 */ @@ -136,8 +136,7 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl> collect = - messagePushRecordVos.stream().collect(Collectors.groupingBy(MessagePushRecordVo::getType)); + Map> collect = messagePushRecordVos.stream().collect(Collectors.groupingBy(MessagePushRecordVo::getType)); List messagePushRecordTypeVos = new ArrayList<>(); //封装数据 @@ -195,21 +194,44 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl pushStat(MessagePushRecordEntityVo vo) { List pushStatTypeVos = baseMapper.pushStat(vo); pushStatTypeVos.forEach(item -> { + //查询出状态信息 + List statusList = baseMapper.selectByStatus(); //业务类型名称 String businessClassify = item.getBusinessClassify(); String businessTypeName = this.getBusinessClassifyByName(businessClassify); item.setBusinessClassifyName(businessTypeName); List pushStatList = item.getPushStatList(); - pushStatList.forEach(pushStat -> { - Integer status = pushStat.getStatus(); - //状态名称 - String name = this.getStatusByName(status); - pushStat.setStatusName(name); + List newPushStatList = new ArrayList<>(); + for (PushStatVo pushStat : pushStatList) { //业务类型名称 String businessClassifyPushStat = pushStat.getBusinessClassify(); String businessTypeNamePushStat = this.getBusinessClassifyByName(businessClassifyPushStat); pushStat.setBusinessClassifyName(businessTypeNamePushStat); - }); + Integer status = pushStat.getStatus(); + //如果list 包含这条数删除 + if (statusList.contains(status)) { + statusList.remove(status); + } + //状态名称 + String name = this.getStatusByName(status); + pushStat.setStatusName(name); + newPushStatList.add(pushStat); + } + //如何list不为空补0 + if (CollectionUtils.isNotEmpty(statusList)) { + for (int i = 0; i < statusList.size(); i++) { + PushStatVo pushStat = new PushStatVo(); + int status = statusList.get(i); + pushStat.setStatus(status); + pushStat.setPower(0L); + pushStat.setBusinessClassify(businessClassify); + pushStat.setBusinessClassifyName(businessTypeName); + pushStat.setStatusName(this.getStatusByName(status)); + newPushStatList.add(pushStat); + } + } + + item.setPushStatList(newPushStatList); }); return pushStatTypeVos; } @@ -218,12 +240,12 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl getPersonalUnreadMessage() { QueryWrapper query = Wrappers.query(); query.select("business_classify businessClassify,count(0) todoNum"); - query.eq("account",AuthUtil.getUserId()); + query.eq("account", AuthUtil.getUserId()); query.groupBy("business_classify"); List> list = this.listMaps(query); return list.stream().map(map -> { UnreadMessageVO unreadMessageVO = Func.toBean(map, UnreadMessageVO.class); - unreadMessageVO.setBusinessName(DictCache.getValue("businessClassify",unreadMessageVO.getBusinessClassify())); + unreadMessageVO.setBusinessName(DictCache.getValue("businessClassify", unreadMessageVO.getBusinessClassify())); return unreadMessageVO; }).collect(Collectors.toList()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java index 8e0f492..0091f31 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity; +import java.time.YearMonth; import java.util.List; /** @@ -25,4 +26,16 @@ public class OperAccessStatisticsDTO extends OperAccessStatisticsEntity { @ApiModelProperty(value = "创建机构集合") private List deptIds; + /** + * 年月 + */ + private YearMonth yearMonth; + + + /** + * 区域Id + */ + private String areaId; + + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.java index 6273e9b..80d3b8d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.java @@ -3,13 +3,13 @@ package com.hnac.hzims.operational.access.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity; +import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; /** - * * Mapper 接口 * * @author xiashandong @@ -18,14 +18,13 @@ import java.util.List; public interface OperAccessStatisticsMapper extends UserDataScopeBaseMapper { - - /** - * 自定义分页 - * - * @param page - * @param dto - * @return - */ - @UserDataAuth - List selectPageList(IPage page, OperAccessStatisticsDTO dto); + /** + * 自定义分页 + * + * @param page + * @param dto + * @return + */ + @UserDataAuth + List selectPageList(IPage page, @Param("dto") OperAccessStatisticsDTO dto); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml index 949afc0..e63515d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml @@ -37,6 +37,12 @@ and OS.PLAN_END_TIME <= #{dto.planEndTime} + + and OS.CREATE_DEPT = #{dto.areaId} + + + and date_format(os.CREATE_TIME,'%Y-%m') = #{dto.yearMonth} + ORDER BY OS.CREATE_TIME DESC diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessStatisticsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessStatisticsService.java index cfc2c2e..417d9ca 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessStatisticsService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessStatisticsService.java @@ -5,7 +5,6 @@ import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.entity.OperAccessStatisticsEntity; import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; import org.springblade.core.mp.base.BaseService; -import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java index dd4a6a2..1ec49af 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java @@ -85,11 +85,6 @@ public class OperDefectController extends BladeController { if (defect.getEndTime() != null) { queryWrapper.le(OperDefectEntity::getCreateTime, defect.getEndTime()); } - - queryWrapper.eq(StringUtils.isNotBlank(defect.getAreaId()), BaseEntity::getCreateDept, defect.getCreateDept()); - - queryWrapper.apply(defect.getYearMonth() != null,"date_format(CREATE_TIME,'%Y-%m')", defect.getYearMonth()); - queryWrapper.orderByDesc(OperDefectEntity::getActStartTime); IPage pages = defectService.page(Condition.getPage(query), queryWrapper); IPage vos = OperDefectWrapper.build().pageVO(pages); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java index abd8d0f..f1e652b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.defect.service; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.vo.OperDefectVO; @@ -88,4 +90,12 @@ public interface IOperDefectService extends BaseService { boolean updateDefectInfo(OperDefectEntity entity); boolean updateDefectHanderState(OperDefectEntity entity); + + /** + * 分页查询 + * @param operDefectEntityPage + * @param defect + * @return + */ + IPage selectPage(Page operDefectEntityPage, OperDefectEntity defect); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java index 625faab..d5df747 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java @@ -2,7 +2,10 @@ package com.hnac.hzims.operational.defect.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.access.constants.AccessConstants; import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; @@ -36,6 +39,7 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.utils.AuthUtil; @@ -69,7 +73,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** - * 服务实现类 + * 服务实现类 * * @author Chill */ @@ -77,857 +81,856 @@ import java.util.stream.Collectors; @AllArgsConstructor public class OperDefectServiceImpl extends BaseServiceImpl implements IOperDefectService { - private static final Logger logger = LoggerFactory.getLogger(OperDefectServiceImpl.class); - - private final IFlowClient flowClient; - - private final OperDefectMapper operDefectMapper; - - private final IUserClient userClient; - - private final OperPhenomenonMapper operPhenomenonMapper; - - /** - * 开始问题处理流程 - * 问题处理流程的第一个处理节点人key 必须是 problemUser - * @param - */ - @Override - public void startFlow(OperPhenomenonEntity phenomenonEntity, OperDefectEntity defectEntity){ - User handler = UserCache.getUser(phenomenonEntity.getHandler()); - String handlerName = handler == null ? "" : handler.getName(); - String sourceName = DictCache.getValue(DefectConstant.SOURCE_CODE_DICT_KEY,phenomenonEntity.getSourceCode()); - String processName = "【" + sourceName + "】" + handlerName + " 发起的缺陷【" + phenomenonEntity.getDefectCode() + "】的问题处理流程"; - defectEntity.setCreateUser(phenomenonEntity.getCreateUser()); - defectEntity.setCreateDept(phenomenonEntity.getCreateDept()); - defectEntity.setTenantId(phenomenonEntity.getTenantId()); - save(defectEntity); - - Kv variables = Kv.create() - .set(ProcessConstant.TASK_VARIABLE_CREATE_USER, "taskUser_" + phenomenonEntity.getCreateUser()) - .set(DefectConstant.PROCESS_VARIABLE_HANDLE_USER, "taskUser_" + phenomenonEntity.getHandler()) - ; - R result = flowClient.startProcessInstanceContainNameByKey(defectEntity.getProcDefId(), FlowUtil.getBusinessKey("hzims_oper_defect",String.valueOf(defectEntity.getId())), processName, variables); - if (result.isSuccess()) { - BladeFlow flow = result.getData(); - log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); - // 返回流程id写入defect - defectEntity.setProcessInstanceId(flow.getProcessInstanceId()); - defectEntity.setHandleStatus(DefectConstant.DefectHandlerStatusEnum.HANDLING_STATUS.getStatus().toString()); - updateById(defectEntity); - } else { - throw new ServiceException("开启流程失败,code="+result.getCode()); - } - - } - - - /** - * 处理问题 - * @param flow - * @return - */ - @Override - public boolean handleProcess(BladeFlow flow) { - if(!invalidHandleProcess(flow.getProcessInstanceId())){ - throw new ServiceException("当前缺陷开具了检修计划,需等任务执行完成才能处理缺陷"); - } - ComleteTask task = new ComleteTask(); - task.setTaskId(flow.getTaskId()); - task.setComment(flow.getComment()); - task.setAttachments(flow.getAttachments()); - task.setFlag(flow.getFlag()); - task.setVariables(flow.getVariables()); - Map map = flow.getVariables(); - - flowClient.completeTask(task); - Integer status = ProcessConstant.ProcessInstanceStatusEnum.running.ordinal(); - R result = flowClient.queryProcessInstanceStatus(flow.getProcessInstanceId()); - if(result.isSuccess()){ - status = ProcessConstant.ProcessInstanceStatusEnum.over.name().equals(result.getData())?ProcessConstant.ProcessInstanceStatusEnum.over.ordinal():status; - } - - LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.set(OperDefectEntity::getHandleStatus,status); - //第一个流程节点传 - if(Func.isNotEmpty(map.get("actStartTime"))){ - updateWrapper.set(OperDefectEntity::getActStartTime, map.get("actStartTime").toString()); - } - //最后一个流程节点传 - if(Func.isNotEmpty(map.get("actEndTime"))){ - updateWrapper.set(OperDefectEntity::getActEndTime, map.get("actEndTime").toString()); - } - //最后一个流程节点传 - if(Func.isNotEmpty(map.get("disposeDesc"))){ - updateWrapper.set(OperDefectEntity::getDisposeDesc, map.get("disposeDesc").toString()); - } - /** - * 每一个流程节点都要传,这个数据属于叠加数据,例如第一个流程节点是8小时,第二个流程节点是2小时, - * 第一个节点完成后存储的数据是8 第二个节点完成后存储的数据是 8,2 - */ - if(Func.isNotEmpty(map.get("actHours"))){ - updateWrapper.set(OperDefectEntity::getActHours, map.get("actHours").toString()); - } - updateWrapper.eq(OperDefectEntity::getProcessInstanceId,flow.getProcessInstanceId()); - update(updateWrapper); - return true; - } - - /** - * 获取缺陷的统计月报 - * @param month 格式:"2021-01" - */ - @Override - public Map getDefectStatistics(String month){ - Map re = new HashMap<>(); - re.put("currentMonth", getCurrentMonthStatic(month)); - re.put("severalMonths", getStatisticBySeveralMonth(month)); - re.put("manageIndex", getManageIndexStatistic(month)); - re.put("repeat", getRepeatStatistic(month)); - return re; - } - - @Override - public void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException { - Map re = new HashMap<>(); - re = this.getDefectStatistics(month); - //获取数据 - List currentMonth = (List) re.get("currentMonth"); - List severalMonths = (List) re.get("severalMonths"); - OperDefectManageIndexDTO manageIndex = (OperDefectManageIndexDTO) re.get("manageIndex"); - List repeat = (List) re.get("repeat"); - - // 第一步,创建一个webbook,对应一个Excel文件 - HSSFWorkbook wb = new HSSFWorkbook(); - // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet - HSSFSheet sheet = wb.createSheet("缺陷月报("+month+")"); - sheet.setDefaultRowHeight((short) (20*20)); - //生成当前行 - int currentRow = 0; - for (int col=0;col<9;col++){ - sheet.setColumnWidth(col, 3900); - } - //创建标题行 - CellRangeAddress region1 = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); - sheet.addMergedRegion(region1); - //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 - HSSFRow headTitle = sheet.createRow(currentRow); - this.setFullHeadCell(wb,headTitle, (short) 9,0); - HSSFCell headCell = headTitle.getCell(0); - headCell.setCellValue("缺陷月报("+month+")"); - currentRow++; - - // 本月与前几月缺陷报表比较表格设置 - currentRow = this.setCompareMonthCell(currentMonth, severalMonths,wb, sheet, new Integer(currentRow)); - currentRow++; - - // 管理指标(本月)设置 - currentRow = this.setManageIndexCell(manageIndex, wb, sheet, currentRow); - currentRow++; - - // 重复分类缺陷汇总表设置 - this.setRepeatCell( repeat, wb, sheet, currentRow); - - // 下载导出 - String filename = "("+month+")缺陷月报表"; - // 设置头信息 - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/vnd.ms-excel"); - ServletOutputStream outputStream = null; - //一定要设置成xlsx格式 - response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); - //创建一个输出流 - outputStream = response.getOutputStream(); - //写入数据 - wb.write(outputStream); - // 关闭 - outputStream.close(); - wb.close(); - } - - @Override - public List getDefectList(String emCode,List list) { - return this.baseMapper.selectDefectList(emCode,list); - } - @Override - public List getDefectByEmCodeList(String emCode) { - return this.baseMapper.selectDefectByEmCodeList(emCode); - } - - @Override - public List getFaultByFaultCode(LocalDate startDate, LocalDate endDate, List deptIdList) { - List defectReportsVOList; - DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE); - List operDefectVOS = this.baseMapper.selectDurationDefect(dtf.format(startDate), dtf.format(endDate), deptIdList); - - defectReportsVOList = operDefectVOS.stream().map(operDefectVO -> { - User finder = UserCache.getUser(operDefectVO.getFinder()); - String finderAndTime = (ObjectUtil.isNotEmpty(finder) && StringUtil.isNotBlank(finder.getName()) ? finder.getName() : operDefectVO.getFinder().toString()) - + ":" + DateFormatUtils.format(operDefectVO.getFindTime(), DateUtil.PATTERN_DATETIME); - String handlerAndTime = ""; - if (Func.isNotEmpty(operDefectVO.getHandler())) { - User handler = UserCache.getUser(operDefectVO.getHandler()); - String handlerName = ObjectUtil.isNotEmpty(handler) && StringUtil.isNotBlank(handler.getName()) ? handler.getName() : operDefectVO.getHandler().toString(); - String handleTime = Func.isNotEmpty(operDefectVO.getActEndTime()) ? DateFormatUtils.format(operDefectVO.getActEndTime(), DateUtil.PATTERN_DATETIME) : ""; - handlerAndTime = String.format("%s:%s", handlerName, handleTime); - } - String seriousSituation = DictCache.getValue(DefectConstant.LEVEL_CODE_DICT_KEY, operDefectVO.getDefectLevel()); - return DefectReportsVO.builder().faultName(operDefectVO.getFaultName()).seriousSituation(seriousSituation) - .finderAndTime(finderAndTime).handlerAndTime(handlerAndTime).handleSituation(operDefectVO.getConclusion()).build(); - }).collect(Collectors.toList()); - - return defectReportsVOList; - } - - @Override - public List getFaultByFaultCode(Map params) { - LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); - List deptIdList = (List) params.get("deptId"); - return getFaultByFaultCode(startDate,endDate,deptIdList); - } - - @Override - public List> getDefectConclusion(Map params) { - return operDefectMapper.getDefectConclusion(params); - } - - @Override - public R detail(OperDefectEntity defect) { - OperDefectEntity detail = getOne(Condition.getQueryWrapper(defect)); - OperDefectVO operDefectVO = null; - if(ObjectUtil.isNotEmpty(detail)) { - operDefectVO = OperDefectWrapper.build().entityVO(detail); - //获取检修计划 - IOperAccessPlanService planService = SpringUtil.getBean(OperAccessPlanServiceImpl.class); - OperAccessPlanEntity accessPlanEntity = planService.getOne(Wrappers.lambdaQuery() - .eq(OperAccessPlanEntity::getDefectId,detail.getId()) - ); - if(ObjectUtil.isNotEmpty(accessPlanEntity)){ - operDefectVO.setAccessPlanId(accessPlanEntity.getId()); - if(ObjectUtil.isNotEmpty(accessPlanEntity.getStatus()) && accessPlanEntity.getStatus() > AccessConstants.PLAN_DRAFT){ - operDefectVO.setEditStatus(0); - } - else { - operDefectVO.setEditStatus(1); - } - } - } - return R.data(operDefectVO); - } - - /** - * 获取安全检查消缺项统计 - * @param startDate 开始时间 - * @param endDate 结束时间 - * @param dept 机构ID - * @param defectType 缺陷类型;1: 重大缺陷 2:一般缺陷 - * @return SafeCheckStatisticVO 对象 - */ - @Override - public SafeCheckStatisticVO getDefectCheck(String startDate, String endDate, Long dept, String defectType) { - SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); - //获取消缺总数 - LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() - .eq(OperPhenomenonEntity::getCreateDept,dept) - .ge(OperPhenomenonEntity::getPlanStartTime,startDate) - .le(OperPhenomenonEntity::getPlanStartTime,endDate) - .eq(OperPhenomenonEntity::getIsDefect,1); - //缺陷等级为Ⅰ级缺陷时为重大缺陷 其他为一般缺陷 - if("1".equals(defectType)){ - vo.setProjectType(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getName()); - wrapper.eq(OperPhenomenonEntity::getDefectLevel,DefectConstant.DefectLevelEnum.ONE.getStatus()); - } - else if("2".equals(defectType)){ - vo.setProjectType(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getType()); - vo.setProjectTypeName(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getName()); - wrapper.ne(OperPhenomenonEntity::getDefectLevel,DefectConstant.DefectLevelEnum.ONE.getStatus()); - } - List operPhenomenonEntities = operPhenomenonMapper.selectList(wrapper); - if(CollectionUtil.isNotEmpty(operPhenomenonEntities)){ - //获取消缺率 - List finishDefects = operPhenomenonEntities.stream().filter( - p-> ObjectUtil.isNotEmpty(p.getConclusionStatus()) && "1".equals(p.getConclusionStatus()) - ).collect(Collectors.toList()); - vo.setTotal(operPhenomenonEntities.size()); - vo.setQualified(finishDefects.size()); - vo.setQualifiedRate(new BigDecimal(finishDefects.size()/(double)operPhenomenonEntities.size()*100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); - } - return vo; - } - - /** - * 根据流程ID判断该缺陷是否能执行 - * @param processInstanceId 流程ID - * @return - */ - private boolean invalidHandleProcess(String processInstanceId) { - boolean result = true; - OperDefectEntity defectEntity = super.getOne(new LambdaQueryWrapper(){{ - eq(OperDefectEntity::getProcessInstanceId, processInstanceId); - }}); - //若类型为检修 - if(Func.isNotEmpty(defectEntity.getDefectCode()) && DefectConstant.DefectSourceEnum.JX.getStatus().equals(defectEntity.getDefectCode().substring(0,2))){ - IOperAccessPlanService planService = SpringUtil.getBean(IOperAccessPlanService.class); - List planList = planService.list(new LambdaQueryWrapper(){{ - eq(OperAccessPlanEntity::getDefectId, defectEntity.getId()); - }}); - if(CollectionUtil.isNotEmpty(planList)){ - //获取未审核的计划 - List pendingReviewList = planList.stream().filter(p->p.getStatus() != AccessConstants.PLAN_FINISH).collect(Collectors.toList()); - if(CollectionUtil.isNotEmpty(pendingReviewList)){ - result = false; - } - //获取检修计划ID集合 - List planIdList = planList.stream().map(OperAccessPlanEntity::getId).collect(Collectors.toList()); - IOperAccessTaskService taskService = SpringUtil.getBean(IOperAccessTaskService.class); - //未完成检修任务集合 - List taskList = taskService.list(new LambdaQueryWrapper(){{ - in(OperAccessTaskEntity::getPlanId, planIdList); - ne(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_4); - }}); - if(CollectionUtil.isNotEmpty(taskList)){ - result = false; - } - } - } - return result; - } - - /** - * 创建标题单元格样式 - * @param wb - * @return - */ - private HSSFCellStyle setHeadCellStyle(HSSFWorkbook wb){ - HSSFCellStyle headStyle = wb.createCellStyle(); - //设置边框 - headStyle.setBorderLeft(BorderStyle.THIN); - headStyle.setBorderRight(BorderStyle.THIN); - headStyle.setBorderTop(BorderStyle.THIN); - headStyle.setBorderBottom(BorderStyle.THIN); - //二、设置单元格背景颜色 - headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); - headStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); - //三、设置居中: - headStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 - headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 - //四、设置字体: - HSSFFont font = wb.createFont(); - font.setFontName("黑体"); - //font.setColor(); - font.setFontHeightInPoints((short) 12);//设置字体大小 - headStyle.setFont(font);//选择需要用到的字体格式 - - return headStyle; - } - - /** - * 创建表格内容单元格样式 - * @param wb - * @return - */ - private HSSFCellStyle setContentCellStyle(HSSFWorkbook wb){ - HSSFCellStyle contentStyle = wb.createCellStyle(); - //设置边框 - contentStyle.setBorderLeft(BorderStyle.THIN); - contentStyle.setBorderRight(BorderStyle.THIN); - contentStyle.setBorderTop(BorderStyle.THIN); - contentStyle.setBorderBottom(BorderStyle.THIN); - //三、设置居中: - contentStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 - contentStyle.setVerticalAlignment(VerticalAlignment.CENTER); - //四、设置字体: - HSSFFont font = wb.createFont(); - font.setFontName("仿宋_GB2312"); - //font.setBold(true);//粗体显示 - font.setFontHeightInPoints((short) 10); - contentStyle.setFont(font);//选择需要用到的字体格式 - return contentStyle; - } - - /** - * 设置缺陷月报表excel导出-本月与前几月缺陷报表内单元格 - * @param sheet - * @param currentRow - */ - private int setCompareMonthCell(List currentMonth, List severalMonths, HSSFWorkbook wb,HSSFSheet sheet, int currentRow){ - //创建当月与1-至当月表表头 - HSSFRow headRow = sheet.createRow(currentRow); - //设置表头信息 - this.setFullHeadCell(wb,headRow, (short) 9,0); - HSSFCell compare_head1_cell1 = headRow.getCell(0); - compare_head1_cell1.setCellValue("指标名称"); - HSSFCell compare_head1_cell2 = headRow.getCell(1); - compare_head1_cell2.setCellValue("本月"); - HSSFCell compare_head1_cell3 = headRow.getCell(5); - compare_head1_cell3.setCellValue("(1-本月)累计"); - //合并单元格 - CellRangeAddress head1_region1 = new CellRangeAddress((short) currentRow, (short) currentRow+1, (short) 0, (short) 0); - CellRangeAddress head1_region2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 1, (short) 4); - CellRangeAddress head1_region3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 8); - sheet.addMergedRegion(head1_region1); - sheet.addMergedRegion(head1_region2); - sheet.addMergedRegion(head1_region3); - currentRow++; - //创建表头 - HSSFRow headRow2 = sheet.createRow(currentRow); - this.setFullHeadCell(wb,headRow2, (short) 9,0); - //设置表头信息 - HSSFCell compare_head2_cell1 = headRow2.getCell(1); - compare_head2_cell1.setCellValue("发生"); - - HSSFCell compare_head2_cell2 = headRow2.getCell(2); - compare_head2_cell2.setCellValue("比率(%)"); - - HSSFCell compare_head2_cell3 = headRow2.getCell(3); - compare_head2_cell3.setCellValue("消除"); - - HSSFCell compare_head2_cell4 = headRow2.getCell(4); - compare_head2_cell4.setCellValue("比率(%)"); - - HSSFCell compare_head2_cell5 = headRow2.getCell(5); - compare_head2_cell5.setCellValue("发生"); - - HSSFCell compare_head2_cell6 = headRow2.getCell(6); - compare_head2_cell6.setCellValue("比率(%)"); - - HSSFCell compare_head2_cell7 = headRow2.getCell(7); - compare_head2_cell7.setCellValue("发生"); - - HSSFCell compare_head2_cell8 = headRow2.getCell(8); - compare_head2_cell8.setCellValue("比率(%)"); - currentRow++; - - for(int i=0;i repeat, HSSFWorkbook wb, HSSFSheet sheet, int currentRow){ - //重复缺陷分类汇总表 - //表头1 - HSSFRow repeat_head1 = sheet.createRow(currentRow); - this.setFullHeadCell(wb,repeat_head1, (short) 9,0); - HSSFCell repeat_head1_cell = repeat_head1.getCell(0); - repeat_head1_cell.setCellValue("重复缺陷分类汇总表"); - CellRangeAddress repeat_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); - sheet.addMergedRegion(repeat_religon); - currentRow++; - - //表头2 - CellRangeAddress repeat_head2_cell_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 2); - sheet.addMergedRegion(repeat_head2_cell_religon); - - HSSFRow repeat_head2 = sheet.createRow(currentRow); - this.setFullHeadCell(wb,repeat_head2, (short) 9,0); - HSSFCell repeat_head2_cell1 = repeat_head2.getCell(3); - CellRangeAddress repeat_head2_cell1_religon = new CellRangeAddress(currentRow, currentRow, (short) 3, (short) 4); - sheet.addMergedRegion(repeat_head2_cell1_religon); - repeat_head2_cell1.setCellValue("发生数量"); - - HSSFCell repeat_head2_cell2 = repeat_head2.getCell(5); - CellRangeAddress repeat_head2_cell2_religon = new CellRangeAddress(currentRow, currentRow, (short) 5, (short) 6); - sheet.addMergedRegion(repeat_head2_cell2_religon); - repeat_head2_cell2.setCellValue("占重复缺陷总数的比率(%)"); - - HSSFCell repeat_head2_cell3 = repeat_head2.getCell(7); - CellRangeAddress repeat_head2_cell3_religon = new CellRangeAddress(currentRow, currentRow, (short) 7, (short) 8); - sheet.addMergedRegion(repeat_head2_cell3_religon); - repeat_head2_cell3.setCellValue("占总缺陷的比率(%)"); - - currentRow++; - - //内容 - for(int i=0;i getCurrentMonthStatic(String month) { - List statisticByMonth = this.baseMapper.getStatisticByMonth(month, AuthUtil.getDeptId()); - return getRatioStatic(statisticByMonth); - } - - /** - * 当年1月 - 当前月获取缺陷等级统计数据 - * @param month "2021-01" - * @return - */ - private List getStatisticBySeveralMonth(String month) { - Integer intervalMonth = Integer.valueOf(month.split("-")[1]); - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date date ; - String firstMonth = month.split("-")[0] + "-01-01"; - try { - date = dateFormat.parse(firstMonth); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - calendar.add(Calendar.MONTH, intervalMonth); - date = calendar.getTime(); - } catch (ParseException e) { - throw new ServiceException("日期转换失败"); - } - log.error("firstMonth:"+firstMonth + "; end=" +dateFormat.format(date)); - - List statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), AuthUtil.getDeptId()); - return getRatioStatic(statisticBySeveralMonth); - } - - /** - * 获取按月管理指标统计数据 - * @param month - * @return - */ - private OperDefectManageIndexDTO getManageIndexStatistic(String month){ - OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); - List list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); - manageIndex.setInTimeNum(list.get(0)); - if(!list.get(1).equals(0)){ - manageIndex.setInTimeRatio(list.get(0).equals(0)? 0.0 : Double.valueOf(list.get(0))/list.get(1)); - } - manageIndex.setHistoryRemindNum(list.get(3)); - manageIndex.setMonthRemindNum(list.get(2)); - if(!list.get(4).equals(0)) { - manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : Double.valueOf(list.get(1)) / list.get(4)); - } - return manageIndex; - } - - /** - * 获取重复缺陷等级统计数据 - * @param month - * @return - */ - private List getRepeatStatistic(String month){ - List re = new ArrayList<>(); - - List repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); - //总缺陷数 - int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); - //总重复缺陷数 - int totalRepeat = repetStatistics - .stream() - .filter(s-> s.getDefectNum() > 1 && s.getDefectLevel() != null ) - .collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); - //等级重复统计 - Map repeatList = repetStatistics - .stream() - .filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null ) - .collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, - Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); - - OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); - one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); - if(repeatList.get(one.getDefectLevel()) != null){ - one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); - one.setHappenRatio(one.getHappenNum()/Double.valueOf(total)); - one.setRepeatRatio(one.getHappenNum()/Double.valueOf(totalRepeat)); - } - - OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); - two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); - if(repeatList.get(two.getDefectLevel()) != null){ - two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); - two.setHappenRatio(two.getHappenNum()/Double.valueOf(total)); - two.setRepeatRatio(two.getHappenNum()/Double.valueOf(totalRepeat)); - } - - OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); - three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); - if(repeatList.get(three.getDefectLevel()) != null) { - three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); - three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); - three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); - } - - OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder() - .defectLevel("合计") - .happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()) - .happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()) - .repeatRatio(1.00) - .build(); - if(addUp.getHappenNum().equals(0L)){ - addUp.setRepeatRatio(0.0); - } - - re.addAll(Arrays.asList(one,two,three,addUp)); - return re; - } - - - private List getRatioStatic(List dtos){ - //本月统计返回 - List re = new ArrayList<>(); - OperDefectRatioDTO one = new OperDefectRatioDTO(); - one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); - OperDefectRatioDTO two = new OperDefectRatioDTO(); - two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); - OperDefectRatioDTO three = new OperDefectRatioDTO(); - three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); - - //等级统计 - Map collectLevel = dtos.stream().filter(s-> s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getDefectLevel, - Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); - //总缺陷数 - int total = dtos.stream().mapToInt(OperDefectStatisticsStatusDTO::getDefectNum).sum(); - //状态统计 - Map collectStatus = dtos.stream().collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getHandleStatus, - Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); - - for (OperDefectStatisticsStatusDTO dto : dtos) { - if(dto.getDefectLevel()!=null){ - switch (dto.getDefectLevel()) { - case "1": - setReturnRatio(total, one, dto, collectLevel, collectStatus); - break; - case "2": - setReturnRatio(total, two, dto, collectLevel, collectStatus); - break; - case "3": - setReturnRatio(total, three, dto, collectLevel, collectStatus); - break; - default: - break; - } - } - } - int solveNum = collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()) == null? 0 : (int)collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum(); - OperDefectRatioDTO addUp = OperDefectRatioDTO.builder() - .happenNum(total) - .happenRatio(total == 0 ? 0 : 1.00) - .defectLevel("合计") - .sovleRatio(solveNum == 0 ? 0 : 1.00) - .sovleNum(solveNum) - .build(); - re.addAll(Arrays.asList(one,two,three,addUp)); - return re; - } - - - private void setReturnRatio(int total, OperDefectRatioDTO ratio, OperDefectStatisticsStatusDTO dto, - Map collectLevel, Map collectStatus){ - if(dto.getHandleStatus().equals(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus())) { - ratio.setSovleNum(dto.getDefectNum()); - ratio.setSovleRatio(Double.valueOf(dto.getDefectNum())/collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum()); - ratio.setHappenNum((int)collectLevel.get(dto.getDefectLevel()).getSum()); - ratio.setHappenRatio(ratio.getHappenNum()/Double.valueOf(total)); - } else { - ratio.setHappenNum((int)collectLevel.get(dto.getDefectLevel()).getSum()); - ratio.setHappenRatio(ratio.getHappenNum()/Double.valueOf(total)); - } - } - - /** - * 更新缺陷信息 - * @param entity - * @return - */ - @Override - public boolean updateDefectInfo(OperDefectEntity entity) { - return this.update(Wrappers.lambdaUpdate() - .set(OperDefectEntity::getActHours, entity.getActHours()) - .set(OperDefectEntity::getActStartTime,entity.getActStartTime()) - .set(OperDefectEntity::getActEndTime,entity.getActEndTime()) - .set(OperDefectEntity::getDisposeDesc,entity.getDisposeDesc()) - .eq(OperDefectEntity::getDefectCode,entity.getDefectCode())); - } - - @Override - public boolean updateDefectHanderState(OperDefectEntity entity) { - return this.update(Wrappers.lambdaUpdate() - .set(OperDefectEntity::getHandleStatus, entity.getHandleStatus()) - .eq(OperDefectEntity::getDefectCode,entity.getDefectCode())); - } + private static final Logger logger = LoggerFactory.getLogger(OperDefectServiceImpl.class); + + private final IFlowClient flowClient; + + private final OperDefectMapper operDefectMapper; + + private final IUserClient userClient; + + private final OperPhenomenonMapper operPhenomenonMapper; + + /** + * 开始问题处理流程 + * 问题处理流程的第一个处理节点人key 必须是 problemUser + * + * @param + */ + @Override + public void startFlow(OperPhenomenonEntity phenomenonEntity, OperDefectEntity defectEntity) { + User handler = UserCache.getUser(phenomenonEntity.getHandler()); + String handlerName = handler == null ? "" : handler.getName(); + String sourceName = DictCache.getValue(DefectConstant.SOURCE_CODE_DICT_KEY, phenomenonEntity.getSourceCode()); + String processName = "【" + sourceName + "】" + handlerName + " 发起的缺陷【" + phenomenonEntity.getDefectCode() + "】的问题处理流程"; + defectEntity.setCreateUser(phenomenonEntity.getCreateUser()); + defectEntity.setCreateDept(phenomenonEntity.getCreateDept()); + defectEntity.setTenantId(phenomenonEntity.getTenantId()); + save(defectEntity); + + Kv variables = Kv.create().set(ProcessConstant.TASK_VARIABLE_CREATE_USER, "taskUser_" + phenomenonEntity.getCreateUser()).set(DefectConstant.PROCESS_VARIABLE_HANDLE_USER, "taskUser_" + phenomenonEntity.getHandler()); + R result = flowClient.startProcessInstanceContainNameByKey(defectEntity.getProcDefId(), FlowUtil.getBusinessKey("hzims_oper_defect", String.valueOf(defectEntity.getId())), processName, variables); + if (result.isSuccess()) { + BladeFlow flow = result.getData(); + log.debug("流程已启动,流程ID:" + flow.getProcessInstanceId()); + // 返回流程id写入defect + defectEntity.setProcessInstanceId(flow.getProcessInstanceId()); + defectEntity.setHandleStatus(DefectConstant.DefectHandlerStatusEnum.HANDLING_STATUS.getStatus().toString()); + updateById(defectEntity); + } else { + throw new ServiceException("开启流程失败,code=" + result.getCode()); + } + + } + + + /** + * 处理问题 + * + * @param flow + * @return + */ + @Override + public boolean handleProcess(BladeFlow flow) { + if (!invalidHandleProcess(flow.getProcessInstanceId())) { + throw new ServiceException("当前缺陷开具了检修计划,需等任务执行完成才能处理缺陷"); + } + ComleteTask task = new ComleteTask(); + task.setTaskId(flow.getTaskId()); + task.setComment(flow.getComment()); + task.setAttachments(flow.getAttachments()); + task.setFlag(flow.getFlag()); + task.setVariables(flow.getVariables()); + Map map = flow.getVariables(); + + flowClient.completeTask(task); + Integer status = ProcessConstant.ProcessInstanceStatusEnum.running.ordinal(); + R result = flowClient.queryProcessInstanceStatus(flow.getProcessInstanceId()); + if (result.isSuccess()) { + status = ProcessConstant.ProcessInstanceStatusEnum.over.name().equals(result.getData()) ? ProcessConstant.ProcessInstanceStatusEnum.over.ordinal() : status; + } + + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.set(OperDefectEntity::getHandleStatus, status); + //第一个流程节点传 + if (Func.isNotEmpty(map.get("actStartTime"))) { + updateWrapper.set(OperDefectEntity::getActStartTime, map.get("actStartTime").toString()); + } + //最后一个流程节点传 + if (Func.isNotEmpty(map.get("actEndTime"))) { + updateWrapper.set(OperDefectEntity::getActEndTime, map.get("actEndTime").toString()); + } + //最后一个流程节点传 + if (Func.isNotEmpty(map.get("disposeDesc"))) { + updateWrapper.set(OperDefectEntity::getDisposeDesc, map.get("disposeDesc").toString()); + } + /** + * 每一个流程节点都要传,这个数据属于叠加数据,例如第一个流程节点是8小时,第二个流程节点是2小时, + * 第一个节点完成后存储的数据是8 第二个节点完成后存储的数据是 8,2 + */ + if (Func.isNotEmpty(map.get("actHours"))) { + updateWrapper.set(OperDefectEntity::getActHours, map.get("actHours").toString()); + } + updateWrapper.eq(OperDefectEntity::getProcessInstanceId, flow.getProcessInstanceId()); + update(updateWrapper); + return true; + } + + /** + * 获取缺陷的统计月报 + * + * @param month 格式:"2021-01" + */ + @Override + public Map getDefectStatistics(String month) { + Map re = new HashMap<>(); + re.put("currentMonth", getCurrentMonthStatic(month)); + re.put("severalMonths", getStatisticBySeveralMonth(month)); + re.put("manageIndex", getManageIndexStatistic(month)); + re.put("repeat", getRepeatStatistic(month)); + return re; + } + + @Override + public void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException { + Map re = new HashMap<>(); + re = this.getDefectStatistics(month); + //获取数据 + List currentMonth = (List) re.get("currentMonth"); + List severalMonths = (List) re.get("severalMonths"); + OperDefectManageIndexDTO manageIndex = (OperDefectManageIndexDTO) re.get("manageIndex"); + List repeat = (List) re.get("repeat"); + + // 第一步,创建一个webbook,对应一个Excel文件 + HSSFWorkbook wb = new HSSFWorkbook(); + // 第二步,在webbook中添加一个sheet,对应Excel文件中的sheet + HSSFSheet sheet = wb.createSheet("缺陷月报(" + month + ")"); + sheet.setDefaultRowHeight((short) (20 * 20)); + //生成当前行 + int currentRow = 0; + for (int col = 0; col < 9; col++) { + sheet.setColumnWidth(col, 3900); + } + //创建标题行 + CellRangeAddress region1 = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); + sheet.addMergedRegion(region1); + //参数1:起始行 参数2:终止行 参数3:起始列 参数4:终止列 + HSSFRow headTitle = sheet.createRow(currentRow); + this.setFullHeadCell(wb, headTitle, (short) 9, 0); + HSSFCell headCell = headTitle.getCell(0); + headCell.setCellValue("缺陷月报(" + month + ")"); + currentRow++; + + // 本月与前几月缺陷报表比较表格设置 + currentRow = this.setCompareMonthCell(currentMonth, severalMonths, wb, sheet, new Integer(currentRow)); + currentRow++; + + // 管理指标(本月)设置 + currentRow = this.setManageIndexCell(manageIndex, wb, sheet, currentRow); + currentRow++; + + // 重复分类缺陷汇总表设置 + this.setRepeatCell(repeat, wb, sheet, currentRow); + + // 下载导出 + String filename = "(" + month + ")缺陷月报表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream = null; + //一定要设置成xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + wb.write(outputStream); + // 关闭 + outputStream.close(); + wb.close(); + } + + @Override + public List getDefectList(String emCode, List list) { + return this.baseMapper.selectDefectList(emCode, list); + } + + @Override + public List getDefectByEmCodeList(String emCode) { + return this.baseMapper.selectDefectByEmCodeList(emCode); + } + + @Override + public List getFaultByFaultCode(LocalDate startDate, LocalDate endDate, List deptIdList) { + List defectReportsVOList; + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE); + List operDefectVOS = this.baseMapper.selectDurationDefect(dtf.format(startDate), dtf.format(endDate), deptIdList); + + defectReportsVOList = operDefectVOS.stream().map(operDefectVO -> { + User finder = UserCache.getUser(operDefectVO.getFinder()); + String finderAndTime = (ObjectUtil.isNotEmpty(finder) && StringUtil.isNotBlank(finder.getName()) ? finder.getName() : operDefectVO.getFinder().toString()) + ":" + DateFormatUtils.format(operDefectVO.getFindTime(), DateUtil.PATTERN_DATETIME); + String handlerAndTime = ""; + if (Func.isNotEmpty(operDefectVO.getHandler())) { + User handler = UserCache.getUser(operDefectVO.getHandler()); + String handlerName = ObjectUtil.isNotEmpty(handler) && StringUtil.isNotBlank(handler.getName()) ? handler.getName() : operDefectVO.getHandler().toString(); + String handleTime = Func.isNotEmpty(operDefectVO.getActEndTime()) ? DateFormatUtils.format(operDefectVO.getActEndTime(), DateUtil.PATTERN_DATETIME) : ""; + handlerAndTime = String.format("%s:%s", handlerName, handleTime); + } + String seriousSituation = DictCache.getValue(DefectConstant.LEVEL_CODE_DICT_KEY, operDefectVO.getDefectLevel()); + return DefectReportsVO.builder().faultName(operDefectVO.getFaultName()).seriousSituation(seriousSituation).finderAndTime(finderAndTime).handlerAndTime(handlerAndTime).handleSituation(operDefectVO.getConclusion()).build(); + }).collect(Collectors.toList()); + + return defectReportsVOList; + } + + @Override + public List getFaultByFaultCode(Map params) { + LocalDate startDate = LocalDate.parse(params.get("startDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + LocalDate endDate = LocalDate.parse(params.get("endDate").toString(), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + List deptIdList = (List) params.get("deptId"); + return getFaultByFaultCode(startDate, endDate, deptIdList); + } + + @Override + public List> getDefectConclusion(Map params) { + return operDefectMapper.getDefectConclusion(params); + } + + @Override + public R detail(OperDefectEntity defect) { + OperDefectEntity detail = getOne(Condition.getQueryWrapper(defect)); + OperDefectVO operDefectVO = null; + if (ObjectUtil.isNotEmpty(detail)) { + operDefectVO = OperDefectWrapper.build().entityVO(detail); + //获取检修计划 + IOperAccessPlanService planService = SpringUtil.getBean(OperAccessPlanServiceImpl.class); + OperAccessPlanEntity accessPlanEntity = planService.getOne(Wrappers.lambdaQuery().eq(OperAccessPlanEntity::getDefectId, detail.getId())); + if (ObjectUtil.isNotEmpty(accessPlanEntity)) { + operDefectVO.setAccessPlanId(accessPlanEntity.getId()); + if (ObjectUtil.isNotEmpty(accessPlanEntity.getStatus()) && accessPlanEntity.getStatus() > AccessConstants.PLAN_DRAFT) { + operDefectVO.setEditStatus(0); + } else { + operDefectVO.setEditStatus(1); + } + } + } + return R.data(operDefectVO); + } + + /** + * 获取安全检查消缺项统计 + * + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param dept 机构ID + * @param defectType 缺陷类型;1: 重大缺陷 2:一般缺陷 + * @return SafeCheckStatisticVO 对象 + */ + @Override + public SafeCheckStatisticVO getDefectCheck(String startDate, String endDate, Long dept, String defectType) { + SafeCheckStatisticVO vo = new SafeCheckStatisticVO(); + //获取消缺总数 + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery().eq(OperPhenomenonEntity::getCreateDept, dept).ge(OperPhenomenonEntity::getPlanStartTime, startDate).le(OperPhenomenonEntity::getPlanStartTime, endDate).eq(OperPhenomenonEntity::getIsDefect, 1); + //缺陷等级为Ⅰ级缺陷时为重大缺陷 其他为一般缺陷 + if ("1".equals(defectType)) { + vo.setProjectType(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.SERIOUS_DEFECT.getName()); + wrapper.eq(OperPhenomenonEntity::getDefectLevel, DefectConstant.DefectLevelEnum.ONE.getStatus()); + } else if ("2".equals(defectType)) { + vo.setProjectType(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getType()); + vo.setProjectTypeName(Constants.SafeCheckProjectEnum.NORMAL_DEFECT.getName()); + wrapper.ne(OperPhenomenonEntity::getDefectLevel, DefectConstant.DefectLevelEnum.ONE.getStatus()); + } + List operPhenomenonEntities = operPhenomenonMapper.selectList(wrapper); + if (CollectionUtil.isNotEmpty(operPhenomenonEntities)) { + //获取消缺率 + List finishDefects = operPhenomenonEntities.stream().filter(p -> ObjectUtil.isNotEmpty(p.getConclusionStatus()) && "1".equals(p.getConclusionStatus())).collect(Collectors.toList()); + vo.setTotal(operPhenomenonEntities.size()); + vo.setQualified(finishDefects.size()); + vo.setQualifiedRate(new BigDecimal(finishDefects.size() / (double) operPhenomenonEntities.size() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); + } + return vo; + } + + /** + * 根据流程ID判断该缺陷是否能执行 + * + * @param processInstanceId 流程ID + * @return + */ + private boolean invalidHandleProcess(String processInstanceId) { + boolean result = true; + OperDefectEntity defectEntity = super.getOne(new LambdaQueryWrapper() {{ + eq(OperDefectEntity::getProcessInstanceId, processInstanceId); + }}); + //若类型为检修 + if (Func.isNotEmpty(defectEntity.getDefectCode()) && DefectConstant.DefectSourceEnum.JX.getStatus().equals(defectEntity.getDefectCode().substring(0, 2))) { + IOperAccessPlanService planService = SpringUtil.getBean(IOperAccessPlanService.class); + List planList = planService.list(new LambdaQueryWrapper() {{ + eq(OperAccessPlanEntity::getDefectId, defectEntity.getId()); + }}); + if (CollectionUtil.isNotEmpty(planList)) { + //获取未审核的计划 + List pendingReviewList = planList.stream().filter(p -> p.getStatus() != AccessConstants.PLAN_FINISH).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(pendingReviewList)) { + result = false; + } + //获取检修计划ID集合 + List planIdList = planList.stream().map(OperAccessPlanEntity::getId).collect(Collectors.toList()); + IOperAccessTaskService taskService = SpringUtil.getBean(IOperAccessTaskService.class); + //未完成检修任务集合 + List taskList = taskService.list(new LambdaQueryWrapper() {{ + in(OperAccessTaskEntity::getPlanId, planIdList); + ne(OperAccessTaskEntity::getStatus, AccessConstants.ACCESS_TASK_STATUS_4); + }}); + if (CollectionUtil.isNotEmpty(taskList)) { + result = false; + } + } + } + return result; + } + + /** + * 创建标题单元格样式 + * + * @param wb + * @return + */ + private HSSFCellStyle setHeadCellStyle(HSSFWorkbook wb) { + HSSFCellStyle headStyle = wb.createCellStyle(); + //设置边框 + headStyle.setBorderLeft(BorderStyle.THIN); + headStyle.setBorderRight(BorderStyle.THIN); + headStyle.setBorderTop(BorderStyle.THIN); + headStyle.setBorderBottom(BorderStyle.THIN); + //二、设置单元格背景颜色 + headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); + //三、设置居中: + headStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 + headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + //四、设置字体: + HSSFFont font = wb.createFont(); + font.setFontName("黑体"); + //font.setColor(); + font.setFontHeightInPoints((short) 12);//设置字体大小 + headStyle.setFont(font);//选择需要用到的字体格式 + + return headStyle; + } + + /** + * 创建表格内容单元格样式 + * + * @param wb + * @return + */ + private HSSFCellStyle setContentCellStyle(HSSFWorkbook wb) { + HSSFCellStyle contentStyle = wb.createCellStyle(); + //设置边框 + contentStyle.setBorderLeft(BorderStyle.THIN); + contentStyle.setBorderRight(BorderStyle.THIN); + contentStyle.setBorderTop(BorderStyle.THIN); + contentStyle.setBorderBottom(BorderStyle.THIN); + //三、设置居中: + contentStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 + contentStyle.setVerticalAlignment(VerticalAlignment.CENTER); + //四、设置字体: + HSSFFont font = wb.createFont(); + font.setFontName("仿宋_GB2312"); + //font.setBold(true);//粗体显示 + font.setFontHeightInPoints((short) 10); + contentStyle.setFont(font);//选择需要用到的字体格式 + return contentStyle; + } + + /** + * 设置缺陷月报表excel导出-本月与前几月缺陷报表内单元格 + * + * @param sheet + * @param currentRow + */ + private int setCompareMonthCell(List currentMonth, List severalMonths, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { + //创建当月与1-至当月表表头 + HSSFRow headRow = sheet.createRow(currentRow); + //设置表头信息 + this.setFullHeadCell(wb, headRow, (short) 9, 0); + HSSFCell compare_head1_cell1 = headRow.getCell(0); + compare_head1_cell1.setCellValue("指标名称"); + HSSFCell compare_head1_cell2 = headRow.getCell(1); + compare_head1_cell2.setCellValue("本月"); + HSSFCell compare_head1_cell3 = headRow.getCell(5); + compare_head1_cell3.setCellValue("(1-本月)累计"); + //合并单元格 + CellRangeAddress head1_region1 = new CellRangeAddress((short) currentRow, (short) currentRow + 1, (short) 0, (short) 0); + CellRangeAddress head1_region2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 1, (short) 4); + CellRangeAddress head1_region3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 8); + sheet.addMergedRegion(head1_region1); + sheet.addMergedRegion(head1_region2); + sheet.addMergedRegion(head1_region3); + currentRow++; + //创建表头 + HSSFRow headRow2 = sheet.createRow(currentRow); + this.setFullHeadCell(wb, headRow2, (short) 9, 0); + //设置表头信息 + HSSFCell compare_head2_cell1 = headRow2.getCell(1); + compare_head2_cell1.setCellValue("发生"); + + HSSFCell compare_head2_cell2 = headRow2.getCell(2); + compare_head2_cell2.setCellValue("比率(%)"); + + HSSFCell compare_head2_cell3 = headRow2.getCell(3); + compare_head2_cell3.setCellValue("消除"); + + HSSFCell compare_head2_cell4 = headRow2.getCell(4); + compare_head2_cell4.setCellValue("比率(%)"); + + HSSFCell compare_head2_cell5 = headRow2.getCell(5); + compare_head2_cell5.setCellValue("发生"); + + HSSFCell compare_head2_cell6 = headRow2.getCell(6); + compare_head2_cell6.setCellValue("比率(%)"); + + HSSFCell compare_head2_cell7 = headRow2.getCell(7); + compare_head2_cell7.setCellValue("发生"); + + HSSFCell compare_head2_cell8 = headRow2.getCell(8); + compare_head2_cell8.setCellValue("比率(%)"); + currentRow++; + + for (int i = 0; i < currentMonth.size(); i++) { + HSSFRow row = sheet.createRow(currentRow); + this.setFullHeadCell(wb, row, (short) 9, 1); + OperDefectRatioDTO currentRatioDTO = currentMonth.get(i); + OperDefectRatioDTO severalRatioDTO = severalMonths.get(i); + //创建表格内容第一个单元格 + HSSFCell compare_content_cell1 = row.getCell(0); + if ("1".equals(currentRatioDTO.getDefectLevel())) { + compare_content_cell1.setCellValue("一类缺陷"); + } else if ("2".equals(currentRatioDTO.getDefectLevel())) { + compare_content_cell1.setCellValue("二类缺陷"); + } else if ("3".equals(currentRatioDTO.getDefectLevel())) { + compare_content_cell1.setCellValue("三类缺陷"); + } else if ("合计".equals(currentRatioDTO.getDefectLevel())) { + compare_content_cell1.setCellValue(currentRatioDTO.getDefectLevel()); + } + HSSFCell compare_content_cell2 = row.getCell(1); + compare_content_cell2.setCellValue(currentRatioDTO.getHappenNum()); + HSSFCell compare_content_cell3 = row.getCell(2); + compare_content_cell3.setCellValue(this.dealDouble(currentRatioDTO.getHappenRatio())); + HSSFCell compare_content_cell4 = row.getCell(3); + compare_content_cell4.setCellValue(currentRatioDTO.getSovleNum()); + HSSFCell compare_content_cell5 = row.getCell(4); + compare_content_cell5.setCellValue(this.dealDouble(currentRatioDTO.getSovleRatio())); + + HSSFCell compare_content_cell6 = row.getCell(5); + compare_content_cell6.setCellValue(severalRatioDTO.getHappenNum()); + HSSFCell compare_content_cell7 = row.getCell(6); + compare_content_cell7.setCellValue(this.dealDouble(severalRatioDTO.getHappenRatio())); + HSSFCell compare_content_cell8 = row.getCell(7); + compare_content_cell8.setCellValue(severalRatioDTO.getSovleNum()); + HSSFCell compare_content_cell9 = row.getCell(8); + compare_content_cell9.setCellValue(this.dealDouble(severalRatioDTO.getSovleRatio())); + currentRow++; + } + return currentRow; + } + + /** + * 设置缺陷月报表excel导出-管理指标(本月)表内单元格 + * + * @param wb + * @param sheet + * @param currentRow 记录表格中叠加后的数据 + */ + private int setManageIndexCell(OperDefectManageIndexDTO manageIndex, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { + //管理指标表头 + HSSFRow headRow3 = sheet.createRow(currentRow); + this.setFullHeadCell(wb, headRow3, (short) 9, 0); + HSSFCell manage_index_head = headRow3.getCell(0); + manage_index_head.setCellValue("管理指标(本月)"); + CellRangeAddress head1_region4 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 8); + sheet.addMergedRegion(head1_region4); + currentRow++; + + HSSFRow headRow4 = sheet.createRow(currentRow); + this.setFullHeadCell(wb, headRow4, (short) 9, 0); + HSSFCell repeat_head2_cell = headRow4.getCell(0); + repeat_head2_cell.setCellValue("及时消除的缺陷数"); + HSSFCell repeat_head2_cell2 = headRow4.getCell(2); + repeat_head2_cell2.setCellValue("消除及时率(%)"); + HSSFCell repeat_head2_cell3 = headRow4.getCell(4); + repeat_head2_cell3.setCellValue("消缺率(%)"); + HSSFCell repeat_head2_cell4 = headRow4.getCell(5); + repeat_head2_cell4.setCellValue("历史遗留缺陷数"); + HSSFCell repeat_head2_cell5 = headRow4.getCell(7); + repeat_head2_cell5.setCellValue("本月遗留缺陷"); + + //合并单元格 + CellRangeAddress head2_region1 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 1); + CellRangeAddress head2_region2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 2, (short) 3); + CellRangeAddress head2_region3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 6); + CellRangeAddress head2_region4 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 7, (short) 8); + + sheet.addMergedRegion(head2_region1); + sheet.addMergedRegion(head2_region2); + sheet.addMergedRegion(head2_region3); + sheet.addMergedRegion(head2_region4); + + currentRow++; + + //表格内容行 + HSSFRow manage_index_row = sheet.createRow(currentRow); + this.setFullHeadCell(wb, manage_index_row, (short) 9, 1); + //表格内容 + //第一列 + CellRangeAddress manage_religon1 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 0, (short) 1); + sheet.addMergedRegion(manage_religon1); + HSSFCell manage_index_cell = manage_index_row.getCell(0); + manage_index_cell.setCellStyle(this.setContentCellStyle(wb)); + manage_index_cell.setCellValue(manageIndex.getInTimeNum()); + //第二列 + CellRangeAddress manage_religon2 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 2, (short) 3); + sheet.addMergedRegion(manage_religon2); + HSSFCell manage_index_cel2 = manage_index_row.getCell(2); + manage_index_cel2.setCellValue(this.dealDouble(manageIndex.getInTimeRatio())); + //第三列 + HSSFCell manage_index_cel3 = manage_index_row.getCell(4); + manage_index_cel3.setCellValue(this.dealDouble(manageIndex.getDealRatio())); + //第四列 + CellRangeAddress manage_religon3 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 5, (short) 6); + sheet.addMergedRegion(manage_religon3); + HSSFCell manage_index_cel4 = manage_index_row.getCell(5); + manage_index_cel4.setCellValue(manageIndex.getHistoryRemindNum()); + //第五列 + CellRangeAddress manage_religon4 = new CellRangeAddress((short) currentRow, (short) currentRow, (short) 7, (short) 8); + sheet.addMergedRegion(manage_religon4); + HSSFCell manage_index_cel5 = manage_index_row.getCell(7); + manage_index_cel5.setCellValue(manageIndex.getMonthRemindNum()); + currentRow++; + return currentRow; + } + + /** + * 设置缺陷月报表excel导出-重复分类缺陷汇总表内单元格 + * + * @param wb + * @param sheet + * @param currentRow 记录表格中叠加后的数据 + */ + private int setRepeatCell(List repeat, HSSFWorkbook wb, HSSFSheet sheet, int currentRow) { + //重复缺陷分类汇总表 + //表头1 + HSSFRow repeat_head1 = sheet.createRow(currentRow); + this.setFullHeadCell(wb, repeat_head1, (short) 9, 0); + HSSFCell repeat_head1_cell = repeat_head1.getCell(0); + repeat_head1_cell.setCellValue("重复缺陷分类汇总表"); + CellRangeAddress repeat_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 8); + sheet.addMergedRegion(repeat_religon); + currentRow++; + + //表头2 + CellRangeAddress repeat_head2_cell_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 2); + sheet.addMergedRegion(repeat_head2_cell_religon); + + HSSFRow repeat_head2 = sheet.createRow(currentRow); + this.setFullHeadCell(wb, repeat_head2, (short) 9, 0); + HSSFCell repeat_head2_cell1 = repeat_head2.getCell(3); + CellRangeAddress repeat_head2_cell1_religon = new CellRangeAddress(currentRow, currentRow, (short) 3, (short) 4); + sheet.addMergedRegion(repeat_head2_cell1_religon); + repeat_head2_cell1.setCellValue("发生数量"); + + HSSFCell repeat_head2_cell2 = repeat_head2.getCell(5); + CellRangeAddress repeat_head2_cell2_religon = new CellRangeAddress(currentRow, currentRow, (short) 5, (short) 6); + sheet.addMergedRegion(repeat_head2_cell2_religon); + repeat_head2_cell2.setCellValue("占重复缺陷总数的比率(%)"); + + HSSFCell repeat_head2_cell3 = repeat_head2.getCell(7); + CellRangeAddress repeat_head2_cell3_religon = new CellRangeAddress(currentRow, currentRow, (short) 7, (short) 8); + sheet.addMergedRegion(repeat_head2_cell3_religon); + repeat_head2_cell3.setCellValue("占总缺陷的比率(%)"); + + currentRow++; + + //内容 + for (int i = 0; i < repeat.size(); i++) { + HSSFRow repeat_row = sheet.createRow(currentRow); + this.setFullHeadCell(wb, repeat_row, (short) 9, 1); + //第一列 + HSSFCell repeat_cell1 = repeat_row.getCell(0); + CellRangeAddress repeat_content_religon = new CellRangeAddress(currentRow, currentRow, (short) 0, (short) 2); + sheet.addMergedRegion(repeat_content_religon); + if ("1".equals(repeat.get(i).getDefectLevel())) { + repeat_cell1.setCellValue("一类缺陷"); + } else if ("2".equals(repeat.get(i).getDefectLevel())) { + repeat_cell1.setCellValue("二类缺陷"); + } else if ("3".equals(repeat.get(i).getDefectLevel())) { + repeat_cell1.setCellValue("三类缺陷"); + } else if ("合计".equals(repeat.get(i).getDefectLevel())) { + repeat_cell1.setCellValue(repeat.get(i).getDefectLevel()); + } + //第二列 + HSSFCell repeat_cell2 = repeat_row.getCell(3); + CellRangeAddress repeat_content_religon1 = new CellRangeAddress(currentRow, currentRow, (short) 3, (short) 4); + sheet.addMergedRegion(repeat_content_religon1); + repeat_cell2.setCellValue(repeat.get(i).getHappenNum()); + + //第三列 + HSSFCell repeat_cell3 = repeat_row.getCell(5); + CellRangeAddress repeat_content_religon2 = new CellRangeAddress(currentRow, currentRow, (short) 5, (short) 6); + sheet.addMergedRegion(repeat_content_religon2); + repeat_cell3.setCellValue(this.dealDouble(repeat.get(i).getRepeatRatio())); + + //第四列 + HSSFCell repeat_cell4 = repeat_row.getCell(7); + CellRangeAddress repeat_content_religon3 = new CellRangeAddress(currentRow, currentRow, (short) 7, (short) 8); + sheet.addMergedRegion(repeat_content_religon3); + repeat_cell4.setCellValue(this.dealDouble(repeat.get(i).getHappenRatio())); + currentRow++; + } + return currentRow; + } + + /** + * 补全合并单元格时 表格行所有单元格 + * + * @param headRow + * @param rowLen + * @param status 0:设置表头样式 1:设置内容样式 + */ + private void setFullHeadCell(HSSFWorkbook wb, HSSFRow headRow, short rowLen, int status) { + for (int i = 0; i < rowLen; i++) { + HSSFCell hssfcell = headRow.createCell(i); + if (status == 0) { + hssfcell.setCellStyle(this.setHeadCellStyle(wb)); + } else if (status == 1) { + hssfcell.setCellStyle(this.setContentCellStyle(wb)); + } + } + } + + /** + * 处理double数据保留两位小数 + * + * @param num + * @return + */ + private Double dealDouble(Double num) { + if (num != null) { + BigDecimal b = new BigDecimal(num * 100); + return b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + return null; + } + + /** + * 获取当前月统计数据 + * + * @param month + * @return + */ + private List getCurrentMonthStatic(String month) { + List statisticByMonth = this.baseMapper.getStatisticByMonth(month, AuthUtil.getDeptId()); + return getRatioStatic(statisticByMonth); + } + + /** + * 当年1月 - 当前月获取缺陷等级统计数据 + * + * @param month "2021-01" + * @return + */ + private List getStatisticBySeveralMonth(String month) { + Integer intervalMonth = Integer.valueOf(month.split("-")[1]); + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date; + String firstMonth = month.split("-")[0] + "-01-01"; + try { + date = dateFormat.parse(firstMonth); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MONTH, intervalMonth); + date = calendar.getTime(); + } catch (ParseException e) { + throw new ServiceException("日期转换失败"); + } + log.error("firstMonth:" + firstMonth + "; end=" + dateFormat.format(date)); + + List statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), AuthUtil.getDeptId()); + return getRatioStatic(statisticBySeveralMonth); + } + + /** + * 获取按月管理指标统计数据 + * + * @param month + * @return + */ + private OperDefectManageIndexDTO getManageIndexStatistic(String month) { + OperDefectManageIndexDTO manageIndex = new OperDefectManageIndexDTO(); + List list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); + manageIndex.setInTimeNum(list.get(0)); + if (!list.get(1).equals(0)) { + manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : Double.valueOf(list.get(0)) / list.get(1)); + } + manageIndex.setHistoryRemindNum(list.get(3)); + manageIndex.setMonthRemindNum(list.get(2)); + if (!list.get(4).equals(0)) { + manageIndex.setDealRatio(list.get(1).equals(0) ? 0.0 : Double.valueOf(list.get(1)) / list.get(4)); + } + return manageIndex; + } + + /** + * 获取重复缺陷等级统计数据 + * + * @param month + * @return + */ + private List getRepeatStatistic(String month) { + List re = new ArrayList<>(); + + List repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); + //总缺陷数 + int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); + //总重复缺陷数 + int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); + //等级重复统计 + Map repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); + + OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); + one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); + if (repeatList.get(one.getDefectLevel()) != null) { + one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); + one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); + one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); + } + + OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); + two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); + if (repeatList.get(two.getDefectLevel()) != null) { + two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); + two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); + two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); + } + + OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); + three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); + if (repeatList.get(three.getDefectLevel()) != null) { + three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); + three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); + three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); + } + + OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()).happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()).repeatRatio(1.00).build(); + if (addUp.getHappenNum().equals(0L)) { + addUp.setRepeatRatio(0.0); + } + + re.addAll(Arrays.asList(one, two, three, addUp)); + return re; + } + + + private List getRatioStatic(List dtos) { + //本月统计返回 + List re = new ArrayList<>(); + OperDefectRatioDTO one = new OperDefectRatioDTO(); + one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); + OperDefectRatioDTO two = new OperDefectRatioDTO(); + two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); + OperDefectRatioDTO three = new OperDefectRatioDTO(); + three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); + + //等级统计 + Map collectLevel = dtos.stream().filter(s -> s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); + //总缺陷数 + int total = dtos.stream().mapToInt(OperDefectStatisticsStatusDTO::getDefectNum).sum(); + //状态统计 + Map collectStatus = dtos.stream().collect(Collectors.groupingBy(OperDefectStatisticsStatusDTO::getHandleStatus, Collectors.summarizingInt(OperDefectStatisticsStatusDTO::getDefectNum))); + + for (OperDefectStatisticsStatusDTO dto : dtos) { + if (dto.getDefectLevel() != null) { + switch (dto.getDefectLevel()) { + case "1": + setReturnRatio(total, one, dto, collectLevel, collectStatus); + break; + case "2": + setReturnRatio(total, two, dto, collectLevel, collectStatus); + break; + case "3": + setReturnRatio(total, three, dto, collectLevel, collectStatus); + break; + default: + break; + } + } + } + int solveNum = collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()) == null ? 0 : (int) collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum(); + OperDefectRatioDTO addUp = OperDefectRatioDTO.builder().happenNum(total).happenRatio(total == 0 ? 0 : 1.00).defectLevel("合计").sovleRatio(solveNum == 0 ? 0 : 1.00).sovleNum(solveNum).build(); + re.addAll(Arrays.asList(one, two, three, addUp)); + return re; + } + + + private void setReturnRatio(int total, OperDefectRatioDTO ratio, OperDefectStatisticsStatusDTO dto, Map collectLevel, Map collectStatus) { + if (dto.getHandleStatus().equals(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus())) { + ratio.setSovleNum(dto.getDefectNum()); + ratio.setSovleRatio(Double.valueOf(dto.getDefectNum()) / collectStatus.get(DefectConstant.HandlerStatusEnum.FINISH_STATUS.getStatus()).getSum()); + ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); + ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); + } else { + ratio.setHappenNum((int) collectLevel.get(dto.getDefectLevel()).getSum()); + ratio.setHappenRatio(ratio.getHappenNum() / Double.valueOf(total)); + } + } + + /** + * 更新缺陷信息 + * + * @param entity + * @return + */ + @Override + public boolean updateDefectInfo(OperDefectEntity entity) { + return this.update(Wrappers.lambdaUpdate().set(OperDefectEntity::getActHours, entity.getActHours()).set(OperDefectEntity::getActStartTime, entity.getActStartTime()).set(OperDefectEntity::getActEndTime, entity.getActEndTime()).set(OperDefectEntity::getDisposeDesc, entity.getDisposeDesc()).eq(OperDefectEntity::getDefectCode, entity.getDefectCode())); + } + + @Override + public boolean updateDefectHanderState(OperDefectEntity entity) { + return this.update(Wrappers.lambdaUpdate().set(OperDefectEntity::getHandleStatus, entity.getHandleStatus()).eq(OperDefectEntity::getDefectCode, entity.getDefectCode())); + } + + /** + * 分页查询 + * + * @param operDefectEntityPage + * @param defect + * @return + */ + @Override + public IPage selectPage(Page operDefectEntityPage, OperDefectEntity defect) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(StringUtils.isNotBlank(defect.getDefectCode()), OperDefectEntity::getDefectCode, defect.getDefectCode()); + + //缺陷编号 + queryWrapper.ge(defect.getActStartTime() != null, OperDefectEntity::getActStartTime, defect.getActStartTime()); + + queryWrapper.le(defect.getActEndTime() != null, OperDefectEntity::getActEndTime, defect.getActEndTime()); + + + queryWrapper.ge(defect.getStartTime() != null, OperDefectEntity::getCreateTime, defect.getStartTime()); + + queryWrapper.le(defect.getEndTime() != null, OperDefectEntity::getCreateTime, defect.getEndTime()); + //区域Id + queryWrapper.eq(BaseEntity::getCreateDept, defect.getCreateDept()); + //年月查询 + queryWrapper.apply(defect.getYearMonth() != null, "date_format(CREATE_TIME,'%Y-%m') = '" + + defect.getYearMonth() + "'"); + + queryWrapper.orderByDesc(OperDefectEntity::getActStartTime); + return baseMapper.selectPage(operDefectEntityPage, queryWrapper); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java index 0e63ad2..99a9de9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java @@ -1,11 +1,26 @@ package com.hnac.hzims.operational.main.controller.web; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; +import com.hnac.hzims.operational.access.service.IOperAccessStatisticsService; +import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; +import com.hnac.hzims.operational.defect.entity.OperDefectEntity; +import com.hnac.hzims.operational.defect.service.IOperDefectService; +import com.hnac.hzims.operational.defect.vo.OperDefectVO; +import com.hnac.hzims.operational.defect.wrapper.OperDefectWrapper; import com.hnac.hzims.operational.main.service.AreaMonthlyDetailsService; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckMonthVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.SafeEquipmentTrialVO; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoEvaluateVO; import com.hnac.hzims.ticket.areamonthly.dto.TicketInfoEvaluateDto; @@ -16,7 +31,9 @@ import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.support.BladePage; +import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.SpringQueryMap; @@ -43,6 +60,10 @@ public class AreaMonthlyDetailsController { private final IOperMaintenanceTaskService taskService; + private final IOperDefectService defectService; + + + private final IOperAccessStatisticsService accessStatisticsService; /** * 操作票 根据月份,区域 获取操作详情数据 @@ -143,4 +164,158 @@ public class AreaMonthlyDetailsController { return R.data(task); } + + /** + * 根据区域和月份分页查询缺陷库 + */ + @ApiOperationSupport(order = 70) + @ApiOperation(value = "分页查询") + @GetMapping("/queryDefectPageList/{page}/{size}") + public R> queryDefectPageList( + @PathVariable Long page, + @PathVariable Long size, + OperDefectEntity defect) { + Page operDefectEntityPage = new Page<>(page, size); + IPage pages = defectService.selectPage(operDefectEntityPage, defect); + IPage vos = OperDefectWrapper.build().pageVO(pages); + return R.data(vos); + } + + + /** + * 根据区域和月份分页查询缺陷库 详情 + */ + @GetMapping("queryDefectPageDetail/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入defect") + public R queryDefectPageDetail(OperDefectEntity defect) { + return defectService.detail(defect); + } + + + /** + * 根据区域和月份分页查询检修任务 + */ + @ApiOperationSupport(order = 80) + @ApiOperation(value = "根据区域和月份分页查询检修任务") + @GetMapping("/queryReconditionPageList/{page}/{size}") + public R> queryReconditionPageList( + @PathVariable Long page, @PathVariable Long size, + OperAccessStatisticsDTO result) { + Page dbPage = new Page<>(page, size); + R> r = accessStatisticsService.list(result, dbPage); + return r; + } + + + /** + * 根据区域 编号查询检修任务详情 + */ + @GetMapping("/queryReconditionPageDetail/detail") + @ApiOperationSupport(order = 40) + @ApiOperation(value = "根据区域 编号查询检修任务详情") + public R queryReconditionPageDetail(@RequestParam Long id) { + R detail = accessStatisticsService.detail(id); + return detail; + } + + + /** + * 根据区域编号查询安全生产会议次数 + */ + @GetMapping("/queryProduceNumByAreaCode/{page}/{size}") + @ApiOperationSupport(order = 90) + @ApiOperation(value = "根据区域编号查询安全生产会议次数") + public R> queryProduceNumByAreaCode(@PathVariable Long page, @PathVariable Long size, + CheckMonthEntity req) { + req.setItemName("现场每月1次安全生产会议"); + BladePage checkMonthVoBladePage = areaMonthlyDetailsService.queryProduceByAreaCode(page, size, + req); + return R.data(checkMonthVoBladePage); + } + + /** + * 根据区域编号查询技能培训 + */ + @GetMapping("/querySkillByAreaCode/{page}/{size}") + @ApiOperationSupport(order = 100) + @ApiOperation(value = "根据区域编号查询技能培训") + public R> querySkillByAreaCode(@PathVariable Long page, @PathVariable Long size, CheckMonthEntity req) { + req.setItemName("每月开展1次技能培训"); + BladePage checkMonthVoBladePage = areaMonthlyDetailsService.queryProduceByAreaCode(page, size, + req); + return R.data(checkMonthVoBladePage); + } + + + /** + * 根据区域编号查询月度自查 + */ + @GetMapping("/queryProduceByAreaCode/{page}/{size}") + @ApiOperationSupport(order = 100) + @ApiOperation(value = "根据区域编号查询技能培训") + public R> queryProduceByAreaCode(@PathVariable Long page, @PathVariable Long size, CheckMonthEntity req) { + BladePage checkMonthVoBladePage = areaMonthlyDetailsService.queryProduceByAreaCode(page, size, + req); + return R.data(checkMonthVoBladePage); + } + + + + /** + * 根据区域编号查询 月度自查 技能培训 安全生产会议次数 + */ + @GetMapping("/queryProduceByAreaCodeDetail/detail/{id}") + @ApiOperationSupport(order = 40) + @ApiOperation(value = "详情", notes = "传入id") + public R queryProduceByAreaCodeDetail(@PathVariable Long id){ + CheckMonthVo checkMonthVo = areaMonthlyDetailsService.queryProduceByAreaCodeDetail(id); + return R.data(checkMonthVo); + } + + + /** + * 根据区域编号查询安全检查 + */ + @GetMapping("/querySecurityAreaCode/{page}/{size}") + @ApiOperationSupport(order = 100) + @ApiOperation(value = "根据区域编号查询安全检查") + public R> querySecurityAreaCode(@PathVariable Long page, + @PathVariable Long size, + CheckCompanyEntity req) { + BladePage checkMonthVoBladePage = areaMonthlyDetailsService.querySecurityAreaCode(page, size, + req); + return R.data(checkMonthVoBladePage); + } + + + /** + * 根据区域编号查询安全检查 详情 + */ + @GetMapping("/querySecurityAreaCode/detail/{id}") + @ApiOperationSupport(order = 100) + @ApiOperation(value = "根据区域编号查询安全检查 详情") + public R querySecurityAreaCodeDetail(@PathVariable Long id) { + CheckCompanyVo checkMonthVoBladePage = areaMonthlyDetailsService.querySecurityAreaCodeDetail(id); + return R.data(checkMonthVoBladePage); + } + + + + /** + * 根据区域编号查询设备试验 + */ + @GetMapping("/queryEquipmentAreaCode/{page}/{size}") + @ApiOperationSupport(order = 100) + @ApiOperation(value = "根据区域编号查询设备试验") + public R> queryEquipmentAreaCode( + @PathVariable Long page, + @PathVariable Long size, + SafeEquipmentTrialDTO safeEquipmentTrialDTO) { + BladePage checkMonthVoBladePage = areaMonthlyDetailsService.queryEquipmentAreaCode(page + ,size,safeEquipmentTrialDTO); + return R.data(checkMonthVoBladePage); + } + + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java index 1322f12..9c3bc26 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/AreaMonthlyDetailsService.java @@ -1,6 +1,12 @@ package com.hnac.hzims.operational.main.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckMonthVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.SafeEquipmentTrialVO; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoEvaluateVO; import com.hnac.hzims.ticket.areamonthly.dto.TicketInfoEvaluateDto; @@ -75,4 +81,45 @@ public interface AreaMonthlyDetailsService { * @return */ TaskEntity queryCheckTaskById(Long id); + + /** + * 根据区域编号查询安全生产会议次数 技能培训 + * @param page + * @param size + * @param req + * @return + */ + BladePage queryProduceByAreaCode(Long page, Long size, CheckMonthEntity req); + + /** + * 根据区域编号查询 月度自查 技能培训 安全生产会议次数 + */ + CheckMonthVo queryProduceByAreaCodeDetail(Long id); + + + /** + * 根据区域编号查询安全检查 + * @param page + * @param size + * @param req + * @return + */ + BladePage querySecurityAreaCode(Long page, Long size, CheckCompanyEntity req); + + /** + * 根据区域编号查询安全检查 详情 + * @param id + * @return + */ + CheckCompanyVo querySecurityAreaCodeDetail(Long id); + + /** + * 根据区域编号查询设备试验 + * @param page + * @param size + * @param safeEquipmentTrialDTO + * @return + */ + BladePage queryEquipmentAreaCode(Long page, Long size, SafeEquipmentTrialDTO safeEquipmentTrialDTO); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java index 6dfda4f..1c43df8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AreaMonthlyDetailsServiceImpl.java @@ -1,6 +1,15 @@ package com.hnac.hzims.operational.main.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.safeproduct.areamonthly.feign.CheckCompanyFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.feign.SafeEquipmentTrialFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.feign.SafeproductFeignClient; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckCompanyVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.CheckMonthVo; +import com.hnac.hzims.safeproduct.areamonthly.vo.SafeEquipmentTrialVO; +import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; +import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; +import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoEvaluateVO; import com.hnac.hzims.ticket.areamonthly.dto.TicketInfoEvaluateDto; @@ -38,6 +47,13 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService private final TaskFeignClient taskFeignClient; + private final SafeproductFeignClient safeproductFeignClient; + + private final CheckCompanyFeignClient checkCompanyFeignClient; + + + private final SafeEquipmentTrialFeignClient safeEquipmentTrialFeignClient; + /** * 根据月份,区域 获取操作详情数据 @@ -49,8 +65,7 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService */ @Override public BladePage areaMonthlyWithOperation(Long page, Long size, StandardTicketWithAreaVo areaMonthly) { - R> pageR = - ticketFeignClient.areaMonthlyWithOperation(page, size, areaMonthly); + R> pageR = ticketFeignClient.areaMonthlyWithOperation(page, size, areaMonthly); if (pageR.isSuccess()) { log.info("获取操作详情数据成功"); return pageR.getData(); @@ -68,9 +83,8 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService * @return */ @Override - public BladePage workTicketListByMonthAndArea(Long page, Long size,StandardTicketWithAreaVo areaMonthlyVo) { - R> pageR = - ticketFeignClient.workTicketListByMonthAndArea(page, size, areaMonthlyVo); + public BladePage workTicketListByMonthAndArea(Long page, Long size, StandardTicketWithAreaVo areaMonthlyVo) { + R> pageR = ticketFeignClient.workTicketListByMonthAndArea(page, size, areaMonthlyVo); if (pageR.isSuccess()) { log.info("获取操作详情数据成功"); return pageR.getData(); @@ -149,6 +163,7 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService /** * 根据id查询巡检任务 + * * @param id * @return */ @@ -162,4 +177,101 @@ public class AreaMonthlyDetailsServiceImpl implements AreaMonthlyDetailsService log.error("获取检查巡检任务详情失败", detail.getMsg()); return null; } + + /** + * 根据区域编号查询安全生产会议次数 技能培训 + * + * @param page + * @param size + * @param req + * @return + */ + @Override + public BladePage queryProduceByAreaCode(Long page, Long size, CheckMonthEntity req) { + R> detail = safeproductFeignClient.listconferenceScope(page, size, req); + if (detail.isSuccess()) { + log.info("获取安全生产会议次数 技能培训成功"); + return detail.getData(); + } + log.error("获取安全生产会议次数 技能培训失败", detail.getMsg()); + return null; + } + + /** + * 根据区域编号查询 月度自查 技能培训 安全生产会议次数 + * + * @param id + */ + @Override + public CheckMonthVo queryProduceByAreaCodeDetail(Long id) { + R detail = safeproductFeignClient.detail(id); + if (detail.isSuccess()) { + log.info("根据区域编号查询 月度自查 技能培训 安全生产会议次数成功"); + return detail.getData(); + } + log.error("根据区域编号查询 月度自查 技能培训 安全生产会议次数失败", detail.getMsg()); + return null; + } + + /** + * 根据区域编号查询安全检查 + * + * @param page + * @param size + * @param req + * @return + */ + @Override + public BladePage querySecurityAreaCode(Long page, Long size, CheckCompanyEntity req) { + Query query = new Query(); + query.setCurrent(page.intValue()); + query.setSize(size.intValue()); + R> list = checkCompanyFeignClient.list(req, query); + if (list.isSuccess()) { + log.info("根据区域编号查询安全检查成功"); + return list.getData(); + } + log.error("根据区域编号查询安全检查失败", list.getMsg()); + return null; + } + + /** + * 根据区域编号查询安全检查详情 + * + * @param id + * @return + */ + @Override + public CheckCompanyVo querySecurityAreaCodeDetail(Long id) { + R detailed = checkCompanyFeignClient.detail(id); + if (detailed.isSuccess()) { + log.info(" 根据区域编号查询安全检查详情成功"); + return detailed.getData(); + } + log.error(" 根据区域编号查询安全检查详情失败", detailed.getMsg()); + return null; + } + + /** + * 根据区域编号查询设备试验 + * + * @param page + * @param size + * @param safeEquipmentTrialDTO + * @return + */ + @Override + public BladePage queryEquipmentAreaCode(Long page, Long size, SafeEquipmentTrialDTO safeEquipmentTrialDTO) { + Query query = new Query(); + query.setCurrent(page.intValue()); + query.setSize(size.intValue()); + R> list = safeEquipmentTrialFeignClient.list(safeEquipmentTrialDTO, query); + if (list.isSuccess()) { + log.info("根据区域编号查询设备试验成功"); + return list.getData(); + } + log.error("根据区域编号查询设备试验失败", list.getMsg()); + return null; + + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckCompanyController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckCompanyController.java index 6cf81d8..24d5f35 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckCompanyController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckCompanyController.java @@ -11,6 +11,7 @@ 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.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.system.entity.Dept; @@ -76,7 +77,7 @@ public class CheckCompanyController extends BladeController { @GetMapping("/list") @ApiOperationSupport(order = 50) @ApiOperation(value = "分页", notes = "查询条件:startDate,endDate,status") - public R> list(CheckCompanyEntity req, Query query) { + public R> list(CheckCompanyEntity req, Query query) { return CheckCompanyService.pageCondition(req, query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckMonthController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckMonthController.java index d783ac6..2359474 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckMonthController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/CheckMonthController.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.controller; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.safeproduct.dto.CheckMonthDTO; import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; @@ -11,6 +12,7 @@ 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.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.system.entity.Dept; @@ -108,4 +110,29 @@ public class CheckMonthController extends BladeController { return R.data(page); } + + + + /** + * 分页查询安全生产会议次数 + */ + @GetMapping("/listconferenceScope/{page}/{size}") + @ApiOperationSupport(order = 50) + @ApiOperation(value = "分页", notes = "查询条件:month,status,createDept") + public R> listconferenceScope( + @PathVariable Long page, @PathVariable Long size, + CheckMonthEntity req) { + Page objectPage = new Page<>(page, size); + R> pageR = checkMonthlyService.listconferenceScope(req,objectPage); + IPage pages = pageR.getData(); + pages.getRecords().forEach(monthlyVo -> { + R deptR = sysClient.getDept(monthlyVo.getCreateDept()); + if (deptR.isSuccess()) { + monthlyVo.setDeptName(Optional.ofNullable(deptR.getData()).map(Dept::getDeptName).orElse(null)); + } + }); + BladePage bladePage = BladePage.of(pages); + return R.data(bladePage); + } + } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafeEquipmentTrialController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafeEquipmentTrialController.java index 70249b2..20685f3 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafeEquipmentTrialController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafeEquipmentTrialController.java @@ -14,6 +14,7 @@ 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.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; @@ -58,7 +59,7 @@ public class SafeEquipmentTrialController extends BladeController { @ApiOperation(value = "分页", notes = "查询条件:createDept,fileName,startTime,endTime") @OperationAnnotation(title = "设备试验",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, action = "分页条件") - public R> list(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query) { + public R> list(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query) { return service.pageCondition(safeEquipmentTrialDTO, query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java index 4f6701a..943098c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.java @@ -2,7 +2,9 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; +import com.hnac.hzims.safeproduct.vo.CheckMonthVo; import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.mp.support.Query; @@ -21,4 +23,11 @@ public interface CheckMonthMapper extends UserDataScopeBaseMapper pageNotDataScope(IPage page, @Param("req") CheckMonthEntity req); + /** + * 分页查询安全生产会议次数 + * @param objectPage + * @param req + * @return + */ + IPage listconferenceScope(IPage objectPage, @Param("req") CheckMonthEntity req); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml index f9f6710..84ad46d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CheckMonthMapper.xml @@ -15,5 +15,32 @@ order by CREATE_TIME desc + + diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckCompanyService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckCompanyService.java index 0987903..217a5dc 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckCompanyService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckCompanyService.java @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.entity.CheckQuarterEntity; import com.hnac.hzims.safeproduct.vo.CheckCompanyVo; import com.hnac.hzims.safeproduct.vo.CheckQuarterVo; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -24,6 +25,6 @@ public interface ICheckCompanyService extends BaseService { R detail(Long id); - R> pageCondition(CheckCompanyEntity req, Query query); + R> pageCondition(CheckCompanyEntity req, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckMonthService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckMonthService.java index 337117a..d71a996 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckMonthService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ICheckMonthService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.service; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.dto.CheckMonthDTO; import com.hnac.hzims.safeproduct.entity.CheckMonthEntity; import com.hnac.hzims.safeproduct.vo.CheckMonthVo; @@ -25,4 +26,12 @@ public interface ICheckMonthService extends BaseService { R> pageNotDataScope(CheckMonthEntity req, Query query); + + /** + * 分页查询安全生产会议次数 + * @param req + * @param objectPage + * @return + */ + R> listconferenceScope(CheckMonthEntity req, Page objectPage); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/SafeEquipmentTrialService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/SafeEquipmentTrialService.java index 1ba9d36..33fad1b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/SafeEquipmentTrialService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/SafeEquipmentTrialService.java @@ -6,6 +6,7 @@ import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; import com.hnac.hzims.safeproduct.vo.SafeEquipmentTrialVO; import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -16,7 +17,7 @@ import java.util.List; */ public interface SafeEquipmentTrialService extends BaseService { - R> pageCondition(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query); + R> pageCondition(SafeEquipmentTrialDTO safeEquipmentTrialDTO, Query query); int getSafeEquipmentCount(SafeEquipmentTrialDTO dto); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckCompanyServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckCompanyServiceImpl.java index 841ca7e..becd6c8 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckCompanyServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckCompanyServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; 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.StringUtils; import com.hnac.hzims.safeproduct.dto.CheckCompanyDTO; import com.hnac.hzims.safeproduct.entity.CheckCompanyEntity; import com.hnac.hzims.safeproduct.entity.CheckItemEntity; @@ -15,7 +16,9 @@ import com.hnac.hzims.safeproduct.vo.CheckCompanyVo; import com.hnac.hzims.safeproduct.wrapper.CheckCompanyWrapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -37,112 +40,117 @@ import java.util.stream.Collectors; @Slf4j public class CheckCompanyServiceImpl extends BaseServiceImpl implements ICheckCompanyService { - private final CheckCompanyMapper CheckCompanyMapper; + private final CheckCompanyMapper CheckCompanyMapper; - private final ICheckItemInstanceService itemInstanceService; + private final ICheckItemInstanceService itemInstanceService; - private final ISysClient sysClient; + private final ISysClient sysClient; - @Override - public boolean doSave(CheckCompanyDTO req) { - boolean result = save(req); - if (result) { - Long checkId = req.getId(); - List items = req.getItems(); - items.forEach(item -> { - item.setOid(item.getId()); - item.setId(null); - item.setCheckId(checkId); - }); - itemInstanceService.saveBatch(items); - } - return result; - } + @Override + public boolean doSave(CheckCompanyDTO req) { + boolean result = save(req); + if (result) { + Long checkId = req.getId(); + List items = req.getItems(); + items.forEach(item -> { + item.setOid(item.getId()); + item.setId(null); + item.setCheckId(checkId); + }); + itemInstanceService.saveBatch(items); + } + return result; + } - @Override - public boolean doUpdate(CheckCompanyDTO req) { - boolean result = updateById(req); - if (result) { - List items = req.getItems(); - items.forEach(itemInstanceService::updateById); - } - return result; - } + @Override + public boolean doUpdate(CheckCompanyDTO req) { + boolean result = updateById(req); + if (result) { + List items = req.getItems(); + items.forEach(itemInstanceService::updateById); + } + return result; + } - @Override - public R detail(Long id) { - CheckCompanyEntity entity = CheckCompanyMapper.selectById(id); - CheckCompanyVo vo = CheckCompanyWrapper.build().entityVO(entity); - //查询检查项 - QueryWrapper queryMapper = new QueryWrapper<>(); - queryMapper.eq("CHECK_ID", vo.getId()); - queryMapper.orderByAsc("ORG_ID", "SORT"); - List items = itemInstanceService.list(queryMapper); - //查询子项,用于前端判断 - items.forEach(item -> item.setChildren(findChildren(item, items))); - //按部门分组 - List> list = new ArrayList<>(); - Map> map = items.stream().collect(Collectors.groupingBy(CheckItemInstanceEntity::getOrgId)); - for (Map.Entry> entry : map.entrySet()) { - Map data = new HashMap<>(); - data.put("deptId", entry.getKey()); - R deptR = sysClient.getDept(entry.getKey()); - if (deptR.isSuccess()) { - data.put("deptName", Optional.ofNullable(deptR.getData()).map(Dept::getDeptName).orElse(null)); - } else { - data.put("deptName", null); - } - data.put("items", entry.getValue()); - list.add(data); - } - vo.setItems(list); - return R.data(vo); - } + @Override + public R detail(Long id) { + CheckCompanyEntity entity = CheckCompanyMapper.selectById(id); + CheckCompanyVo vo = CheckCompanyWrapper.build().entityVO(entity); + //查询检查项 + QueryWrapper queryMapper = new QueryWrapper<>(); + queryMapper.eq("CHECK_ID", vo.getId()); + queryMapper.orderByAsc("ORG_ID", "SORT"); + List items = itemInstanceService.list(queryMapper); + //查询子项,用于前端判断 + items.forEach(item -> item.setChildren(findChildren(item, items))); + //按部门分组 + List> list = new ArrayList<>(); + Map> map = items.stream().collect(Collectors.groupingBy(CheckItemInstanceEntity::getOrgId)); + for (Map.Entry> entry : map.entrySet()) { + Map data = new HashMap<>(); + data.put("deptId", entry.getKey()); + R deptR = sysClient.getDept(entry.getKey()); + if (deptR.isSuccess()) { + data.put("deptName", Optional.ofNullable(deptR.getData()).map(Dept::getDeptName).orElse(null)); + } else { + data.put("deptName", null); + } + data.put("items", entry.getValue()); + list.add(data); + } + vo.setItems(list); + return R.data(vo); + } - private List findChildren(CheckItemInstanceEntity entity, List list) { - List child = new ArrayList<>(); - for (CheckItemInstanceEntity itemEntity : list) { - if (null != itemEntity.getParentItem() - && itemEntity.getParentItem().equals(entity.getOid()) - && itemEntity.getOrgId().equals(entity.getOrgId())) { - child.add(itemEntity); - itemEntity.setChildren(findChildren(itemEntity, list)); - } - } - return child; - } + private List findChildren(CheckItemInstanceEntity entity, List list) { + List child = new ArrayList<>(); + for (CheckItemInstanceEntity itemEntity : list) { + if (null != itemEntity.getParentItem() + && itemEntity.getParentItem().equals(entity.getOid()) + && itemEntity.getOrgId().equals(entity.getOrgId())) { + child.add(itemEntity); + itemEntity.setChildren(findChildren(itemEntity, list)); + } + } + return child; + } - @Override - public boolean doDelete(String ids) { - List list = Func.toLongList(ids); - boolean result = deleteLogic(list); - if (result) { - list.forEach(id -> { - QueryWrapper queryMapper = new QueryWrapper<>(); - queryMapper.eq("CHECK_ID", id); - itemInstanceService.remove(queryMapper); - }); - } - return result; - } + @Override + public boolean doDelete(String ids) { + List list = Func.toLongList(ids); + boolean result = deleteLogic(list); + if (result) { + list.forEach(id -> { + QueryWrapper queryMapper = new QueryWrapper<>(); + queryMapper.eq("CHECK_ID", id); + itemInstanceService.remove(queryMapper); + }); + } + return result; + } - @Override - public R> pageCondition(CheckCompanyEntity req, Query query) { - Wrapper queryWrapper = new LambdaQueryWrapper() {{ - orderByDesc(CheckCompanyEntity::getCreateTime); - if (ObjectUtil.isNotEmpty(req.getStartTime())) { - ge(CheckCompanyEntity::getStartTime, req.getStartTime()); - } - if (ObjectUtil.isNotEmpty(req.getEndTime())) { - le(CheckCompanyEntity::getEndTime, req.getEndTime()); - } - if (ObjectUtil.isNotEmpty(req.getStatus())) { - eq(CheckCompanyEntity::getStatus, req.getStatus()); - } - }}; - IPage page = page(Condition.getPage(query), queryWrapper); - page.setRecords(CheckCompanyWrapper.build().listVO(page.getRecords())); - return R.data(page); - } + @Override + public R> pageCondition(CheckCompanyEntity req, Query query) { + Wrapper queryWrapper = new LambdaQueryWrapper() {{ + orderByDesc(CheckCompanyEntity::getCreateTime); + if (ObjectUtil.isNotEmpty(req.getStartTime())) { + ge(CheckCompanyEntity::getStartTime, req.getStartTime()); + } + if (ObjectUtil.isNotEmpty(req.getEndTime())) { + le(CheckCompanyEntity::getEndTime, req.getEndTime()); + } + if (ObjectUtil.isNotEmpty(req.getStatus())) { + eq(CheckCompanyEntity::getStatus, req.getStatus()); + } + eq(StringUtils.isNotBlank(req.getAreaId()), BaseEntity::getCreateDept, req.getAreaId()); + apply(req.getYearMonth() != null, "date_format(start_time ,'%Y-%m') = '" + + req.getYearMonth() + "'" + "and date_format(end_time,'%Y-%m') = '" + req.getYearMonth() + "'"); + + }}; + IPage page = page(Condition.getPage(query), queryWrapper); + page.setRecords(CheckCompanyWrapper.build().listVO(page.getRecords())); + BladePage bladePage = BladePage.of(page); + return R.data(bladePage); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckMonthServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckMonthServiceImpl.java index 0b1a41b..e316f8a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckMonthServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/CheckMonthServiceImpl.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; 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.extension.plugins.pagination.Page; import com.hnac.hzims.safeproduct.dto.CheckMonthDTO; import com.hnac.hzims.safeproduct.entity.CheckItemEntity; import com.hnac.hzims.safeproduct.entity.CheckItemInstanceEntity; @@ -140,4 +141,17 @@ public class CheckMonthServiceImpl extends BaseServiceImpl> listconferenceScope(CheckMonthEntity req, Page objectPage) { + IPage page = checkMonthMapper.listconferenceScope(objectPage, req); + page.setRecords(CheckMonthWrapper.build().listVO(page.getRecords())); + return R.data(page); + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafeEquipmentTrialServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafeEquipmentTrialServiceImpl.java index b9ffebb..7c9f4a9 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafeEquipmentTrialServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafeEquipmentTrialServiceImpl.java @@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.hnac.hzims.safeproduct.dto.SafeEquipmentDTO; import com.hnac.hzims.safeproduct.dto.SafeEquipmentTrialDTO; import com.hnac.hzims.safeproduct.entity.SafeEquipmentTrialEntity; @@ -11,6 +12,7 @@ import com.hnac.hzims.safeproduct.vo.SafeEquipmentTrialVO; import com.hnac.hzims.safeproduct.wrapper.SafeEquipmentTrialWrapper; import lombok.RequiredArgsConstructor; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -26,83 +28,91 @@ import java.util.Optional; @RequiredArgsConstructor public class SafeEquipmentTrialServiceImpl extends BaseServiceImpl implements SafeEquipmentTrialService { - /** - * 分页查询 - * @param param - * @param query - * @return - */ - @Override - public R> pageCondition(SafeEquipmentTrialDTO param, Query query) { - QueryWrapper queryWrapper = new QueryWrapper() {{ - if(Optional.ofNullable(param.getCreateDept()).isPresent()){ - eq("create_dept",param.getCreateDept()); - } - if(Optional.ofNullable(param.getFileName()).isPresent()){ - like("file_name","%".concat(param.getFileName()).concat("%")); - } - if(Optional.ofNullable(param.getStartTime()).isPresent()){ - gt("create_time", param.getStartTime()); - } - if(Optional.ofNullable(param.getEndTime()).isPresent()){ - lt("create_time", param.getEndTime()); - } - orderByDesc("create_time"); - }}; - IPage pages = super.page(Condition.getPage(query), queryWrapper); - List list = SafeEquipmentTrialWrapper.build().listVO(pages.getRecords()); - return R.data(pages.setRecords(list)); - } + /** + * 分页查询 + * + * @param param + * @param query + * @return + */ + @Override + public R> pageCondition(SafeEquipmentTrialDTO param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper() {{ + if (Optional.ofNullable(param.getCreateDept()).isPresent()) { + eq("create_dept", param.getCreateDept()); + } + if (Optional.ofNullable(param.getFileName()).isPresent()) { + like("file_name", "%".concat(param.getFileName()).concat("%")); + } + if (Optional.ofNullable(param.getStartTime()).isPresent()) { + gt("create_time", param.getStartTime()); + } + if (Optional.ofNullable(param.getEndTime()).isPresent()) { + lt("create_time", param.getEndTime()); + } + lambda().eq(StringUtils.isNotBlank(param.getAreaId()), SafeEquipmentTrialEntity::getCreateDept, + param.getAreaId()); + eq(param.getYearMonth() != null, "date_format(CREATE_TIME,'%Y-%m)", param.getYearMonth()); + orderByDesc("create_time"); + }}; + IPage pages = super.page(Condition.getPage(query), queryWrapper); + List list = SafeEquipmentTrialWrapper.build().listVO(pages.getRecords()); + pages.setRecords(list); + BladePage bladePage = BladePage.of(pages); + return R.data(bladePage); + } - /** - * 获取设备试验次数 - * @param param - * @return - */ - @Override - public int getSafeEquipmentCount(SafeEquipmentTrialDTO param) { - if(ObjectUtil.isEmpty(param)){ - return 0; - } - QueryWrapper queryWrapper = new QueryWrapper() {{ - if(CollectionUtil.isEmpty(param.getDeptList())){ - if(Optional.ofNullable(param.getCreateDept()).isPresent()){ - eq("create_dept",param.getCreateDept()); - } - } else { - in("create_dept",param.getDeptList()); - } - if(Optional.ofNullable(param.getStartTime()).isPresent()){ - gt("create_time", param.getStartTime()); - } - if(Optional.ofNullable(param.getEndTime()).isPresent()){ - lt("create_time", param.getEndTime()); - } - }}; - return this.baseMapper.selectCount(queryWrapper); - } + /** + * 获取设备试验次数 + * + * @param param + * @return + */ + @Override + public int getSafeEquipmentCount(SafeEquipmentTrialDTO param) { + if (ObjectUtil.isEmpty(param)) { + return 0; + } + QueryWrapper queryWrapper = new QueryWrapper() {{ + if (CollectionUtil.isEmpty(param.getDeptList())) { + if (Optional.ofNullable(param.getCreateDept()).isPresent()) { + eq("create_dept", param.getCreateDept()); + } + } else { + in("create_dept", param.getDeptList()); + } + if (Optional.ofNullable(param.getStartTime()).isPresent()) { + gt("create_time", param.getStartTime()); + } + if (Optional.ofNullable(param.getEndTime()).isPresent()) { + lt("create_time", param.getEndTime()); + } + }}; + return this.baseMapper.selectCount(queryWrapper); + } - /** - * 查询设备列表 - * @param entity - * @return - */ - @Override - public List getList(SafeEquipmentDTO entity) { - QueryWrapper queryWrapper = new QueryWrapper() {{ - if(CollectionUtil.isEmpty(entity.getDeptList())){ - if(Optional.ofNullable(entity.getCreateDept()).isPresent()){ - eq("create_dept",entity.getCreateDept()); - } - } else { - in("create_dept",entity.getDeptList()); - } - if(Optional.ofNullable(entity.getTime()).isPresent()){ - gt("create_time", entity.getTime()); - lt("create_time", entity.getTime()); - } - }}; - return this.baseMapper.selectList(queryWrapper); - } + /** + * 查询设备列表 + * + * @param entity + * @return + */ + @Override + public List getList(SafeEquipmentDTO entity) { + QueryWrapper queryWrapper = new QueryWrapper() {{ + if (CollectionUtil.isEmpty(entity.getDeptList())) { + if (Optional.ofNullable(entity.getCreateDept()).isPresent()) { + eq("create_dept", entity.getCreateDept()); + } + } else { + in("create_dept", entity.getDeptList()); + } + if (Optional.ofNullable(entity.getTime()).isPresent()) { + gt("create_time", entity.getTime()); + lt("create_time", entity.getTime()); + } + }}; + return this.baseMapper.selectList(queryWrapper); + } }