Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
tyty 1 year ago
parent
commit
a02480a8a9
  1. 8
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java
  2. 36
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindDeviceVo.java
  3. 33
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindGenerationVo.java
  4. 8
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java
  5. 71
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindStationVo.java
  6. 59
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindSubordinateVo.java
  7. 33
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindTargetCurveVo.java
  8. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml
  9. 6
      hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java
  10. 20
      hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java
  11. 41
      hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java
  12. 36
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ThreadConfig.java
  13. 37
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java
  14. 12
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/WindHomeService.java
  15. 468
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java
  16. 70
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java
  17. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java
  18. 32
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/propperties/ThreadPoolConfigProperties.java
  19. 4
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java
  20. 54
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  21. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/utils/OperationWordHelper.java
  22. 14
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java
  23. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  24. 8
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java
  25. BIN
      hzims-service/ticket/src/main/resources/template/电气操作票.docx

8
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EminfoAndEmParamVo.java

@ -26,6 +26,14 @@ public class EminfoAndEmParamVo extends EmInfoExtendVo {
@JsonSerialize(nullsUsing = NullSerializer.class) @JsonSerialize(nullsUsing = NullSerializer.class)
private int rideCount; private int rideCount;
@ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lgtd;
@ApiModelProperty(value = "纬度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lttd;
@ApiModelProperty(value = "机组运行状态") @ApiModelProperty(value = "机组运行状态")
private String runStatus; private String runStatus;

36
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindDeviceVo.java

@ -0,0 +1,36 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电设备对象")
public class WindDeviceVo {
@ApiModelProperty(value = "归属机构")
private Long deptId;
@ApiModelProperty(value = "编码")
private String code;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lgtd;
@ApiModelProperty(value = "纬度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lttd;
@ApiModelProperty(value = "排序")
private Integer ord;
}

33
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindGenerationVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindGenerationVo {
@ApiModelProperty(value = "年份")
private Integer year;
@ApiModelProperty(value = "月份")
private String mon;
@ApiModelProperty(value = "计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double plan;
@ApiModelProperty(value = "发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
}

8
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindScoreVo.java

@ -12,15 +12,9 @@ import java.util.List;
* @author ysj * @author ysj
*/ */
@Data @Data
@ApiModel(value = "水电站分计对象") @ApiModel(value = "风电集团/区域指标对象")
public class WindScoreVo { public class WindScoreVo {
@ApiModelProperty(value = "机构Id")
private Long departId;
@ApiModelProperty(value = "机构名称")
private String departName;
@ApiModelProperty(value = "站点数量") @ApiModelProperty(value = "站点数量")
private Integer stationCount; private Integer stationCount;

71
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindStationVo.java

@ -0,0 +1,71 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindStationVo {
@ApiModelProperty(value = "机构Id")
private Long departId;
@ApiModelProperty(value = "机构名称")
private String departName;
@ApiModelProperty(value = "城市行政区域编码")
private String areaCode;
@ApiModelProperty(value = "运行天数")
private Long runDay;
@ApiModelProperty(value = "装机容量")
private Double capacity;
@ApiModelProperty(value = "年计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double planYear;
@ApiModelProperty(value = "月计划发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double planMon;
@ApiModelProperty(value = "已发电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generation;
@ApiModelProperty(value = "日上网电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "日平均风速")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double speed;
@ApiModelProperty(value = "日峰值功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double peak;
@ApiModelProperty(value = "日综合厂用电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double comprehensivePower;
@ApiModelProperty(value = "日可用时长")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double available;
@ApiModelProperty(value = "风电设备")
private List<WindDeviceVo> devices;
@ApiModelProperty(value = "天气")
private List<Daily> weather;
}

59
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindSubordinateVo.java

@ -0,0 +1,59 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电集团/区域占比")
public class WindSubordinateVo {
@ApiModelProperty(value = "机构Id")
private Long departId;
@ApiModelProperty(value = "机构名称")
private String departName;
@ApiModelProperty(value = "地市编码")
private String areaCode;
@ApiModelProperty(value = "地市名称")
private String areaName;
@ApiModelProperty("经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lgtd;
@ApiModelProperty("纬度(北纬)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lttd;
@ApiModelProperty(value = "温度")
private String temp;
@ApiModelProperty(value = "天气")
private List<Daily> weather;
@ApiModelProperty(value = "发电量")
private Double generation;
@ApiModelProperty(value = "集团/区域发电占比")
private Double generationRate;
@ApiModelProperty(value = "发电完成率")
private Double generationComplete;
@ApiModelProperty(value = "风机利用率")
private Double fanUse;
@ApiModelProperty(value = "厂用电率")
private Double factoryUse;
}

33
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/WindTargetCurveVo.java

@ -0,0 +1,33 @@
package com.hnac.hzims.operational.main.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author ysj
*/
@Data
@ApiModel(value = "风电站点对象")
public class WindTargetCurveVo {
@ApiModelProperty(value = "月份")
private String mon;
@ApiModelProperty(value = "日期")
private Integer day;
@ApiModelProperty(value = "日上网电量")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double generationDay;
@ApiModelProperty(value = "日平均风速")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double speed;
@ApiModelProperty(value = "日峰值功率")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double peak;
}

2
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml

@ -91,7 +91,7 @@
SELECT * FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 and `NUMBER` = #{emCode} SELECT * FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 and `NUMBER` = #{emCode}
</select> </select>
<select id="selectEminfoAndEmParamVoList" resultType="com.hnac.hzims.equipment.vo.EminfoAndEmParamVo"> <select id="selectEminfoAndEmParamVoList" resultType="com.hnac.hzims.equipment.vo.EminfoAndEmParamVo">
SELECT ID AS id, `NAME` as name,`NUMBER` as emCode,CREATE_DEPT as createDept,RUN_STATUS as runStatus,IFNULL(EM_INDEX,1) as ord FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1 SELECT ID AS id, `NAME` as name,`NUMBER` as emCode,CREATE_DEPT as createDept,RUN_STATUS as runStatus,IFNULL(EM_INDEX,1) as ord,LGTD,LTTD FROM `hzims_em_info` WHERE IS_DELETED = 0 AND HOME_PAGE_DISPLAY = 1
</select> </select>
<update id="updateBachEmState"> <update id="updateBachEmState">

6
hzims-service/message/src/main/java/com/hnac/hzims/message/config/ThreadPoolConfig.java

@ -18,9 +18,13 @@ public class ThreadPoolConfig {
@Bean @Bean
public ExecutorService logExecutorService() { public ExecutorService logExecutorService() {
return new ThreadPoolExecutor(1, 1, return new ThreadPoolExecutor(2, 5,
0L, TimeUnit.MILLISECONDS, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>()); new LinkedBlockingQueue<Runnable>());
} }
@Bean
public ExecutorService appMessagePushExecutor() {
return new ThreadPoolExecutor(2, 5, 5L, TimeUnit.SECONDS,new LinkedBlockingQueue<Runnable>());
}
} }

20
hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessageController.java

@ -7,6 +7,7 @@ import com.hnac.hzims.message.dto.SmsPushDto;
import com.hnac.hzims.message.dto.WsPushDto; import com.hnac.hzims.message.dto.WsPushDto;
import com.hnac.hzims.message.fegin.IPushMsgClient; import com.hnac.hzims.message.fegin.IPushMsgClient;
import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.IMessageService;
import com.hnac.hzims.message.service.IPushMessageService;
import com.hnac.hzims.message.service.impl.MailMessageServiceImpl; import com.hnac.hzims.message.service.impl.MailMessageServiceImpl;
import com.hnac.hzims.message.service.impl.PushMessageServiceImpl; import com.hnac.hzims.message.service.impl.PushMessageServiceImpl;
import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl;
@ -14,16 +15,16 @@ import com.hnac.hzims.message.service.impl.WebsocketServiceImpl;
import com.hnac.hzims.message.utils.HtmlModule; import com.hnac.hzims.message.utils.HtmlModule;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -79,4 +80,15 @@ public class MessageController extends BladeController {
IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class); IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class);
return messageService.send(wsPushDto); return messageService.send(wsPushDto);
} }
@GetMapping("/sendByUsers")
@ApiOperation("发送APP消息(多人)")
@ApiOperationSupport(order=5)
public R sendByUsers(@ApiParam("消息主题") String subject,
@ApiParam("消息内容") String content,
@ApiParam("用户ID列表") String userIds,
@ApiParam("租户ID") String tenantId) throws Exception {
PushMessageServiceImpl messageService = SpringUtil.getBean(PushMessageServiceImpl.class);
return R.status(messageService.sendByUsers(subject,content, Func.toStrList(",",userIds),tenantId));
}
} }

41
hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/PushMessageServiceImpl.java

@ -30,6 +30,7 @@ import org.springframework.util.Assert;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -42,6 +43,7 @@ public class PushMessageServiceImpl implements IMessageService {
private final IPushClient pushClient; private final IPushClient pushClient;
private final BladeLogger logger; private final BladeLogger logger;
private final ExecutorService appMessagePushExecutor;
@Override @Override
@SaveLog(type = MessageConstants.APP_NAME) @SaveLog(type = MessageConstants.APP_NAME)
@ -88,36 +90,13 @@ public class PushMessageServiceImpl implements IMessageService {
@Override @Override
public boolean send(MessagePushRecordEntity request) { public boolean send(MessagePushRecordEntity request) {
PushInfoVO pushInfoVO = new PushInfoVO(); String tenantId = Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId();
pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId()); try {
ArrayList<PlatformType> platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS); return this.sendByUsers(request.getSubject(), request.getContent(), Func.toStrList(",",request.getPusher()),tenantId);
platformTypes.forEach(platformType -> {
PushPlatform platform = PushPlatform.newBuilder().addPlatformType(platformType).build();
R<PushResponse> response;
// 安卓推送
if(PlatformType.Android.equals(platformType)) {
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build();
PushInfo pushInfo = new PushInfo("ops-push-android", request.getSubject(), request.getContent(),
"", null, platform, pushAudience);
pushInfoVO.setPushInfo(pushInfo);
response = pushClient.tenantPush(pushInfoVO);
} }
// IOS推送 catch (Exception e) {
else if(PlatformType.IOS.equals(platformType)) { throw new ServiceException(e.getMessage());
PushAudience pushAudience = PushAudience.newBuilder().addPushAudienceType(PushAudienceType.TAG, Lists.newArrayList(request.getPusher())).build();
PushInfo pushInfo = new PushInfo("ops-push-ios", request.getSubject(), request.getContent(),
"", null, platform, pushAudience);
pushInfoVO.setPushInfo(pushInfo);
response = pushClient.tenantPush(pushInfoVO);
} else {
response = null;
} }
Assert.isTrue(ObjectUtil.isNotEmpty(response) && response.isSuccess(),() -> {
logger.error("hzims-message:PushMessageServiceImpl:send", "请求参数为:"+JSON.toJSONString(pushInfoVO)+"错误信息为:"+response.getMsg());
throw new ServiceException(response.getMsg());
});
});
return true;
} }
/** /**
@ -125,7 +104,7 @@ public class PushMessageServiceImpl implements IMessageService {
* @param subject 消息主题 * @param subject 消息主题
* @param content 消息内容 * @param content 消息内容
* @param userIds 用户ID列表 * @param userIds 用户ID列表
* @param tenantId 推送成功标识 * @param tenantId 租户ID
* @return * @return
*/ */
public boolean sendByUsers(String subject, String content, List<String> userIds,String tenantId) throws Exception { public boolean sendByUsers(String subject, String content, List<String> userIds,String tenantId) throws Exception {
@ -140,7 +119,7 @@ public class PushMessageServiceImpl implements IMessageService {
R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO); R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO);
return pushResult.isSuccess(); return pushResult.isSuccess();
}); });
new Thread(androidPush,"安卓推送").start(); appMessagePushExecutor.submit(new Thread(androidPush,"安卓推送"));
// IOS推送 // IOS推送
FutureTask<Boolean> iosPush = new FutureTask<>(() -> { FutureTask<Boolean> iosPush = new FutureTask<>(() -> {
@ -153,7 +132,7 @@ public class PushMessageServiceImpl implements IMessageService {
R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO); R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO);
return pushResult.isSuccess(); return pushResult.isSuccess();
}); });
new Thread(iosPush,"ios推送").start(); appMessagePushExecutor.submit(new Thread(iosPush,"ios推送"));
return androidPush.get() && iosPush.get(); return androidPush.get() && iosPush.get();
} }

36
hzims-service/operational/src/main/java/com/hnac/hzims/operational/config/ThreadConfig.java

@ -0,0 +1,36 @@
package com.hnac.hzims.operational.config;
import com.hnac.hzims.operational.propperties.ThreadPoolConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/10 12:49
*/
@Configuration
public class ThreadConfig {
@Autowired
private ThreadPoolConfigProperties threadPoolConfigProperties;
@Bean
public ThreadPoolExecutor threadPoolExecutor() {
return new ThreadPoolExecutor(threadPoolConfigProperties.getCorePoolSize(),
threadPoolConfigProperties.getMaxSize(),
threadPoolConfigProperties.getKeepAliveTime(),
TimeUnit.SECONDS,
new LinkedBlockingDeque<>(threadPoolConfigProperties.getCapacity()),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.AbortPolicy());
}
}

37
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/WindHomeController.java

@ -2,8 +2,7 @@ package com.hnac.hzims.operational.main.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.operational.main.service.WindHomeService; import com.hnac.hzims.operational.main.service.WindHomeService;
import com.hnac.hzims.operational.main.vo.HydropowerScoreVo; import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.main.vo.WindScoreVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
@ -15,6 +14,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* @author ysj * @author ysj
*/ */
@ -34,4 +35,36 @@ public class WindHomeController extends BladeController {
return R.data(service.KPIs(deptId)); return R.data(service.KPIs(deptId));
} }
@ApiLog
@ApiOperation("风电站集团/区域占比")
@GetMapping("/subordinate")
@ApiOperationSupport(order = 2)
public R<List<WindSubordinateVo>> subordinate(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.subordinate(deptId));
}
@ApiLog
@ApiOperation("风电站点指标数据")
@GetMapping("/station")
@ApiOperationSupport(order = 3)
public R<WindStationVo> station(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.station(deptId));
}
@ApiLog
@ApiOperation("风电站点发电量")
@GetMapping("/generation")
@ApiOperationSupport(order = 4)
public R<List<WindGenerationVo>> generation(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.generation(deptId));
}
@ApiLog
@ApiOperation("风电站点月份曲线数据")
@GetMapping("/target_curve")
@ApiOperationSupport(order = 3)
public R<List<WindTargetCurveVo>> target_curve(@ApiParam(value = "站点机构ID") Long deptId) {
return R.data(service.target_curve(deptId));
}
} }

12
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/WindHomeService.java

@ -1,6 +1,8 @@
package com.hnac.hzims.operational.main.service; package com.hnac.hzims.operational.main.service;
import com.hnac.hzims.operational.main.vo.WindScoreVo; import com.hnac.hzims.operational.main.vo.*;
import java.util.List;
/** /**
* @author ysj * @author ysj
@ -9,4 +11,12 @@ public interface WindHomeService {
WindScoreVo KPIs(Long deptId); WindScoreVo KPIs(Long deptId);
WindStationVo station(Long deptId);
List<WindGenerationVo> generation(Long deptId);
List<WindTargetCurveVo> target_curve(Long deptId);
List<WindSubordinateVo> subordinate(Long deptId);
} }

468
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java

@ -1,22 +1,42 @@
package com.hnac.hzims.operational.main.service.impl; package com.hnac.hzims.operational.main.service.impl;
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.toolkit.Wrappers;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.hzimsweather.response.weather.Daily;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherDailyResponse;
import com.hnac.hzims.hzimsweather.response.weather.HeWeatherWeatherNowResponse;
import com.hnac.hzims.operational.fill.entity.WindEntity; import com.hnac.hzims.operational.fill.entity.WindEntity;
import com.hnac.hzims.operational.fill.service.WindService; import com.hnac.hzims.operational.fill.service.WindService;
import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.main.service.AreaService;
import com.hnac.hzims.operational.main.service.IWeatherService;
import com.hnac.hzims.operational.main.service.WindHomeService; import com.hnac.hzims.operational.main.service.WindHomeService;
import com.hnac.hzims.operational.main.vo.WindScoreVo; import com.hnac.hzims.operational.main.vo.*;
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;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil; 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.entity.Dept;
import org.springblade.system.entity.Region;
import org.springblade.system.feign.ISysClient;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.Duration;
import java.util.List; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -27,10 +47,25 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class WindHomeServiceImpl implements WindHomeService { public class WindHomeServiceImpl implements WindHomeService {
private final WindService windService;
private final AreaService areaService;
private final IWeatherService weatherService;
private final IStationService stationService; private final IStationService stationService;
private final WindService windService; private final RedisTemplate redisTemplate;
private final ISysClient sysClient;
public final static String device_cache_final = "hzims:equipment:emInfo:deviceCode.emInfoList";
/**
* 集团/区域指标数据
* @param deptId
* @return
*/
@Override @Override
public WindScoreVo KPIs(Long deptId) { public WindScoreVo KPIs(Long deptId) {
// 查询风电站 // 查询风电站
@ -38,74 +73,405 @@ public class WindHomeServiceImpl implements WindHomeService {
eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE); eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE);
eq(StationEntity::getType,HomePageConstant.WIND_POWER); eq(StationEntity::getType,HomePageConstant.WIND_POWER);
}}); }});
if(CollectionUtil.isNotEmpty(stations)){ if(CollectionUtil.isEmpty(stations)){
return new WindScoreVo(); return new WindScoreVo();
} }
// 查询站点年填报数据 // 查询站点填报数据
List<WindEntity> years = windService.list(new LambdaQueryWrapper<WindEntity>() {{ List<WindEntity> winds = windService.list(new LambdaQueryWrapper<WindEntity>() {{
like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy"));
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
}});
// 查询站点月填报数据
List<WindEntity> mons = windService.list(new LambdaQueryWrapper<WindEntity>() {{
like(WindEntity::getFillDate, DateUtil.format(new Date(),"yyyy-MM"));
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
}});
// 查询站点日填报数据
List<WindEntity> days = windService.list(new LambdaQueryWrapper<WindEntity>() {{
like(WindEntity::getFillDate, DateUtil.format(new Date(), DateUtil.format(new Date(),DateUtil.PATTERN_DATE)));
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
}}); }});
WindScoreVo score = new WindScoreVo(); WindScoreVo score = new WindScoreVo();
// 站点数量
score.setStationCount(stations.size()); score.setStationCount(stations.size());
this.year(years,score); if(CollectionUtil.isEmpty(winds)){
this.mon(mons,score);
this.days(days,score);
return score; return score;
} }
// 装机容量
/** List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
* 风电数据 - if(CollectionUtil.isNotEmpty(devices)){
* @param years score.setInstalledCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
* @param score
*/
private void year(List<WindEntity> years, WindScoreVo score) {
if(CollectionUtil.isNotEmpty(years)){
return;
} }
// 年发电量 // 年发电量
score.setGenerateYear(years.stream().mapToDouble(WindEntity::getPower).sum()); score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).sum());
// 年计划发电量 // 年计划发电量
score.setPlanYear(years.stream().mapToDouble(WindEntity::getPlan).sum()); score.setPlanYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum());
// 年发电完成率 // 年发电完成率
if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){ if(Math.abs(score.getGenerateYear()) > 0 && Math.abs(score.getPlanYear()) > 0){
score.setSpeedRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
} }
/**
* 风电数据 -
* @param mons
* @param score
*/
private void mon(List<WindEntity> mons, WindScoreVo score) {
// 月发电量 // 月发电量
score.setGenerateMon(mons.stream().mapToDouble(WindEntity::getPower).sum()); score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum());
// 月平均风速 // 月平均风速
score.setSpeedRate(mons.stream().mapToDouble(WindEntity::getSpeed).average().getAsDouble()); score.setSpeedRate(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getSpeed).average().getAsDouble());
// 月短期准确率 // 月短期准确率
score.setAccuracy(mons.stream().mapToDouble(WindEntity::getAccuracy).average().getAsDouble()); score.setAccuracy(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getAccuracy).average().getAsDouble());
// 月超短期准确率 // 月超短期准确率
score.setUltraShortAccuracyRate(mons.stream().mapToDouble(WindEntity::getUltraShortAccuracy).average().getAsDouble()); score.setUltraShortAccuracyRate(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getUltraShortAccuracy).average().getAsDouble());
// 日发电量
score.setGenerateDay(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getPower).sum());
// 近年发电量
score.setPowerYearVoList(this.threeGenerateYear(winds));
// 计划发电完成率
score.setPowerMonthVoList(this.currentGenerateCurve(winds));
return score;
} }
/** /**
* 风电数据 - * 近3年发电量
* @param days * @param winds
* @param score * @return
*/ */
private void days(List<WindEntity> days, WindScoreVo score) { private List<PowerYearVo> threeGenerateYear(List<WindEntity> winds) {
// 日发电量 List<String> mons = this.mons(2,12,false);
score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum()); // 月份发电量赋值
List<PowerMonthVo> list = mons.stream().map(mon->{
PowerMonthVo power = new PowerMonthVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
power.setYear(localDate.getYear());
power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum());
return power;
}).collect(Collectors.toList());
if(CollectionUtil.isEmpty(list)){
return new ArrayList<>();
}
// 转换年份分组
return list.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear)).entrySet().stream().map(entry->{
PowerYearVo year = new PowerYearVo();
year.setYear(entry.getKey());
year.setPowerMonthVoList(entry.getValue());
return year;
}).collect(Collectors.toList());
}
/**
* 年发电量趋势
* @param winds
* @return
*/
private List<PowerMonthVo> currentGenerateCurve(List<WindEntity> winds) {
List<String> mons = this.mons(0,12,false);
return mons.stream().map(mon->{
PowerMonthVo power = new PowerMonthVo();
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
power.setYear(localDate.getYear());
power.setStrMonth(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
power.setPlanPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPlan).sum());
power.setPower((float) winds.stream().filter(o->o.getFillDate().contains(localDate.getYear() + "-" + power.getStrMonth())).mapToDouble(WindEntity::getPower).sum());
return power;
}).collect(Collectors.toList());
}
/**
* 风电站集团/区域占比
* @param deptId
* @return
*/
@Override
public List<WindSubordinateVo> subordinate(Long deptId) {
Map<Dept, List<StationEntity>> areas = areaService.areaOrStaion(deptId, Collections.singletonList(HomePageConstant.WIND_POWER));
if (MapUtils.isEmpty(areas)) {
return new ArrayList<>();
}
// 风电站填报数据查询
List<String> codes = new ArrayList<>();
areas.forEach((key,value)-> codes.addAll(value.stream().map(StationEntity::getCode).collect(Collectors.toList())));
List<WindEntity> winds = windService.list(new LambdaQueryWrapper<WindEntity>() {{
in(WindEntity::getStationCode,codes)
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy"));
}});
// 获取站点编码集合
List<String> stations = areas.values().stream().map(values -> values.get(0).getCode()).collect(Collectors.toList());
// 获取站点实时天气
Map<String, HeWeatherWeatherNowResponse> nowWeather = this.weatherService.getNowWeather(stations);
// 获取站点7日天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = this.weatherService.getWeekWeather(stations);
return areas.entrySet().stream().map(entry -> {
WindSubordinateVo subordinate = new WindSubordinateVo();
// 获取第一个站点经纬度、行政编码信息
StationEntity station = entry.getValue().get(0);
subordinate.setLttd(station.getLttd());
subordinate.setLgtd(station.getLgtd());
// 省市编码
String areaCode = station.getAreaCode();
subordinate.setAreaCode(areaCode);
if (!StringUtil.isEmpty(areaCode)) {
String[] arrCode = areaCode.split(",");
R<Region> R = sysClient.getRegion(arrCode[1]);
if (R.isSuccess() && ObjectUtil.isNotEmpty(R.getData())) {
subordinate.setAreaName(R.getData().getName());
}
}
// 机构Id
subordinate.setDepartId(entry.getKey().getId());
// 机构名称
subordinate.setDepartName(entry.getKey().getDeptName());
// 天气
this.getAreaWearther(subordinate, nowWeather, weekWeather, entry.getValue().get(0).getCode());
if(CollectionUtil.isNotEmpty(winds)){
List<WindEntity> piece = winds.stream().filter(o->entry.getValue().stream().map(StationEntity::getCode).collect(Collectors.toList()).contains(o.getStationCode())).collect(Collectors.toList());
if(CollectionUtil.isEmpty(piece)){
return subordinate;
}
// 发电量
subordinate.setGeneration(piece.stream().mapToDouble(WindEntity::getPower).sum());
// 集团发电占比
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(winds.stream().mapToDouble(WindEntity::getPower).sum()) > 0){
subordinate.setGenerationRate(BigDecimal.valueOf(subordinate.getGeneration() / winds.stream().mapToDouble(WindEntity::getPower).sum() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 发电完成率
double plan = piece.stream().mapToDouble(WindEntity::getPlan).sum();
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(plan) > 0){
subordinate.setGenerationComplete(BigDecimal.valueOf(subordinate.getGeneration() / plan * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 风机利用率 : (总时间 - 故障时间) / 总时间
double fault = piece.stream().mapToDouble(WindEntity::getFaultHours).sum();
if(Math.abs(fault) > 0 ){
subordinate.setFanUse(BigDecimal.valueOf(fault / (30 * 24) * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 厂用电率 : (发电量-上网电量+下网电量)/发电量
double surf = piece.stream().mapToDouble(WindEntity::getSurfPower).sum();
double below = piece.stream().mapToDouble(WindEntity::getBelowPower).sum();
if(Math.abs(subordinate.getGeneration()) > 0 && Math.abs(surf + below) > 0){
subordinate.setFactoryUse(BigDecimal.valueOf(subordinate.getGeneration() - surf + below / subordinate.getGeneration() * 100).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
}
}
return subordinate;
}).filter(o-> Math.abs(o.getGeneration()) > 0 || Math.abs(o.getGenerationRate()) > 0 || Math.abs(o.getGenerationComplete()) > 0
|| Math.abs(o.getFactoryUse()) > 0 || Math.abs(o.getFanUse()) > 0 ).sorted(Comparator.comparing(WindSubordinateVo::getGeneration).reversed()).collect(Collectors.toList());
}
/**
* 区域天气
* @param scale
* @param nowWeather
* @param weekWeather
* @param code
*/
private void getAreaWearther(WindSubordinateVo scale,Map<String, HeWeatherWeatherNowResponse> nowWeather, Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) {
// 实时天气
if(MapUtils.isNotEmpty(nowWeather) && nowWeather.containsKey(code)){
HeWeatherWeatherNowResponse nowData = nowWeather.get(code);
if(ObjectUtil.isNotEmpty(nowData.getNow())){
scale.setTemp(nowData.getNow().getTemp());
}
}
// 站点七日内天气
if(MapUtils.isNotEmpty(weekWeather) && weekWeather.containsKey(code)){
HeWeatherWeatherDailyResponse weekData = weekWeather.get(code);
List<Daily> dailyList = weekData.getDaily();
if (CollectionUtil.isNotEmpty(dailyList)) {
scale.setWeather(dailyList);
}
}
}
/**
* 站点指标数据
* @param deptId
* @return
*/
@Override
public WindStationVo station(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new WindStationVo();
}
WindStationVo wind = new WindStationVo();
// 机构编码
wind.setDepartId(station.getRefDept());
// 机构名称
wind.setDepartName(station.getName());
// 站点行政区域编码
if(!StringUtil.isEmpty(station.getAreaCode())){
String[] code = station.getAreaCode().split(",");
wind.setAreaCode(code[code.length - 1]);
}
// 站点七天天气
Map<String, HeWeatherWeatherDailyResponse> weekWeather = weatherService.getWeekWeather(Collections.singletonList(station.getCode()));
wind.setWeather(this.getDailyList(weekWeather,station.getCode()));
// 安全运行天数
if (ObjectUtil.isNotEmpty(station.getCommissionTime())) {
wind.setRunDay(Duration.between(station.getCommissionTime(), LocalDateTime.now()).toDays());
}
// 设备
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
if(CollectionUtil.isNotEmpty(devices)){
// 装机容量
wind.setCapacity(devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
// 设备列表
wind.setDevices(devices.stream().filter(device->device.getCreateDept().equals(station.getRefDept())).map(item->{
WindDeviceVo windDevice = new WindDeviceVo();
windDevice.setDeptId(item.getCreateDept());
windDevice.setCode(item.getEmCode());
windDevice.setName(item.getName());
windDevice.setOrd(item.getOrd());
windDevice.setLgtd(item.getLgtd());
windDevice.setLttd(item.getLttd());
return windDevice;
}).collect(Collectors.toList()));
}
// 查询站点填报数据 - 全部
List<WindEntity> all = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
);
if(CollectionUtil.isNotEmpty(all)){
// 年计划发电量
wind.setPlanYear(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPlan).sum());
// 月计划发电量
wind.setPlanMon(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPlan).sum());
// 总发电量
wind.setGeneration(all.stream().mapToDouble(WindEntity::getPower).sum());
// 日上网电量
wind.setGenerationDay(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getSurfPower).sum());
// 日平均风速
wind.setSpeed(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getSpeed).sum());
// 日峰值功率
wind.setPeak(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getPeakPower).sum());
// 日综合厂用电量
wind.setComprehensivePower(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getComprehensivePower).sum());
// 日可用时长
wind.setAvailable(all.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),DateUtil.PATTERN_DATE))).mapToDouble(WindEntity::getAvailable).sum());
}
return wind;
}
/**
* 风电站点发电量柱状数据
* @param deptId
* @return
*/
@Override
public List<WindGenerationVo> generation(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new ArrayList<>();
}
// 查询风电填报数据
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
);
if(CollectionUtil.isEmpty(winds)){
return new ArrayList<>();
}
List<String> monList = this.mons(1,12,false);
return monList.stream().map(mon->{
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), mon), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
WindGenerationVo generation = new WindGenerationVo();
generation.setYear(localDate.getYear());
generation.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
generation.setPlan(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPlan).sum());
generation.setGeneration(winds.stream().filter(o->o.getFillDate().contains(generation.getYear() + "-" + generation.getMon())).mapToDouble(WindEntity::getPower).sum());
return generation;
}).collect(Collectors.toList());
}
/**
* 风电站点月份曲线数据
* @param deptId
* @return
*/
@Override
public List<WindTargetCurveVo> target_curve(Long deptId) {
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery()
.eq(StationEntity::getRefDept,deptId)
);
if(ObjectUtil.isEmpty(station)){
return new ArrayList<>();
}
// 查询风电填报数据
List<WindEntity> winds = windService.list(Wrappers.<WindEntity>lambdaQuery()
.eq(WindEntity::getStationCode,station.getCode())
.like(WindEntity::getFillDate,DateUtil.format(new Date(),"yyyy-MM"))
);
if(CollectionUtil.isEmpty(winds)){
return new ArrayList<>();
}
List<String> days = this.getCurrentDayList();
return days.stream().map(day->{
LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), day), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE));
WindTargetCurveVo curve = new WindTargetCurveVo();
curve.setMon(localDate.getMonthValue() > 9 ? String.valueOf(localDate.getMonthValue()) : "0" + localDate.getMonthValue());
curve.setDay(localDate.getDayOfMonth());
curve.setPeak(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getPeakPower).sum());
curve.setGenerationDay(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getSurfPower).sum());
curve.setSpeed(winds.stream().filter(o->o.getFillDate().contains(day)).mapToDouble(WindEntity::getSpeed).sum());
return curve;
}).collect(Collectors.toList());
}
/**
* 获取七天天气
* @param weekWeather
* @param code
* @return
*/
private List<Daily> getDailyList(Map<String, HeWeatherWeatherDailyResponse> weekWeather, String code) {
if(MapUtils.isEmpty(weekWeather)){
return null;
}
HeWeatherWeatherDailyResponse week = weekWeather.get(code);
if(ObjectUtil.isEmpty(week)){
return null;
}
return week.getDaily();
}
/**
* 获取近年月份集合
* @param year
* @return
*/
public List<String> mons(int year, int endMoth, boolean nextMon) {
List<String> list = new ArrayList<>();
// 开始日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + endMoth);
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
// 结束日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR) - year);
startCal.add(Calendar.MONTH, -startCal.get(Calendar.MONTH));
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 获取日期之间的月份
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.MONTH, 1);
}
if(nextMon){
list.add(DateUtil.format(endCal.getTime(),DateUtil.PATTERN_DATE));
}
return list;
}
/**
* 获取当月日期List
* @return
*/
private List<String> getCurrentDayList() {
List<String> list = new ArrayList<>();
// 开始日期
Calendar startCal = Calendar.getInstance();
startCal.setTime(new Date());
startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1);
// 结束日期
Calendar endCal = Calendar.getInstance();
endCal.setTime(new Date());
endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1);
endCal.add(Calendar.MONTH, 1);
// 获取日期之间日期
while (endCal.after(startCal)) {
list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE));
startCal.add(Calendar.DATE, 1);
}
return list;
} }
} }

70
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/MaintenanceServiceImpl.java

@ -37,8 +37,12 @@ import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
@ -46,6 +50,9 @@ import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -71,6 +78,11 @@ public class MaintenanceServiceImpl implements MaintenanceService {
private final IFlowClient flowClient; private final IFlowClient flowClient;
private final ISysClient sysClient; private final ISysClient sysClient;
private final ThreadPoolExecutor executor;
private final DataSourceTransactionManager dataSourceTransactionManager;
/** /**
* 日常维护生成任务 * 日常维护生成任务
* *
@ -79,17 +91,13 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void createTask(List<String> ids) { public void createTask(List<String> ids) {
try {
//获取日常维护计划 //获取日常维护计划
LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids); planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids);
List<OperMaintenancePlanEntity> planEntities = maintenancePlanService List<OperMaintenancePlanEntity> planEntities = maintenancePlanService.list(planEntityLambdaQueryWrapper);
.list(planEntityLambdaQueryWrapper);
//筛选当月没生成任务的计划 //筛选当月没生成任务的计划
List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity -> List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) || !DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())).collect(Collectors.toList());
ObjectUtil.isEmpty(planEntity.getCreateTaskTime())
|| !DateUtil.judgeSameDay(
DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())
).collect(Collectors.toList());
if (CollectionUtil.isEmpty(finalPlanEntities)) { if (CollectionUtil.isEmpty(finalPlanEntities)) {
throw new ServiceException("所选计划当天已生成任务"); throw new ServiceException("所选计划当天已生成任务");
} }
@ -97,8 +105,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
// 通过计划生成任务 // 通过计划生成任务
this.createTaskByPlan(finalPlanEntity); this.createTaskByPlan(finalPlanEntity);
//更新任务派发时间 //更新任务派发时间
LambdaUpdateWrapper<OperMaintenancePlanEntity> planEntityLambdaUpdateWrapper = LambdaUpdateWrapper<OperMaintenancePlanEntity> planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
new LambdaUpdateWrapper<>();
planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date()); planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date());
planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId()); planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId());
boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper); boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper);
@ -107,6 +114,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
throw new ServiceException("更新任务派发失败"); throw new ServiceException("更新任务派发失败");
} }
} }
} catch (Exception e) {
e.printStackTrace();
}
} }
/** /**
@ -117,6 +127,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override @Override
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public void findPending(ProcessWorkFlowResponse response) { public void findPending(ProcessWorkFlowResponse response) {
try {
log.info("获取businessKey: {}", response.getBusinessKey()); log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {} ", response.getTaskId()); log.info("获取taskId: {} ", response.getTaskId());
log.info("获取下一个审批人是: {} ", response.getNextStepOperator()); log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
@ -129,8 +140,8 @@ public class MaintenanceServiceImpl implements MaintenanceService {
OperMaintenanceTaskEntityVo standardTicketInfoVo = null; OperMaintenanceTaskEntityVo standardTicketInfoVo = null;
try { try {
JSONObject jsonObject = JSONObject.parseObject(formData); JSONObject jsonObject = JSONObject.parseObject(formData);
standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"), standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"), new TypeReference<OperMaintenanceTaskEntityVo>() {
new TypeReference<OperMaintenanceTaskEntityVo>(){}); });
// standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo"); // standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo");
// standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class); // standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class);
} catch (Exception e) { } catch (Exception e) {
@ -196,10 +207,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId()); businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId());
businessMessageDTO.setTenantId("200000"); businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****; //您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = String countent = "您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle()).concat(",审批环节:").concat(response.getTaskName());
"您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle())
.concat(",审批环节:")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent); businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept()); businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept()); R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept());
@ -219,6 +227,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
} }
log.info("推送成功~"); log.info("推送成功~");
} }
} catch (Exception e) {
e.printStackTrace();
}
} }
@ -281,6 +292,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
* @param finalPlanEntity * @param finalPlanEntity
*/ */
private void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) { private void fillTask(OperMaintenanceTaskEntity taskEntity, OperMaintenancePlanEntity finalPlanEntity) {
DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition();
defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus transaction = dataSourceTransactionManager.getTransaction(defaultTransactionDefinition);
taskEntity.setId(null); taskEntity.setId(null);
taskEntity.setCreateTime(new Date()); taskEntity.setCreateTime(new Date());
taskEntity.setUpdateTime(new Date()); taskEntity.setUpdateTime(new Date());
@ -299,8 +313,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
if (ObjectUtil.isNotEmpty(finalPlanEntity.getMaintenanceModel()) && finalPlanEntity.getMaintenanceModel() == 2) { if (ObjectUtil.isNotEmpty(finalPlanEntity.getMaintenanceModel()) && finalPlanEntity.getMaintenanceModel() == 2) {
//查询值班信息 //查询值班信息
LambdaQueryWrapper<ImsDutyMainEntity> entityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ImsDutyMainEntity> entityLambdaQueryWrapper = new LambdaQueryWrapper<>();
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate, entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate, DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getClassId, finalPlanEntity.getImsDutyClassId()); entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getClassId, finalPlanEntity.getImsDutyClassId());
ImsDutyMainEntity entity = mainService.getOne(entityLambdaQueryWrapper); ImsDutyMainEntity entity = mainService.getOne(entityLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) { if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) {
@ -312,16 +325,26 @@ public class MaintenanceServiceImpl implements MaintenanceService {
} }
} }
taskService.save(taskEntity); taskService.save(taskEntity);
//生成工作流实例 dataSourceTransactionManager.commit(transaction);
//启动流程
String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity); String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity);
//推送消息
CompletableFuture<Void> operMaintenanceTaskEntityCompletableFuture =
CompletableFuture.runAsync(() -> {
taskEntity.setProcessInstanceId(processInstanceId); taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity); taskService.updateById(taskEntity);
finalPlanEntity.setCreateTaskTime(new Date()); finalPlanEntity.setCreateTaskTime(new Date());
maintenancePlanService.updateById(finalPlanEntity); maintenancePlanService.updateById(finalPlanEntity);
OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId());
taskEntity = taskService.getById(taskEntity.getId());
//推送消息 //推送消息
this.pushTaskMessage(taskEntity); this.pushTaskMessage(maintenanceTask);
}, executor);
//启动队列
try {
CompletableFuture.allOf(operMaintenanceTaskEntityCompletableFuture).get();
} catch (Exception e) {
e.printStackTrace();
}
} }
@ -343,10 +366,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
params.put("initUserIds", taskUsers); params.put("initUserIds", taskUsers);
params.put("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo); params.put("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo);
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params).getData().getProcessInstanceId();
String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params)
.getData()
.getProcessInstanceId();
} }

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceMonitorServiceImpl.java

@ -21,6 +21,8 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -42,10 +44,11 @@ public class OperMaintenanceMonitorServiceImpl implements IOperMaintenanceMonito
@Override @Override
public R<Map<String, List<OperMaintenancePlanVO>>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) { public R<Map<String, List<OperMaintenancePlanVO>>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) {
List<OperMaintenancePlanEntity> planEntities = planMapper.selectList(new LambdaQueryWrapper<OperMaintenancePlanEntity>() {{ List<OperMaintenancePlanEntity> planEntities = planMapper.selectList(new LambdaQueryWrapper<OperMaintenancePlanEntity>() {{
Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE); LocalDate startDate = LocalDate.of(req.getYear(), req.getMonth(),1);
// Date startTime = DateUtil.parse(DateUtil.format(DateUtil.now(), "yyyy-MM") + "-01", DateUtil.PATTERN_DATE);
eq(OperMaintenancePlanEntity::getIsDeleted, 0L); eq(OperMaintenancePlanEntity::getIsDeleted, 0L);
ge(OperMaintenancePlanEntity::getDisposeTime, startTime); ge(OperMaintenancePlanEntity::getDisposeTime, startDate);
lt(OperMaintenancePlanEntity::getDisposeTime, DateUtil.plusMonths(startTime, 1)); lt(OperMaintenancePlanEntity::getDisposeTime, startDate.with(TemporalAdjusters.lastDayOfMonth()));
}}); }});
//获取列表班次ID集合 //获取列表班次ID集合

32
hzims-service/operational/src/main/java/com/hnac/hzims/operational/propperties/ThreadPoolConfigProperties.java

@ -0,0 +1,32 @@
package com.hnac.hzims.operational.propperties;
import lombok.Data;
import org.springframework.context.annotation.Configuration;
/**
*
* @Author WL
* @Version v1.0
* @Serial 1.0
* @Date 2023/5/10 12:51
*/
@Configuration
@Data
public class ThreadPoolConfigProperties {
/**
* 核心数
*/
private Integer corePoolSize = 20;
/**
* 最大数
*/
private Integer maxSize = 200;
/**
* 存活时间
*/
private Integer keepAliveTime = 20;
/**
* 容量
*/
private Integer capacity = 10000;
}

4
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/OperationTicketServiceImpl.java

@ -249,7 +249,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
businessMessageDTO.setTenantId("200000"); businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****; //您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = String countent =
"您有一张作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle()) "您有一张作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle())
.concat(",审批环节:") .concat(",审批环节:")
.concat(response.getTaskName()); .concat(response.getTaskName());
businessMessageDTO.setContent(countent); businessMessageDTO.setContent(countent);
@ -472,7 +472,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
Map<String, Object> map = PdfUtils.objectToMap(measure); Map<String, Object> map = PdfUtils.objectToMap(measure);
map.put("index", index.get()); map.put("index", index.get());
map.put("status", TicketConstants.MATTER_FINISH_STATUS.equals(measure.getStatus()) ? "√" : ""); map.put("status", TicketConstants.MATTER_FINISH_STATUS.equals(measure.getStatus()) ? "√" : "");
map.put("operationTime", measure.getOperationTime()); // map.put("operationTime", measure.getOperationTime());
map.put("hello", ""); map.put("hello", "");
map.put("hello1", ""); map.put("hello1", "");
index.getAndIncrement(); index.getAndIncrement();

54
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java

@ -36,6 +36,7 @@ import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
@ -112,6 +113,10 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
LambdaQueryWrapper<StandardTicketInfoEntity> queryWrapper = this.getQueryWrapper(req); LambdaQueryWrapper<StandardTicketInfoEntity> queryWrapper = this.getQueryWrapper(req);
queryWrapper.eq(Func.isNotEmpty(req.getCreateDept()), StandardTicketInfoEntity::getCreateDept, req.getCreateDept()); queryWrapper.eq(Func.isNotEmpty(req.getCreateDept()), StandardTicketInfoEntity::getCreateDept, req.getCreateDept());
queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime); queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime);
//操作票已完成的数量
if (StringUtils.isNoneBlank(req.getFlowTaskName())) {
queryWrapper.eq(StandardTicketInfoEntity::getFlowTaskName, req.getFlowTaskName());
}
IPage pages = super.page(Condition.getPage(query), queryWrapper); IPage pages = super.page(Condition.getPage(query), queryWrapper);
return R.data(pages.setRecords(StandardTicketInfoWrapper.build().listVO(pages.getRecords()))); return R.data(pages.setRecords(StandardTicketInfoWrapper.build().listVO(pages.getRecords())));
} }
@ -144,11 +149,7 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
} }
/*开启工作流*/ /*开启工作流*/
String processInstanceId = this.startProcessInstance(standardFlowKey, req); String processInstanceId = this.startProcessInstance(standardFlowKey, req);
return R.status(this.update( return R.status(this.update(Wrappers.<StandardTicketInfoEntity>lambdaUpdate().set(StandardTicketInfoEntity::getProcessInstanceId, processInstanceId).eq(StandardTicketInfoEntity::getId, req.getId())));
Wrappers.<StandardTicketInfoEntity>lambdaUpdate()
.set(StandardTicketInfoEntity::getProcessInstanceId, processInstanceId)
.eq(StandardTicketInfoEntity::getId, req.getId())
));
} }
@Override @Override
@ -244,9 +245,7 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
if (Func.isEmpty(ticketInfoEntity.getProcessInstanceId())) { if (Func.isEmpty(ticketInfoEntity.getProcessInstanceId())) {
return R.fail("该操作票未开启工作流"); return R.fail("该操作票未开启工作流");
} }
this.update(Wrappers.<StandardTicketInfoEntity>lambdaUpdate() this.update(Wrappers.<StandardTicketInfoEntity>lambdaUpdate().set(StandardTicketInfoEntity::getStatus, TicketConstants.StandardTicketStatusEnum.TERMINATION.getStatus()).eq(StandardTicketInfoEntity::getId, id));
.set(StandardTicketInfoEntity::getStatus, TicketConstants.StandardTicketStatusEnum.TERMINATION.getStatus())
.eq(StandardTicketInfoEntity::getId, id));
/**删除工作流**/ /**删除工作流**/
R r = flowClient.delProcessInstanceById(ticketInfoEntity.getProcessInstanceId(), comment); R r = flowClient.delProcessInstanceById(ticketInfoEntity.getProcessInstanceId(), comment);
if (!r.isSuccess()) { if (!r.isSuccess()) {
@ -335,23 +334,18 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
//1.查询 //1.查询
QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>();
//开票来源 //开票来源
queryWrapper.eq(Func.isNotEmpty(areaVo.getTaskType()), "sti.task_type", queryWrapper.eq(Func.isNotEmpty(areaVo.getTaskType()), "sti.task_type", areaVo.getTaskType());
areaVo.getTaskType());
//编号 //编号
queryWrapper.like(Func.isNotEmpty(areaVo.getCode()), "sti.code", areaVo.getCode()); queryWrapper.like(Func.isNotEmpty(areaVo.getCode()), "sti.code", areaVo.getCode());
//状态 //状态
queryWrapper.eq(Func.isNotEmpty(areaVo.getStatus()), "sti.status", queryWrapper.eq(Func.isNotEmpty(areaVo.getStatus()), "sti.status", areaVo.getStatus());
areaVo.getStatus());
//开始时间 //开始时间
queryWrapper.lt(Func.isNotEmpty(areaVo.getStartTime()), "sti.create_time", queryWrapper.lt(Func.isNotEmpty(areaVo.getStartTime()), "sti.create_time", areaVo.getStartTime());
areaVo.getStartTime());
//结束时间 //结束时间
queryWrapper.le(Func.isNotEmpty(areaVo.getEndTime()), "sti.create_time", queryWrapper.le(Func.isNotEmpty(areaVo.getEndTime()), "sti.create_time", areaVo.getEndTime());
areaVo.getEndTime());
queryWrapper.eq("sti.CREATE_DEPT", areaVo.getAreaId()); queryWrapper.eq("sti.CREATE_DEPT", areaVo.getAreaId());
queryWrapper.eq(areaVo.getYearMonth() != null, queryWrapper.eq(areaVo.getYearMonth() != null, "date_format(sti.create_time,'%Y-%m')", areaVo.getYearMonth());
"date_format(sti.create_time,'%Y-%m')", areaVo.getYearMonth());
// queryWrapper.eq("tie.status",1); // queryWrapper.eq("tie.status",1);
Page<StandardTicketInfoEntity> standardTicketInfoEntityPage = baseMapper.selectPages(searchPage, queryWrapper); Page<StandardTicketInfoEntity> standardTicketInfoEntityPage = baseMapper.selectPages(searchPage, queryWrapper);
@ -450,8 +444,7 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
private boolean isTicketPercentById(StandardTicketInfoEntity item) { private boolean isTicketPercentById(StandardTicketInfoEntity item) {
LambdaQueryWrapper<TicketInfoEvaluateEntity> ticketInfoEvaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TicketInfoEvaluateEntity> ticketInfoEvaluateEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
ticketInfoEvaluateEntityLambdaQueryWrapper.eq(TicketInfoEvaluateEntity::getTicketId, item.getId()); ticketInfoEvaluateEntityLambdaQueryWrapper.eq(TicketInfoEvaluateEntity::getTicketId, item.getId());
ticketInfoEvaluateEntityLambdaQueryWrapper.eq(TicketInfoEvaluateEntity::getStatus, ticketInfoEvaluateEntityLambdaQueryWrapper.eq(TicketInfoEvaluateEntity::getStatus, TicketConstants.TicketQualifiedEnum.Qualified.getCode());
TicketConstants.TicketQualifiedEnum.Qualified.getCode());
int count = ticketInfoEvaluateService.count(ticketInfoEvaluateEntityLambdaQueryWrapper); int count = ticketInfoEvaluateService.count(ticketInfoEvaluateEntityLambdaQueryWrapper);
return count > 0; return count > 0;
} }
@ -580,9 +573,7 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
put("guardianUserIds", "taskUser_".concat(entity.getGuardian().toString())); put("guardianUserIds", "taskUser_".concat(entity.getGuardian().toString()));
}}; }};
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, "standardTicket:task:" + entity.getId(), entity.getTitle(), params) return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, "standardTicket:task:" + entity.getId(), entity.getTitle(), params).getData().getProcessInstanceId();
.getData()
.getProcessInstanceId();
} }
/*** /***
@ -680,21 +671,12 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
List<OperateTicketStatisticVO> operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList); List<OperateTicketStatisticVO> operateTicketReportStatistic = this.baseMapper.getOperateTicketReportStatistic(startDate, endDate, deptIdList);
if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) { if (CollectionUtil.isNotEmpty(operateTicketReportStatistic)) {
//已完成数量 //已完成数量
int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(ticket -> TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(ticket.getStatus())) int ticketInfoCompleteNum = operateTicketReportStatistic.stream().filter(ticket -> TicketConstants.StandardTicketStatusEnum.END.getStatus().equals(ticket.getStatus())).collect(Collectors.toList()).size();
.collect(Collectors.toList()).size();
//合格数量 //合格数量
int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size(); int ticketInfoQualifiedNum = operateTicketReportStatistic.stream().filter(ticket -> Func.isNotEmpty(ticket.getEvaluation()) && 1 == ticket.getEvaluation().intValue()).collect(Collectors.toList()).size();
//计算合格率 //计算合格率
double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100) double ticketInfoProportion = new BigDecimal(ticketInfoQualifiedNum / (double) operateTicketReportStatistic.size() * 100).setScale(2, RoundingMode.HALF_DOWN).doubleValue();
.setScale(2, RoundingMode.HALF_DOWN).doubleValue(); result = TicketInfoStatisticVO.builder().ticketInfoType("操作票").ticketInfoNumber(operateTicketReportStatistic.size()).ticketInfoCompleteNum(ticketInfoCompleteNum).ticketInfoQualifiedNum(ticketInfoQualifiedNum).ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum).ticketInfoProportion(ticketInfoProportion).build();
result = TicketInfoStatisticVO.builder()
.ticketInfoType("操作票")
.ticketInfoNumber(operateTicketReportStatistic.size())
.ticketInfoCompleteNum(ticketInfoCompleteNum)
.ticketInfoQualifiedNum(ticketInfoQualifiedNum)
.ticketInfoStartNum(operateTicketReportStatistic.size() - ticketInfoCompleteNum)
.ticketInfoProportion(ticketInfoProportion)
.build();
} }
return result; return result;
} }
@ -712,7 +694,9 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
public List<StandardTicketInfoEntity> selectStandardTicketByDeptIdWithTicketType(List<Long> createDept, String ticketType, String dateTime) { public List<StandardTicketInfoEntity> selectStandardTicketByDeptIdWithTicketType(List<Long> createDept, String ticketType, String dateTime) {
QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<StandardTicketInfoEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(StandardTicketInfoEntity::getTicketType, ticketType); queryWrapper.lambda().eq(StandardTicketInfoEntity::getTicketType, ticketType);
if (CollectionUtils.isNotEmpty(createDept)) {
queryWrapper.lambda().in(StandardTicketInfoEntity::getCreateDept, createDept); queryWrapper.lambda().in(StandardTicketInfoEntity::getCreateDept, createDept);
}
queryWrapper.apply("date_format(CREATE_TIME,'%Y-%m') = {0}", dateTime); queryWrapper.apply("date_format(CREATE_TIME,'%Y-%m') = {0}", dateTime);
return baseMapper.selectList(queryWrapper); return baseMapper.selectList(queryWrapper);
} }

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/utils/OperationWordHelper.java

@ -44,8 +44,10 @@ public class OperationWordHelper {
switch (status) { switch (status) {
case 1: case 1:
result = "电气操作票.docx"; result = "电气操作票.docx";
break;
default: default:
result = "电气操作票.docx"; result = "电气操作票.docx";
break;
} }
return result; return result;
} }

14
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java

@ -6,6 +6,7 @@ import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
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.ObjectUtils;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity;
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService;
@ -19,6 +20,7 @@ import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountResponseVo;
import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountVo; import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountVo;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService;
import jodd.util.ObjectUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -82,6 +84,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
@SneakyThrows @SneakyThrows
@Override @Override
public void loadMonthReport(String dateTime) { public void loadMonthReport(String dateTime) {
//根据登录人查询所属机构及下属机构 //根据登录人查询所属机构及下属机构
BladeUser user = AuthUtil.getUser(); BladeUser user = AuthUtil.getUser();
List<Long> createDept = userClient.getDataScope(user.getUserId()); List<Long> createDept = userClient.getDataScope(user.getUserId());
@ -92,6 +95,7 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
List<TicketCount> ticketCounts = baseMapper.selectList(queryWrapper); List<TicketCount> ticketCounts = baseMapper.selectList(queryWrapper);
return ticketCounts; return ticketCounts;
}, executor); }, executor);
//第一种工作票 //第一种工作票
CompletableFuture<Void> oneTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> { CompletableFuture<Void> oneTicketCompletableFuture = ticketCountsCompletableFuture.thenAcceptAsync((items) -> {
//查询第一种工作票 //查询第一种工作票
@ -324,10 +328,13 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
ticketCount.setTenantId(user.getTenantId()); ticketCount.setTenantId(user.getTenantId());
ticketCount.setCreateDept(Long.valueOf(user.getDeptId())); ticketCount.setCreateDept(Long.valueOf(user.getDeptId()));
ticketCount.setCreateUser(user.getUserId()); ticketCount.setCreateUser(user.getUserId());
log.info("getStandardTicketCountList entry.getKey() ================================================> " + entry.getKey());
if (ObjectUtils.isNotEmpty(entry.getKey())) {
//根据id获取部门名称 //根据id获取部门名称
R<String> deptName = systemClient.getDeptName(entry.getKey()); R<String> deptName = systemClient.getDeptName(entry.getKey());
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
ticketCount.setDeptName(deptName.getData()); ticketCount.setDeptName(deptName.getData() == null ? "" : deptName.getData());
}
} }
List<StandardTicketInfoEntity> values = entry.getValue(); List<StandardTicketInfoEntity> values = entry.getValue();
ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getTicketType() : ticketType); ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getTicketType() : ticketType);
@ -389,10 +396,13 @@ public class TicketCountServiceImpl extends BaseServiceImpl<TicketCountMapper, T
TicketCount ticketCount = new TicketCount(); TicketCount ticketCount = new TicketCount();
ticketCount.setDeptId(entry.getKey()); ticketCount.setDeptId(entry.getKey());
ticketCount.setDateTime(dateTime); ticketCount.setDateTime(dateTime);
log.info("getTicketCountList entry.getKey() ================================================> " + entry.getKey());
if (ObjectUtils.isNotEmpty(entry.getKey())) {
//根据id获取部门名称 //根据id获取部门名称
R<String> deptName = systemClient.getDeptName(entry.getKey()); R<String> deptName = systemClient.getDeptName(entry.getKey());
if (deptName.isSuccess()) { if (deptName.isSuccess()) {
ticketCount.setDeptName(deptName.getData()); ticketCount.setDeptName(deptName.getData() == null ? "" : deptName.getData());
}
} }
List<WorkTicketInfoEntity> values = entry.getValue(); List<WorkTicketInfoEntity> values = entry.getValue();
ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getType() : ticketType); ticketCount.setTicketType(CollectionUtils.isNotEmpty(values) ? values.get(0).getType() : ticketType);

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -249,6 +249,8 @@ public class TicketProcessServiceImpl implements TicketProcessService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void findPending(ProcessWorkFlowResponse response) { public void findPending(ProcessWorkFlowResponse response) {
try {
log.info("获取待处理的数据 {}", response); log.info("获取待处理的数据 {}", response);
log.info("获取businessKey: {}", response.getBusinessKey()); log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId()); log.info("获取taskId: {}", response.getTaskId());
@ -478,6 +480,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
} }
log.info("推送成功~"); log.info("推送成功~");
} }
} catch (Exception e) {
e.printStackTrace();
}
} }

8
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

@ -242,7 +242,10 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
if (ObjectUtil.isNotEmpty(req.getCreateDept())) { if (ObjectUtil.isNotEmpty(req.getCreateDept())) {
lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept()); lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept());
} }
//已完成的工作票
if (StringUtils.isNotEmpty(req.getFlowTaskName())) {
lqw.eq(WorkTicketInfoEntity::getFlowTaskName,req.getFlowTaskName());
}
lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime); lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime);
IPage<WorkTicketInfoEntity> pages = this.page(Condition.getPage(query), lqw); IPage<WorkTicketInfoEntity> pages = this.page(Condition.getPage(query), lqw);
//数据转换 //数据转换
@ -1104,7 +1107,10 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
public List<WorkTicketInfoEntity> selectTicketByDeptIdWithTicketType(List<Long> createDept, String ticketType, String dateTime) { public List<WorkTicketInfoEntity> selectTicketByDeptIdWithTicketType(List<Long> createDept, String ticketType, String dateTime) {
QueryWrapper<WorkTicketInfoEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<WorkTicketInfoEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(WorkTicketInfoEntity::getType, ticketType); queryWrapper.lambda().eq(WorkTicketInfoEntity::getType, ticketType);
if (CollectionUtils.isNotEmpty(createDept)) {
queryWrapper.lambda().in(BaseEntity::getCreateDept, createDept); queryWrapper.lambda().in(BaseEntity::getCreateDept, createDept);
}
queryWrapper.apply("date_format(CREATE_TIME,'%Y-%m') = {0}" , dateTime); queryWrapper.apply("date_format(CREATE_TIME,'%Y-%m') = {0}" , dateTime);
return baseMapper.selectList(queryWrapper); return baseMapper.selectList(queryWrapper);
} }

BIN
hzims-service/ticket/src/main/resources/template/电气操作票.docx

Binary file not shown.
Loading…
Cancel
Save