From 455ccee19e6757b25d7c18ae825cb3f06c469d12 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 8 Jun 2023 11:46:19 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8A=BD?= =?UTF-8?q?=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/main/vo/RegularWorkVO.java | 20 + .../mapper/operation/DutyGroupMapper.java | 27 + .../scheduled/mapper/operation/DutyMapper.java | 20 + .../mapper/operation/DutyPersonMapper.java | 11 + .../scheduled/mapper/ticket/WorkDelayMapper.java | 16 + .../mapper/ticket/WorkPrincipalMapper.java | 11 + .../scheduled/scheduled/ShowScheduledTask.java | 13 + .../scheduled/service/operation/DutyService.java | 15 + .../service/operation/MaintenanceService.java | 6 +- .../service/operation/PhenomenonService.java | 3 + .../scheduled/service/operation/ShowService.java | 2 + .../service/operation/impl/DutyServiceImpl.java | 176 +++++ .../operation/impl/MaintenanceServiceImpl.java | 36 ++ .../operation/impl/PhenomenonServiceImpl.java | 39 ++ .../service/operation/impl/ShowServiceImpl.java | 719 ++++++++++++++++++++- .../scheduled/service/ticket/TicketService.java | 4 +- .../scheduled/service/ticket/WorkDelayService.java | 12 + .../service/ticket/WorkPrincipalService.java | 11 + .../service/ticket/WorkTicketService.java | 5 + .../service/ticket/impl/TicketServiceImpl.java | 20 + .../service/ticket/impl/WorkDelayServiceImpl.java | 19 + .../ticket/impl/WorkPrincipalServiceImpl.java | 20 + .../service/ticket/impl/WorkTicketServiceImpl.java | 65 ++ .../resources/mapper/operation/DutyGroupMapper.xml | 4 + .../main/resources/mapper/operation/DutyMapper.xml | 34 + .../mapper/operation/DutyPersonMapper.xml | 4 + .../resources/mapper/ticket/WorkDelayMapper.xml | 5 + .../mapper/ticket/WorkPrincipalMapper.xml | 5 + .../main/service/impl/SideHustleServiceImpl.java | 2 +- .../service/IOperMaintenanceTaskService.java | 2 +- .../impl/OperMaintenanceTaskServiceImpl.java | 10 +- .../operational/maintenance/vo/RegularWorkVO.java | 20 - 32 files changed, 1318 insertions(+), 38 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyGroupMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyPersonMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkDelayMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkPrincipalMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DutyService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DutyServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkDelayService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkPrincipalService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml delete mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/vo/RegularWorkVO.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java new file mode 100644 index 0000000..aafb15a --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.main.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 定期工作 + */ +@Data +public class RegularWorkVO{ + + @ApiModelProperty("定期工作总数") + private Integer regularWorkSum; + + @ApiModelProperty("修改人名称") + private Integer regularWork; + + @ApiModelProperty("日常维护任务Id 按逗号分隔") + private String mainTaskIds; +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyGroupMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyGroupMapper.java new file mode 100644 index 0000000..3ba69d8 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyGroupMapper.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.duty.entity.ImsDutyGroupEntity; +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 Chill + */ +public interface DutyGroupMapper extends UserDataScopeBaseMapper { + + /** + * 根据班组ID修改负责人为null + * @param id + * @return + */ + int updateManagerIdById(Long id); + + @UserDataAuth + List selectDutyGroupJoinDutyMain(@Param("startDate") String startDate, @Param("endDate") String endDate); + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyMapper.java new file mode 100644 index 0000000..2811137 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyMapper.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; +import com.hnac.hzims.operational.duty.vo.DutyInfoVo; +import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.List; + +/** + * @author ysj + */ +public interface DutyMapper extends UserDataScopeBaseMapper { + + List dutyData(List collect); + + DutyMainInfoVo queryDuty(Long preDutyId); + + DutyMainInfoVo selectDuty(Long preDutyId); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyPersonMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyPersonMapper.java new file mode 100644 index 0000000..1326c30 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyPersonMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.operation; + +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface DutyPersonMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkDelayMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkDelayMapper.java new file mode 100644 index 0000000..b69757a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkDelayMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.scheduled.mapper.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + *

+ * 工作票延期 Mapper 接口 + *

+ * + * @author hx + * @since 2021-10-22 + */ +public interface WorkDelayMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkPrincipalMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkPrincipalMapper.java new file mode 100644 index 0000000..4520735 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkPrincipalMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.mapper.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * @author ysj + */ +public interface WorkPrincipalMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java index 426502e..19c294c 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.Date; import static com.hnac.hzims.operational.main.constant.MainConstants.LOAD_HOME_TARGET; +import static com.hnac.hzims.operational.main.constant.MainConstants.REGIONAL_DUTY_INFO; /** @@ -35,4 +36,16 @@ public class ShowScheduledTask { service.loadHomeTarget(param); return new ReturnT<>("SUCCESS"); } + + /** + * 首页-区域班组数据 + */ + @XxlJob(REGIONAL_DUTY_INFO) + public ReturnT loadRegionalDuty(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } + service.loadRegionalDuty(param); + return new ReturnT<>("SUCCESS"); + } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DutyService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DutyService.java new file mode 100644 index 0000000..08efdcd --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DutyService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.service.operation; + +import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; +import com.hnac.hzims.operational.duty.vo.DutyInfoVo; +import org.springblade.core.mp.base.BaseService; + +import java.util.List; + +/** + * @author ysj + */ +public interface DutyService extends BaseService { + + List dutyData(List collect); +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java index 31d2be0..b193f91 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java @@ -1,9 +1,11 @@ package com.hnac.hzims.scheduled.service.operation; import com.hnac.hzims.operational.main.vo.MaintainVo; +import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import org.springblade.core.mp.base.BaseService; +import java.util.Date; import java.util.List; /** @@ -12,7 +14,9 @@ import java.util.List; public interface MaintenanceService extends BaseService { // 查询当年日常维护数量 - Integer maintenanceCount(List departList); + Integer maintenanceCount(List areas); MaintainVo maintain(String start, String end, List areas); + + RegularWorkVO regularWork(Date start, Date end, List areas); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java index fe294d8..362fbe9 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.scheduled.service.operation; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.main.vo.ShortagesVo; import com.hnac.hzims.operational.report.vo.DutyDefectVO; import org.springblade.core.mp.base.BaseService; @@ -12,4 +13,6 @@ import java.util.List; public interface PhenomenonService extends BaseService { DutyDefectVO defect(String start, String end, List areas); + + ShortagesVo defectMonth(String start, String end, List list); } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java index a86eed7..78a454b6 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java @@ -6,4 +6,6 @@ package com.hnac.hzims.scheduled.service.operation; public interface ShowService { void loadHomeTarget(String param); + + void loadRegionalDuty(String param); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DutyServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DutyServiceImpl.java new file mode 100644 index 0000000..cbaf723 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DutyServiceImpl.java @@ -0,0 +1,176 @@ +package com.hnac.hzims.scheduled.service.operation.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.hnac.hzims.operational.duty.entity.ImsDutyGroupEntity; +import com.hnac.hzims.operational.duty.entity.ImsDutyMainEntity; +import com.hnac.hzims.operational.duty.entity.ImsDutyMainPersonEntity; +import com.hnac.hzims.operational.duty.vo.DutyInfoVo; +import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; +import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo; +import com.hnac.hzims.scheduled.mapper.operation.DutyGroupMapper; +import com.hnac.hzims.scheduled.mapper.operation.DutyMapper; +import com.hnac.hzims.scheduled.mapper.operation.DutyPersonMapper; +import com.hnac.hzims.scheduled.service.operation.DutyService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class DutyServiceImpl extends BaseServiceImpl implements DutyService { + + private final DutyPersonMapper dutyPersonMapper; + private final DutyGroupMapper dutyGroupMapper; + + @Override + public List dutyData(List collect) { + if (CollectionUtil.isEmpty(collect)) { + return null; + } + // 查询区域当前值班 + List dutyInfoVoList = this.baseMapper.dutyData(collect); + if (CollectionUtil.isEmpty(dutyInfoVoList)) { + return null; + } + //修改数据结构后:分灵活排班和班组排班拿负责人 + dutyInfoVoList = dutyInfoVoList.stream().peek(s -> { + if (null == s.getGroupId()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = dutyPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, s.getId()); + last(" limit 1"); + }}); + s.setManagerId(imsDutyMainPersonEntity.getDutyChargePerson().toString()); + } else { + ImsDutyGroupEntity imsDutyGroupEntity = dutyGroupMapper.selectById(s.getGroupId()); + s.setGroupName(imsDutyGroupEntity.getGroupName()); + s.setManagerId(imsDutyGroupEntity.getManagerId().toString()); + } + }).collect(Collectors.toList()); + dutyInfoVoList.forEach(item -> { + // 负责人 + User user = UserCache.getUser(Long.valueOf(item.getManagerId())); + if (ObjectUtil.isNotEmpty(user)) { + item.setManagerName(user.getName()); + item.setManagerPhone(user.getPhone()); + } + // FIXME 上网 + item.setOnlineCapacity(0.0); + // 发电量 + item.setGeneratingCapacity(0); + // 上一班组 + NextDutyInfoVo upDutyInfoVo = this.getUpDutyInfo(item); + item.setUpDutyInfoVo(upDutyInfoVo); + // 下一班组 + NextDutyInfoVo nextDutyInfoVo = this.getNextDutyInfo(item); + item.setNextDutyInfoVo(nextDutyInfoVo); + }); + return dutyInfoVoList; + } + + + /** + * 获取上一班组 + * + * @param item + * @return + */ + private NextDutyInfoVo getUpDutyInfo(DutyInfoVo item) { + if(ObjectUtil.isEmpty(item.getPreDutyId())){ + return null; + } + DutyMainInfoVo dutyMainInfoVo = this.baseMapper.queryDuty(item.getPreDutyId()); + if (null == dutyMainInfoVo.getDutyGroupId()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = dutyPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); + last(" LIMIT 1"); + }}); + 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; + } + // 赋值 + NextDutyInfoVo dutyInfoVo = new NextDutyInfoVo(); + dutyInfoVo.setGroupName(dutyMainInfoVo.getGroupName()); + dutyInfoVo.setClassName(dutyMainInfoVo.getClassName()); + dutyInfoVo.setDateTime(dutyMainInfoVo.getDateTime()); + dutyInfoVo.setStartTime(dutyMainInfoVo.getStartTime()); + dutyInfoVo.setEndTime(dutyMainInfoVo.getEndTime()); + // 负责人 + User user = UserCache.getUser(Long.valueOf(dutyMainInfoVo.getManagerId())); + if (ObjectUtil.isNotEmpty(user)) { + dutyInfoVo.setManagerName(user.getName()); + dutyInfoVo.setManagerPhone(user.getPhone()); + } + // 发电量 + dutyInfoVo.setGeneratingCapacity(0); + return dutyInfoVo; + } + + /** + * 获取下一班组 + * + * @param item + * @return + */ + private NextDutyInfoVo getNextDutyInfo(DutyInfoVo item) { + DutyMainInfoVo dutyMainInfoVo = this.nextDuty(item.getId()); + if (ObjectUtil.isEmpty(dutyMainInfoVo)) { + return null; + } + // 赋值 + NextDutyInfoVo dutyInfoVo = new NextDutyInfoVo(); + dutyInfoVo.setGroupName(dutyMainInfoVo.getGroupName()); + dutyInfoVo.setClassName(dutyMainInfoVo.getClassName()); + // 负责人 + User user = UserCache.getUser(Long.valueOf(dutyMainInfoVo.getManagerId())); + if (ObjectUtil.isNotEmpty(user)) { + dutyInfoVo.setManagerName(user.getName()); + dutyInfoVo.setManagerPhone(user.getPhone()); + } + dutyInfoVo.setGeneratingCapacity(0); + return dutyInfoVo; + } + + /** + * 下一班组 + * @param parentId + * @return + */ + public DutyMainInfoVo nextDuty(Long parentId) { + DutyMainInfoVo dutyMainInfoVo = this.baseMapper.selectDuty(parentId); + if(ObjectUtil.isEmpty(dutyMainInfoVo)){ + return new DutyMainInfoVo(); + } + if (null == dutyMainInfoVo.getDutyGroupId()) { + ImsDutyMainPersonEntity imsDutyMainPersonEntity = dutyPersonMapper.selectOne(new LambdaQueryWrapper() {{ + eq(ImsDutyMainPersonEntity::getDutyMainId, dutyMainInfoVo.getId()); + last("limit 1"); + }}); + 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; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java index 7152ace..35b4ab5 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java @@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.service.operation.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.operational.main.vo.MaintainVo; +import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.scheduled.mapper.operation.MaintenanceMapper; @@ -16,6 +17,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; +import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -84,5 +86,39 @@ public class MaintenanceServiceImpl extends BaseServiceImpl areas) { + RegularWorkVO regularWorkVO = new RegularWorkVO(); + // 查询定期工作任务 + List regularWorkList = this.list(new LambdaQueryWrapper() {{ + ge(OperMaintenanceTaskEntity::getDisposeTime, start) + .le(OperMaintenanceTaskEntity::getDisposeTime, end) + .eq(OperMaintenanceTaskEntity::getTypeCode, "05") + .in(OperMaintenanceTaskEntity::getCreateDept, areas); + }}); + if (CollectionUtil.isEmpty(regularWorkList)) { + regularWorkVO.setRegularWorkSum(0); + regularWorkVO.setRegularWork(0); + return regularWorkVO; + } + regularWorkVO.setMainTaskIds(regularWorkList.stream().map(OperMaintenanceTaskEntity::getId).map(id -> id.toString()).collect(Collectors.joining(","))); + regularWorkVO.setRegularWorkSum(regularWorkList.size()); + // 定期工作任务完成数量 + List regularWorkFinishList = regularWorkList.stream().filter(o -> MaintenanceConstant.TASK_STATUS_5 == o.getStatus()).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(regularWorkFinishList)) { + regularWorkVO.setRegularWork(0); + return regularWorkVO; + } + regularWorkVO.setRegularWork(regularWorkFinishList.size()); + return regularWorkVO; + } + } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java index 4afdf08..d993192 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java @@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.service.operation.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; +import com.hnac.hzims.operational.main.vo.ShortagesVo; import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.scheduled.mapper.operation.PhenomenonMapper; import com.hnac.hzims.scheduled.service.operation.PhenomenonService; @@ -12,6 +13,9 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.List; import java.util.stream.Collectors; @@ -57,4 +61,39 @@ public class PhenomenonServiceImpl extends BaseServiceImpl list) { + ShortagesVo shortagesVo = new ShortagesVo(); + LocalDate firstDay = LocalDate.now().withDayOfMonth(1); + LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN); + LocalDateTime now = LocalDateTime.now(); + // 消缺总数 + List defects = this.list(new LambdaQueryWrapper(){{ + ge(OperPhenomenonEntity::getCreateTime,firstDateTime); + le(OperPhenomenonEntity::getCreateTime,now); + in(OperPhenomenonEntity::getCreateDept,list); + }}); + if(CollectionUtil.isEmpty(defects)){ + shortagesVo.setShortagesSum(0); + shortagesVo.setShortages(0); + return shortagesVo; + } + // 消缺数 + shortagesVo.setShortagesSum(defects.size()); + List shortagesList = defects.stream().filter(o -> (Func.isNotEmpty(o.getIsDefect()) && o.getIsDefect() == 0) || "1".equals(o.getConclusionStatus())). + map(OperPhenomenonEntity::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(shortagesList)){ + shortagesVo.setShortages(0); + } + shortagesVo.setShortages(shortagesList.size()); + return shortagesVo; + } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java index 5d87218..9c64c59 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java @@ -1,26 +1,39 @@ package com.hnac.hzims.scheduled.service.operation.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; +import com.hnac.hzims.operational.duty.vo.DutyInfoVo; +import com.hnac.hzims.operational.duty.vo.DutyTaskVo; +import com.hnac.hzims.operational.duty.vo.NextDutyInfoVo; import com.hnac.hzims.operational.fill.entity.*; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.vo.*; +import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.scheduled.service.equipment.PlanService; +import com.hnac.hzims.scheduled.service.inspect.TaskService; import com.hnac.hzims.scheduled.service.operation.*; import com.hnac.hzims.scheduled.service.ticket.TicketService; +import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; +import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; +import com.hnac.hzinfo.datasearch.analyse.IAnalyseInstanceClient; +import com.hnac.hzinfo.inspect.task.vo.DutyInspectTaskVO; +import com.xxl.job.core.log.XxlJobLogger; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; +import org.apache.poi.ss.formula.functions.T; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.DateUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.utils.*; import org.springblade.system.cache.DictCache; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; @@ -36,11 +49,12 @@ import java.math.BigDecimal; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.sql.Time; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.concurrent.*; import java.util.stream.Collectors; @@ -52,6 +66,7 @@ import java.util.stream.Collectors; @Slf4j public class ShowServiceImpl implements ShowService { + private final TaskService taskService; private final OverService overService; private final PlanService planService; private final PowerService powerService; @@ -60,12 +75,16 @@ public class ShowServiceImpl implements ShowService { private final AccessService accessService; private final TicketService ticketService; private final DefectService defectService; + private final DutyService dutyService; private final StationService stationService; private final OverDetailsService detailsService; + private final WorkTicketService workTicketService; + private final PhenomenonService phenomenonService; + private final AnalyseDataService analyseDataService; private final MaintenanceService maintenanceService; private final RedisTemplate redisTemplate; private final ISysClient sysClient; - + private final IAnalyseInstanceClient deviceInstanceClient; private final static String charge = "hzims:operation:key:charge"; private final static String home_target_cache_final = "load:operation:home:target:key"; @@ -77,6 +96,12 @@ public class ShowServiceImpl implements ShowService { @Value("${hzims.operation.homePage.charge.url}") public String charge_url; + @Value("${hzims.equipment.emInfo.emInfoList}") + public String device_cache_cofig_final; + + @Value("${hzims.operation.region.areaDutyInfoKey}") + private String area_duty_cofig_final; + /** * 集团总指标-首页数据 */ @@ -112,6 +137,64 @@ public class ShowServiceImpl implements ShowService { redisTemplate.opsForValue().set(home_target_cache_final,targets.stream().filter(( target -> ObjectUtil.isNotEmpty(target.getType()))).collect(Collectors.toList())); } + + /** + * 智能生产-值班数据 + * @param param + */ + @Override + public void loadRegionalDuty(String param) { + R> R = sysClient.getDeptList(); + if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { + return; + } + Map> map = this.area(R.getData(),null, Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE); + if (MapUtils.isEmpty(map)) { + return; + } + // 查询所有区域值班/接班数据 + List dutyInfoVoList = dutyService.dutyData(map.keySet().stream().map(Dept::getId).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(dutyInfoVoList)){ + return; + } + // 所有设备 + List devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference>() {}); + List areaDutyVoList = new ArrayList<>(); + map.forEach((key,value) -> { + List singlet = Collections.singletonList(key.getId()); + AreaDutyVo areaDutyVo = new AreaDutyVo(); + areaDutyVo.setDepartId(key.getId()); + areaDutyVo.setDepartName(key.getDeptName()); + areaDutyVo.setSort(key.getSort()); + // 值班情况 + this.dutySituation(dutyInfoVoList, key, areaDutyVo); + // 厂站运行情况 + this.factoryStationRun(devices, value, areaDutyVo); + // 当月任务执行情况 + this.executeTaskMonth(singlet, areaDutyVo); + // 获取区域当班时间 + List dutyList = dutyInfoVoList.stream().filter(o -> key.getId().equals(o.getCreateDept())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(dutyList)) { + areaDutyVoList.add(areaDutyVo); + return; + } + Date startDate = this.dutyStartTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime()); + Date endDate = this.dutyEndTime(dutyList.get(0).getDateTime(),dutyList.get(0).getStartTime(),dutyList.get(0).getEndTime()); + areaDutyVo.setStartTimeDuty(DateUtil.format(startDate,DateUtil.PATTERN_DATETIME)); + areaDutyVo.setEndTimeDuty(DateUtil.format(endDate,DateUtil.PATTERN_DATETIME)); + // 上一班组发电量 + this.upDutyPower(dutyList,devices,key.getId(),value,areaDutyVo); + // 班组实时发电量 + this.dutyPower(startDate,endDate,devices,value,areaDutyVo,false); + // 当班双票 + this.dutyDoubleTicket(startDate,endDate,singlet,areaDutyVo); + // 当班运行数据 + this.dutyRunCondition(startDate,endDate,singlet,areaDutyVo); + areaDutyVoList.add(areaDutyVo); + }); + redisTemplate.opsForValue().set(area_duty_cofig_final, areaDutyVoList); + } + /** * 水电站指标 * @return @@ -477,4 +560,626 @@ public class ShowServiceImpl implements ShowService { } return stringBuilder.toString(); } + + /** + * 获取权限区域 + * @param list : 机构列表 + * @param deptId : 起始过滤权限机构 + * @param typeList : 查询站点类型-水电、水利、光伏.... + * @param serveType : 站点服务类型 + * @return Map> + */ + private Map> area(List list,Long deptId, List typeList, Integer serveType) { + // 未传入机构列表,使用用户权限机构过滤 + if(CollectionUtil.isEmpty(list)){ + R> R = sysClient.getDeptByCurrentUser(); + if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){ + return null; + } + list = R.getData(); + } + // 根据参数查询有效站点 + List stationList = this.stationByParams(list,deptId,typeList,serveType); + if(CollectionUtil.isEmpty(stationList)){ + return null; + } + // 有效站点归属机构Id集合 + List refDeptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(refDeptList)){ + return null; + } + // 有效站点归属机构集合 + List vaildDeptList = list.stream().filter(o->refDeptList.contains(o.getId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(vaildDeptList)){ + return null; + } + // 根据有效站点归属机构向上区域Id + List areaIdList = vaildDeptList.stream().map(Dept::getParentId).distinct().collect(Collectors.toList()); + if(CollectionUtil.isEmpty(areaIdList)){ + return null; + } + // 根据区域Id查询区域机构 + List areaList = list.stream().filter(o->o.getDeptCategory().equals(HomePageConstant.AREA) && areaIdList.contains(o.getId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(areaList)){ + return null; + } + // 返回结构 + Map> result = new HashMap<>(); + for(Dept area : areaList){ + List childDeptIdList = list.stream().filter(o->o.getParentId().equals(area.getId())).map(Dept::getId).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(childDeptIdList)){ + continue; + } + List resultList = stationList.stream().filter(o->childDeptIdList.contains(o.getRefDept())).collect(Collectors.toList()); + result.put(area,resultList); + } + return result; + } + + /** + * 获取站点集合 + * @param authList + * @param deptId + * @param types + * @param servrType + * @return + */ + private List stationByParams(List authList, Long deptId, List types, Integer servrType) { + Dept dept; + if (null == deptId) { + // 最小类型机构 + Optional min = authList.stream().min(Comparator.comparing(Dept::getDeptCategory)); + dept = min.orElse(null); + if (ObjectUtil.isEmpty(dept)) { + return null; + } + } else { + // 检查是否存在传入机构 + List list = authList.stream().filter(o -> deptId.equals(o.getId())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(list)) { + return null; + } + // 传入机构为站点 + dept = list.get(0); + } + List depts; + if (dept.getDeptCategory().equals(4)) { + depts = Collections.singletonList(dept.getId()); + // 传入机构为区域、省子公司、集团 + } else { + // 递归权限机构获取站点级机构 + depts = this.stationDept(authList, dept.getId(), new ArrayList<>()); + } + // 获取水利站点(过滤其他站点类型) + return stationService.list(new LambdaQueryWrapper() {{ + eq(StationEntity::getIsDeleted, 0); + if (ObjectUtil.isNotEmpty(servrType)) { + eq(StationEntity::getServeType, servrType); + } + if (CollectionUtil.isNotEmpty(types)) { + in(StationEntity::getType, types); + } + if (CollectionUtil.isNotEmpty(depts)) { + in(StationEntity::getRefDept, depts); + } + }}); + } + + /** + * 递归权限机构获取站点级机构 + * + * @param departList + * @param deptId + * @param list + * @return + */ + private List stationDept(List departList, Long deptId, List list) { + if (null == deptId || CollectionUtil.isEmpty(departList)) { + return null; + } + departList.forEach(dept -> { + if (dept.getParentId().equals(deptId)) { + if (dept.getDeptCategory().equals(4)) { + list.add(dept.getId()); + } + stationDept(departList, dept.getId(), list); + } + }); + return list; + } + + /** + * 获取开始时间 + * @param date + * @param time + * @return + */ + private Date dutyStartTime(Date date, Time time){ + Calendar dateCal = Calendar.getInstance(); + dateCal.setTime(date); + Calendar timeCal = Calendar.getInstance(); + timeCal.setTime(time); + dateCal.set(Calendar.HOUR_OF_DAY, timeCal.get(Calendar.HOUR_OF_DAY)); + dateCal.set(Calendar.MINUTE, timeCal.get(Calendar.MINUTE)); + dateCal.set(Calendar.SECOND, timeCal.get(Calendar.SECOND)); + return dateCal.getTime(); + } + + /** + * 获取结束时间 + * @param date + * @param time + * @return + */ + private Date dutyEndTime(Date date, Time time,Time endTime){ + Calendar dateCal = Calendar.getInstance(); + dateCal.setTime(date); + Calendar timeCal = Calendar.getInstance(); + timeCal.setTime(time); + Calendar endCal = Calendar.getInstance(); + endCal.setTime(endTime); + // 结束时间 < 开始时间 + if(timeCal.after(endCal)){ + dateCal.set(Calendar.DAY_OF_MONTH, dateCal.get(Calendar.DAY_OF_MONTH) + 1 ); + } + dateCal.set(Calendar.HOUR_OF_DAY, endCal.get(Calendar.HOUR_OF_DAY)); + dateCal.set(Calendar.MINUTE, endCal.get(Calendar.MINUTE)); + dateCal.set(Calendar.SECOND, endCal.get(Calendar.SECOND)); + return dateCal.getTime(); + } + + /** + * 值班情况 + * + * @param dutyInfoVoList + * @param dept + * @param areaDutyVo + */ + private void dutySituation(List dutyInfoVoList, Dept dept, AreaDutyVo areaDutyVo) { + if (CollectionUtil.isEmpty(dutyInfoVoList) || ObjectUtil.isEmpty(dept)) { + return; + } + Long deptId = dept.getId(); + List filterList = dutyInfoVoList.stream().filter(o -> o.getCreateDept().equals(deptId)).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(filterList)) { + return; + } + DutyInfoVo dutyInfoVo = filterList.get(0); + areaDutyVo.setGeneratingCapacity(dutyInfoVo.getGeneratingCapacity()); + areaDutyVo.setOnlineCapacity(dutyInfoVo.getOnlineCapacity()); + areaDutyVo.setClassName(dutyInfoVo.getClassName()); + areaDutyVo.setGroupName(dutyInfoVo.getGroupName()); + areaDutyVo.setManagerName(dutyInfoVo.getManagerName()); + areaDutyVo.setManagerPhone(dutyInfoVo.getManagerPhone()); + areaDutyVo.setNextDutyInfoVo(dutyInfoVo.getNextDutyInfoVo()); + // 当班任务 + + String taskCount = this.taskCount(dutyInfoVo.getDateTime(),dutyInfoVo.getStartTime(),dutyInfoVo.getEndTime(),dutyInfoVo.getCreateDept()); + String[] task = taskCount.split("\\|"); + areaDutyVo.setTaskCount(Integer.valueOf(task[0])); + areaDutyVo.setFinishTaskCount(Integer.valueOf(task[1])); + NextDutyInfoVo upDutyInfoVo = dutyInfoVo.getUpDutyInfoVo(); + if(ObjectUtil.isEmpty(upDutyInfoVo)){ + return; + } + // 上一班组当班任务 + String upTaskCount = this.taskCount(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime(),upDutyInfoVo.getEndTime(),dutyInfoVo.getCreateDept()); + String[] upTask = upTaskCount.split("\\|"); + upDutyInfoVo.setTaskCount(Integer.valueOf(upTask[0])); + upDutyInfoVo.setFinishTaskCount(Integer.valueOf(upTask[1])); + areaDutyVo.setUpDutyInfoVo(upDutyInfoVo); + } + + + /** + * 获取当班任务 + * @param dateTime + * @param startTime + * @param endTime + * @param createDept + * @return + */ + private String taskCount(Date dateTime, Time startTime, Time endTime, Long createDept) { + DutyTaskVo task = new DutyTaskVo(); + //通过线程池异步获取月报各模块内容 主要分为五块内容 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("duty-task-count-pool-%d").build(); + ExecutorService exe = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(4); + List list = Collections.singletonList(createDept); + String start = DateUtil.format(this.dutyStartTime(dateTime,startTime),DateUtil.PATTERN_DATETIME); + String end = DateUtil.format(this.dutyEndTime(dateTime,startTime,endTime),DateUtil.PATTERN_DATETIME); + // 日常维护 + exe.execute(()->{ + MaintainVo maintainVo = maintenanceService.maintain(start,end,list); + int maintainSum = maintainVo.getMaintain(); + int maintainFinish = maintainVo.getMaintainFinish(); + task.setMaintainSum(maintainSum); + task.setMaintainFinish(maintainFinish); + countDownLatch.countDown(); + }); + + // 消缺 + exe.execute(()->{ + ShortagesVo shortagesVo = phenomenonService.defectMonth(start,end,list); + int shortagesSum = shortagesVo.getShortagesSum(); + int shortages = shortagesVo.getShortages(); + task.setShortagesSum(shortagesSum); + task.setShortages(shortages); + countDownLatch.countDown(); + }); + // 检修 + exe.execute(()->{ + OverhaulVo overhaulVo = accessService.overhaul(start,end,list); + int overhaul = overhaulVo.getOverhaul(); + int overhaulFinish = overhaulVo.getOverhaulFinish(); + task.setOverhaul(overhaul); + task.setOverhaulFinish(overhaulFinish); + countDownLatch.countDown(); + }); + // 巡检 + exe.execute(()->{ + // 巡检任务 + DutyInspectTaskVO inspectTask = taskService.task(start,end,list); + if(ObjectUtil.isEmpty(inspectTask)){ + task.setInspect(0); + task.setInspectFinish(0); + }else{ + int inspect = inspectTask.getInspectTaskSum(); + int inspectFinish = inspectTask.getInspectTaskFinish(); + task.setInspect(inspect); + task.setInspectFinish(inspectFinish); + } + countDownLatch.countDown(); + }); + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + return (task.getMaintainSum() + task.getShortagesSum() + task.getOverhaul() + task.getInspect()) + "|" + + (task.getMaintainFinish() + task.getShortages() + task.getOverhaulFinish() + task.getInspectFinish()); + } + + /** + * 厂站运行情况 + * + * @param list + * @param areaDutyVo + */ + private void factoryStationRun(List deviceList,List list, AreaDutyVo areaDutyVo) { + areaDutyVo.setStationSum(0); + areaDutyVo.setStationRun(0); + if (CollectionUtil.isEmpty(list) || CollectionUtil.isEmpty(deviceList)) { + return; + } + areaDutyVo.setStationSum(list.size()); + List deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deptList)){ + log.info("run_station_dept_list_null : {}",areaDutyVo.getDepartName()); + return; + } + // 过滤未绑定设备 + List codes = deviceList.stream().filter(o->deptList.contains(o.getCreateDept())).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList()); + R> R = deviceInstanceClient.getListAnalyseCode(codes); + if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) { + log.info("run_station_valid_device_null : {}",areaDutyVo.getDepartName()); + return; + } + // 根据机构分组 + Map> map = deviceList.stream().filter(o->R.getData().contains(o.getEmCode())).collect(Collectors.groupingBy(EminfoAndEmParamVo::getCreateDept)); + if(CollectionUtil.isEmpty(map)){ + log.info("run_station_group_by_valid_null : {}",areaDutyVo.getDepartName()); + return; + } + int runCount = 0; + // 遍历分组设备 + for(Map.Entry> entry : map.entrySet()){ + // 运行设备code集合 + List runCodes = entry.getValue().stream().filter(o -> (Func.isEmpty(o.getRunStatus()) || "1".equals(o.getRunStatus()))).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(runCodes)){ + return; + } + runCount++; + } + areaDutyVo.setStationRun(runCount); + areaDutyVo.setStationSum(list.size()); + } + + /** + * 当月任务执行情况 + * + * @param list + * @param areaDutyVo + */ + private void executeTaskMonth(List list, AreaDutyVo areaDutyVo) { + if (CollectionUtil.isEmpty(list)) { + areaDutyVo.setMaintainSumMoth(0); + areaDutyVo.setMaintainFinishSumMoth(0); + areaDutyVo.setMaintainRateMoth("0"); + areaDutyVo.setShortagesSumMoth(0); + areaDutyVo.setShortagesMoth(0); + areaDutyVo.setShortagesRateMoth("0"); + areaDutyVo.setOverhaulSumMoth(0); + areaDutyVo.setOverhaulFinishSumMoth(0); + areaDutyVo.setOverhaulRateMoth("0"); + areaDutyVo.setOperateSumMoth(0); + areaDutyVo.setOperateQualifySumMoth(0); + areaDutyVo.setOperateRateMoth("0"); + areaDutyVo.setWorkSumMoth(0); + areaDutyVo.setWorkQualifySumMoth(0); + areaDutyVo.setWorkRateMoth("0"); + return; + } + LocalDate firstDay = LocalDate.now().withDayOfMonth(1); + String start = DateUtil.format(new Date(),"yyyy-MM") + "-01 00:00:00"; + String end = DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME); + //通过线程池异步获取月报各模块内容 主要分为五块内容 + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("month-task-pool-%d").build(); + ScheduledExecutorService exe = new ScheduledThreadPoolExecutor(4, namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); + //监控线程执行完后返回结果 + CountDownLatch countDownLatch = new CountDownLatch(4); + // 日常维护 + exe.execute(()->{ + MaintainVo maintainVo = maintenanceService.maintain(start,end,list); + int maintainSum = maintainVo.getMaintain(); + int maintainFinish = maintainVo.getMaintainFinish(); + areaDutyVo.setMaintainSumMoth(maintainSum); + areaDutyVo.setMaintainFinishSumMoth(maintainFinish); + if (maintainFinish == 0) { + areaDutyVo.setMaintainRateMoth("0"); + } else { + double maintainRate = BigDecimal.valueOf(maintainFinish / (double)maintainSum * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setMaintainRateMoth(String.valueOf(maintainRate)); + } + countDownLatch.countDown(); + }); + + // 消缺 + exe.execute(()->{ + ShortagesVo shortagesVo = phenomenonService.defectMonth(start,end,list); + int shortagesSum = shortagesVo.getShortagesSum(); + int shortages = shortagesVo.getShortages(); + areaDutyVo.setShortagesSumMoth(shortagesSum); + areaDutyVo.setShortagesMoth(shortages); + if (Math.abs(shortagesSum) <= 0) { + areaDutyVo.setShortagesRateMoth("0"); + } else { + double shortagesRate = BigDecimal.valueOf(shortages / (double)shortagesSum * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setShortagesRateMoth(String.valueOf(shortagesRate)); + } + countDownLatch.countDown(); + }); + // 检修 + exe.execute(()->{ + OverhaulVo overhaulVo = accessService.overhaul(start,end,list); + int overhaul = overhaulVo.getOverhaul(); + int overhaulFinish = overhaulVo.getOverhaulFinish(); + areaDutyVo.setOverhaulSumMoth(overhaul); + areaDutyVo.setOverhaulFinishSumMoth(overhaulFinish); + if (overhaulFinish == 0) { + areaDutyVo.setOverhaulRateMoth("0"); + } else { + double overhaulRate = BigDecimal.valueOf(overhaulFinish / (double)overhaul * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setOverhaulRateMoth(String.valueOf(overhaulRate)); + } + countDownLatch.countDown(); + }); + // 操作票&工作票 + exe.execute(()->{ + TicketMonthVO ticket = ticketService.operateWork(start,end,list); + if (ObjectUtil.isEmpty(ticket)) { + areaDutyVo.setOperateSumMoth(0); + areaDutyVo.setOperateQualifySumMoth(0); + areaDutyVo.setOperateRateMoth("0"); + areaDutyVo.setWorkSumMoth(0); + areaDutyVo.setWorkQualifySumMoth(0); + areaDutyVo.setWorkRateMoth("0"); + countDownLatch.countDown(); + return; + } + int operate = ticket.getOperate(); + int operateQualify = ticket.getOperateQualify(); + areaDutyVo.setOperateSumMoth(operate); + areaDutyVo.setOperateQualifySumMoth(operateQualify); + if (operateQualify == 0) { + areaDutyVo.setOperateRateMoth("0"); + } else { + double operateRate = BigDecimal.valueOf(operateQualify / (double)operate * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setOperateRateMoth(String.valueOf(operateRate)); + } + // 工作票 + int work = ticket.getWork(); + int workQualify = ticket.getWorkQualify(); + areaDutyVo.setWorkSumMoth(work); + areaDutyVo.setWorkQualifySumMoth(workQualify); + if (workQualify == 0) { + areaDutyVo.setWorkRateMoth("0"); + } else { + double workRate = BigDecimal.valueOf(workQualify / (double)work * 100L).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setWorkRateMoth(String.valueOf(workRate)); + } + countDownLatch.countDown(); + }); + + // 等待所有线程执行完成 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + exe.shutdown(); + } + + /** + * 上一班组发电量 + * @param dutyList + * @param deviceList + * @param value + * @param areaDutyVo + */ + private void upDutyPower(List dutyList, List deviceList,Long deptId, List value, AreaDutyVo areaDutyVo) { + List list = dutyList.stream().filter(o -> deptId.equals(o.getCreateDept())).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(list)) { + return; + } + NextDutyInfoVo upDutyInfoVo = dutyList.get(0).getUpDutyInfoVo(); + if(ObjectUtil.isEmpty(upDutyInfoVo)){ + return; + } + // 上一班组开始时间、结束时间 + Date startDate = this.dutyStartTime(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime()); + Date endDate = this.dutyEndTime(upDutyInfoVo.getDateTime(),upDutyInfoVo.getStartTime(),upDutyInfoVo.getEndTime()); + // 获取时间断内发电量 + this.dutyPower(startDate,endDate,deviceList,value,areaDutyVo,true); + } + + /** + * 班组实时发电量 + * @param startDate + * @param endDate + * @param deviceList + * @param list + * @param areaDutyVo + */ + private void dutyPower(Date startDate, Date endDate, List deviceList,List list,AreaDutyVo areaDutyVo,boolean flag) { + areaDutyVo.setGeneratingCapacity(0); + List deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deptList)){ + return; + } + // 区域站点下设备 + List devices = deviceList.stream().filter(o->deptList.contains(o.getCreateDept())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(devices)){ + return; + } + // 获取当班时间内发电量 + float generatingCapacity = this.generateByDuty(devices,startDate,endDate); + // 是否为查询上一班组发电量 + if(flag){ + NextDutyInfoVo upDutyInfoVo = areaDutyVo.getUpDutyInfoVo(); + upDutyInfoVo.setGeneratingCapacity(generatingCapacity); + areaDutyVo.setUpDutyInfoVo(upDutyInfoVo); + return; + } + areaDutyVo.setGeneratingCapacity(generatingCapacity); + } + + /*** + * 根据当班时间查询发电量 + * @param devices + * @param start + * @param end + * @return + */ + private float generateByDuty(List devices, Date start, Date end) { + float generate = 0f; + if(CollectionUtil.isEmpty(devices)){ + return generate; + } + for(EminfoAndEmParamVo device : devices ){ + generate += analyseDataService.periodTargetFloat(DateUtil.format(start,DateUtil.PATTERN_DATETIME),DateUtil.format(end,DateUtil.PATTERN_DATETIME),5,3,device.getEmCode(),device.getRideCount(),HomePageConstant.HYDROPOWER_GENERATE_POWER); + } + return generate; + } + + /** + * 当班双票 + * @param startDate + * @param endDate + * @param list + * @param areaDutyVo + */ + private void dutyDoubleTicket(Date startDate,Date endDate, List list,AreaDutyVo areaDutyVo) { + String start = DateUtil.format(startDate,"yyyy-MM") + "-01 00:00:00"; + String end = DateUtil.format(endDate,DateUtil.PATTERN_DATETIME); + if (CollectionUtil.isEmpty(list)) { + areaDutyVo.setWorkTicketCount(0); + areaDutyVo.setHandoverTicketCount(0); + areaDutyVo.setVoidTicketCount(0); + areaDutyVo.setDeferredTicketCount(0); + areaDutyVo.setCloseTicketCount(0); + areaDutyVo.setOperationTicketCount(0); + return; + } + WorkTicketStatisticVO work = workTicketService.work(start,end,list); + if (ObjectUtil.isEmpty(work)) { + areaDutyVo.setWorkTicketCount(0); + areaDutyVo.setHandoverTicketCount(0); + areaDutyVo.setVoidTicketCount(0); + areaDutyVo.setDeferredTicketCount(0); + areaDutyVo.setCloseTicketCount(0); + }else{ + areaDutyVo.setWorkTicketCount(work.getTotal()); + areaDutyVo.setHandoverTicketCount(work.getTransfer()); + areaDutyVo.setVoidTicketCount(work.getInvalid()); + areaDutyVo.setDeferredTicketCount(work.getDelay()); + areaDutyVo.setCloseTicketCount(work.getComplete()); + } + // 查询操作票 + Integer operater = ticketService.operate(start,end,list); + areaDutyVo.setOperationTicketCount(operater); + } + + /** + * 当班运行数据 + * @param start + * @param end + * @param childList + * @param areaDutyVo + */ + private void dutyRunCondition(Date startTime, Date endTime, List areas,AreaDutyVo areaDutyVo) { + String start = DateUtil.format(startTime,DateUtil.PATTERN_DATETIME); + String end = DateUtil.format(endTime,DateUtil.PATTERN_DATETIME); + // 巡检任务 + DutyInspectTaskVO task = taskService.task(start,end,areas); + areaDutyVo.setInspectionSum(0); + areaDutyVo.setInspectionFinish(0); + if(ObjectUtil.isNotEmpty(task)){ + areaDutyVo.setInspectionSum(task.getInspectTaskSum()); + areaDutyVo.setInspectionFinish(task.getInspectTaskFinish()); + if(Math.abs(task.getInspectTaskSum()) <= 0){ + areaDutyVo.setInspectionFinishRate(0.0); + }else{ + double inspectionFinishRate = BigDecimal.valueOf(task.getInspectTaskFinish() / (double)task.getInspectTaskSum() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setInspectionFinishRate(inspectionFinishRate); + } + areaDutyVo.setInspectTaskIds(task.getInspectTaskIds()); + } + + // 消缺 + DutyDefectVO defect = phenomenonService.defect(start,end,areas); + areaDutyVo.setShortagesSum(0); + areaDutyVo.setShortages(0); + if(ObjectUtil.isNotEmpty(defect)){ + areaDutyVo.setShortagesSum(defect.getDefectSum()); + areaDutyVo.setShortages(defect.getDefect()); + areaDutyVo.setPhenomenonIds(defect.getTotalIds()); + if(Math.abs(defect.getDefectSum()) <= 0){ + areaDutyVo.setShortagesRate(0.0); + }else{ + double shortagesRate = BigDecimal.valueOf(defect.getDefect() / (double)defect.getDefectSum() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setShortagesRate(shortagesRate); + } + } + // 定期工作 + RegularWorkVO regular = maintenanceService.regularWork(startTime,endTime,areas); + areaDutyVo.setWorkRegularlySum(0); + areaDutyVo.setWorkRegularly(0); + if(ObjectUtil.isNotEmpty(regular)){ + areaDutyVo.setWorkRegularlySum(regular.getRegularWorkSum()); + areaDutyVo.setWorkRegularly(regular.getRegularWork()); + areaDutyVo.setMainTaskIds(regular.getMainTaskIds()); + if(Math.abs(areaDutyVo.getWorkRegularlySum()) <= 0){ + areaDutyVo.setWorkRegularlyRate(0.0); + }else{ + double workRegularlyRate = BigDecimal.valueOf(areaDutyVo.getWorkRegularly() / (double)areaDutyVo.getWorkRegularlySum() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + areaDutyVo.setWorkRegularlyRate(workRegularlyRate); + } + } + } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java index ff5e1ad..63d5ceb 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java @@ -16,5 +16,7 @@ public interface TicketService extends BaseService { DoublePassRateVO doublePassRate(List areas, LocalDateTime firstDateTime, LocalDateTime now); - TicketMonthVO operateWork(String start, String end, List list); + TicketMonthVO operateWork(String start, String end, List areas); + + Integer operate(String start, String end, List areas); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkDelayService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkDelayService.java new file mode 100644 index 0000000..ec3ef3c --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkDelayService.java @@ -0,0 +1,12 @@ +package com.hnac.hzims.scheduled.service.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity; +import org.springblade.core.mp.base.BaseService; + + +/** + * @author ysj + */ +public interface WorkDelayService extends BaseService { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkPrincipalService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkPrincipalService.java new file mode 100644 index 0000000..b819667 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkPrincipalService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.scheduled.service.ticket; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface WorkPrincipalService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java index 0117669..9b1f4ac 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java @@ -1,10 +1,15 @@ package com.hnac.hzims.scheduled.service.ticket; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; import org.springblade.core.mp.base.BaseService; +import java.util.List; +import java.util.Map; + /** * @author ysj */ public interface WorkTicketService extends BaseService { + WorkTicketStatisticVO work(String start, String end, List areas); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java index 62ef9a0..a108ff0 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java @@ -147,4 +147,24 @@ public class TicketServiceImpl extends BaseServiceImpl areas) { + List operates = this.list(new LambdaQueryWrapper() {{ + ge(StandardTicketInfoEntity::getStartTime, start); + le(StandardTicketInfoEntity::getStartTime, end); + in(StandardTicketInfoEntity::getCreateDept, areas); + }}); + if (CollectionUtil.isEmpty(operates)) { + return 0; + } + return operates.size(); + } + } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java new file mode 100644 index 0000000..97d6b02 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.scheduled.service.ticket.impl; + +import com.hnac.hzims.scheduled.mapper.ticket.WorkDelayMapper; +import com.hnac.hzims.scheduled.service.ticket.WorkDelayService; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class WorkDelayServiceImpl extends BaseServiceImpl implements WorkDelayService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java new file mode 100644 index 0000000..fce60fd --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.scheduled.service.ticket.impl; + +import com.hnac.hzims.scheduled.mapper.ticket.WorkPrincipalMapper; +import com.hnac.hzims.scheduled.service.ticket.WorkPrincipalService; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + +/** + * @author ysj + */ +@Service +@AllArgsConstructor +@Slf4j +public class WorkPrincipalServiceImpl extends BaseServiceImpl implements WorkPrincipalService { + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java index d859eeb..e8bb066 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java @@ -1,14 +1,28 @@ package com.hnac.hzims.scheduled.service.ticket.impl; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.scheduled.mapper.ticket.WorkTicketMapper; +import com.hnac.hzims.scheduled.service.ticket.WorkDelayService; +import com.hnac.hzims.scheduled.service.ticket.WorkPrincipalService; import com.hnac.hzims.scheduled.service.ticket.WorkTicketService; +import com.hnac.hzims.ticket.constants.TicketConstants; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketDelayEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.FutureTask; +import java.util.stream.Collectors; + /** * @author ysj @@ -18,4 +32,55 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor @DS("ticket") public class WorkTicketServiceImpl extends BaseServiceImpl implements WorkTicketService { + + private WorkPrincipalService workPrincipalService; + private WorkDelayService workDelayService; + + @Override + public WorkTicketStatisticVO work(String start, String end, List areas) { + WorkTicketStatisticVO work = new WorkTicketStatisticVO(); + List infoList = this.list(new LambdaQueryWrapper() {{ + ge(WorkTicketInfoEntity::getPlanStartTime, start); + le(WorkTicketInfoEntity::getPlanStartTime, end); + in(WorkTicketInfoEntity::getCreateDept, areas); + }}); + if (CollectionUtil.isNotEmpty(infoList)) { + List infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList()); + work.setTotal(infoList.size()); + //工作票作废 + List invalidList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.INVALID.getStatus().equals(w.getStatus())) + .collect(Collectors.toList()); + work.setInvalid(CollectionUtil.isNotEmpty(invalidList) ? invalidList.size() : 0); + // 工作票完成数 + List completeList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.FINISH.getStatus().equals(w.getStatus())) + .collect(Collectors.toList()); + work.setComplete(CollectionUtil.isNotEmpty(completeList) ? completeList.size() : 0); + //工作票移交 + FutureTask transferTask = new FutureTask(() -> { + List moveList = workPrincipalService.list(new LambdaQueryWrapper() {{ + in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList); + }}); + return CollectionUtil.isNotEmpty(moveList) ? moveList.size() : 0; + }); + + new Thread(transferTask, "工作票移交Thread").start(); + //工作票延期 + FutureTask delayTask = new FutureTask(() -> { + log.info("开始工作票延期"); + List delayEntityList = workDelayService.list(Wrappers.lambdaQuery() + .in(WorkTicketDelayEntity::getTicketId, infoIdList) + ); + return CollectionUtil.isNotEmpty(delayEntityList) ? delayEntityList.size() : 0; + }); + new Thread(delayTask, "工作票延期Thread").start(); + try { + work.setDelay((Integer) delayTask.get()); + work.setTransfer((Integer) transferTask.get()); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + } + } + return work; + } } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml new file mode 100644 index 0000000..6078ecc --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml new file mode 100644 index 0000000..6efe983 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml @@ -0,0 +1,34 @@ + + + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml new file mode 100644 index 0000000..d4dca99 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml new file mode 100644 index 0000000..74634e7 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml new file mode 100644 index 0000000..cae0516 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java index 7d58740..84a660b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java @@ -29,7 +29,7 @@ import com.hnac.hzims.operational.main.vo.*; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; -import com.hnac.hzims.operational.maintenance.vo.RegularWorkVO; +import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.report.vo.DutyDefectVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.service.IStationService; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java index 45098e1..c821f1c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java @@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; -import com.hnac.hzims.operational.maintenance.vo.RegularWorkVO; +import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index b253525..f744297 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -10,21 +10,18 @@ import com.google.common.collect.Lists; 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.ImsDutyClassEntity; -import com.hnac.hzims.operational.duty.service.IImsDutyClassService; -import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; -import com.hnac.hzims.operational.maintenance.vo.RegularWorkVO; -import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; +import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.maintenance.constants.DictConstant; import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; +import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper; +import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; -import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.vo.SafeCheckStatisticVO; @@ -53,7 +50,6 @@ import org.springframework.util.CollectionUtils; import java.text.DecimalFormat; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.atomic.AtomicReference; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/vo/RegularWorkVO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/vo/RegularWorkVO.java deleted file mode 100644 index 747e37d..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/vo/RegularWorkVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.hnac.hzims.operational.maintenance.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * 定期工作 - */ -@Data -public class RegularWorkVO{ - - @ApiModelProperty("定期工作总数") - private Integer regularWorkSum; - - @ApiModelProperty("修改人名称") - private Integer regularWork; - - @ApiModelProperty("日常维护任务Id 按逗号分隔") - private String mainTaskIds; -}