Browse Source

#工作任务单序号修改

zhongwei
yang_shj 7 months ago
parent
commit
a0244d9ea3
  1. 6
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java
  2. 2
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java
  3. 18
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java
  4. 33
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  5. 28
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java

6
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/repair/entity/WorkTaskEntity.java

@ -28,6 +28,9 @@ public class WorkTaskEntity extends TenantEntity {
private static final long serialVersionUID = -3122149146340663132L; private static final long serialVersionUID = -3122149146340663132L;
@ApiModelProperty(value = "序号")
private String number;
@ApiModelProperty(value = "工作任务单编号") @ApiModelProperty(value = "工作任务单编号")
private String code; private String code;
@ -58,9 +61,6 @@ public class WorkTaskEntity extends TenantEntity {
@ApiModelProperty(value = "工作计划结束时间") @ApiModelProperty(value = "工作计划结束时间")
private Date planEndTime; private Date planEndTime;
@ApiModelProperty(value = "工作票据ID")
private Long workTicketId;
@ApiModelProperty(value = "工作任务") @ApiModelProperty(value = "工作任务")
private String workTask; private String workTask;

2
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java

@ -274,7 +274,7 @@ public class AlarmServiceImpl implements AlarmService {
alarm.setType(Integer.parseInt(entity.getType())); alarm.setType(Integer.parseInt(entity.getType()));
alarm.setStation(entity.getStationId()); alarm.setStation(entity.getStationId());
alarm.setRealId(entity.getRealId()); alarm.setRealId(entity.getRealId());
alarm.setContext(entity.getSoeExplain()); alarm.setContext(entity.getStationName() + "." + entity.getSoeExplain());
alarm.setState(entity.getStatus()); alarm.setState(entity.getStatus());
log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm));
mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm));

18
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java

@ -78,6 +78,9 @@ public class MonitorServiceImpl implements MonitorService {
private final IAnalyseDataSearchClient analyseDataSearchClient; private final IAnalyseDataSearchClient analyseDataSearchClient;
private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
@Value("${hzims.equipment.emInfo.emInfoList}") @Value("${hzims.equipment.emInfo.emInfoList}")
public String device_cache_final; public String device_cache_final;
@ -312,16 +315,14 @@ public class MonitorServiceImpl implements MonitorService {
// 分割,每个map限制10个长度 // 分割,每个map限制10个长度
List<Map<String, List<StationAttributeEntity>>> handleList = this.mapChunk(stationAttbtMap); List<Map<String, List<StationAttributeEntity>>> handleList = this.mapChunk(stationAttbtMap);
// 创建线程池 // 创建线程池
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("load-monitoring-pool-%d").build(); CountDownLatch countDownLatch = new CountDownLatch(handleList.size());
ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
CountDownLatch countDownLatch = new CountDownLatch(handleList.size());
// 所有机构 // 所有机构
R<List<Dept>> deptAll = sysClient.getDeptList(); R<List<Dept>> deptAll = sysClient.getDeptList();
// 存储数据节点 // 存储数据节点
List<RealStationVo> stationList = new CopyOnWriteArrayList<>(); List<RealStationVo> stationList = new CopyOnWriteArrayList<>();
pool.execute(()->{ // 线程处理数据
// 线程处理数据 for(Map<String, List<StationAttributeEntity>> item : handleList){
for(Map<String, List<StationAttributeEntity>> item : handleList){ pool.submit(()->{
item.forEach((key,value)->{ item.forEach((key,value)->{
RealStationVo station = new RealStationVo(); RealStationVo station = new RealStationVo();
// 站点编码 // 站点编码
@ -353,8 +354,8 @@ public class MonitorServiceImpl implements MonitorService {
stationList.add(station); stationList.add(station);
}); });
countDownLatch.countDown(); countDownLatch.countDown();
} });
}); }
// 等待所有线程执行完成 // 等待所有线程执行完成
try { try {
countDownLatch.await(); countDownLatch.await();
@ -362,7 +363,6 @@ public class MonitorServiceImpl implements MonitorService {
e.printStackTrace(); e.printStackTrace();
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
pool.shutdown();
redisTemplate.opsForValue().set(moniter_station_cache_final, stationList); redisTemplate.opsForValue().set(moniter_station_cache_final, stationList);
} }

33
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -167,8 +167,10 @@ public class HydropowerServiceImpl implements HydropowerService {
response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode())); response.setPlanPowerMon(this.getPlanPowerrMon(station.getCode()));
// 年计划发电量 // 年计划发电量
response.setPlanPowerYear(this.getPlanPowerYear(station.getCode())); response.setPlanPowerYear(this.getPlanPowerYear(station.getCode()));
// 月发电量、年发电量、年发电完成率 // 年发电量、年发电完成率
this.handleStationInfo(station.getRefDept(),response); this.handleStationInfo(station.getRefDept(),response);
// 月发电量
this.stationMonthPower(station.getId(),map,response);
// 水位、水位曲线 // 水位、水位曲线
this.handleWaterLeve(station.getCode(),response); this.handleWaterLeve(station.getCode(),response);
// 年发电量完成百分比 // 年发电量完成百分比
@ -178,7 +180,6 @@ public class HydropowerServiceImpl implements HydropowerService {
return response; return response;
} }
/** /**
* 水电站-机组列表 * 水电站-机组列表
* @param deptId * @param deptId
@ -396,16 +397,12 @@ public class HydropowerServiceImpl implements HydropowerService {
* @param response * @param response
*/ */
private void handleStationInfo(Long deptId, HydropowerStationVo response) { private void handleStationInfo(Long deptId, HydropowerStationVo response) {
response.setPowerMon(0f);
response.setPowerYear(0f); response.setPowerYear(0f);
response.setPowerRateYear(0.0); response.setPowerRateYear(0.0);
List<HydropowerUnitTargetVo> targetList = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key); List<HydropowerUnitTargetVo> targetList = (List<HydropowerUnitTargetVo>) redisTemplate.opsForValue().get(load_hydropower_unit_target_key);
if(CollectionUtil.isEmpty(targetList)){ if(CollectionUtil.isEmpty(targetList)){
return; return;
} }
// 月发电量
float powerMont = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum();
response.setPowerMon(powerMont);
// 年发电量 // 年发电量
float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum(); float powerYear = (float) targetList.stream().filter(o-> deptId.equals(o.getDeptId())).mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum();
response.setPowerYear(powerYear); response.setPowerYear(powerYear);
@ -420,6 +417,22 @@ public class HydropowerServiceImpl implements HydropowerService {
} }
/** /**
* 月发电量
* @param id
* @param map
* @param response
*/
private void stationMonthPower(Long id, Map<Long, Map<String, Float>> map, HydropowerStationVo response) {
if(MapUtils.isEmpty(map) || !map.containsKey(id)){
response.setPowerMon(0f);
return;
}
String month = DateUtil.format(new Date(),"yyyy-MM") + "-01";
response.setPowerMon(map.get(id).getOrDefault(month, 0f));
}
/**
* 站点水位数据处理 * 站点水位数据处理
* @param code * @param code
* @param response * @param response
@ -637,6 +650,14 @@ public class HydropowerServiceImpl implements HydropowerService {
if (MapUtils.isEmpty(map)) { if (MapUtils.isEmpty(map)) {
return kpi; return kpi;
} }
String month = DateUtil.format(new Date(),"yyyy-MM") + "-01";
// 当月发电量
kpi.setGenerateMon(map.entrySet().stream().filter(o->stations.stream().map(StationEntity::getId).collect(Collectors.toList()).contains(o.getKey())).mapToDouble(entry->{
if(entry.getValue().containsKey(month)){
return Double.valueOf(entry.getValue().get(month));
}
return 0.0;
}).sum());
// 今年发电趋势 // 今年发电趋势
kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map)); kpi.setPowerMonthVoList(this.handlePowerFinish(stations,map));
// 近3年发电量 // 近3年发电量

28
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.MessageConstants;
import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.dto.BusinessMessageDTO;
@ -123,7 +124,28 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas
* @param workTask * @param workTask
*/ */
private void saveWorkTask(WorkTaskVO workTask) { private void saveWorkTask(WorkTaskVO workTask) {
workTask.setCode("GZRWD" + DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME_MINI)); // 查询当月最序号记录
WorkTaskEntity max = this.getOne(Wrappers.<WorkTaskEntity>lambdaQuery()
.like(WorkTaskEntity::getCreateTime,DateUtil.format(new Date(),"yyyy-MM"))
.orderByDesc(WorkTaskEntity::getNumber)
.last("LIMIT 1")
);
if(ObjectUtil.isEmpty(max)){
workTask.setNumber("001");
workTask.setCode("GZRWD" + DateUtil.format(new Date(),"yyyyMM") + "001");
}else{
int number = Integer.parseInt(max.getNumber()) + 1;
String code = "";
if(number > 100){
code += number;
}else if(number > 10){
code = code + "0" + number;
}else{
code = code + "00" + number;
}
workTask.setNumber(code);
workTask.setCode("GZRWD" + DateUtil.format(new Date(),"yyyyMM") + code);
}
R<Dept> result = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId())); R<Dept> result = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){ if(result.isSuccess() && ObjectUtil.isNotEmpty(result.getData())){
workTask.setDeptName(result.getData().getDeptName()); workTask.setDeptName(result.getData().getDeptName());
@ -149,9 +171,7 @@ public class WorkTaskServiceImpl extends BaseServiceImpl<WorkTaskMapper, WorkTas
entity.setTaskName(processWorkFlowResponse.getTaskName()); entity.setTaskName(processWorkFlowResponse.getTaskName());
// 流程阶段执行人员名称 // 流程阶段执行人员名称
entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator()); entity.setNextStepOperator(processWorkFlowResponse.getNextStepOperator());
if(ObjectUtil.isNotEmpty(entity.getWorkTicketId())){ entity.setHeadHandleTime(new Date());
entity.setHeadHandleTime(new Date());
}
if(ObjectUtil.isNotEmpty(entity.getTerminator())){ if(ObjectUtil.isNotEmpty(entity.getTerminator())){
entity.setWorkEndTime(new Date()); entity.setWorkEndTime(new Date());
entity.setTaskName("结束"); entity.setTaskName("结束");

Loading…
Cancel
Save