diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyEmergencyEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyEmergencyEntity.java new file mode 100644 index 0000000..2cc9887 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyEmergencyEntity.java @@ -0,0 +1,85 @@ +package com.hnac.hzims.operational.duty.entity; + +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + + +/** + * 实体类 + * + * @author ty + */ +@Data +@TableName("hz_ims_duty_emergency") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "ImsDutyEmergency对象", description = "突发事件登记") +public class ImsDutyEmergencyEntity extends TenantEntity { + + private static final long serialVersionUID = 4259568798118459986L; + /** + * 值班日期 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @ApiModelProperty(value = "值班日期") + private Date dutyTime; + + /** + * 班次 + */ + @ApiModelProperty(value = "班次") + private Long dutyClass; + /** + * 登记人 + */ + @ApiModelProperty(value = "登记人") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long registrant; + /** + * 值班长 + */ + @ApiModelProperty(value = "值班长") + @JsonSerialize(nullsUsing = NullSerializer.class) + private Long chargePerson; + /** + * 登记时间 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @ApiModelProperty(value = "登记时间") + private Date registerTime; + /** + * 事件主题 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件主题") + private String eventTitle; + /** + * 事件内容 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件内容") + private String eventInfo; + + /** + * 事件方式 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件方式") + private String eventType; + + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainEntity.java index 8990c16..cd5f5ed 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainEntity.java @@ -22,17 +22,22 @@ import java.util.Date; @Data @TableName("hz_ims_duty_main") @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "ImsDutyMain对象", description = "值班信息") +@ApiModel(value = "ImsDutyMain对象", description = "值班-班组信息") public class ImsDutyMainEntity extends TenantEntity { private static final long serialVersionUID = -1913292438493450113L; - + /** + * 主键ID + */ + @ApiModelProperty(value = "排班计划id") + private Long id; /** * 值班组id */ @ApiModelProperty(value = "值班组id") private Long dutyGroupId; + /** * 值班人IDS, ID之间用^隔开 */ diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainPersonEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainPersonEntity.java new file mode 100644 index 0000000..c0d5a5d --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainPersonEntity.java @@ -0,0 +1,76 @@ +package com.hnac.hzims.operational.duty.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + + +/** + * 实体类 + * + * @author TY + */ +@Data +@TableName("hz_ims_duty_main_person") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "ImsDutyMainPerson对象", description = "值班-人员信息") +public class ImsDutyMainPersonEntity extends TenantEntity { + + private static final long serialVersionUID = -1913292438493450113L; + + /** + * 值班组id + */ + @ApiModelProperty(value = "值班组id") + private Long dutyGroupId; + + /** + * 值班人ID + */ + @ApiModelProperty(value = "值班人ID") + private Long dutyPerson; + /** + * 值班负责人ID + */ + @ApiModelProperty(value = "值班负责人ID") + private Long dutyChargePerson; + /** + * 值班日期 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATE) + @JsonFormat(pattern = DateUtil.PATTERN_DATE) + @ApiModelProperty(value = "值班日期") + private Date dutyDate; + + /** + * 班次ID + */ + @ApiModelProperty(value = "班次ID") + private Long classId; + /** + * 班次名称 + */ + @TableField(exist=false) + @ApiModelProperty(value = "班次名称") + private String className; + /** + * 值班-班组ID + */ + @ApiModelProperty(value = "值班-班组ID") + private Long dutyMainId; + /** + * 备注 + */ + @ApiModelProperty(value = "备注") + private String remark; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainTemplateEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainTemplateEntity.java index c8b5c02..eb0b18b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainTemplateEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/entity/ImsDutyMainTemplateEntity.java @@ -30,6 +30,9 @@ public class ImsDutyMainTemplateEntity extends TenantEntity { private Integer dutyNum; @ApiModelProperty("班次类型ID") private Long dutyClassTypeId; - + @ApiModelProperty("灵活排班人员IDs") + private String flexible; + @ApiModelProperty("排班类型")//1:班组,2:灵活排班 + private Integer type; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/FlexibleSchedulingVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/FlexibleSchedulingVo.java new file mode 100644 index 0000000..ed37a92 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/FlexibleSchedulingVo.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.operational.duty.vo; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class FlexibleSchedulingVo { + + + /** + * 值班组长ID + */ + @JsonSerialize(nullsUsing = NullSerializer.class) + @ApiModelProperty("值班组长ID") + private String chargeId; + + /** + * 人员IDs + */ + @JsonSerialize(nullsUsing = NullSerializer.class) + @ApiModelProperty("人员ID") + private List personIds; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyEmergencyVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyEmergencyVo.java new file mode 100644 index 0000000..bc4c837 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsDutyEmergencyVo.java @@ -0,0 +1,86 @@ +package com.hnac.hzims.operational.duty.vo; + +import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; +import java.util.List; + + +/** + * 实体类 + * + * @author ty + */ +@Data +public class ImsDutyEmergencyVo extends TenantEntity { + + private static final long serialVersionUID = 4259568798118459986L; + /** + * 值班开始日期 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @ApiModelProperty(value = "值班开始日期") + private Date dutyStartTime; + /** + * 值班结束日期 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @ApiModelProperty(value = "值班结束日期") + private Date dutyEndTime; + /** + * 班次 + */ + @ApiModelProperty(value = "班次") + private List dutyClass; + /** + * 登记人 + */ + @ApiModelProperty(value = "登记人") + @JsonSerialize(nullsUsing = NullSerializer.class) + private List registrant; + /** + * 值班长 + */ + @ApiModelProperty(value = "值班长") + @JsonSerialize(nullsUsing = NullSerializer.class) + private List chargePerson; + /** + * 登记时间 + */ + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) + @ApiModelProperty(value = "登记时间") + private Date registerTime; + /** + * 事件主题 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件主题") + private String eventTitle; + /** + * 事件内容 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件内容") + private String eventInfo; + + /** + * 事件方式 + */ + @QueryField(condition = SqlCondition.LIKE) + @ApiModelProperty(value = "事件方式") + private String eventType; + + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsSchedulingVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsSchedulingVo.java index 6bf0050..0a3a0fd 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsSchedulingVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/duty/vo/ImsSchedulingVo.java @@ -6,6 +6,7 @@ import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; import java.util.Map; @Data @@ -68,10 +69,15 @@ public class ImsSchedulingVo extends ImsDutyMainEntity { private String templateName; @ApiModelProperty("排班类型: 1、轮询 2 、周期") private Integer schedulingType; + @ApiModelProperty("人员类型: 1、班组 2 、人员") + private Integer personType; @ApiModelProperty("是否保存为模版,true 是,false 否") private Boolean template; @ApiModelProperty("班次类型ID") @JsonSerialize(nullsUsing = NullSerializer.class) private Long dutyClassTypeId; - + @ApiModelProperty("灵活人员排班-轮询") + private Map> rosters; + @ApiModelProperty("灵活人员排班-周期") + private Map> flexible; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyChangeController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyChangeController.java index 3493ce0..52bb3fe 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyChangeController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyChangeController.java @@ -50,9 +50,9 @@ public class ImsDutyChangeController extends BladeController { ImsDutyChangeEntity detail = imsDutyService.getOne(Condition.getQueryWrapper(changeEntity)); ImsDutyChangeVO vo = ImsDutyChangeWrapper.build().entityVO(detail); imsDutyService.setUserNmae(vo); - ImsSchedulingVo imsSchedulingVo1 = imsDutyMainService.getByIdOne(detail.getAcceptDutyId()); + ImsSchedulingVo imsSchedulingVo1 = imsDutyMainService.getByIdOneV2(detail.getAcceptDutyId()); vo.setAcceptDutyMainVo(imsSchedulingVo1 == null ? null : imsSchedulingVo1); - ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOne(detail.getApplyDutyId()); + ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOneV2(detail.getApplyDutyId()); vo.setApplyDutyMainVo(imsSchedulingVo == null ? null : imsSchedulingVo); return R.data(vo); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java index 3e0ded7..378e287 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyMainController.java @@ -87,7 +87,7 @@ public class ImsDutyMainController extends BladeController { @ApiOperationSupport(order = 7) @ApiOperation(value = "逻辑删除", notes = "传入ids") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { - return imsDutyMainService.delete(Func.toLongList(ids)); + return imsDutyMainService.deleteV2(Func.toLongList(ids)); } /** @@ -100,7 +100,7 @@ public class ImsDutyMainController extends BladeController { if (null == imsSchedulingVo.getCreateDept()) { imsSchedulingVo.setCreateDept(Long.valueOf(AuthUtil.getDeptId())); } - return imsDutyMainService.getScheduling(imsSchedulingVo); + return imsDutyMainService.getSchedulingV2(imsSchedulingVo); } /** @@ -115,7 +115,7 @@ public class ImsDutyMainController extends BladeController { if (null == deptId) { deptId = Long.valueOf(AuthUtil.getDeptId()); } - return imsDutyMainService.getSchedulingList(year, month, deptId); + return imsDutyMainService.getSchedulingListV2(year, month, deptId); } /** @@ -125,7 +125,7 @@ public class ImsDutyMainController extends BladeController { @ApiOperationSupport(order = 9) @ApiOperation(value = "根据值班id查询人员", notes = "传id") public R person(@ApiParam(value = "值班Id", required = true) @RequestParam Long id) { - return imsDutyMainService.getMainIdByPerson(id); + return imsDutyMainService.getMainIdByPersonV2(id); } /** @@ -146,10 +146,19 @@ public class ImsDutyMainController extends BladeController { */ @GetMapping("/getHomePageDutyInfo") @ApiOperationSupport(order = 9) - @ApiOperation(value = "获取首页值班数据", notes = "") + @ApiOperation(value = "获取首页值班数据", notes = "传id") public R> getHomePageDutyInfo(Long deptId) { return R.data(imsDutyMainService.getHomePageDutyInfo(deptId)); } + /** + * 返回对应部门所有人员 + */ + @GetMapping("/getAllPersonInfo") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "返回对应部门所有人员", notes = "") + public R getAllPersonInfo(Long deptId) { + return R.data(imsDutyMainService.getAllPersonInfo(deptId)); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java index 6a2ab86..8fb4054 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/controller/ImsDutyRecController.java @@ -2,9 +2,12 @@ package com.hnac.hzims.operational.duty.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; import com.hnac.hzims.operational.duty.entity.ImsDutyRecEntity; +import com.hnac.hzims.operational.duty.service.IImsDutyEmergencyService; import com.hnac.hzims.operational.duty.service.IImsDutyRecService; +import com.hnac.hzims.operational.duty.vo.ImsDutyEmergencyVo; import com.hnac.hzims.operational.duty.vo.ImsDutyRecVO; import com.hnac.hzinfo.inspect.plan.vo.PlanVO; import io.swagger.annotations.Api; @@ -21,11 +24,12 @@ import org.springblade.core.tool.utils.Func; import org.springblade.flow.core.entity.BladeFlow; import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; import javax.validation.Valid; /** - * 控制器 + * 控制器 * * @author Chill */ @@ -36,6 +40,8 @@ import javax.validation.Valid; public class ImsDutyRecController extends BladeController { private final IImsDutyRecService imsDutyRecService; + @Resource + private IImsDutyEmergencyService iImsDutyEmergencyService; /** * 详情 @@ -94,9 +100,6 @@ public class ImsDutyRecController extends BladeController { } - - - /** * 删除 代码自定义代号 */ @@ -214,10 +217,34 @@ public class ImsDutyRecController extends BladeController { } - - - - + /** + * 新增:突发事件记录 + */ + @PostMapping("/addEmergency") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增突发事件", notes = "传入imsDutyEmergencyEntity") + public R addEmergency(@Valid @RequestBody ImsDutyEmergencyEntity imsDutyEmergencyEntity) { + return iImsDutyEmergencyService.saveEntity(imsDutyEmergencyEntity); + } + /** + * 删除:突发事件记录 + */ + @PostMapping("/deleteEmergency") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "删除突发事件记录", notes = "传入imsDutyEmergencyEntity") + public R deleteEmergency( @RequestBody ImsDutyEmergencyEntity imsDutyEmergencyEntity) { + //TODO 是否要加权限控制 + return iImsDutyEmergencyService.deleteEntity(imsDutyEmergencyEntity); + } + /** + * 查询:突发事件记录 + */ + @PostMapping("/queryEmergency") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "查询突发事件记录", notes = "传入imsDutyEmergencyEntity") + public R queryEmergency(@RequestBody ImsDutyEmergencyVo imsDutyEmergencyVo,Query query) { + return iImsDutyEmergencyService.queryEntity(imsDutyEmergencyVo,query); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.java new file mode 100644 index 0000000..ca3d905 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.duty.mapper; + +import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + + +/** + * Mapper 接口 + * + * @author Chill + */ +public interface ImsDutyEmergencyMapper extends UserDataScopeBaseMapper { + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.xml new file mode 100644 index 0000000..2c9cee9 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyEmergencyMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.java index 64fd012..f799afa 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.java @@ -29,6 +29,8 @@ public interface ImsDutyGroupPMapper extends BaseMapper { */ List selectByGroupId(Long groupId); + List selectByGroupIds(List groupId); + void deleteBatch(List list); void insertBatchPersonnel(List list); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml index 893e49d..06765c9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyGroupPMapper.xml @@ -29,6 +29,15 @@ from hz_ims_duty_group_p where group_id = #{groupId,jdbcType=BIGINT} + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java index 93cdf08..c1878e1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.java @@ -34,6 +34,7 @@ public interface ImsDutyMainMapper extends UserDataScopeBaseMapper selectDutyMainByDept(List list); + List selectDutyMainByDeptV2(List list); List selectSchedulingVoByDateList(@Param("startDate") String startDate, @Param("endDate") String endDate); @UserDataAuth List selectDutyMainInfoVo(@Param("deptId") Long deptId); + @UserDataAuth + List selectDutyMainInfoVoV2(@Param("deptId") Long deptId); DutyMainInfoVo selectDutyMainInfoSign(Long preDutyId); + DutyMainInfoVo selectDutyMainInfoSignV2(Long preDutyId); DutyMainInfoVo queryDutyInfo(Long dutyId); + DutyMainInfoVo queryDutyInfoV2(Long dutyId); List getDutyData(@Param("list") List deptIdList); + List getDutyDataV2(@Param("list") List deptIdList); + + List selectByDateListV2(@Param(value = "date")String date,@Param(value = "deptId") Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml index c8a9c38..33fd80b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainMapper.xml @@ -76,6 +76,33 @@ ORDER BY DM.ID + - + + + + - + + - + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.java new file mode 100644 index 0000000..af9a298 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.operational.duty.mapper; + +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + + +/** + * Mapper 接口 + * + * @author ty + */ +public interface ImsDutyMainPersonMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml new file mode 100644 index 0000000..a544f90 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainPersonMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + ID + , TENANT_ID, DUTY_PERSON_IDS, DUTY_DATE, CLASS_ID, STATUS, + REMARK,CREATE_TIME, UPDATE_TIME, CREATE_USER, UPDATE_USER, IS_DELETED,CREATE_DEPT + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainTemplateMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainTemplateMapper.xml index c6cbab2..c94d688 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainTemplateMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/mapper/ImsDutyMainTemplateMapper.xml @@ -1,27 +1,30 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - ID, TENANT_ID, TEMPLATE_NAME, DUTY_ORDER_IDS , DUTY_ARR_IDS, DUTY_CLASS_TYPE_ID, - DUTY_NUM, STATUS, CREATE_TIME, UPDATE_TIME, CREATE_USER, UPDATE_USER, IS_DELETED, + + ID + , TENANT_ID, TEMPLATE_NAME, DUTY_ORDER_IDS , DUTY_ARR_IDS, DUTY_CLASS_TYPE_ID, + DUTY_NUM, STATUS, FLEXIBLE,TYPE,CREATE_TIME, UPDATE_TIME, CREATE_USER, UPDATE_USER, IS_DELETED, CREATE_DEPT - + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/ThreadTask.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/ThreadTask.java index f29a06b..797f7db 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/ThreadTask.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/scheduled/ThreadTask.java @@ -3,6 +3,8 @@ package com.hnac.hzims.operational.duty.scheduled; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.monitor.utils.DateUtils; import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import com.hnac.hzims.operational.duty.service.IImsDutyMainPersonService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenancePlanService; import lombok.extern.slf4j.Slf4j; @@ -21,6 +23,8 @@ public class ThreadTask { @Autowired private IImsDutyMainService iImsDutyMainService; + @Autowired + private IImsDutyMainPersonService iImsDutyMainPersonService; @Autowired private IOperMaintenancePlanService operMaintenancePlanService; @@ -42,7 +46,21 @@ public class ThreadTask { log.error(e.getMessage(), e.toString()); } } - + public static void dutyTask(List list, List personEntityList, String date, String proDutyMainId, Long dept, Long classTypeId) { + try { + Runnable runnable = new Runnable() { + @Override + public void run() { + //异步任务 + saveBaschTask(list,personEntityList,date,proDutyMainId,dept,classTypeId); + } + }; + Thread thread = new Thread(runnable); + thread.start(); + } catch (Exception e) { + log.error(e.getMessage(), e.toString()); + } + } // 声明对象 public static ThreadTask threadTask; @@ -60,7 +78,19 @@ public class ThreadTask { */ private static void saveBaschTask(List list,String date,String proDutyMainId,Long dept,Long classTypeId) { threadTask.iImsDutyMainService.doSaveBasch(list); + ImsDutyMainEntity entity = new ImsDutyMainEntity(); + entity.setPreDutyId(Long.valueOf(proDutyMainId)); + String subDate = DateUtils.dayStringDate(date, 1, true); + + threadTask.iImsDutyMainService.update(entity, new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getDutyDate, subDate).eq(ImsDutyMainEntity::getCreateDept, dept).orderByAsc(ImsDutyMainEntity::getId).last(" LIMIT 1"); + }}); + threadTask.operMaintenancePlanService.compensateClassTypeTask(classTypeId.toString()); + } + private static void saveBaschTask(List list,List personEntityList,String date,String proDutyMainId,Long dept,Long classTypeId) { + threadTask.iImsDutyMainService.doSaveBasch(list); + threadTask.iImsDutyMainPersonService.doSaveBasch(personEntityList); ImsDutyMainEntity entity = new ImsDutyMainEntity(); entity.setPreDutyId(Long.valueOf(proDutyMainId)); String subDate = DateUtils.dayStringDate(date, 1, true); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyEmergencyService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyEmergencyService.java new file mode 100644 index 0000000..36709ef --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyEmergencyService.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.operational.duty.service; + +import com.hnac.hzims.operational.duty.entity.ImsDutyEmergencyEntity; +import com.hnac.hzims.operational.duty.vo.ImsDutyEmergencyVo; +import org.springblade.core.mp.base.BaseService; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; + + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsDutyEmergencyService extends BaseService { + + + R saveEntity(ImsDutyEmergencyEntity imsDutyEmergencyEntity); + + R deleteEntity(ImsDutyEmergencyEntity imsDutyEmergencyEntity); + + R queryEntity(ImsDutyEmergencyVo imsDutyEmergencyVo, Query query); +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyGroupPService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyGroupPService.java index b01d6f4..ce80e95 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyGroupPService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyGroupPService.java @@ -24,7 +24,7 @@ public interface IImsDutyGroupPService extends IService { * @return */ List selectByGroupId(Long groupId); - + List selectByGroupIds(List groupId); /** * 批量删除 * @param ids diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java new file mode 100644 index 0000000..8082f09 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainPersonService.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.operational.duty.service; + +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import org.springblade.core.mp.base.BaseService; +import java.util.List; + + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsDutyMainPersonService extends BaseService { + + void doSaveBasch(List list); + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java index af3c632..f83dd44 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyMainService.java @@ -34,6 +34,7 @@ public interface IImsDutyMainService extends BaseService { * @return */ R delete(List ids); + R deleteV2(List ids); /** @@ -45,6 +46,8 @@ public interface IImsDutyMainService extends BaseService { R getByDateListAll(String dutyDate, Long personId); ImsSchedulingVo getByIdOne(Long id); + ImsSchedulingVo getByIdOneV2(Long id); + ImsSchedulingVo getByIdOneV2(Long id, Long preDutyId); ImsDutyMainEntity getMainEntity(Long id); @@ -55,12 +58,16 @@ public interface IImsDutyMainService extends BaseService { */ R getScheduling(ImsSchedulingVo imsSchedulingVo); + R getSchedulingV2(ImsSchedulingVo imsSchedulingVo); R getSchedulingList(int year, int month, Long deptId); + R getSchedulingListV2(int year, int month, Long deptId); R getMainIdByPerson(Long id); + R getMainIdByPersonV2(Long id); + ImsSchedulingVo getTheManinGroup(); /** @@ -82,6 +89,8 @@ public interface IImsDutyMainService extends BaseService { List getDutyMainByDept(List list); + List getDutyMainByDeptV2(List list); + void doSaveBasch(List list); @@ -118,12 +127,14 @@ public interface IImsDutyMainService extends BaseService { * 获取当班 */ List getDutyData(Long deptId); + List getDutyDataV2(Long deptId); /** * 获取当班 */ DutyMainInfoVo getNextDutyData(Long parentId); + DutyMainInfoVo getNextDutyDataV2(Long parentId); /** * 获取区域值班 @@ -131,4 +142,6 @@ public interface IImsDutyMainService extends BaseService { * @return */ List getDutyData(List deptIdList); + + R getAllPersonInfo(Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java index 0459755..d47481f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/IImsDutyRecService.java @@ -53,6 +53,7 @@ public interface IImsDutyRecService extends BaseService { IPage getRecVoPage(IPage page, ImsDutyRecVO vo); R getTheManinGroupRec(Long deptId); +// R getTheManinGroupRecV2(Long deptId); /** * 获取签到二维码 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyChangeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyChangeServiceImpl.java index 9087ae5..0708d25 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyChangeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyChangeServiceImpl.java @@ -124,9 +124,9 @@ public class ImsDutyChangeServiceImpl extends BaseServiceImpl implements IImsDutyEmergencyService { + @Resource + private ImsDutyMainMapper imsDutyMainMapper; + + @Override + public R saveEntity(ImsDutyEmergencyEntity imsDutyEmergencyEntity) { + ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); + eq(ImsDutyMainEntity::getCreateDept, imsDutyEmergencyEntity.getCreateDept()); + like(ImsDutyMainEntity::getDutyPersonIds, AuthUtil.getUserId()).last(" limit 1"); + }}); + if (ObjectUtil.isEmpty(entity)) { + return R.success("您当前未值班"); + } + this.saveOrUpdate(imsDutyEmergencyEntity); + return R.success("保存成功"); + } + + @Override + public R deleteEntity(ImsDutyEmergencyEntity imsDutyEmergencyEntity) { + this.removeById(imsDutyEmergencyEntity.getId()); + return R.success("删除成功"); + } + + @Override + public R queryEntity(ImsDutyEmergencyVo imsDutyEmergencyVo, Query query) { + QueryWrapper queryWrapper = getQueryWrapper(imsDutyEmergencyVo); + IPage imsDutyEmergencyEntityIPage = baseMapper.selectPage(Condition.getPage(query), queryWrapper); + return R.data(imsDutyEmergencyEntityIPage); + } + + private QueryWrapper getQueryWrapper(ImsDutyEmergencyVo imsDutyEmergencyVo) { + QueryWrapper queryWrapper = new QueryWrapper(); + if (ObjectUtils.isNotEmpty(imsDutyEmergencyVo.getId())) { + queryWrapper.lambda().in(ImsDutyEmergencyEntity::getId, imsDutyEmergencyVo.getId()); + } + if (ObjectUtils.isNotEmpty(imsDutyEmergencyVo.getDutyStartTime())) { + queryWrapper.lambda().ge(ImsDutyEmergencyEntity::getDutyTime, imsDutyEmergencyVo.getDutyStartTime()); + } + if (ObjectUtils.isNotEmpty(imsDutyEmergencyVo.getDutyEndTime())) { + queryWrapper.lambda().le(ImsDutyEmergencyEntity::getDutyTime, imsDutyEmergencyVo.getDutyEndTime()); + } + if (CollectionUtils.isNotEmpty(imsDutyEmergencyVo.getDutyClass())) { + queryWrapper.lambda().in(ImsDutyEmergencyEntity::getDutyClass, imsDutyEmergencyVo.getDutyClass()); + } + if (CollectionUtils.isNotEmpty(imsDutyEmergencyVo.getChargePerson())) { + queryWrapper.lambda().in(ImsDutyEmergencyEntity::getChargePerson, imsDutyEmergencyVo.getChargePerson()); + } + if (CollectionUtils.isNotEmpty(imsDutyEmergencyVo.getRegistrant())) { + queryWrapper.lambda().in(ImsDutyEmergencyEntity::getRegistrant, imsDutyEmergencyVo.getRegistrant()); + } + if (CollectionUtils.isNotEmpty(imsDutyEmergencyVo.getRegistrant())) { + queryWrapper.lambda().in(ImsDutyEmergencyEntity::getRegistrant, imsDutyEmergencyVo.getRegistrant()); + } + if (StringUtils.isNotEmpty(imsDutyEmergencyVo.getEventTitle())) { + queryWrapper.lambda().like(ImsDutyEmergencyEntity::getEventTitle, imsDutyEmergencyVo.getEventTitle()); + } + if (StringUtils.isNotEmpty(imsDutyEmergencyVo.getEventInfo())) { + queryWrapper.lambda().like(ImsDutyEmergencyEntity::getEventInfo, imsDutyEmergencyVo.getEventInfo()); + } + if (StringUtils.isNotEmpty(imsDutyEmergencyVo.getEventType())) { + queryWrapper.lambda().like(ImsDutyEmergencyEntity::getEventType, imsDutyEmergencyVo.getEventType()); + } + return queryWrapper; + } + + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupPServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupPServiceImpl.java index d44b045..89c46dc 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupPServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyGroupPServiceImpl.java @@ -36,7 +36,10 @@ public class ImsDutyGroupPServiceImpl extends ServiceImpl selectByGroupId(Long groupId) { return this.baseMapper.selectByGroupId(groupId); } - + @Override + public List selectByGroupIds(List groupId) { + return this.baseMapper.selectByGroupIds(groupId); + } @Override public void deleteBatch(List ids) { this.baseMapper.deleteBatch(ids); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java new file mode 100644 index 0000000..4456fb9 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainPersonServiceImpl.java @@ -0,0 +1,74 @@ +package com.hnac.hzims.operational.duty.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.hnac.hzims.monitor.utils.DateUtils; +import com.hnac.hzims.operational.defect.constants.DefectConstant; +import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; +import com.hnac.hzims.operational.duty.entity.*; +import com.hnac.hzims.operational.duty.enume.DutyRecStatus; +import com.hnac.hzims.operational.duty.enume.JoinStatus; +import com.hnac.hzims.operational.duty.mapper.*; +import com.hnac.hzims.operational.duty.scheduled.ThreadTask; +import com.hnac.hzims.operational.duty.service.IImsDutyGroupPService; +import com.hnac.hzims.operational.duty.service.IImsDutyMainPersonService; +import com.hnac.hzims.operational.duty.service.IImsDutyMainService; +import com.hnac.hzims.operational.duty.service.IImsDutyMainTemplateService; +import com.hnac.hzims.operational.duty.vo.*; +import com.hnac.hzims.operational.main.vo.DutyPersonalReportVO; +import com.hnac.hzims.operational.report.vo.DutyReportVO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.AuthUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.*; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Time; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 服务实现类 + * + * @author Chill + */ +@Service +@Slf4j +public class ImsDutyMainPersonServiceImpl extends BaseServiceImpl implements IImsDutyMainPersonService { + @Autowired + private ImsDutyGroupPMapper imsDutyGroupPMapper; + @Autowired + private IImsDutyMainTemplateService iImsDutyMainTemplateService; + @Autowired + private ImsDutyGroupMapper dutyGroupMapper; + @Autowired + private OperPhenomenonMapper operPhenomenonMapper; + @Autowired + private ImsDutyRecMapper imsDutyRecMapper; + @Autowired + private IImsDutyGroupPService imsDutyGroupPService; + @Autowired + private DutyGroupGeneratingCapacityMapper groupGeneratingCapacityMapper; + + + @Override + public void doSaveBasch(List list) { + this.saveBatch(list); + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java index bf26530..3b79884 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainServiceImpl.java @@ -15,6 +15,7 @@ import com.hnac.hzims.operational.duty.enume.JoinStatus; import com.hnac.hzims.operational.duty.mapper.*; import com.hnac.hzims.operational.duty.scheduled.ThreadTask; import com.hnac.hzims.operational.duty.service.IImsDutyGroupPService; +import com.hnac.hzims.operational.duty.service.IImsDutyMainPersonService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.service.IImsDutyMainTemplateService; import com.hnac.hzims.operational.duty.vo.*; @@ -28,8 +29,11 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import java.sql.Time; import java.text.DateFormat; @@ -58,11 +62,18 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl ids) { + if (ids.size() == 0) { + return R.fail("ids不能为空"); + } + //状态为待值班的才可以删除 + for (int i = 0; i < ids.size(); i++) { + ImsDutyMainEntity imsDutyMainEntity = this.getById(ids.get(i)); + if (imsDutyMainEntity.getStatus() != JoinStatus.DUTY_WAIT.getStatus()) { + return R.fail("状态为待值班的才可以删除"); + } + } + List personEntityList = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper() {{ + in(ImsDutyMainPersonEntity::getDutyMainId, ids); + }}); + List collect = personEntityList.stream().map(s -> s.getId()).collect(Collectors.toList()); + return R.status(this.deleteLogic(ids) && iImsDutyMainPersonService.deleteLogic(collect)); + } + + @Override public R getByDateListAll(String dutyDate, Long personId) { return R.data(this.baseMapper.selectByDateListAll(dutyDate, personId)); } @@ -121,6 +152,42 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, id); + }}); + imsSchedulingVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsSchedulingVo.getGroupId()); + imsSchedulingVo.setGroupName(imsDutyGroupEntity.getGroupName()); + imsSchedulingVo.setGroupId(imsDutyGroupEntity.getId()); + imsSchedulingVo.setManagerId(imsDutyGroupEntity.getManagerId()); + } + return imsSchedulingVo; + } + + @Override + public ImsSchedulingVo getByIdOneV2(Long id, Long preDutyId) { + ImsSchedulingVo imsSchedulingVo = this.baseMapper.selectByIdOneV2(id, preDutyId); + if (null == imsSchedulingVo.getGroupId()) { + imsSchedulingVo.setGroupName("临时班组"); + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, id); + }}); + imsSchedulingVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsSchedulingVo.getGroupId()); + imsSchedulingVo.setGroupName(imsDutyGroupEntity.getGroupName()); + imsSchedulingVo.setGroupId(imsDutyGroupEntity.getId()); + imsSchedulingVo.setManagerId(imsDutyGroupEntity.getManagerId()); + } + return imsSchedulingVo; + } + + @Override public ImsDutyMainEntity getMainEntity(Long id) { return this.baseMapper.selectMainByIdOne(id); } @@ -133,6 +200,8 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl imsDutyMainEntities = this.baseMapper.selectByDateAndDept(minusOnedDay, imsSchedulingVo.getCreateDept()); + if (CollectionUtil.isEmpty(imsDutyMainEntities)) { + return R.fail("所选日期之前存在未排班情况,请重新选择日期区间!"); + } + } + List dates = getTwoPeriodsAll(Integer.valueOf(start[0]), Integer.valueOf(start[1]), Integer.valueOf(start[2]), Integer.valueOf(end[0]), Integer.valueOf(end[1]), Integer.valueOf(end[2])); + if (Integer.valueOf(start[0]) < year) { + return R.fail("年份必须大于或等于当前年份!"); + } + if (Integer.valueOf(start[0]) == year && Integer.valueOf(start[1]) < month) { + return R.fail("时间必须大于或等于当前时间"); + } + List imsDutyMainEntities2 = this.baseMapper.selectList(new LambdaQueryWrapper() {{ + ge(ImsDutyMainEntity::getDutyDate, imsSchedulingVo.getStartDate()); + le(ImsDutyMainEntity::getDutyDate, imsSchedulingVo.getEndDate()); + eq(ImsDutyMainEntity::getCreateDept, imsSchedulingVo.getCreateDept()); + }}); + List imsDutyMainPersonEntities = imsDutyMainPersonMapper.selectList(new LambdaQueryWrapper() {{ + ge(ImsDutyMainPersonEntity::getDutyDate, imsSchedulingVo.getStartDate()); + le(ImsDutyMainPersonEntity::getDutyDate, imsSchedulingVo.getEndDate()); + eq(ImsDutyMainPersonEntity::getCreateDept, imsSchedulingVo.getCreateDept()); + }}); + if (CollectionUtil.isNotEmpty(imsDutyMainPersonEntities) || CollectionUtil.isNotEmpty(imsDutyMainEntities2)) { + if (imsSchedulingVo.isCompose() == false) { + //如果有排班记录且无需排序,则返回 + return R.data(1); + } else { + if (CollectionUtil.isNotEmpty(dates)) { + //重新修改已有的排版,先删除,在添加 + this.baseMapper.delete(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getCreateDept, imsSchedulingVo.getCreateDept()); + in(ImsDutyMainEntity::getDutyDate, dates); + }}); + imsDutyMainPersonMapper.delete(new LambdaQueryWrapper() {{ + in(ImsDutyMainPersonEntity::getDutyDate, dates); + eq(ImsDutyMainPersonEntity::getCreateDept, imsSchedulingVo.getCreateDept()); + }}); + } + } + } + String subDayDate = DateUtils.dayDate(DateUtil.parse(imsSchedulingVo.getStartDate(), DateUtil.PATTERN_DATE), -1, DateUtil.PATTERN_DATE); + ImsDutyMainEntity imsDutyMainEntity1 = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainEntity::getDutyDate, subDayDate); + eq(ImsDutyMainEntity::getCreateDept, imsSchedulingVo.getCreateDept()); + ne(ImsDutyMainEntity::getStatus, "-1"); + orderByDesc(ImsDutyMainEntity::getId).last("LIMIT 1"); + }}); + if (null == imsSchedulingVo.getSchedulingType()) { + imsSchedulingVo.setSchedulingType(1); + } + //符合条件后根据周期、轮询排班方式保存 + if (1 == imsSchedulingVo.getSchedulingType()) { + return pollSchedulingV2(imsSchedulingVo, dates, imsDutyMainEntity1); + } + return cycleSchedulingTowV2(imsSchedulingVo, dates, imsDutyMainEntity1); + } + + /** + * 轮询排班 + * + * @param imsSchedulingVo + * @param dates + * @param imsDutyMainEntity1 + * @return + */ + private R pollSchedulingV2(ImsSchedulingVo imsSchedulingVo, List dates, ImsDutyMainEntity imsDutyMainEntity1) { + String[] groupIdsSplit; + int dutyNum; + //轮询排班分为:班组还是灵活;如果是2.灵活人员排班,则不需要查数据库,直接存对应信息 + if (2 == imsSchedulingVo.getPersonType()) { + Map> rosters = imsSchedulingVo.getRosters(); + groupIdsSplit = rosters.keySet().toArray(new String[0]); + dutyNum = groupIdsSplit.length; + } else { + groupIdsSplit = imsSchedulingVo.getGroupIds().split("\\^"); + String[] groupNamesSplit = imsSchedulingVo.getGroupNames().split("\\^"); + dutyNum = groupNamesSplit.length; + } + String[] classIdsSplit = imsSchedulingVo.getClassIds().split("\\^"); + String[] classNamesSplit = imsSchedulingVo.getClassNames().split("\\^"); + int classNum = classNamesSplit.length; + int allClass = 0; + List imsDutyMainEntityList = new ArrayList<>(); + List imsDutyMainPersonEntityList = new ArrayList<>(); + String proDutyMainId = ""; + for (int i = 1; i <= dates.size(); i++) { + String date = dates.get(i - 1); + for (int j = 1; j <= classNum; j++) { + //总排班数加1 + allClass++; + int temp, tempSub = 0; + temp = allClass % dutyNum; + //班组下标,确定取哪个班组 + tempSub = temp - 1; + //如果整除,取最后一个班组 + if (temp == 0) { + tempSub = dutyNum - 1; + } + ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); + imsDutyMainEntity.setClassId(Long.valueOf(classIdsSplit[j - 1])); + imsDutyMainEntity.setClassName(classNamesSplit[j - 1]); + imsDutyMainEntity.setDutyDate(DateUtil.parse(date, DateUtil.PATTERN_DATE)); + imsDutyMainEntity.setStatus(0); + imsDutyMainEntity.setCreateTime(new Date()); + if (Func.isBlank(proDutyMainId)) { + if (ObjectUtil.isNotEmpty(imsDutyMainEntity1)) { + proDutyMainId = imsDutyMainEntity1.getId().toString(); + } + imsDutyMainEntity.setPreDutyId(Long.valueOf(proDutyMainId)); + } + imsDutyMainEntity.setCreateDept(imsSchedulingVo.getCreateDept()); + List collect; + Long managerId; + if (2 == imsSchedulingVo.getPersonType()) { + List idList = imsSchedulingVo.getRosters().get(groupIdsSplit[tempSub]); + collect = idList.stream().map(s -> Long.valueOf(s)).collect(Collectors.toList()); + managerId = Long.valueOf(groupIdsSplit[tempSub]); + } else { + String groupId = groupIdsSplit[tempSub]; + imsDutyMainEntity.setDutyGroupId(Long.valueOf(groupIdsSplit[tempSub])); + //查询预备排班的班组人员,为空,则失败 + List longList = Arrays.asList(imsSchedulingVo.getGroupIds().split("\\^")) + .parallelStream() + .map(a -> Long.parseLong(a.trim())) + .collect(Collectors.toList()); + List list = imsDutyGroupPService.selectByGroupIds(longList); + collect = list.stream().filter(iter -> iter.getGroupId().toString().equals(groupId)).map(iter -> + iter.getPersonId()).collect(Collectors.toList()); + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(groupId); + if (ObjectUtil.isNotEmpty(imsDutyGroupEntity) && ObjectUtil.isNotEmpty(imsDutyGroupEntity.getManagerId())) { + managerId = imsDutyGroupEntity.getManagerId(); + } else { + return R.fail("该班组没有值班组组长"); + } + } + String ids = StringUtils.join(collect, "^"); + imsDutyMainEntity.setDutyPersonIds(ids); + Long id = IdWorker.getId(); + imsDutyMainEntity.setId(id); + imsDutyMainEntity.setCreateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setUpdateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setTenantId(AuthUtil.getTenantId()); + if (ObjectUtil.isNotEmpty(imsDutyMainEntity1)) { + proDutyMainId = imsDutyMainEntity1.getId().toString(); + } + imsDutyMainEntity.setPreDutyId(Long.valueOf(proDutyMainId)); + imsDutyMainEntityList.add(imsDutyMainEntity); + proDutyMainId = id == null ? "" : imsDutyMainEntity.getId() + ""; + //值班人员表同步保存一份 + copyPersonByDutyMain(imsSchedulingVo, managerId, imsDutyMainPersonEntityList, imsDutyMainEntity, collect); + } + } + ThreadTask.dutyTask(imsDutyMainEntityList, imsDutyMainPersonEntityList, imsSchedulingVo.getEndDate(), proDutyMainId, imsSchedulingVo.getCreateDept(), imsSchedulingVo.getDutyClassTypeId()); + return R.success("操作成功,系统正在排班中,请稍后查看"); + } + + private static void copyPersonByDutyMain(ImsSchedulingVo imsSchedulingVo, Long managerId, List imsDutyMainPersonEntityList, ImsDutyMainEntity imsDutyMainEntity, List collect) { + //每个人员对应一条排班-人员计划 + for (Long personId : collect) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = new ImsDutyMainPersonEntity(); + imsDutyMainPersonEntity.setClassId(imsDutyMainEntity.getClassId()); + imsDutyMainPersonEntity.setCreateDept(imsDutyMainEntity.getCreateDept()); + imsDutyMainPersonEntity.setClassName(imsDutyMainEntity.getClassName()); + imsDutyMainPersonEntity.setDutyDate(imsDutyMainEntity.getDutyDate()); + imsDutyMainPersonEntity.setStatus(imsDutyMainEntity.getStatus()); + imsDutyMainPersonEntity.setCreateTime(imsDutyMainEntity.getCreateTime()); + imsDutyMainPersonEntity.setDutyMainId(imsDutyMainEntity.getId()); + imsDutyMainPersonEntity.setCreateUser(imsDutyMainEntity.getCreateUser()); + imsDutyMainPersonEntity.setUpdateUser(imsDutyMainEntity.getUpdateUser()); + imsDutyMainPersonEntity.setTenantId(imsDutyMainEntity.getTenantId()); + imsDutyMainPersonEntity.setDutyPerson(personId); + long id1 = IdWorker.getId(imsDutyMainPersonEntity); + imsDutyMainPersonEntity.setId(id1); + if (2 == imsSchedulingVo.getPersonType()) { + imsDutyMainPersonEntity.setDutyChargePerson(imsSchedulingVo.getManagerId()); + } else { + imsDutyMainPersonEntity.setDutyChargePerson(managerId); + } + imsDutyMainPersonEntityList.add(imsDutyMainPersonEntity); + } + } + + /** + * 周期排班 + * + * @param imsSchedulingVo + * @param dates + * @param imsDutyMainEntity1 + * @return + */ + private R cycleSchedulingTowV2(ImsSchedulingVo imsSchedulingVo, List dates, ImsDutyMainEntity imsDutyMainEntity1) { + if (imsSchedulingVo.getTemplate()) { + if (!doSaveTemplate(imsSchedulingVo)) { + return R.fail("模版名称已存在"); + } + } + List imsDutyMainEntityList = new ArrayList<>(); + List personEntityList = new ArrayList<>(); + String proDutyMainId = ""; + String[] dutyArrIds = imsSchedulingVo.getDutyArrIds(); + for (int i = 1; i <= dates.size(); i++) { + String date = dates.get(i - 1); + for (int j = 1; j <= dutyArrIds.length; j++) { + String classId = dutyArrIds[j - 1]; + //按值班周期的天数取模 + int temp = i % imsSchedulingVo.getDutyNum(); + //值班下标 + int tempSub = temp - 1; + //如果整除,取最后一个值班 + if (temp == 0) { + tempSub = imsSchedulingVo.getDutyNum() - 1; + } + String groupId; + String[] split; + if (imsSchedulingVo.getPersonType() == 1) { + //获取对应班组的值班班次 + groupId = imsSchedulingVo.getDutyOrderIds().get(classId)[tempSub]; + }else { + //灵活排班,无实际作用,只是为了groupId能够初始化 + groupId =""; + } + //人员IDS + String personIds = ""; + if ("0".equals(classId)) { + //班组排班比灵活排班,多保存一部分没有排到班的信息 + if (imsSchedulingVo.getPersonType() == 1) { + split = groupId.split(","); + if (ObjectUtil.isNotEmpty(split)) { + for (String dutyGroupId : split) { + //查询班组信息 + List list = imsDutyGroupPService.selectByGroupIds(Arrays.asList(Long.valueOf(dutyGroupId))); + List collectPerson = list.stream().filter(iter -> iter.getGroupId().toString().equals(dutyGroupId)).map(iter -> iter.getPersonId()).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(collectPerson)) { + personIds = StringUtils.join(collectPerson, "^"); + } + if (StringUtil.isNotBlank(dutyGroupId)) { + ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); + setMainEntity(imsDutyMainEntity, classId, Long.valueOf(dutyGroupId), date); + imsDutyMainEntity.setStatus(-1); + imsDutyMainEntity.setDutyPersonIds(personIds); + imsDutyMainEntity.setCreateDept(imsSchedulingVo.getCreateDept()); + Long id = IdWorker.getId(); + imsDutyMainEntity.setId(id); + imsDutyMainEntity.setCreateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setUpdateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setTenantId(AuthUtil.getTenantId()); + imsDutyMainEntityList.add(imsDutyMainEntity); + } + } + } + } + } else { + ImsDutyMainEntity imsDutyMainEntity = new ImsDutyMainEntity(); + //人员ID + List collectPerson; + //负责人ID + Long managerId = 0l; + if (imsSchedulingVo.getPersonType() == 1) { + //查询班组信息 + List list = imsDutyGroupPService.selectByGroupIds(Arrays.asList(Long.valueOf(groupId))); + collectPerson = list.stream().filter(iter -> iter.getGroupId().toString().equals(groupId)).map(iter -> iter.getPersonId()).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(collectPerson)) { + personIds = StringUtils.join(collectPerson, "^"); + } + imsDutyMainEntity.setDutyGroupId(Long.valueOf(groupId)); + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(groupId); + if (ObjectUtil.isNotEmpty(imsDutyGroupEntity) && ObjectUtil.isNotEmpty(imsDutyGroupEntity.getManagerId())) { + managerId = imsDutyGroupEntity.getManagerId(); + } + } else { + //灵活排版没有班组信息 + FlexibleSchedulingVo flexibleSchedulingVo = imsSchedulingVo.getFlexible().get(classId).get(tempSub); + collectPerson = flexibleSchedulingVo.getPersonIds().stream().map(s -> Long.valueOf(s)).collect(Collectors.toList()); + personIds = StringUtils.join(collectPerson, "^"); + managerId = Long.valueOf(flexibleSchedulingVo.getChargeId()); + } + setMainEntity(imsDutyMainEntity, classId, date); + if (Func.isBlank(proDutyMainId)) { + if (ObjectUtil.isNotEmpty(imsDutyMainEntity1)) { + proDutyMainId = imsDutyMainEntity1.getId().toString(); + } + imsDutyMainEntity.setPreDutyId(Long.valueOf(proDutyMainId)); + } + if (StringUtil.isNotBlank(personIds)) { + imsDutyMainEntity.setDutyPersonIds(personIds); + } + imsDutyMainEntity.setCreateDept(imsSchedulingVo.getCreateDept()); + Long id = IdWorker.getId(imsDutyMainEntity); + imsDutyMainEntity.setId(id); + imsDutyMainEntity.setCreateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setUpdateUser(AuthUtil.getUserId()); + imsDutyMainEntity.setTenantId(AuthUtil.getTenantId()); + imsDutyMainEntityList.add(imsDutyMainEntity); + proDutyMainId = id == null ? "" : imsDutyMainEntity.getId().toString(); + //同步保存到排班计划-人员表 + copyPersonByDutyMain(imsSchedulingVo, managerId, personEntityList, imsDutyMainEntity, collectPerson); + } + } + } + ThreadTask.dutyTask(imsDutyMainEntityList, personEntityList, imsSchedulingVo.getEndDate(), proDutyMainId, imsSchedulingVo.getCreateDept(), imsSchedulingVo.getDutyClassTypeId()); + return R.success("操作成功,系统正在排班中,请稍后查看"); + } + private R pollScheduling(ImsSchedulingVo imsSchedulingVo) { String[] start = imsSchedulingVo.getStartDate().split("-"); @@ -261,7 +648,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl(map)); } + /** + * 查询已排班记录 + * + * @param year + * @param month + * @param deptId + * @return + */ + @Override + public R getSchedulingListV2(int year, int month, Long deptId) { + String yearAndMonth = ""; + + if (month < 10) { + yearAndMonth = year + "-0" + month; + } else { + yearAndMonth = year + "-" + month; + } + List imsSchedulingVos = this.baseMapper.selectByDateListV2(yearAndMonth, deptId); + if (CollectionUtil.isEmpty(imsSchedulingVos)) { + return R.success("该月未排班"); + } + int days = getDaysByYearMonth(year, month); + Map> map = new HashMap(); + for (int i = 1; i <= days; i++) { + String date = getDate(year, month, i); + List collect = imsSchedulingVos.stream().filter(o -> DateUtil.format(o.getDutyDate(), DateUtil.PATTERN_DATE).equals(date)).sorted(Comparator.comparing(ImsSchedulingVo::getId)).collect(Collectors.toList()); + collect = collect.stream().map(s -> { + //灵活排班把班组名称拼接成人员名称 + if (s.getGroupId() == null) { + String[] split = s.getDutyPersonIds().split("\\^"); + if (null != split && split.length > 0) { + for (int j = 0; j < split.length; j++) { + User user = UserCache.getUser(Long.valueOf(split[j])); + if (ObjectUtil.isNotEmpty(user)) { + if (j == split.length - 1) { + s.setName(s.getName() + user.getName()); + } else { + s.setName(s.getName() + user.getName() + "、"); + } + } + } + } + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId()); + s.setName(s.getName() + imsDutyGroupEntity.getGroupName()); + } + return s; + }).sorted(Comparator.comparing(ImsSchedulingVo::getId)).collect(Collectors.toList()); + map.put(date, collect); + } + return R.data(new TreeMap<>(map)); + } + + /* @Override public R getSchedulingList(int year, int month,Long deptId) { if (month < 10) { @@ -397,6 +838,50 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl list = new ArrayList<>(); + ImsDutyMainEntity imsDutyMainEntity = this.baseMapper.selectById(id); + if (ObjectUtils.isEmpty(imsDutyMainEntity) || StringUtil.isBlank(imsDutyMainEntity.getDutyPersonIds())) { + return R.data(""); + } + String ids = imsDutyMainEntity.getDutyPersonIds(); + String[] split = ids.split("\\^"); + if (null != split && split.length > 0) { + for (String s : split) { + ImsDutyMainVO vo = new ImsDutyMainVO(); + User user = UserCache.getUser(Long.valueOf(s)); + if (ObjectUtil.isNotEmpty(user)) { + vo.setUserId(s); + if (ObjectUtil.isNotEmpty(user)) { + vo.setUserName(user.getName()); + } + vo.setId(id); + list.add(vo); + } + } + } + Long managerId; + if (null != (imsDutyMainEntity.getDutyGroupId())) { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(imsDutyMainEntity.getDutyGroupId()); + managerId = imsDutyGroupEntity.getManagerId(); + + } else { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, imsDutyMainEntity.getId()); + last("limit 1;"); + }}); + managerId = imsDutyMainPersonEntity.getDutyChargePerson(); + } + list = list.stream().map(s -> { + if (s.getUserId().equals(managerId.toString())) { + s.setUserName(s.getUserName() + "(值班组组长)"); + } + return s; + }).collect(Collectors.toList()); + return R.data(list); + } + /** * 获取当前值班班组 主页任务统计 * @@ -408,7 +893,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl list = iImsDutyMainTemplateService.list(new LambdaQueryWrapper() {{ eq(ImsDutyMainTemplateEntity::getTemplateName, vo.getTemplateName()); + eq(ImsDutyMainTemplateEntity::getType, vo.getPersonType()); }}); if (CollectionUtil.isNotEmpty(list)) { return false; } ImsDutyMainTemplateEntity entity = new ImsDutyMainTemplateEntity(); - String dutyOrderIds = JSONObject.toJSONString(vo.getDutyOrderIds(), SerializerFeature.WriteMapNullValue); + if (1 == vo.getPersonType()) { + String dutyOrderIds = JSONObject.toJSONString(vo.getDutyOrderIds(), SerializerFeature.WriteMapNullValue); + entity.setDutyOrderIds(dutyOrderIds); + entity.setType(1); + } else { + String flexible = JSONObject.toJSONString(vo.getFlexible(), SerializerFeature.WriteMapNullValue); + entity.setFlexible(flexible); + entity.setType(2); + } String dutyArrIds = JSONObject.toJSONString(vo.getDutyArrIds(), SerializerFeature.WriteMapNullValue); entity.setDutyNum(vo.getDutyNum()); entity.setTemplateName(vo.getTemplateName()); - entity.setDutyOrderIds(dutyOrderIds); entity.setDutyArrIds(dutyArrIds); entity.setDutyClassTypeId(vo.getDutyClassTypeId()); entity.setCreateDept(vo.getCreateDept()); @@ -492,7 +985,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl deptId = (List) params.get("deptId"); - return getDutyMainStatisticsByClassId(startDate,endDate,deptId); + return getDutyMainStatisticsByClassId(startDate, endDate, deptId); } @Override @@ -513,7 +1006,27 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyMainByDept(List list) { - return this.baseMapper.selectDutyMainByDept(list); + return getDutyMainByDeptV2(list); + } + + @Override + public List getDutyMainByDeptV2(List list) { + List imsDutyMainMergeVos = this.baseMapper.selectDutyMainByDeptV2(list); + imsDutyMainMergeVos = imsDutyMainMergeVos.stream().map(s -> { + if (null == s.getGroupId()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, s.getDutyId()); + }}); + s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId()); + s.setGroupName(imsDutyGroupEntity.getGroupName()); + s.setGroupId(imsDutyGroupEntity.getId()); + s.setManagerId(imsDutyGroupEntity.getManagerId()); + } + return s; + }).collect(Collectors.toList()); + return imsDutyMainMergeVos; } @Override @@ -553,11 +1066,11 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getHomePageDutyInfo(Long deptId) { List list = new ArrayList<>(); - List dutyMainInfoVos = this.baseMapper.selectDutyMainInfoVo(deptId); - + List dutyMainInfoVos = getDutyDataV2(deptId); if (CollectionUtil.isNotEmpty(dutyMainInfoVos)) { for (DutyMainInfoVo dutyMainInfoVo : dutyMainInfoVos) { HomePageDutyMainInfoVo vo = new HomePageDutyMainInfoVo(); @@ -591,7 +1104,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl auditVoList = new ArrayList<>(); for (String personId : corryVo.getDutyPersonIds().split("\\^")) { @@ -619,7 +1132,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyDurationDate() { //获取当班信息 - List dutyList = this.baseMapper.selectDutyMainInfoVo(null); + List dutyList = getDutyDataV2(null); dutyList.forEach(dutyVO -> { Time startTime = dutyVO.getStartTime(); Time endTime = dutyVO.getEndTime(); @@ -639,19 +1152,34 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyData(List deptIdList) { - if(CollectionUtil.isEmpty(deptIdList)){ + if (CollectionUtil.isEmpty(deptIdList)) { return null; } // 查询区域当前值班 - List dutyInfoVoList = this.baseMapper.getDutyData(deptIdList); - if(CollectionUtil.isEmpty(dutyInfoVoList)){ + List dutyInfoVoList = this.baseMapper.getDutyDataV2(deptIdList); + if (CollectionUtil.isEmpty(dutyInfoVoList)) { return null; } + //修改数据结构后:分灵活排班和班组排班拿负责人 + dutyInfoVoList = dutyInfoVoList.stream().map(s -> { + if (null == s.getGroupId()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); + }}); + s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId()); + s.setGroupName(imsDutyGroupEntity.getGroupName()); + s.setManagerId(imsDutyGroupEntity.getManagerId().toString()); + } + return s; + }).collect(Collectors.toList()); dutyInfoVoList.forEach(item -> { // 负责人 User user = UserCache.getUser(Long.valueOf(item.getManagerId())); @@ -673,15 +1201,33 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl> allUserList = userClient.userListByDeptId(deptId); + return allUserList; + } + /** * 获取上一班组 + * * @param item * @return */ private NextDutyInfoVo getUpDutyInfo(DutyInfoVo item) { - DutyMainInfoVo dutyMainInfoVo = this.baseMapper.queryDutyInfo(item.getPreDutyId()); - if(ObjectUtil.isEmpty(dutyMainInfoVo)){ + DutyMainInfoVo dutyMainInfoVo = this.baseMapper.queryDutyInfoV2(item.getPreDutyId()); + if (null == dutyMainInfoVo.getGroupName()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); + }}); + dutyMainInfoVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(dutyMainInfoVo.getDutyGroupId()); + dutyMainInfoVo.setGroupName(imsDutyGroupEntity.getGroupName()); + dutyMainInfoVo.setDutyGroupId(imsDutyGroupEntity.getId()); + dutyMainInfoVo.setManagerId(imsDutyGroupEntity.getManagerId().toString()); + } + if (ObjectUtil.isEmpty(dutyMainInfoVo)) { return null; } // 赋值 @@ -704,12 +1250,13 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl imsDutyMainEntityList = new ArrayList<>(); - String proDutyMainId = ""; //排班 for (int i = 1; i <= dates.size(); i++) { @@ -880,7 +1426,7 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl getDutyData(Long deptId) { - return this.baseMapper.selectDutyMainInfoVo(deptId); + return getDutyDataV2(deptId); + } + + @Override + public List getDutyDataV2(Long deptId) { + List dutyMainInfoVos = this.baseMapper.selectDutyMainInfoVoV2(deptId); + dutyMainInfoVos = dutyMainInfoVos.stream().map(s -> { + if (null == s.getGroupName()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = imsDutyMainPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); + }}); + s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getDutyGroupId()); + s.setGroupName(imsDutyGroupEntity.getGroupName()); + s.setDutyGroupId(imsDutyGroupEntity.getId()); + s.setManagerId(imsDutyGroupEntity.getManagerId().toString()); + } + return s; + }).collect(Collectors.toList()); + return dutyMainInfoVos; } @Override @@ -921,4 +1494,20 @@ public class ImsDutyMainServiceImpl extends BaseServiceImpl() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); + }}); + dutyMainInfoVo.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(dutyMainInfoVo.getDutyGroupId()); + dutyMainInfoVo.setGroupName(imsDutyGroupEntity.getGroupName()); + dutyMainInfoVo.setDutyGroupId(imsDutyGroupEntity.getId()); + dutyMainInfoVo.setManagerId(imsDutyGroupEntity.getManagerId().toString()); + } + return dutyMainInfoVo; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainTemplateImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainTemplateImpl.java index f07b752..7e91c96 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainTemplateImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyMainTemplateImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.operational.duty.entity.ImsDutyMainTemplateEntity; import com.hnac.hzims.operational.duty.mapper.ImsDutyMainTemplateMapper; import com.hnac.hzims.operational.duty.service.IImsDutyMainTemplateService; +import com.hnac.hzims.operational.duty.vo.FlexibleSchedulingVo; import com.hnac.hzims.operational.duty.vo.ImsSchedulingVo; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; @@ -24,21 +25,28 @@ public class ImsDutyMainTemplateImpl extends BaseServiceImpl doListAll(ImsDutyMainTemplateEntity entity) { List vos = new ArrayList<>(); - List list = this.list(new LambdaQueryWrapper(){{ - if(null != entity.getCreateDept()){ - eq(ImsDutyMainTemplateEntity::getCreateDept,entity.getCreateDept()); + List list = this.list(new LambdaQueryWrapper() {{ + if (null != entity.getCreateDept()) { + eq(ImsDutyMainTemplateEntity::getCreateDept, entity.getCreateDept()); + eq(ImsDutyMainTemplateEntity::getType, entity.getType()); } }}); - if(CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { for (ImsDutyMainTemplateEntity imsDutyMainTemplateEntity : list) { ImsSchedulingVo vo = new ImsSchedulingVo(); String[] dutyArrIds = JSONObject.parseObject(imsDutyMainTemplateEntity.getDutyArrIds(), new TypeReference() { }); - HashMap dutyOrderIds = JSONObject.parseObject(imsDutyMainTemplateEntity.getDutyOrderIds(), new TypeReference>() { - }); - + if (1==entity.getType()) { + HashMap dutyOrderIds = JSONObject.parseObject(imsDutyMainTemplateEntity.getDutyOrderIds(), new TypeReference>() { + }); + vo.setDutyOrderIds(dutyOrderIds); + }else { + HashMap> map = JSONObject.parseObject(imsDutyMainTemplateEntity.getFlexible(), new TypeReference>>() { + }); + vo.setFlexible(map); + } + vo.setPersonType(imsDutyMainTemplateEntity.getType()); vo.setDutyArrIds(dutyArrIds); - vo.setDutyOrderIds(dutyOrderIds); vo.setDutyNum(imsDutyMainTemplateEntity.getDutyNum()); vo.setTemplateName(imsDutyMainTemplateEntity.getTemplateName()); vo.setId(imsDutyMainTemplateEntity.getId()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java index 18be74d..440dad5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsDutyRecServiceImpl.java @@ -75,6 +75,8 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl() {{ eq("PRE_DUTY_ID", vo.getDutyId()); }}); if (ObjectUtil.isNotEmpty(imsDutyMainEntity)) { - ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOne(imsDutyMainEntity.getId()); + ImsSchedulingVo imsSchedulingVo = imsDutyMainService.getByIdOneV2(imsDutyMainEntity.getId()); vo.setCarryDutyMainVo(imsSchedulingVo); } return vo; @@ -294,7 +296,7 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl getTheManinGroupRecV2(Long deptId) { +// ImsDutyRecVO vo = new ImsDutyRecVO(); +// +// ImsDutyMainEntity entity = imsDutyMainMapper.selectOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyMainEntity::getStatus, DutyMainStatus.EXEC.getVal()); +// eq(ImsDutyMainEntity::getCreateDept, deptId); +// like(ImsDutyMainEntity::getDutyPersonIds, AuthUtil.getUserId()).last(" limit 1"); +// }}); +// if (ObjectUtil.isEmpty(entity)) { +// return R.success("您当前未值班"); +// } +// +// ImsDutyGroupEntity groupEntity = imsDutyGroupService.getOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyGroupEntity::getId, entity.getDutyGroupId()); +// eq(ImsDutyGroupEntity::getManagerId, AuthUtil.getUserId()); +// }}); +// if (ObjectUtil.isEmpty(groupEntity)) { +// return R.success("您不是该班组负责人,不可交班!"); +// } +// +// ImsDutyRecEntity recEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyRecEntity::getDutyId, entity.getId()); +// }}); +// if (ObjectUtil.isNotEmpty(recEntity)) { +// return R.success("您已提交交班申请"); +// } +// +// ImsDutyRecEntity dutyRecEntity = this.baseMapper.selectOne(new LambdaQueryWrapper() {{ +// eq(ImsDutyRecEntity::getDutyId, entity.getPreDutyId()); +// }}); +// if (ObjectUtil.isNotEmpty(dutyRecEntity)) { +// vo.setInspectTaskId(dutyRecEntity.getInspectTaskId()); +// } +// ImsSchedulingVo imsSchedulingVo = imsDutyMainMapper.selectByIdOneV2(entity.getId(), null);//交班人 +// if (null != imsSchedulingVo.getManagerId()) { +// imsSchedulingVo.setUserName(userClient.userInfoById(imsSchedulingVo.getManagerId()).getData().getName()); +// } +// ImsSchedulingVo imsSchedulingVo1 = imsDutyMainMapper.selectByIdOneV2(null, entity.getId()); +// if (null != imsSchedulingVo1.getManagerId()) { +// imsSchedulingVo1.setUserName(userClient.userInfoById(imsSchedulingVo1.getManagerId()).getData().getName()); +// } +// vo.setHeadDutyMainVo(imsSchedulingVo); +// vo.setCarryDutyMainVo(imsSchedulingVo1); +// return R.data(vo); +// } /** * 获取签到二维码 * @@ -570,7 +622,6 @@ public class ImsDutyRecServiceImpl extends BaseServiceImpl list = imsDutyMainService.list(new LambdaQueryWrapper() {{ ge(ImsDutyMainEntity::getDutyDate, mainEntity.getDutyDate()); le(ImsDutyMainEntity::getDutyDate, entity.getDutyDate()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java index ad08a3f..1df4106 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AppHomeServiceImpl.java @@ -485,7 +485,7 @@ public class AppHomeServiceImpl implements IAppHomeService { @Override public List getDutyData(Long deptId) { // 获取当班列表数据 - List list = this.dutyMainService.getDutyData(deptId); + List list = this.dutyMainService.getDutyDataV2(deptId); if(CollectionUtil.isEmpty(list)){ return null; } @@ -573,7 +573,7 @@ public class AppHomeServiceImpl implements IAppHomeService { * @param id */ private void getNextDuty(AppDutyVo item, Long id) { - DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyData(id); + DutyMainInfoVo nextDuty = this.dutyMainService.getNextDutyDataV2(id); if(ObjectUtil.isEmpty(nextDuty)){ return; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java index 5288fa3..500a342 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainStatisticsServiceImpl.java @@ -79,7 +79,7 @@ public class MainStatisticsServiceImpl implements IMainStatisticsService { } } else{ - imsDutyMainEntity = iImsDutyMainService.getByIdOne(mainDutyId); + imsDutyMainEntity = iImsDutyMainService.getByIdOneV2(mainDutyId); } //完善值班统计属性 DutyStatisticsVO dutyStatisticsVo = new DutyStatisticsVO(); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java index 51f7169..b7993af 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PlatformServiceImpl.java @@ -319,7 +319,7 @@ public class PlatformServiceImpl implements IPlatformService { //根据站点数据获取所有机构ID List deptList = imsDeptEntityList.stream().map(ImsDeptEntity::getId).collect(Collectors.toList()); //根据机构ID获取值班数据 - List dutyMainByDept = dutyMainService.getDutyMainByDept(deptList); + List dutyMainByDept = dutyMainService.getDutyMainByDeptV2(deptList); Map> collect = dutyMainByDept.stream().collect(Collectors.groupingBy(ImsDutyMainMergeVo::getDutyId)); Map> preDytuMap = dutyMainByDept.stream().collect(Collectors.groupingBy(ImsDutyMainMergeVo::getPreDutyId)); Map> beOnDutyMap = dutyMainByDept.stream().filter(o -> o.getStatus() == 1).collect(Collectors.groupingBy(ImsDutyMainMergeVo::getDutyId));