Browse Source

#定时任务抽离

zhongwei
yang_shj 1 year ago
parent
commit
455ccee19e
  1. 2
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java
  2. 27
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyGroupMapper.java
  3. 20
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyMapper.java
  4. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/operation/DutyPersonMapper.java
  5. 16
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkDelayMapper.java
  6. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/ticket/WorkPrincipalMapper.java
  7. 13
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/ShowScheduledTask.java
  8. 15
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/DutyService.java
  9. 6
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/MaintenanceService.java
  10. 3
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/PhenomenonService.java
  11. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/ShowService.java
  12. 176
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/DutyServiceImpl.java
  13. 36
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/MaintenanceServiceImpl.java
  14. 39
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/PhenomenonServiceImpl.java
  15. 719
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/impl/ShowServiceImpl.java
  16. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java
  17. 12
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkDelayService.java
  18. 11
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkPrincipalService.java
  19. 5
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/WorkTicketService.java
  20. 20
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/TicketServiceImpl.java
  21. 19
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkDelayServiceImpl.java
  22. 20
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkPrincipalServiceImpl.java
  23. 65
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/impl/WorkTicketServiceImpl.java
  24. 4
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml
  25. 34
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml
  26. 4
      hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml
  27. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml
  28. 5
      hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml
  29. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/SideHustleServiceImpl.java
  30. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java
  31. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/vo/RegularWorkVO.java → hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RegularWorkVO.java

@ -1,4 +1,4 @@
package com.hnac.hzims.operational.maintenance.vo; package com.hnac.hzims.operational.main.vo;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;

27
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<ImsDutyGroupEntity> {
/**
* 根据班组ID修改负责人为null
* @param id
* @return
*/
int updateManagerIdById(Long id);
@UserDataAuth
List<ImsDutyGroupEntity> selectDutyGroupJoinDutyMain(@Param("startDate") String startDate, @Param("endDate") String endDate);
}

20
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<ImsDutyMainEntity> {
List<DutyInfoVo> dutyData(List<Long> collect);
DutyMainInfoVo queryDuty(Long preDutyId);
DutyMainInfoVo selectDuty(Long preDutyId);
}

11
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<ImsDutyMainPersonEntity> {
}

16
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;
/**
* <p>
* 工作票延期 Mapper 接口
* </p>
*
* @author hx
* @since 2021-10-22
*/
public interface WorkDelayMapper extends UserDataScopeBaseMapper<WorkTicketDelayEntity> {
}

11
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<WorkTicketPrincipalChangeEntity> {
}

13
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 java.util.Date;
import static com.hnac.hzims.operational.main.constant.MainConstants.LOAD_HOME_TARGET; 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); service.loadHomeTarget(param);
return new ReturnT<>("SUCCESS"); return new ReturnT<>("SUCCESS");
} }
/**
* 首页-区域班组数据
*/
@XxlJob(REGIONAL_DUTY_INFO)
public ReturnT<String> 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");
}
} }

15
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<ImsDutyMainEntity> {
List<DutyInfoVo> dutyData(List<Long> collect);
}

6
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; package com.hnac.hzims.scheduled.service.operation;
import com.hnac.hzims.operational.main.vo.MaintainVo; 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 com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -12,7 +14,9 @@ import java.util.List;
public interface MaintenanceService extends BaseService<OperMaintenanceTaskEntity> { public interface MaintenanceService extends BaseService<OperMaintenanceTaskEntity> {
// 查询当年日常维护数量 // 查询当年日常维护数量
Integer maintenanceCount(List<Long> departList); Integer maintenanceCount(List<Long> areas);
MaintainVo maintain(String start, String end, List<Long> areas); MaintainVo maintain(String start, String end, List<Long> areas);
RegularWorkVO regularWork(Date start, Date end, List<Long> areas);
} }

3
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; package com.hnac.hzims.scheduled.service.operation;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; 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.operational.report.vo.DutyDefectVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
@ -12,4 +13,6 @@ import java.util.List;
public interface PhenomenonService extends BaseService<OperPhenomenonEntity> { public interface PhenomenonService extends BaseService<OperPhenomenonEntity> {
DutyDefectVO defect(String start, String end, List<Long> areas); DutyDefectVO defect(String start, String end, List<Long> areas);
ShortagesVo defectMonth(String start, String end, List<Long> list);
} }

2
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 { public interface ShowService {
void loadHomeTarget(String param); void loadHomeTarget(String param);
void loadRegionalDuty(String param);
} }

176
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<DutyMapper, ImsDutyMainEntity> implements DutyService {
private final DutyPersonMapper dutyPersonMapper;
private final DutyGroupMapper dutyGroupMapper;
@Override
public List<DutyInfoVo> dutyData(List<Long> collect) {
if (CollectionUtil.isEmpty(collect)) {
return null;
}
// 查询区域当前值班
List<DutyInfoVo> 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<ImsDutyMainPersonEntity>() {{
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<ImsDutyMainPersonEntity>() {{
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<ImsDutyMainPersonEntity>() {{
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;
}
}

36
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.operational.main.vo.MaintainVo; 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.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.scheduled.mapper.operation.MaintenanceMapper; import com.hnac.hzims.scheduled.mapper.operation.MaintenanceMapper;
@ -16,6 +17,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -84,5 +86,39 @@ public class MaintenanceServiceImpl extends BaseServiceImpl<MaintenanceMapper, O
return maintainVo; return maintainVo;
} }
/**
* 查询日常维护-定期工作类型数据
* @param start
* @param end
* @param areas
* @return
*/
@Override
public RegularWorkVO regularWork(Date start, Date end, List<Long> areas) {
RegularWorkVO regularWorkVO = new RegularWorkVO();
// 查询定期工作任务
List<OperMaintenanceTaskEntity> regularWorkList = this.list(new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{
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<OperMaintenanceTaskEntity> 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;
}
} }

39
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; 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.operational.report.vo.DutyDefectVO;
import com.hnac.hzims.scheduled.mapper.operation.PhenomenonMapper; import com.hnac.hzims.scheduled.mapper.operation.PhenomenonMapper;
import com.hnac.hzims.scheduled.service.operation.PhenomenonService; 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.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -57,4 +61,39 @@ public class PhenomenonServiceImpl extends BaseServiceImpl<PhenomenonMapper, Ope
defectVO.setDefect(defectList.size()); defectVO.setDefect(defectList.size());
return defectVO; return defectVO;
} }
/**
* 查询当月机构缺陷数据
* @param start
* @param end
* @param list
* @return
*/
@Override
public ShortagesVo defectMonth(String start, String end, List<Long> list) {
ShortagesVo shortagesVo = new ShortagesVo();
LocalDate firstDay = LocalDate.now().withDayOfMonth(1);
LocalDateTime firstDateTime = LocalDateTime.of(firstDay, LocalTime.MIN);
LocalDateTime now = LocalDateTime.now();
// 消缺总数
List<OperPhenomenonEntity> defects = this.list(new LambdaQueryWrapper<OperPhenomenonEntity>(){{
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<Long> 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;
}
} }

719
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; package com.hnac.hzims.scheduled.service.operation.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; 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.fill.entity.*;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.vo.*; 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.operational.station.entity.StationEntity;
import com.hnac.hzims.scheduled.service.equipment.PlanService; 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.operation.*;
import com.hnac.hzims.scheduled.service.ticket.TicketService; 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.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.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; 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.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.cache.DictCache; import org.springblade.system.cache.DictCache;
import org.springblade.system.entity.Dept; import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient; import org.springblade.system.feign.ISysClient;
@ -36,11 +49,12 @@ import java.math.BigDecimal;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -52,6 +66,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class ShowServiceImpl implements ShowService { public class ShowServiceImpl implements ShowService {
private final TaskService taskService;
private final OverService overService; private final OverService overService;
private final PlanService planService; private final PlanService planService;
private final PowerService powerService; private final PowerService powerService;
@ -60,12 +75,16 @@ public class ShowServiceImpl implements ShowService {
private final AccessService accessService; private final AccessService accessService;
private final TicketService ticketService; private final TicketService ticketService;
private final DefectService defectService; private final DefectService defectService;
private final DutyService dutyService;
private final StationService stationService; private final StationService stationService;
private final OverDetailsService detailsService; private final OverDetailsService detailsService;
private final WorkTicketService workTicketService;
private final PhenomenonService phenomenonService;
private final AnalyseDataService analyseDataService;
private final MaintenanceService maintenanceService; private final MaintenanceService maintenanceService;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final ISysClient sysClient; private final ISysClient sysClient;
private final IAnalyseInstanceClient deviceInstanceClient;
private final static String charge = "hzims:operation:key:charge"; private final static String charge = "hzims:operation:key:charge";
private final static String home_target_cache_final = "load:operation:home:target:key"; 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}") @Value("${hzims.operation.homePage.charge.url}")
public String 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())); 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<List<Dept>> R = sysClient.getDeptList();
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
return;
}
Map<Dept,List<StationEntity>> map = this.area(R.getData(),null, Collections.singletonList(HomePageConstant.HYDROPOWER),HomePageConstant.HYDROPOWER_SERVETYPE);
if (MapUtils.isEmpty(map)) {
return;
}
// 查询所有区域值班/接班数据
List<DutyInfoVo> dutyInfoVoList = dutyService.dutyData(map.keySet().stream().map(Dept::getId).collect(Collectors.toList()));
if(CollectionUtil.isEmpty(dutyInfoVoList)){
return;
}
// 所有设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_cofig_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
List<AreaDutyVo> areaDutyVoList = new ArrayList<>();
map.forEach((key,value) -> {
List<Long> 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<DutyInfoVo> 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 * @return
@ -477,4 +560,626 @@ public class ShowServiceImpl implements ShowService {
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
/**
* 获取权限区域
* @param list : 机构列表
* @param deptId : 起始过滤权限机构
* @param typeList : 查询站点类型-水电水利光伏....
* @param serveType : 站点服务类型
* @return Map<Dept, List<StationEntity>>
*/
private Map<Dept, List<StationEntity>> area(List<Dept> list,Long deptId, List<Integer> typeList, Integer serveType) {
// 未传入机构列表,使用用户权限机构过滤
if(CollectionUtil.isEmpty(list)){
R<List<Dept>> R = sysClient.getDeptByCurrentUser();
if(!R.isSuccess() || CollectionUtil.isEmpty(R.getData())){
return null;
}
list = R.getData();
}
// 根据参数查询有效站点
List<StationEntity> stationList = this.stationByParams(list,deptId,typeList,serveType);
if(CollectionUtil.isEmpty(stationList)){
return null;
}
// 有效站点归属机构Id集合
List<Long> refDeptList = stationList.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(refDeptList)){
return null;
}
// 有效站点归属机构集合
List<Dept> vaildDeptList = list.stream().filter(o->refDeptList.contains(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(vaildDeptList)){
return null;
}
// 根据有效站点归属机构向上区域Id
List<Long> areaIdList = vaildDeptList.stream().map(Dept::getParentId).distinct().collect(Collectors.toList());
if(CollectionUtil.isEmpty(areaIdList)){
return null;
}
// 根据区域Id查询区域机构
List<Dept> areaList = list.stream().filter(o->o.getDeptCategory().equals(HomePageConstant.AREA) && areaIdList.contains(o.getId())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(areaList)){
return null;
}
// 返回结构
Map<Dept, List<StationEntity>> result = new HashMap<>();
for(Dept area : areaList){
List<Long> childDeptIdList = list.stream().filter(o->o.getParentId().equals(area.getId())).map(Dept::getId).collect(Collectors.toList());
if(CollectionUtil.isEmpty(childDeptIdList)){
continue;
}
List<StationEntity> 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<StationEntity> stationByParams(List<Dept> authList, Long deptId, List<Integer> types, Integer servrType) {
Dept dept;
if (null == deptId) {
// 最小类型机构
Optional<Dept> min = authList.stream().min(Comparator.comparing(Dept::getDeptCategory));
dept = min.orElse(null);
if (ObjectUtil.isEmpty(dept)) {
return null;
}
} else {
// 检查是否存在传入机构
List<Dept> list = authList.stream().filter(o -> deptId.equals(o.getId())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(list)) {
return null;
}
// 传入机构为站点
dept = list.get(0);
}
List<Long> 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<StationEntity>() {{
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<Long> stationDept(List<Dept> departList, Long deptId, List<Long> 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<DutyInfoVo> dutyInfoVoList, Dept dept, AreaDutyVo areaDutyVo) {
if (CollectionUtil.isEmpty(dutyInfoVoList) || ObjectUtil.isEmpty(dept)) {
return;
}
Long deptId = dept.getId();
List<DutyInfoVo> 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<Long> 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<EminfoAndEmParamVo> deviceList,List<StationEntity> list, AreaDutyVo areaDutyVo) {
areaDutyVo.setStationSum(0);
areaDutyVo.setStationRun(0);
if (CollectionUtil.isEmpty(list) || CollectionUtil.isEmpty(deviceList)) {
return;
}
areaDutyVo.setStationSum(list.size());
List<Long> deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deptList)){
log.info("run_station_dept_list_null : {}",areaDutyVo.getDepartName());
return;
}
// 过滤未绑定设备
List<String> codes = deviceList.stream().filter(o->deptList.contains(o.getCreateDept())).map(EminfoAndEmParamVo::getEmCode).collect(Collectors.toList());
R<List<String>> R = deviceInstanceClient.getListAnalyseCode(codes);
if (!R.isSuccess() || CollectionUtil.isEmpty(R.getData())) {
log.info("run_station_valid_device_null : {}",areaDutyVo.getDepartName());
return;
}
// 根据机构分组
Map<Long, List<EminfoAndEmParamVo>> 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<Long, List<EminfoAndEmParamVo>> entry : map.entrySet()){
// 运行设备code集合
List<String> 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<Long> 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<DutyInfoVo> dutyList, List<EminfoAndEmParamVo> deviceList,Long deptId, List<StationEntity> value, AreaDutyVo areaDutyVo) {
List<DutyInfoVo> 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<EminfoAndEmParamVo> deviceList,List<StationEntity> list,AreaDutyVo areaDutyVo,boolean flag) {
areaDutyVo.setGeneratingCapacity(0);
List<Long> deptList = list.stream().map(StationEntity::getRefDept).collect(Collectors.toList());
if(CollectionUtil.isEmpty(deptList)){
return;
}
// 区域站点下设备
List<EminfoAndEmParamVo> 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<EminfoAndEmParamVo> 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<Long> 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<Long> 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);
}
}
}
} }

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/ticket/TicketService.java

@ -16,5 +16,7 @@ public interface TicketService extends BaseService<StandardTicketInfoEntity> {
DoublePassRateVO doublePassRate(List<Long> areas, LocalDateTime firstDateTime, LocalDateTime now); DoublePassRateVO doublePassRate(List<Long> areas, LocalDateTime firstDateTime, LocalDateTime now);
TicketMonthVO operateWork(String start, String end, List<Long> list); TicketMonthVO operateWork(String start, String end, List<Long> areas);
Integer operate(String start, String end, List<Long> areas);
} }

12
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<WorkTicketDelayEntity> {
}

11
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<WorkTicketPrincipalChangeEntity> {
}

5
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; package com.hnac.hzims.scheduled.service.ticket;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/** /**
* @author ysj * @author ysj
*/ */
public interface WorkTicketService extends BaseService<WorkTicketInfoEntity> { public interface WorkTicketService extends BaseService<WorkTicketInfoEntity> {
WorkTicketStatisticVO work(String start, String end, List<Long> areas);
} }

20
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<TicketMapper, StandardTic
return ticket; return ticket;
} }
/**
* 操作票查询
* @param start
* @param end
* @param areas
* @return
*/
@Override
public Integer operate(String start, String end, List<Long> areas) {
List<StandardTicketInfoEntity> operates = this.list(new LambdaQueryWrapper<StandardTicketInfoEntity>() {{
ge(StandardTicketInfoEntity::getStartTime, start);
le(StandardTicketInfoEntity::getStartTime, end);
in(StandardTicketInfoEntity::getCreateDept, areas);
}});
if (CollectionUtil.isEmpty(operates)) {
return 0;
}
return operates.size();
}
} }

19
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<WorkDelayMapper, WorkTicketDelayEntity> implements WorkDelayService {
}

20
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<WorkPrincipalMapper, WorkTicketPrincipalChangeEntity> implements WorkPrincipalService {
}

65
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; package com.hnac.hzims.scheduled.service.ticket.impl;
import com.baomidou.dynamic.datasource.annotation.DS; 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.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.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.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketPrincipalChangeEntity;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketStatisticVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.stereotype.Service; 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 * @author ysj
@ -18,4 +32,55 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor @RequiredArgsConstructor
@DS("ticket") @DS("ticket")
public class WorkTicketServiceImpl extends BaseServiceImpl<WorkTicketMapper, WorkTicketInfoEntity> implements WorkTicketService { public class WorkTicketServiceImpl extends BaseServiceImpl<WorkTicketMapper, WorkTicketInfoEntity> implements WorkTicketService {
private WorkPrincipalService workPrincipalService;
private WorkDelayService workDelayService;
@Override
public WorkTicketStatisticVO work(String start, String end, List<Long> areas) {
WorkTicketStatisticVO work = new WorkTicketStatisticVO();
List<WorkTicketInfoEntity> infoList = this.list(new LambdaQueryWrapper<WorkTicketInfoEntity>() {{
ge(WorkTicketInfoEntity::getPlanStartTime, start);
le(WorkTicketInfoEntity::getPlanStartTime, end);
in(WorkTicketInfoEntity::getCreateDept, areas);
}});
if (CollectionUtil.isNotEmpty(infoList)) {
List<Long> infoIdList = infoList.stream().map(WorkTicketInfoEntity::getId).collect(Collectors.toList());
work.setTotal(infoList.size());
//工作票作废
List<WorkTicketInfoEntity> invalidList = infoList.stream().filter(w -> TicketConstants.FirstWorkTicketFlowStatusEnum.INVALID.getStatus().equals(w.getStatus()))
.collect(Collectors.toList());
work.setInvalid(CollectionUtil.isNotEmpty(invalidList) ? invalidList.size() : 0);
// 工作票完成数
List<WorkTicketInfoEntity> 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<WorkTicketPrincipalChangeEntity> moveList = workPrincipalService.list(new LambdaQueryWrapper<WorkTicketPrincipalChangeEntity>() {{
in(WorkTicketPrincipalChangeEntity::getTicketId, infoIdList);
}});
return CollectionUtil.isNotEmpty(moveList) ? moveList.size() : 0;
});
new Thread(transferTask, "工作票移交Thread").start();
//工作票延期
FutureTask delayTask = new FutureTask(() -> {
log.info("开始工作票延期");
List<WorkTicketDelayEntity> delayEntityList = workDelayService.list(Wrappers.<WorkTicketDelayEntity>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;
}
} }

4
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyGroupMapper.xml

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

34
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyMapper.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.scheduled.mapper.operation.DutyMapper">
<select id="dutyData" resultType="com.hnac.hzims.operational.duty.vo.DutyInfoVo">
SELECT DM.DUTY_GROUP_ID AS groupId ,DC.CLASS_NAME, DC.START_TIME, DC.END_TIME,
DM.DUTY_DATE DATE_TIME,DM.ID,DM.PRE_DUTY_ID,DM.CREATE_DEPT
FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC
ON DM.CLASS_ID = DC.ID
WHERE DM.STATUS = '1'
AND DM.CREATE_DEPT IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="queryDuty" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo">
SELECT DM.ID,DM.DUTY_GROUP_ID AS dutyGroupId,DM.DUTY_DATE DATE_TIME, DC.`CLASS_NAME`,DC.`START_TIME`, DC.`END_TIME`
FROM hz_ims_duty_main DM JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID`
AND DM.ID = #{dutyId}
order by DM.duty_date desc
limit 1;
</select>
<select id="selectDuty" resultType="com.hnac.hzims.operational.duty.vo.DutyMainInfoVo">
SELECT DM.*, DC.`CLASS_NAME` as managerId, DC.`START_TIME`, DC.`END_TIME`
FROM hz_ims_duty_main DM
JOIN hz_ims_duty_class DC
ON DM.`CLASS_ID` = DC.`ID`
WHERE DM.PRE_DUTY_ID = #{preDutyId}
order by DM.duty_date desc
limit 1;
</select>
</mapper>

4
hzims-service/hzims-scheduled/src/main/resources/mapper/operation/DutyPersonMapper.xml

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

5
hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkDelayMapper.xml

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

5
hzims-service/hzims-scheduled/src/main/resources/mapper/ticket/WorkPrincipalMapper.xml

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

2
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.constants.MaintenanceConstant;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; 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.report.vo.DutyDefectVO;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;

2
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.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; 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.operational.report.vo.MaintenanceReportVO;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo;

10
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.constants.DefectConstant;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper;
import com.hnac.hzims.operational.duty.entity.ImsDutyClassEntity; import com.hnac.hzims.operational.main.vo.RegularWorkVO;
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.maintenance.constants.DictConstant; import com.hnac.hzims.operational.maintenance.constants.DictConstant;
import com.hnac.hzims.operational.maintenance.constants.MaintenanceConstant; 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.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper; 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.Constants;
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; 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.MaintenanceTaskVo;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo;
import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzims.vo.SafeCheckStatisticVO;
@ -53,7 +50,6 @@ import org.springframework.util.CollectionUtils;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;

Loading…
Cancel
Save