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. 47
      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. 470
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/WindHomeServiceImpl.java
  16. 294
      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. 56
      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. 26
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketCountServiceImpl.java
  23. 415
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  24. 10
      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)
private int rideCount;
@ApiModelProperty(value = "经度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lgtd;
@ApiModelProperty(value = "纬度")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Double lttd;
@ApiModelProperty(value = "机组运行状态")
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
*/
@Data
@ApiModel(value = "水电站分计对象")
@ApiModel(value = "风电集团/区域指标对象")
public class WindScoreVo {
@ApiModelProperty(value = "机构Id")
private Long departId;
@ApiModelProperty(value = "机构名称")
private String departName;
@ApiModelProperty(value = "站点数量")
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>
<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>
<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
public ExecutorService logExecutorService() {
return new ThreadPoolExecutor(1, 1,
return new ThreadPoolExecutor(2, 5,
0L, TimeUnit.MILLISECONDS,
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.fegin.IPushMsgClient;
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.PushMessageServiceImpl;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
@ -79,4 +80,15 @@ public class MessageController extends BladeController {
IMessageService messageService = SpringUtil.getBean(WebsocketServiceImpl.class);
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));
}
}

47
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.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicReference;
@ -42,6 +43,7 @@ public class PushMessageServiceImpl implements IMessageService {
private final IPushClient pushClient;
private final BladeLogger logger;
private final ExecutorService appMessagePushExecutor;
@Override
@SaveLog(type = MessageConstants.APP_NAME)
@ -87,37 +89,14 @@ public class PushMessageServiceImpl implements IMessageService {
}
@Override
public boolean send(MessagePushRecordEntity request) {
PushInfoVO pushInfoVO = new PushInfoVO();
pushInfoVO.setTenantId(Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId());
ArrayList<PlatformType> platformTypes = Lists.newArrayList(PlatformType.Android, PlatformType.IOS);
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推送
else if(PlatformType.IOS.equals(platformType)) {
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;
public boolean send(MessagePushRecordEntity request) {
String tenantId = Func.isNotEmpty(AuthUtil.getTenantId()) ? AuthUtil.getTenantId() : request.getTenantId();
try {
return this.sendByUsers(request.getSubject(), request.getContent(), Func.toStrList(",",request.getPusher()),tenantId);
}
catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
@ -125,7 +104,7 @@ public class PushMessageServiceImpl implements IMessageService {
* @param subject 消息主题
* @param content 消息内容
* @param userIds 用户ID列表
* @param tenantId 推送成功标识
* @param tenantId 租户ID
* @return
*/
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);
return pushResult.isSuccess();
});
new Thread(androidPush,"安卓推送").start();
appMessagePushExecutor.submit(new Thread(androidPush,"安卓推送"));
// IOS推送
FutureTask<Boolean> iosPush = new FutureTask<>(() -> {
@ -153,7 +132,7 @@ public class PushMessageServiceImpl implements IMessageService {
R<PushResponse> pushResult = pushClient.tenantPush(pushInfoVO);
return pushResult.isSuccess();
});
new Thread(iosPush,"ios推送").start();
appMessagePushExecutor.submit(new Thread(iosPush,"ios推送"));
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.hnac.hzims.operational.main.service.WindHomeService;
import com.hnac.hzims.operational.main.vo.HydropowerScoreVo;
import com.hnac.hzims.operational.main.vo.WindScoreVo;
import com.hnac.hzims.operational.main.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* @author ysj
*/
@ -34,4 +35,36 @@ public class WindHomeController extends BladeController {
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;
import com.hnac.hzims.operational.main.vo.WindScoreVo;
import com.hnac.hzims.operational.main.vo.*;
import java.util.List;
/**
* @author ysj
@ -9,4 +11,12 @@ public interface WindHomeService {
WindScoreVo KPIs(Long deptId);
WindStationVo station(Long deptId);
List<WindGenerationVo> generation(Long deptId);
List<WindTargetCurveVo> target_curve(Long deptId);
List<WindSubordinateVo> subordinate(Long deptId);
}

470
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;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
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.service.WindService;
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.vo.WindScoreVo;
import com.hnac.hzims.operational.main.vo.*;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService;
import lombok.RequiredArgsConstructor;
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.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 java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -27,10 +47,25 @@ import java.util.stream.Collectors;
@Slf4j
public class WindHomeServiceImpl implements WindHomeService {
private final WindService windService;
private final AreaService areaService;
private final IWeatherService weatherService;
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
public WindScoreVo KPIs(Long deptId) {
// 查询风电站
@ -38,74 +73,405 @@ public class WindHomeServiceImpl implements WindHomeService {
eq(StationEntity::getServeType, HomePageConstant.HYDROPOWER_SERVETYPE);
eq(StationEntity::getType,HomePageConstant.WIND_POWER);
}});
if(CollectionUtil.isNotEmpty(stations)){
if(CollectionUtil.isEmpty(stations)){
return new WindScoreVo();
}
// 查询站点年填报数据
List<WindEntity> years = 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)));
// 查询站点填报数据
List<WindEntity> winds = windService.list(new LambdaQueryWrapper<WindEntity>() {{
in(WindEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList()));
}});
WindScoreVo score = new WindScoreVo();
// 站点数量
score.setStationCount(stations.size());
this.year(years,score);
this.mon(mons,score);
this.days(days,score);
if(CollectionUtil.isEmpty(winds)){
return score;
}
// 装机容量
List<EminfoAndEmParamVo> devices = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(), new TypeReference<List<EminfoAndEmParamVo>>() {});
if(CollectionUtil.isNotEmpty(devices)){
score.setInstalledCapacity(devices.stream().filter(o->stations.stream().map(StationEntity::getRefDept).collect(Collectors.toList()).contains(o.getCreateDept())).mapToDouble(EminfoAndEmParamVo::getInstalledCapacity).sum());
}
// 年发电量
score.setGenerateYear(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy"))).mapToDouble(WindEntity::getPower).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){
score.setCompleteRate(BigDecimal.valueOf(score.getGenerateYear() / score.getPlanYear() * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}
// 月发电量
score.setGenerateMon(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getPower).sum());
// 月平均风速
score.setSpeedRate(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getSpeed).average().getAsDouble());
// 月短期准确率
score.setAccuracy(winds.stream().filter(o->o.getFillDate().contains(DateUtil.format(new Date(),"yyyy-MM"))).mapToDouble(WindEntity::getAccuracy).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;
}
/**
* 风电数据 -
* @param years
* @param score
* 近3年发电量
* @param winds
* @return
*/
private void year(List<WindEntity> years, WindScoreVo score) {
if(CollectionUtil.isNotEmpty(years)){
return;
private List<PowerYearVo> threeGenerateYear(List<WindEntity> winds) {
List<String> mons = this.mons(2,12,false);
// 月份发电量赋值
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<>();
}
// 年发电量
score.setGenerateYear(years.stream().mapToDouble(WindEntity::getPower).sum());
// 年计划发电量
score.setPlanYear(years.stream().mapToDouble(WindEntity::getPlan).sum());
// 年发电完成率
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());
// 转换年份分组
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 mons
* @param score
* 区域天气
* @param scale
* @param nowWeather
* @param weekWeather
* @param code
*/
private void mon(List<WindEntity> mons, WindScoreVo score) {
// 月发电量
score.setGenerateMon(mons.stream().mapToDouble(WindEntity::getPower).sum());
// 月平均风速
score.setSpeedRate(mons.stream().mapToDouble(WindEntity::getSpeed).average().getAsDouble());
// 月短期准确率
score.setAccuracy(mons.stream().mapToDouble(WindEntity::getAccuracy).average().getAsDouble());
// 月超短期准确率
score.setUltraShortAccuracyRate(mons.stream().mapToDouble(WindEntity::getUltraShortAccuracy).average().getAsDouble());
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 days
* @param score
* 站点指标数据
* @param deptId
* @return
*/
private void days(List<WindEntity> days, WindScoreVo score) {
// 日发电量
score.setGenerateDay(days.stream().mapToDouble(WindEntity::getPower).sum());
@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;
}
}

294
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.entity.User;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
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.support.DefaultTransactionDefinition;
import java.time.Instant;
import java.time.LocalDate;
@ -46,6 +50,9 @@ import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
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.Stream;
@ -71,6 +78,11 @@ public class MaintenanceServiceImpl implements MaintenanceService {
private final IFlowClient flowClient;
private final ISysClient sysClient;
private final ThreadPoolExecutor executor;
private final DataSourceTransactionManager dataSourceTransactionManager;
/**
* 日常维护生成任务
*
@ -79,33 +91,31 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override
@Transactional(rollbackFor = Exception.class)
public void createTask(List<String> ids) {
//获取日常维护计划
LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids);
List<OperMaintenancePlanEntity> planEntities = maintenancePlanService
.list(planEntityLambdaQueryWrapper);
//筛选当月没生成任务的计划
List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity ->
ObjectUtil.isEmpty(planEntity.getCreateTaskTime())
|| !DateUtil.judgeSameDay(
DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())
).collect(Collectors.toList());
if (CollectionUtil.isEmpty(finalPlanEntities)) {
throw new ServiceException("所选计划当天已生成任务");
}
for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) {
// 通过计划生成任务
this.createTaskByPlan(finalPlanEntity);
//更新任务派发时间
LambdaUpdateWrapper<OperMaintenancePlanEntity> planEntityLambdaUpdateWrapper =
new LambdaUpdateWrapper<>();
planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date());
planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId());
boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper);
if (!update) {
log.error("maintenance:generateTask 更新任务派发失败");
throw new ServiceException("更新任务派发失败");
try {
//获取日常维护计划
LambdaQueryWrapper<OperMaintenancePlanEntity> planEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
planEntityLambdaQueryWrapper.in(BaseEntity::getId, ids);
List<OperMaintenancePlanEntity> planEntities = maintenancePlanService.list(planEntityLambdaQueryWrapper);
//筛选当月没生成任务的计划
List<OperMaintenancePlanEntity> finalPlanEntities = planEntities.stream().filter(planEntity -> ObjectUtil.isEmpty(planEntity.getCreateTaskTime()) || !DateUtil.judgeSameDay(DateUtil.DateToLocalDateTime(planEntity.getCreateTaskTime()), LocalDate.now())).collect(Collectors.toList());
if (CollectionUtil.isEmpty(finalPlanEntities)) {
throw new ServiceException("所选计划当天已生成任务");
}
for (OperMaintenancePlanEntity finalPlanEntity : finalPlanEntities) {
// 通过计划生成任务
this.createTaskByPlan(finalPlanEntity);
//更新任务派发时间
LambdaUpdateWrapper<OperMaintenancePlanEntity> planEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
planEntityLambdaUpdateWrapper.set(OperMaintenancePlanEntity::getCreateTaskTime, new Date());
planEntityLambdaUpdateWrapper.eq(OperMaintenancePlanEntity::getId, finalPlanEntity.getId());
boolean update = maintenancePlanService.update(planEntityLambdaUpdateWrapper);
if (!update) {
log.error("maintenance:generateTask 更新任务派发失败");
throw new ServiceException("更新任务派发失败");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
@ -117,107 +127,108 @@ public class MaintenanceServiceImpl implements MaintenanceService {
@Override
@Transactional(rollbackFor = RuntimeException.class)
public void findPending(ProcessWorkFlowResponse response) {
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {} ", response.getTaskId());
log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
log.info("获取下一个用户Id是: {} ", response.getUserId());
log.info("获取当前任务名称是: {} ", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
OperMaintenanceTaskEntityVo standardTicketInfoVo = null;
try {
JSONObject jsonObject = JSONObject.parseObject(formData);
standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"),
new TypeReference<OperMaintenanceTaskEntityVo>(){});
// standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo");
// standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class);
} catch (Exception e) {
log.error("获取表单出现异常了~~~~");
throw new IllegalArgumentException(e.getMessage());
}
//1.查询日常维护信息
Long id = NumberUtils.toLong(response.getBusinessKey());
OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id);
if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) {
log.error("获取日常维护数据不存在");
return;
}
OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity();
BeanUtils.copyProperties(standardTicketInfoVo, entity);
entity.setId(id);
//填充日常维护信息
saveOperMaintenanceTaskEntity(entity, response);
entity.setProcessInstanceId(response.getProcessInstanceId());
taskService.updateById(entity);
//推送消息
if (response.getTaskId() != null) {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
// message.setTaskId(entity.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一条日常维护任务待审批,工作内容:".concat(entity.getTitle())
// .concat(",审批环节:")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(entity.getCreateDept());
// R<String> deptName = sysClient.getDeptName(entity.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (com.hnac.hzims.common.logs.utils.StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getDescription());
businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle())
.concat(",审批环节:")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {} ", response.getTaskId());
log.info("获取下一个审批人是: {} ", response.getNextStepOperator());
log.info("获取下一个用户Id是: {} ", response.getUserId());
log.info("获取当前任务名称是: {} ", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
OperMaintenanceTaskEntityVo standardTicketInfoVo = null;
try {
JSONObject jsonObject = JSONObject.parseObject(formData);
standardTicketInfoVo = JSONObject.parseObject(jsonObject.getString("operMaintenanceTaskEntityVo"), new TypeReference<OperMaintenanceTaskEntityVo>() {
});
// standardTicketInfoVo = (OperMaintenanceTaskEntityVo) jsonObject.get("operMaintenanceTaskEntityVo");
// standardTicketInfoVo = JSONObject.toJavaObject(jsonObject, OperMaintenanceTaskEntityVo.class);
} catch (Exception e) {
log.error("获取表单出现异常了~~~~");
throw new IllegalArgumentException(e.getMessage());
}
String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(dbOperMaintenanceTaskEntity.getCreateUser());
//1.查询日常维护信息
Long id = NumberUtils.toLong(response.getBusinessKey());
OperMaintenanceTaskEntity dbOperMaintenanceTaskEntity = taskService.getById(id);
if (ObjectUtils.isEmpty(dbOperMaintenanceTaskEntity)) {
log.error("获取日常维护数据不存在");
return;
}
OperMaintenanceTaskEntity entity = new OperMaintenanceTaskEntity();
BeanUtils.copyProperties(standardTicketInfoVo, entity);
entity.setId(id);
//填充日常维护信息
saveOperMaintenanceTaskEntity(entity, response);
entity.setProcessInstanceId(response.getProcessInstanceId());
taskService.updateById(entity);
//推送消息
if (response.getTaskId() != null) {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.OPERATIONTICKETMESSAGE.getDescription());
// message.setTaskId(entity.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一条日常维护任务待审批,工作内容:".concat(entity.getTitle())
// .concat(",审批环节:")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(entity.getCreateDept());
// R<String> deptName = sysClient.getDeptName(entity.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (com.hnac.hzims.common.logs.utils.StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.ROUTINEMAINTENANCE.getDescription());
businessMessageDTO.setTaskId(dbOperMaintenanceTaskEntity.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent = "您有一条日常维护任务待审批,工作内容:".concat(dbOperMaintenanceTaskEntity.getTitle()).concat(",审批环节:").concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(dbOperMaintenanceTaskEntity.getCreateDept());
R<String> deptName = sysClient.getDeptName(dbOperMaintenanceTaskEntity.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(dbOperMaintenanceTaskEntity.getCreateUser());
log.info("================================================");
log.info("businessMessageDTO = " + businessMessageDTO);
log.info("================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
log.info("================================================");
log.info("businessMessageDTO = " + businessMessageDTO);
log.info("================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
}
log.info("推送成功~");
}
log.info("推送成功~");
} catch (Exception e) {
e.printStackTrace();
}
}
@ -281,6 +292,9 @@ public class MaintenanceServiceImpl implements MaintenanceService {
* @param 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.setCreateTime(new Date());
taskEntity.setUpdateTime(new Date());
@ -299,8 +313,7 @@ public class MaintenanceServiceImpl implements MaintenanceService {
if (ObjectUtil.isNotEmpty(finalPlanEntity.getMaintenanceModel()) && finalPlanEntity.getMaintenanceModel() == 2) {
//查询值班信息
LambdaQueryWrapper<ImsDutyMainEntity> entityLambdaQueryWrapper = new LambdaQueryWrapper<>();
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate,
DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getDutyDate, DateTimeFormatter.ofPattern(PATTERN_DATE).format(disposeTime));
entityLambdaQueryWrapper.eq(ImsDutyMainEntity::getClassId, finalPlanEntity.getImsDutyClassId());
ImsDutyMainEntity entity = mainService.getOne(entityLambdaQueryWrapper);
if (ObjectUtil.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getDutyPersonIds())) {
@ -312,16 +325,26 @@ public class MaintenanceServiceImpl implements MaintenanceService {
}
}
taskService.save(taskEntity);
//生成工作流实例
dataSourceTransactionManager.commit(transaction);
//启动流程
String processInstanceId = this.startProcess(finalPlanEntity.getProcDefId(), taskEntity);
taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity);
finalPlanEntity.setCreateTaskTime(new Date());
maintenancePlanService.updateById(finalPlanEntity);
taskEntity = taskService.getById(taskEntity.getId());
//推送消息
this.pushTaskMessage(taskEntity);
CompletableFuture<Void> operMaintenanceTaskEntityCompletableFuture =
CompletableFuture.runAsync(() -> {
taskEntity.setProcessInstanceId(processInstanceId);
taskService.updateById(taskEntity);
finalPlanEntity.setCreateTaskTime(new Date());
maintenancePlanService.updateById(finalPlanEntity);
OperMaintenanceTaskEntity maintenanceTask = taskService.getById(taskEntity.getId());
//推送消息
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("operMaintenanceTaskEntityVo", operMaintenanceTaskEntityVo);
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey,
String.valueOf(taskEntity.getId()), taskEntity.getTitle(), params)
.getData()
.getProcessInstanceId();
return flowClient.startProcessInstanceContainNameByKey(processDefinitionKey, 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.LocalDateTime;
import java.time.YearMonth;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
@ -42,10 +44,11 @@ public class OperMaintenanceMonitorServiceImpl implements IOperMaintenanceMonito
@Override
public R<Map<String, List<OperMaintenancePlanVO>>> reportMonth(OperMaintenanceMonitorReportMonthDTO req) {
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);
ge(OperMaintenancePlanEntity::getDisposeTime, startTime);
lt(OperMaintenancePlanEntity::getDisposeTime, DateUtil.plusMonths(startTime, 1));
ge(OperMaintenancePlanEntity::getDisposeTime, startDate);
lt(OperMaintenancePlanEntity::getDisposeTime, startDate.with(TemporalAdjusters.lastDayOfMonth()));
}});
//获取列表班次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");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一张作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle())
"您有一张作票待审批,工作内容:".concat(standardTicketInfoEntity.getTitle())
.concat(",审批环节:")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent);
@ -472,7 +472,7 @@ public class OperationTicketServiceImpl implements OperationTicketService {
Map<String, Object> map = PdfUtils.objectToMap(measure);
map.put("index", index.get());
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("hello1", "");
index.getAndIncrement();

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

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

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

@ -249,234 +249,239 @@ public class TicketProcessServiceImpl implements TicketProcessService {
@Override
@Transactional(rollbackFor = Exception.class)
public void findPending(ProcessWorkFlowResponse response) {
log.info("获取待处理的数据 {}", response);
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取下一个用户Id是: {}", response.getUserId());
log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
FristWorkTicketVo fristWorkFlowResponse = null;
try {
fristWorkFlowResponse = JSONObject.parseObject(formData, FristWorkTicketVo.class);
} catch (Exception e) {
log.error("获取表单出现异常了~~~~");
throw new IllegalArgumentException(e.getMessage());
}
//获取表单数据
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//2.流程处理
String businessKey = response.getBusinessKey();
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
if (ObjectUtils.isEmpty(workTicketInfo)) {
log.error("获取工作票的数据为不存在");
return;
}
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicket.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setCreateUser(workTicketInfo.getCreateUser());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
//更新安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) {
if (ObjectUtils.isNotEmpty(item.getId())) {
workTicketSafetyMeasureService.updateById(item);
} else {
item.setTicketId(workTicketInfo.getId());
workTicketSafetyMeasureService.save(item);
log.info("获取待处理的数据 {}", response);
log.info("获取businessKey: {}", response.getBusinessKey());
log.info("获取taskId: {}", response.getTaskId());
log.info("获取下一个审批人是: {}", response.getNextStepOperator());
log.info("获取下一个用户Id是: {}", response.getUserId());
log.info("获取当前任务名称是: {}", response.getTaskName());
log.info("获取根据handleType区分是用户还是候选组角色: {}", response.getHandleType());
//json转换表单
String formData = JSON.toJSONString(response.getVariables());
log.info("获取表单的数据:{}", formData);
FristWorkTicketVo fristWorkFlowResponse = null;
try {
fristWorkFlowResponse = JSONObject.parseObject(formData, FristWorkTicketVo.class);
} catch (Exception e) {
log.error("获取表单出现异常了~~~~");
throw new IllegalArgumentException(e.getMessage());
}
//获取表单数据
WorkTicketVo workTicketVo = fristWorkFlowResponse.getWorkTicketVo();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//2.流程处理
String businessKey = response.getBusinessKey();
WorkTicketInfoEntity workTicketInfo = ticketInfoService.getById(businessKey);
if (ObjectUtils.isEmpty(workTicketInfo)) {
log.error("获取工作票的数据为不存在");
return;
}
//更新工作票
workTicket.setId(workTicketInfo.getId());
//保存流程描述
workTicket.setCreateDept(workTicketInfo.getCreateDept());
workTicket.setCreateUser(workTicketInfo.getCreateUser());
workTicket.setTenantId(workTicketInfo.getTenantId());
saveWorkTicket(workTicket, response);
//工作流ID
workTicket.setProcessInstanceId(response.getProcessInstanceId());
workTicketInfoService.updateById(workTicket);
//更新安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
if (CollectionUtils.isNotEmpty(safetyMeasuresList)) {
log.info("获取安全措施的数据:{}", safetyMeasuresList);
for (WorkTicketSafetyMeasureEntity item : safetyMeasuresList) {
if (ObjectUtils.isNotEmpty(item.getId())) {
workTicketSafetyMeasureService.updateById(item);
} else {
item.setTicketId(workTicketInfo.getId());
workTicketSafetyMeasureService.save(item);
}
}
}
}
// 第二种 工作票工作任务组
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
workTicketContentDtoList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) {
contentService.save(item);
// 第二种 工作票工作任务组
List<WorkTicketContentEntity> workTicketContentDtoList = workTicketVo.getWorkTicketContentDtoList();
if (CollectionUtils.isNotEmpty(workTicketContentDtoList)) {
log.info("获取工作票工作任务组:{}", workTicketContentDtoList);
workTicketContentDtoList.forEach(item -> {
if (ObjectUtils.isEmpty(item.getId())) {
contentService.save(item);
} else {
contentService.updateById(item);
}
});
}
// 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
contentService.updateById(item);
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
}
});
}
// 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
if (ObjectUtils.isNotEmpty(workTicketDelay) && "延期".equals(workTicket.getInput())) {
WorkTicketDelayEntity workTicketDelayEntity = workTicketDelayService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作票延期:{}", workTicketDelay);
workTicketDelay.setCreateDept(workTicketInfo.getCreateDept());
workTicketDelay.setTicketId(workTicketInfo.getId());
workTicketDelay.setTenantId(workTicketInfo.getTenantId());
if (ObjectUtils.isEmpty(workTicketDelayEntity)) {
log.info("正在保存工作票延期");
workTicketDelayService.save(workTicketDelay);
} else {
log.info("正在更新工作票延期");
workTicketDelayService.updateByTicketId(workTicketDelay);
}
}
//工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue()));
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作结束:{}", workTicketFinish);
if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) {
log.info("获取工作结束保存成功");
workTicketFinish.setTicketId(workTicketInfo.getId());
workTicketFinishService.save(workTicketFinish);
} else {
log.info("获取工作结束更新成功");
workTicketDelay.setInitialTime(LocalDateTime.now());
workTicketFinishService.updateByTicketId(workTicketFinish);
//工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
log.info("工作结束==============>" + (workTicket.getFlowStatus().intValue()));
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
WorkTicketFinish ticketFinish = workTicketFinishService.selectByTicketId(workTicketInfo.getId());
log.info("获取工作结束:{}", workTicketFinish);
if (ObjectUtils.isEmpty(workTicketFinish.getId()) || ObjectUtils.isEmpty(ticketFinish)) {
log.info("获取工作结束保存成功");
workTicketFinish.setTicketId(workTicketInfo.getId());
workTicketFinishService.save(workTicketFinish);
} else {
log.info("获取工作结束更新成功");
workTicketDelay.setInitialTime(LocalDateTime.now());
workTicketFinishService.updateByTicketId(workTicketFinish);
}
}
}
// 工作开始时间和结束时间
// List<WorkTicketOperateTimeEntity> workTicketOperateTimeEntities = workTicketVo.getWorkTicketOperateTimeEntities();
// if (CollectionUtils.isNotEmpty(workTicketOperateTimeEntities)) {
// log.info("工作开始时间和结束时间:{}", workTicketFinish);
// workTicketOperateTimeService.saveBatch(workTicketOperateTimeEntities);
// }
//工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) {
log.info("工作票负责人变更: {}", workTicketPrincipalChange);
//原来的负责人
User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal());
//新的负责人
User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal());
workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept());
workTicketPrincipalChange.setTicketId(workTicketInfo.getId());
workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId());
if (workTicketPrincipalChange.getFlowCode() == null) {
workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr());
}
// 工作开始时间和结束时间
// List<WorkTicketOperateTimeEntity> workTicketOperateTimeEntities = workTicketVo.getWorkTicketOperateTimeEntities();
// if (CollectionUtils.isNotEmpty(workTicketOperateTimeEntities)) {
// log.info("工作开始时间和结束时间:{}", workTicketFinish);
// workTicketOperateTimeService.saveBatch(workTicketOperateTimeEntities);
// }
//工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange) && "转移".equals(workTicket.getInput())) {
log.info("工作票负责人变更: {}", workTicketPrincipalChange);
//原来的负责人
User user = UserCache.getUser(workTicketPrincipalChange.getInitialPrincipal());
//新的负责人
User newUser = UserCache.getUser(workTicketPrincipalChange.getChangePrincipal());
workTicketPrincipalChange.setCreateDept(workTicketInfo.getCreateDept());
workTicketPrincipalChange.setTicketId(workTicketInfo.getId());
workTicketPrincipalChange.setTenantId(workTicketInfo.getTenantId());
if (workTicketPrincipalChange.getFlowCode() == null) {
workTicketPrincipalChange.setFlowCode(IdWorker.getIdStr());
}
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity = workTicketPrincipalChangeService.selectByTicketId(workTicket.getId());
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else {
log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
if (ObjectUtils.isEmpty(workTicketPrincipalChangeEntity)) {
log.info("工作票负责人保存变更");
workTicketPrincipalChangeService.save(workTicketPrincipalChange);
} else {
log.info("工作票负责人更新变更");
workTicketPrincipalChangeService.updateByTicketId(workTicketPrincipalChange);
}
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
}
log.info("工作负责人变更 原来的负责人 {},变更为 {}", user.getName(), newUser.getName());
workTicket.setPrincipal(workTicketPrincipalChange.getChangePrincipal());
workTicket.setPrincipalName(newUser.getName());
//更新工作票
workTicketInfoService.updateById(workTicket);
}
//工作票危险点分析及控制措施票
if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId());
return item;
}).collect(Collectors.toList());
//工作票危险点分析及控制措施票
if (workTicket.getIsHazard()) {
List<TicketInfoDanger> ticketInfoDangers = workTicketVo.getTicketInfoDangers();
if (CollectionUtils.isNotEmpty(ticketInfoDangers)) {
List<TicketInfoDanger> collect = ticketInfoDangers.stream().map(item -> {
item.setTicketId(workTicketInfo.getId());
return item;
}).collect(Collectors.toList());
System.out.println("工作票危险点分析及控制措施票 : " + collect);
System.out.println("工作票危险点分析及控制措施票 : " + collect);
ticketInfoDangerService.saveBatch(collect);
ticketInfoDangerService.saveBatch(collect);
}
}
}
if (response.getTaskId() != null || response.getUserId() != null) {
//推送消息
// try {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
// message.setTaskId(workTicketInfo.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
// .concat(",审批环节: ")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(workTicketInfo.getCreateDept());
// message.setCreateDept(workTicketInfo.getCreateDept());
// R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// log.info("推送消息成功,用户名称{},消息{}", user.getName(), message);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(workTicketInfo.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
.concat(",审批环节: ")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(workTicketInfo.getCreateDept());
R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(workTicketInfo.getCreateUser());
System.out.println("======================================================");
System.out.println("businessMessageDTO = " + businessMessageDTO);
System.out.println("======================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
if (response.getTaskId() != null || response.getUserId() != null) {
//推送消息
// try {
// MessagePushRecordDto message = new MessagePushRecordDto();
// message.setBusinessClassify("business");
// message.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
// message.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
// message.setTaskId(workTicketInfo.getId());
// message.setTenantId("200000");
// message.setTypes(Arrays.asList(MessageConstants.APP_PUSH, MessageConstants.WS_PUSH));
// message.setPushType(MessageConstants.IMMEDIATELY);
// //您有一张工作票待审批,工作内容:*****,审批环节:*****;
// String countent =
// "您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
// .concat(",审批环节: ")
// .concat(response.getTaskName());
// message.setContent(countent);
// message.setDeptId(workTicketInfo.getCreateDept());
// message.setCreateDept(workTicketInfo.getCreateDept());
// R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
// if (deptName.isSuccess()) {
// message.setDeptName(deptName.getData());
// }
// String userIds = response.getUserId();
// if (StringUtils.isBlank(userIds)) {
// log.error("推送的消息不能为空哦,{}", userIds);
// return;
// }
// String[] split = userIds.split(",");
// for (String userId : split) {
// message.setPusher(userId);
// User user = UserCache.getUser(NumberUtils.toLong(userId));
// if (ObjectUtils.isNotEmpty(user)) {
// message.setPusherName(user.getName());
// }
// message.setAccount(userId);
// message.setCreateUser(NumberUtils.toLong(userId));
// messageClient.sendMessage(message);
// log.info("推送消息成功,用户名称{},消息{}", user.getName(), message);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
BusinessMessageDTO businessMessageDTO = new BusinessMessageDTO();
businessMessageDTO.setBusinessClassify("business");
businessMessageDTO.setBusinessKey(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getKey());
businessMessageDTO.setSubject(MessageConstants.BusinessClassifyEnum.TICKETMESSAGE.getDescription());
businessMessageDTO.setTaskId(workTicketInfo.getId());
businessMessageDTO.setTenantId("200000");
//您有一张工作票待审批,工作内容:*****,审批环节:*****;
String countent =
"您有一张工作票待审批,工作内容: ".concat(workTicketInfo.getWorkContent())
.concat(",审批环节: ")
.concat(response.getTaskName());
businessMessageDTO.setContent(countent);
businessMessageDTO.setDeptId(workTicketInfo.getCreateDept());
R<String> deptName = sysClient.getDeptName(workTicketInfo.getCreateDept());
if (deptName.isSuccess()) {
businessMessageDTO.setDeptName(deptName.getData());
}
String userIds = response.getUserId();
businessMessageDTO.setUserIds(userIds);
businessMessageDTO.setCreateUser(workTicketInfo.getCreateUser());
System.out.println("======================================================");
System.out.println("businessMessageDTO = " + businessMessageDTO);
System.out.println("======================================================");
R booleanR = messageClient.sendAppAndWsMsgByUsers(businessMessageDTO);
if (!booleanR.isSuccess()) {
throw new ServiceException("消息推送失败");
}
log.info("推送成功~");
}
log.info("推送成功~");
} catch (Exception e) {
e.printStackTrace();
}
}

10
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())) {
lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept());
}
//已完成的工作票
if (StringUtils.isNotEmpty(req.getFlowTaskName())) {
lqw.eq(WorkTicketInfoEntity::getFlowTaskName,req.getFlowTaskName());
}
lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime);
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) {
QueryWrapper<WorkTicketInfoEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(WorkTicketInfoEntity::getType, ticketType);
queryWrapper.lambda().in(BaseEntity::getCreateDept, createDept);
if (CollectionUtils.isNotEmpty(createDept)) {
queryWrapper.lambda().in(BaseEntity::getCreateDept, createDept);
}
queryWrapper.apply("date_format(CREATE_TIME,'%Y-%m') = {0}" , dateTime);
return baseMapper.selectList(queryWrapper);
}

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

Binary file not shown.
Loading…
Cancel
Save