diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java index 9d871bd..d39dde7 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/MessagePushRecordEntity.java @@ -14,6 +14,7 @@ import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tool.utils.DateUtil; import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDate; import java.time.LocalDateTime; @Data @@ -22,6 +23,13 @@ import java.time.LocalDateTime; @EqualsAndHashCode public class MessagePushRecordEntity extends MessageTemplateEntity { + @ApiModelProperty("站点编码") + @QueryField(condition = SqlCondition.EQUAL) + private String stationCode; + + @ApiModelProperty("站点名称") + private String stationName; + @ApiModelProperty("业务任务ID") @QueryField(condition = SqlCondition.EQUAL) private Long taskId; @@ -66,4 +74,16 @@ public class MessagePushRecordEntity extends MessageTemplateEntity { @ApiModelProperty(value = "响应说明") private String respondRemark; + @ApiModelProperty("查询开始时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATE) + @JsonFormat(pattern = DateUtil.PATTERN_DATE) + @TableField(exist = false) + private LocalDate startTime; + + @ApiModelProperty("查询结束时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATE) + @JsonFormat(pattern = DateUtil.PATTERN_DATE) + @TableField(exist = false) + private LocalDate endTime; + } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java index 3da5a62..93f5930 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/entity/config/MessageTemplateEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzims.message.entity.config; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -51,4 +52,8 @@ public class MessageTemplateEntity extends TenantEntity implements Serializable @QueryField(condition = SqlCondition.EQUAL) private String advanceTimeUnit; + @TableField(exist = false) + @ApiModelProperty(value = "创建人名称") + private String creatorName; + } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java index 76fbea8..1faa7cd 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/IMessageClient.java @@ -3,6 +3,7 @@ package com.hnac.hzims.message.fegin; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.entity.MessagePushRecordEntity; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestBody; public interface IMessageClient { String API_PREFIX = "/feign/message"; String SEND_SMS_MESSAGE = API_PREFIX + "/send-sms-message"; + String SEND_MESSAGE = API_PREFIX + "/sendMessage"; /** * 推送消息(短信) * @param pushDto @@ -25,4 +27,7 @@ public interface IMessageClient { */ @PostMapping(SEND_SMS_MESSAGE) R sendSmsMessage(SmsPushDto pushDto); + + @PostMapping(SEND_MESSAGE) + R sendMessage(@RequestBody MessagePushRecordEntity request); } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java index 9a393a3..0c6058a 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/fegin/MessageClientFallback.java @@ -2,6 +2,7 @@ package com.hnac.hzims.message.fegin; import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.entity.MessagePushRecordEntity; import org.springblade.core.tool.api.R; import org.springframework.stereotype.Component; @@ -15,4 +16,9 @@ public class MessageClientFallback implements IMessageClient { public R sendSmsMessage(SmsPushDto pushDto) { return R.fail("推送失败"); } + + @Override + public R sendMessage(MessagePushRecordEntity request) { + return R.fail("推送失败"); + } } diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordEntityVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordEntityVo.java new file mode 100644 index 0000000..2b2e11d --- /dev/null +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordEntityVo.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.message.vo.msgpushrecord; + +import lombok.Data; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:58 + */ +@Data +public class MessagePushRecordEntityVo { + + /** + * 站点编号 + */ + private String stationCode; + + /** + * 月份 + */ + private Integer month; + + + /** + * type + */ + private String type; +} diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java index 2cbd0d7..0362dd8 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/vo/msgpushrecord/MessagePushRecordVo.java @@ -5,6 +5,7 @@ import lombok.Data; import java.io.Serializable; import java.time.LocalDateTime; +import java.time.YearMonth; /** * @Author WL @@ -17,6 +18,12 @@ public class MessagePushRecordVo implements Serializable { /** + * 年 + */ + private Integer year; + + + /** * 月份 */ private Integer month; @@ -25,7 +32,8 @@ public class MessagePushRecordVo implements Serializable { /** * 实现推送时间 */ - private String strMonth; + private YearMonth strMonth; + /** * 消息类型 diff --git a/hzims-service/equipment/pom.xml b/hzims-service/equipment/pom.xml index 24ad6ad..6f37bf3 100644 --- a/hzims-service/equipment/pom.xml +++ b/hzims-service/equipment/pom.xml @@ -94,6 +94,10 @@ hzims-operational-api compile + + org.apache.commons + commons-collections4 + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index 1435528..d2a1d0a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java @@ -117,21 +117,6 @@ public class EmInfoController extends BladeController { @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入em_info") public R save(@Valid @RequestBody EmInfoAddVo em_info) { - List name = em_infoService.list(new QueryWrapper() {{ - eq("NAME", em_info.getInfo().getName()); - }}); - if (CollectionUtil.isNotEmpty(name)) { - return R.fail("设备名称已存在"); - } - if(Func.isNotEmpty(em_info.getInfo().getEmIndex())) { - List exist = em_infoService.list(Wrappers.lambdaQuery() - .eq(EmInfoEntity::getCreateDept, AuthUtil.getDeptId()) - .eq(EmInfoEntity::getEmIndex, em_info.getInfo().getEmIndex()) - ); - Assert.isTrue(CollectionUtil.isEmpty(exist),() -> { - throw new ServiceException("该设备序号已存在,设备新增失败"); - }); - } return em_infoService.saveInfo(em_info); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index 1361370..5430d51 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -23,6 +23,7 @@ import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.*; import org.springblade.system.vo.CreateTableVO; @@ -103,17 +104,11 @@ public class EmInfoServiceImpl extends BaseServiceImpl existResult = deviceClient.isDeviceCodeExist(em_info.getInfo().getNumber()); - Assert.isTrue(existResult.isSuccess() && !existResult.getData(),() -> { - throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!"); - }); - EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber()); - if (ObjectUtil.isNotEmpty(emInfoEntity)) { - return R.fail("设备编号已存在"); - } - - if (this.save(em_info.getInfo())) { + // 验证设备信息 + this.validEmInfo(em_info); + EmInfoEntity infoEntity = em_info.getInfo(); + //infoEntity.setNumber(Func.); + if (this.save(infoEntity)) { this.getStationCodeStoreRedis(); Long infoId = em_info.getInfo().getId(); if (em_info.getAttach() != null) { @@ -469,4 +464,34 @@ public class EmInfoServiceImpl extends BaseServiceImpl Math.abs(o.getInstalledCapacity()) > 0 || MapUtils.isNotEmpty(o.getPoint())).collect(Collectors.toList()))); } + + private void validEmInfo(EmInfoAddVo em_info) { + // 验证设备名称 + List existName = this.list( + Wrappers.lambdaQuery().eq(EmInfoEntity::getName, em_info.getInfo().getName()) + ); + Assert.isTrue(CollectionUtil.isEmpty(existName),()-> { + throw new ServiceException("设备名称已存在"); + }); + // 验证设备序号 + if(Func.isNotEmpty(em_info.getInfo().getEmIndex())) { + List exist = super.list(Wrappers.lambdaQuery() + .eq(EmInfoEntity::getCreateDept, AuthUtil.getDeptId()) + .eq(EmInfoEntity::getEmIndex, em_info.getInfo().getEmIndex()) + ); + Assert.isTrue(CollectionUtil.isEmpty(exist),() -> { + throw new ServiceException("该设备序号已存在,设备新增失败"); + }); + } + // 查询设备编码设备实例是否已存在 + R existResult = deviceClient.isDeviceCodeExist(em_info.getInfo().getNumber()); + Assert.isTrue(existResult.isSuccess() && !existResult.getData(),() -> { + throw new ServiceException("该设备编码在设备实例中找到对应记录,保存失败!"); + }); + // 验证设备编号是否已存在 + EmInfoEntity emInfoEntity = this.baseMapper.selectEmInfoByCode(em_info.getInfo().getNumber()); + Assert.isTrue(ObjectUtil.isEmpty(emInfoEntity),() -> { + throw new ServiceException("设备编号已存在"); + }); + } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java index ff38d71..a1f3fa8 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/MessagePushRecordController.java @@ -54,7 +54,7 @@ public class MessagePushRecordController extends BladeController { @GetMapping("/send/{id}") @ApiOperation("推送消息记录") @ApiOperationSupport(order = 4) - public R send(@PathVariable @ApiParam("消息记录ID") String id) { + public R send(@PathVariable @ApiParam("消息记录ID") Long id) { return R.data(messagePushRecordService.send(id)); } } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java index 99db6b8..1c43025 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/controller/web/MessageStatisticsController.java @@ -1,10 +1,7 @@ package com.hnac.hzims.message.controller.web; import com.hnac.hzims.message.service.IMessagePushRecordService; -import com.hnac.hzims.message.vo.msgpushrecord.BusinessTypeStatVo; -import com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordTypeVo; -import com.hnac.hzims.message.vo.msgpushrecord.PushStatTypeVo; -import com.hnac.hzims.message.vo.msgpushrecord.UserPushStatTypeVo; +import com.hnac.hzims.message.vo.msgpushrecord.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.api.R; @@ -23,7 +20,7 @@ import java.util.List; @Slf4j @RestController @RequiredArgsConstructor -@RequestMapping("/api/message/statistics") +@RequestMapping("/message/statistics") public class MessageStatisticsController { @@ -35,9 +32,9 @@ public class MessageStatisticsController { * @return */ @GetMapping("/smsPushStat") - public R smsPushStat() { + public R smsPushStat(MessagePushRecordEntityVo vo) { log.info("短信推送统计"); - List messagePushRecordVos = messagePushRecordService.smsPushStat(); + List messagePushRecordVos = messagePushRecordService.smsPushStat(vo); log.info("短信推送统计 返回的数据: {}",messagePushRecordVos); return R.data(messagePushRecordVos); } @@ -48,9 +45,9 @@ public class MessageStatisticsController { * 业务类型统计 */ @GetMapping("/businessTypeStat") - public R businessTypeStat() { + public R businessTypeStat(MessagePushRecordEntityVo vo) { log.info("业务类型统计"); - List messagePushRecordVos = messagePushRecordService.businessTypeStat(); + List messagePushRecordVos = messagePushRecordService.businessTypeStat(vo); log.info("业务类型统计 返回的数据: {}",messagePushRecordVos); return R.data(messagePushRecordVos); } @@ -60,9 +57,9 @@ public class MessageStatisticsController { * 人员发送统计 */ @GetMapping("/userPushStat") - public R userPushStat() { + public R userPushStat(MessagePushRecordEntityVo vo) { log.info("人员发送统计"); - List messagePushRecordVos = messagePushRecordService.userPushStat(); + List messagePushRecordVos = messagePushRecordService.userPushStat(vo); log.info("人员发送统计 返回的数据: {}",messagePushRecordVos); return R.data(messagePushRecordVos); } @@ -72,8 +69,8 @@ public class MessageStatisticsController { * 推送成功失败统计 */ @GetMapping("/pushStat") - public R pushStat() { - List messagePushRecordVos = messagePushRecordService.pushStat(); + public R pushStat(MessagePushRecordEntityVo vo) { + List messagePushRecordVos = messagePushRecordService.pushStat(vo); log.info("推送成功失败统计 返回的数据: {}",messagePushRecordVos); return R.data(messagePushRecordVos); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java index 352e2f9..3a04b61 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/fegin/MessageClient.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.PushDto; import com.hnac.hzims.message.dto.SmsPushDto; +import com.hnac.hzims.message.entity.MessagePushRecordEntity; +import com.hnac.hzims.message.service.IMessagePushRecordService; import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.service.impl.SmsMessageServiceImpl; import lombok.AllArgsConstructor; @@ -23,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j public class MessageClient extends BladeController implements IMessageClient{ + private final IMessagePushRecordService recordService; + @Override @PostMapping(SEND_SMS_MESSAGE) public R sendSmsMessage(@RequestBody SmsPushDto pushDto) { @@ -30,4 +34,10 @@ public class MessageClient extends BladeController implements IMessageClient{ return messageService.send(pushDto); } + @Override + @PostMapping(SEND_MESSAGE) + public R sendMessage(@RequestBody MessagePushRecordEntity request) { + return R.status(recordService.saveAndSend(request)); + } + } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java index 36af591..de23097 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.java @@ -1,14 +1,11 @@ package com.hnac.hzims.message.mapper; import com.hnac.hzims.message.entity.MessagePushRecordEntity; -import com.hnac.hzims.message.vo.msgpushrecord.BusinessTypeStatVo; -import com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordVo; -import com.hnac.hzims.message.vo.msgpushrecord.PushStatTypeVo; -import com.hnac.hzims.message.vo.msgpushrecord.UserPushStatTypeVo; +import com.hnac.hzims.message.vo.msgpushrecord.*; +import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import java.util.List; -import java.util.Map; public interface MessagePushRecordMapper extends UserDataScopeBaseMapper { @@ -16,27 +13,27 @@ public interface MessagePushRecordMapper extends UserDataScopeBaseMapper smsPushStat(); + List smsPushStat(@Param("vo") MessagePushRecordEntityVo vo); /** * 业务类型统计 * @return */ - List businessTypeStat(); + List businessTypeStat(@Param("vo") MessagePushRecordEntityVo vo); /** * 人员发送统计 * @return */ - List userPushStat(); + List userPushStat(@Param("vo") MessagePushRecordEntityVo vo); /** * 推送成功失败统计 * @return */ - List pushStat(); + List pushStat(@Param("vo") MessagePushRecordEntityVo vo); } diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml index 4c88d7f..9ae9935 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/mapper/MessagePushRecordMapper.xml @@ -23,15 +23,32 @@ type from hzims_message_push_record where IS_DELETED = 0 + + + and + STATION_CODE = #{vo.stationCode} + group by strMonth, TYPE @@ -42,6 +59,18 @@ count(1) count from hzims_message_push_record where IS_DELETED = 0 + + and + STATION_CODE = #{vo.stationCode} + + + and + date_format(PLAN_TIME, '%m') = #{vo.month} + + + and + type = #{vo.type} + group by businessClassify, pusherName @@ -61,6 +90,18 @@ \ No newline at end of file diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java index 797bec7..30565d2 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/schedule/MessagePushSchedule.java @@ -17,6 +17,7 @@ import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springframework.stereotype.Component; @@ -53,10 +54,14 @@ public class MessagePushSchedule { LocalDateTime endTime = DateUtil.plus(LocalDateTime.now(), template.getConcentratedDuration(), template.getConcentratedTimeUnit()); endTime = DateUtil.plus(endTime, template.getAdvanceDuration(), template.getAdvanceTimeUnit()); LambdaQueryWrapper lqw = Wrappers.lambdaQuery() - .eq(MessagePushRecordEntity::getStatus, MessageConstants.NOT_PUSH) - .ge(MessagePushRecordEntity::getPlanTime, now) - .le(MessagePushRecordEntity::getPlanTime, endTime); + .eq(MessagePushRecordEntity::getStatus, MessageConstants.NOT_PUSH) + .eq(MessagePushRecordEntity::getTemplateId,template.getId()) + .ge(MessagePushRecordEntity::getPlanTime, now) + .le(MessagePushRecordEntity::getPlanTime, endTime); List list = recordService.list(lqw); + if(CollectionUtil.isEmpty(list) || list.size() == 0) { + return; + } this.sendMessage(list); }); return ReturnT.SUCCESS; @@ -77,6 +82,9 @@ public class MessagePushSchedule { // 完善推送内容 request.setContent(this.getPushContent(type,records)); Boolean flag = service.send(request); + if(!flag) { + return; + } List ids = records.stream().map(MessagePushRecordEntity::getId).collect(Collectors.toList()); // 更新消息推送状态 LambdaUpdateWrapper lwq = Wrappers.lambdaUpdate() diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java index 1b7f1d4..b978230 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/IMessagePushRecordService.java @@ -2,15 +2,11 @@ package com.hnac.hzims.message.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.message.entity.MessagePushRecordEntity; -import com.hnac.hzims.message.vo.msgpushrecord.BusinessTypeStatVo; -import com.hnac.hzims.message.vo.msgpushrecord.MessagePushRecordTypeVo; -import com.hnac.hzims.message.vo.msgpushrecord.PushStatTypeVo; -import com.hnac.hzims.message.vo.msgpushrecord.UserPushStatTypeVo; +import com.hnac.hzims.message.vo.msgpushrecord.*; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import java.util.List; -import java.util.Map; public interface IMessagePushRecordService extends BaseService { @@ -35,34 +31,42 @@ public interface IMessagePushRecordService extends BaseService smsPushStat(); + List smsPushStat(MessagePushRecordEntityVo vo); /** * 业务类型统计 * @return */ - List businessTypeStat(); + List businessTypeStat(MessagePushRecordEntityVo vo); /** * 人员发送统计 * @return */ - List userPushStat(); + List userPushStat(MessagePushRecordEntityVo vo); /** * 推送成功失败统计 * @return */ - List pushStat(); + List pushStat(MessagePushRecordEntityVo vo); diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java index 2f2371a..c7d1e44 100644 --- a/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/service/impl/MessagePushRecordServiceImpl.java @@ -1,7 +1,10 @@ package com.hnac.hzims.message.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.config.MessageFactory; import com.hnac.hzims.message.entity.MessagePushRecordEntity; import com.hnac.hzims.message.enums.PushStatEnum; @@ -11,12 +14,16 @@ import com.hnac.hzims.message.service.IMessageService; import com.hnac.hzims.message.vo.msgpushrecord.*; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.utils.Func; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.Assert; +import java.time.LocalDateTime; import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -39,25 +46,62 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl { + throw new ServiceException("发送消息失败!"); + }); + // 更新推送状态以及推送时间 + LambdaUpdateWrapper luw = Wrappers.lambdaUpdate() + .set(MessagePushRecordEntity::getPushTime, LocalDateTime.now()) + .set(MessagePushRecordEntity::getStatus, MessageConstants.PUSH_SUCCESS) + .eq(MessagePushRecordEntity::getId, id); + return this.update(luw); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean saveAndSend(MessagePushRecordEntity request) { + if(Func.isEmpty(request.getPlanTime())) { + request.setPlanTime(LocalDateTime.now()); + } + if(this.save(request) && Func.isNotEmpty(request.getId())) { + return this.send(request.getId()); + } + return false; + } + /** + * 获取 QueryWrapper + * @param request 查询条件 + * @return QueryWrapper + */ + private LambdaQueryWrapper getQueryWrapper(MessagePushRecordEntity request) { + LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda(); + if(Func.isNotEmpty(request.getStartTime())) { + lambda.ge(MessagePushRecordEntity::getPushTime,request.getStartTime()); + } + if(Func.isNotEmpty(request.getEndTime())) { + lambda.le(MessagePushRecordEntity::getPushTime,request.getEndTime()); + } + lambda.orderByDesc(MessagePushRecordEntity::getPushTime); + return lambda; + } /** * 短信推送统计 */ @Override - public List smsPushStat() { + public List smsPushStat(MessagePushRecordEntityVo vo) { //根据type统计数量 - List messagePushRecordVos = baseMapper.smsPushStat(); + List messagePushRecordVos = baseMapper.smsPushStat(vo); messagePushRecordVos.forEach(item -> { - String strMonth = item.getStrMonth(); + YearMonth strMonth = item.getStrMonth(); // 字符串转localDate 获取月份 - int month = this.getCurrentMonth(strMonth); - item.setMonth(month); + item.setMonth(strMonth.getMonthValue()); + item.setYear(strMonth.getYear()); }); //按类型分组 @@ -81,8 +125,8 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl businessTypeStat() { - List businessTypeStatVos = baseMapper.businessTypeStat(); + public List businessTypeStat(MessagePushRecordEntityVo vo) { + List businessTypeStatVos = baseMapper.businessTypeStat(vo); businessTypeStatVos.forEach(item -> { String businessClassifyByName = this.getBusinessClassifyByName(item.getBusinessClassify()); item.setBusinessClassifyName(businessClassifyByName); @@ -96,8 +140,8 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl userPushStat() { - List userPushStatTypeVos = baseMapper.userPushStat(); + public List userPushStat(MessagePushRecordEntityVo vo) { + List userPushStatTypeVos = baseMapper.userPushStat(vo); //添加业务类型名称 userPushStatTypeVos.forEach(item -> { List pushStatList = item.getPushStatList(); @@ -117,8 +161,8 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl pushStat() { - List pushStatTypeVos = baseMapper.pushStat(); + public List pushStat(MessagePushRecordEntityVo vo) { + List pushStatTypeVos = baseMapper.pushStat(vo); pushStatTypeVos.forEach(item -> { //业务类型名称 String businessClassify = item.getBusinessClassify(); @@ -141,21 +185,6 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl getQueryWrapper(MessagePushRecordEntity request) { - LambdaQueryWrapper lambda = Condition.getQueryWrapper(request).lambda(); - if (Func.isNotEmpty(request.getStatus())) { - lambda.eq(MessagePushRecordEntity::getStatus, request.getStatus()); - } - return lambda; - } - - - /** * 状态 ===> 状态名称 * * @param key 状态 @@ -220,8 +249,8 @@ public class MessagePushRecordServiceImpl extends BaseServiceImpl implements IMessageTemplateService { @Override public List list(MessageTemplateEntity req) { - return this.list(this.getQueryWrapper(req)); + List record = this.list(this.getQueryWrapper(req)); + return MessageTemplateWrapper.build().listVO(record); } @Override public IPage listPage(MessageTemplateEntity req, Query query) { - return this.page(Condition.getPage(query) , this.getQueryWrapper(req)); + IPage page = this.page(Condition.getPage(query), this.getQueryWrapper(req)); + return page.setRecords(MessageTemplateWrapper.build().listVO(page.getRecords())); } /** diff --git a/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java b/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java new file mode 100644 index 0000000..31ba882 --- /dev/null +++ b/hzims-service/message/src/main/java/com/hnac/hzims/message/wrapper/MessageTemplateWrapper.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.message.wrapper; + +import com.hnac.hzims.message.entity.config.MessageTemplateEntity; +import org.springblade.core.mp.support.BaseEntityWrapper; +import org.springblade.system.cache.DictCache; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; + +import java.util.Optional; + +/** + * @ClassName MessageTemplateWrapper + * @description: + * @author: hx + * @create: 2023-04-06 17:30 + * @Version 4.0 + **/ +public class MessageTemplateWrapper extends BaseEntityWrapper { + + public static MessageTemplateWrapper build() { + return new MessageTemplateWrapper(); + } + + @Override + public MessageTemplateEntity entityVO(MessageTemplateEntity entity) { + User user = UserCache.getUser(entity.getCreateUser()); + entity.setCreatorName(Optional.ofNullable(user).map(User::getName).orElse(entity.getCreateUser().toString())); + return entity; + } +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 71be197..59aded9 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -641,7 +641,7 @@ public class StationServiceImpl extends BaseServiceImpl 1) { throw new ServiceException("获取站点数量超过一条"); } - return Optional.ofNullable(list).map(l -> l.get(0)).orElse(null); + return list.size() > 0 ? list.get(0) : null; } /** diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java new file mode 100644 index 0000000..4d0471b --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/constant/TicketProcessConstant.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.ticket.processflow.constant; + +/** + * 开票常量类 + * + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 10:53 + */ +public class TicketProcessConstant { + + public final static String STARTEVENT = "startEvent1"; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java index cbb5aec..b03730f 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/consumer/StandardWorkTicketConsumer.java @@ -5,14 +5,13 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.ticket.processflow.entity.WorkflowOperationLog; import com.hnac.hzims.ticket.processflow.service.WorkflowOperationLogService; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; -import com.hnac.hzims.ticket.processflow.strategy.service.TicketService; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.processflow.strategy.service.ProcessService; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import lombok.extern.slf4j.Slf4j; import org.springblade.queue.annotation.RedisQueue; import org.springblade.queue.consume.IQueueConsume; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.retry.listener.RetryListenerSupport; import org.springframework.stereotype.Service; import java.util.List; @@ -32,7 +31,7 @@ public class StandardWorkTicketConsumer implements IQueueConsume { @Autowired - private List ticketServiceList; + private List ticketServiceList; @Autowired private WorkflowOperationLogService workflowOperationLogService; @@ -40,12 +39,12 @@ public class StandardWorkTicketConsumer implements IQueueConsume { @Override public void handlerMessage(String message) { log.info("监听到数据:{}", message); - WorkTicketMessageResponse response = JSONObject.parseObject(message, WorkTicketMessageResponse.class); - String taskDefinitionKey = response.getTaskDefinitionKey(); + ProcessWorkFlowResponse response = JSONObject.parseObject(message, ProcessWorkFlowResponse.class); + String taskDefinitionKey = response.getProcessDefinitionKey(); WorkflowQueue ticker = new WorkflowQueue(); - ticker.setDeploymentId(taskDefinitionKey); + ticker.setProcessDefinitionKey(taskDefinitionKey); //判断执行具体的实现类 - TicketService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowTicket(ticker)) + ProcessService ticketService = ticketServiceList.stream().filter(item -> item.isWorkflowProcess(ticker)) .findFirst().orElse(null); if (ObjectUtils.isNotEmpty(ticketService)) { //执行业务方法 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java index e158466..ade2805 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/controller/ProcessTypeController.java @@ -10,8 +10,8 @@ import com.hnac.hzims.ticket.processflow.properties.TicketProperties; import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; import com.hnac.hzims.ticket.processflow.service.ProcessTypeService; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; -import com.hnac.hzims.ticket.processflow.strategy.service.TicketService; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.processflow.strategy.service.ProcessService; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import lombok.RequiredArgsConstructor; import org.springblade.core.tool.api.R; import org.springblade.core.tool.jackson.JsonUtil; @@ -48,7 +48,7 @@ public class ProcessTypeController { - private final List ticketServiceList; + private final List ticketServiceList; private final RedisTemplate redisTemplate; @@ -80,12 +80,12 @@ public class ProcessTypeController { public String list(@PathVariable String key) { //判断执行具体的实现类 WorkflowQueue workflowQueue = new WorkflowQueue(); - workflowQueue.setDeploymentId(key); - TicketService ticketService = - ticketServiceList.stream().filter(item -> item.isWorkflowTicket(workflowQueue)) + workflowQueue.setProcessDefinitionKey(key); + ProcessService ticketService = + ticketServiceList.stream().filter(item -> item.isWorkflowProcess(workflowQueue)) .findFirst().orElse(null); - String calculate = ticketService.calculate(null); - return calculate; + ticketService.calculate(null); + return "key"; } @@ -111,12 +111,11 @@ public class ProcessTypeController { action ="审批流处理") @GetMapping("/build") public void addList() { - - WorkTicketMessageResponse workTicketMessageResponse = new WorkTicketMessageResponse(); + ProcessWorkFlowResponse workTicketMessageResponse = new ProcessWorkFlowResponse(); workTicketMessageResponse.setTaskId("1"); - workTicketMessageResponse.setProcessInstanceKey("1"); + workTicketMessageResponse.setProcessDefinitionKey("1"); workTicketMessageResponse.setTaskName("1"); - workTicketMessageResponse.setFormData(1); + workTicketMessageResponse.setFormData("1"); String qqqq = JsonUtil.toJson(workTicketMessageResponse); queueProduceService.sendMessage("blade:queue:flow",qqqq); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/TicketAbstractService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/ProcessAbstractService.java similarity index 61% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/TicketAbstractService.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/ProcessAbstractService.java index 0589fb2..c00872d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/TicketAbstractService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/abstracts/ProcessAbstractService.java @@ -1,11 +1,8 @@ package com.hnac.hzims.ticket.processflow.strategy.abstracts; import com.hnac.hzims.ticket.processflow.entity.ProcessType; -import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; -import com.hnac.hzims.ticket.processflow.properties.TicketProperties; import com.hnac.hzims.ticket.processflow.service.ProcessTypeService; -import com.hnac.hzims.ticket.processflow.service.WorkflowOperationLogService; -import com.hnac.hzims.ticket.processflow.strategy.service.TicketService; +import com.hnac.hzims.ticket.processflow.strategy.service.ProcessService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +15,7 @@ import java.util.List; * @Date 2023/3/28 9:02 */ @Slf4j -public abstract class TicketAbstractService implements TicketService { +public abstract class ProcessAbstractService implements ProcessService { @@ -30,7 +27,7 @@ public abstract class TicketAbstractService implements TicketService { * * @return */ - public List getTicketList() { + public List getProcessList() { log.info("实例化:" + processTypeService); List workTickets = processTypeService.list(); return workTickets; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/TicketIdWorker.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java similarity index 98% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/TicketIdWorker.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java index ef486b0..70aafab 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/TicketIdWorker.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java @@ -2,7 +2,6 @@ package com.hnac.hzims.ticket.processflow.strategy.core; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.hnac.hzims.common.config.RedisMessageListener; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; @@ -24,7 +23,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @Date 2023/3/27 10:11 */ @Component -public class TicketIdWorker { +public class ProcessIdWorker { private static Map cacheMap = new HashMap<>(); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/entity/WorkflowQueue.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/entity/WorkflowQueue.java index c29ea11..1424f63 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/entity/WorkflowQueue.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/entity/WorkflowQueue.java @@ -16,7 +16,7 @@ public class WorkflowQueue { /** * 当前环节流程ID */ - private String deploymentId; + private String processDefinitionKey; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/TicketService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/ProcessService.java similarity index 63% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/TicketService.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/ProcessService.java index 31ceab6..6dd725b 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/TicketService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/service/ProcessService.java @@ -1,6 +1,6 @@ package com.hnac.hzims.ticket.processflow.strategy.service; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; /** @@ -9,20 +9,20 @@ import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; * @Serial 1.0 * @Date 2023/3/27 16:39 */ -public interface TicketService { +public interface ProcessService { /** * 设置执行那种实现类 * @param flowQueue * @return */ - Boolean isWorkflowTicket(WorkflowQueue flowQueue); + Boolean isWorkflowProcess(WorkflowQueue flowQueue); /** * 两票管理业务方法 * @param response */ - String calculate(WorkTicketMessageResponse response); + void calculate(ProcessWorkFlowResponse response); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java similarity index 53% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeTicketServiceImpl.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java index 08e05d5..ea3f3e0 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/MakeProcessServiceImpl.java @@ -1,10 +1,12 @@ package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; +import com.hnac.hzims.ticket.processflow.constant.TicketProcessConstant; import com.hnac.hzims.ticket.processflow.entity.ProcessType; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; -import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; -import com.hnac.hzims.ticket.processflow.strategy.abstracts.TicketAbstractService; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; +import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -20,7 +22,14 @@ import java.util.List; */ @Slf4j @Service -public class MakeTicketServiceImpl extends TicketAbstractService { +@RequiredArgsConstructor +public class MakeProcessServiceImpl extends ProcessAbstractService { + + + + private final TicketProcessService ticketProcessService; + + /** * 设置执行那种实现类 * @@ -28,11 +37,9 @@ public class MakeTicketServiceImpl extends TicketAbstractService { * @return */ @Override - public Boolean isWorkflowTicket(WorkflowQueue flowQueue) { + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { log.info("是否执行开工作票流程环节操作~~~~,流程ticket: {}", flowQueue); - List ticketList = this.getTicketList(); - ProcessType properties = ticketList.get(0); - if (properties.getDeploymentId().equals(flowQueue.getDeploymentId())) { + if (TicketProcessConstant.STARTEVENT.equals(flowQueue.getProcessDefinitionKey())) { log.info("已执行开工作票流程环节操作~~~~"); return true; } @@ -46,9 +53,8 @@ public class MakeTicketServiceImpl extends TicketAbstractService { * @param response */ @Override - public String calculate(WorkTicketMessageResponse response) { - System.out.println("OperatorTicketServiceImpl"); - return "开票"; - + public void calculate(ProcessWorkFlowResponse response) { + log.info("启动开票流程环节...."); + ticketProcessService.startUp(response); } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorProcessServiceImpl.java similarity index 62% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorTicketServiceImpl.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorProcessServiceImpl.java index e5eb803..84088a0 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/OperatorProcessServiceImpl.java @@ -1,9 +1,8 @@ package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; import com.hnac.hzims.ticket.processflow.entity.ProcessType; -import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; -import com.hnac.hzims.ticket.processflow.strategy.abstracts.TicketAbstractService; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -20,7 +19,10 @@ import java.util.List; */ @Slf4j @Service -public class OperatorTicketServiceImpl extends TicketAbstractService { +public class OperatorProcessServiceImpl extends ProcessAbstractService { + + + /** * 设置执行那种实现类 * @@ -28,11 +30,11 @@ public class OperatorTicketServiceImpl extends TicketAbstractService { * @return */ @Override - public Boolean isWorkflowTicket(WorkflowQueue flowQueue) { + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { log.info("是否执行运行人接收操作~~~~,流程flowQueue: {}", flowQueue); - List ticketList = this.getTicketList(); + List ticketList = this.getProcessList(); ProcessType properties = ticketList.get(2); - if (properties.getDeploymentId().equals(flowQueue.getDeploymentId())) { + if (properties.getDeploymentId().equals(flowQueue.getProcessDefinitionKey())) { log.info("已执行运行人接收操作~~~~"); return true; } @@ -46,9 +48,7 @@ public class OperatorTicketServiceImpl extends TicketAbstractService { * @param response */ @Override - public String calculate(WorkTicketMessageResponse response) { + public void calculate(ProcessWorkFlowResponse response) { System.out.println("OperatorTicketServiceImpl"); - return "运行人接收"; - } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureProcessServiceImpl.java similarity index 62% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureTicketServiceImpl.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureProcessServiceImpl.java index cb36a91..4461926 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/serviceimpl/SignatureProcessServiceImpl.java @@ -1,9 +1,8 @@ package com.hnac.hzims.ticket.processflow.strategy.serviceimpl; import com.hnac.hzims.ticket.processflow.entity.ProcessType; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; -import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; -import com.hnac.hzims.ticket.processflow.strategy.abstracts.TicketAbstractService; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.processflow.strategy.abstracts.ProcessAbstractService; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -20,7 +19,7 @@ import java.util.List; */ @Slf4j @Service -public class SignatureTicketServiceImpl extends TicketAbstractService { +public class SignatureProcessServiceImpl extends ProcessAbstractService { /** @@ -30,11 +29,11 @@ public class SignatureTicketServiceImpl extends TicketAbstractService { * @return */ @Override - public Boolean isWorkflowTicket(WorkflowQueue flowQueue) { + public Boolean isWorkflowProcess(WorkflowQueue flowQueue) { log.info("是否执行运行人接收操作~~~~,流程flowQueue: {}", flowQueue); - List ticketList = this.getTicketList(); + List ticketList = this.getProcessList(); ProcessType properties = ticketList.get(1); - if (properties.getDeploymentId().equals(flowQueue.getDeploymentId())){ + if (properties.getDeploymentId().equals(flowQueue.getProcessDefinitionKey())){ log.info("已执行运行人接收操作~~~~"); return true; } @@ -48,8 +47,7 @@ public class SignatureTicketServiceImpl extends TicketAbstractService { * @param response */ @Override - public String calculate(WorkTicketMessageResponse response) { + public void calculate(ProcessWorkFlowResponse response) { System.out.println("SignatureTicketServiceImpl"); - return "签发人签发"; } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java index eba614f..37bf5c2 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/redisConsume/WorkTicketMsgConsume.java @@ -3,7 +3,7 @@ package com.hnac.hzims.ticket.redisConsume; import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.common.config.RedisMessageListener; import com.hnac.hzims.ticket.constants.TicketConstants; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.twoTicket.service.IFirstWorkTicketService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -31,8 +31,9 @@ public class WorkTicketMsgConsume { Assert.isTrue(StringUtil.isNotBlank(message),() -> { throw new ServiceException("两票接收流程消息为空!"); }); - WorkTicketMessageResponse response = JSONObject.parseObject(message, WorkTicketMessageResponse.class); - TicketConstants.WorkTicketFlowEnum workTicketFlowEnum = TicketConstants.WorkTicketFlowEnum.getEnumByFlowId(response.getTaskDefinitionKey()); + ProcessWorkFlowResponse response = JSONObject.parseObject(message, ProcessWorkFlowResponse.class); + TicketConstants.WorkTicketFlowEnum workTicketFlowEnum = + TicketConstants.WorkTicketFlowEnum.getEnumByFlowId(response.getProcessDefinitionKey()); switch(workTicketFlowEnum) { case START: //FIXME 开票暂用此接口 diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/WorkTicketMessageResponse.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java similarity index 65% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/WorkTicketMessageResponse.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java index 49df219..8e4dcbf 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/WorkTicketMessageResponse.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/response/ProcessWorkFlowResponse.java @@ -7,16 +7,17 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; /** + * * @author hx * @version 1.0 * @date 2023/3/14 19:13 */ @Data @EqualsAndHashCode -public class WorkTicketMessageResponse implements Serializable { +public class ProcessWorkFlowResponse implements Serializable { /**当前任务ID**/ - @NotNull + private String taskId; /**当前任务名称**/ @@ -24,20 +25,27 @@ public class WorkTicketMessageResponse implements Serializable { /**当前环节流程ID**/ @NotNull - private String taskDefinitionKey; + private String processDefinitionKey; + + + /** + * 业务Id + */ + private String businessKey; /** * 流程实例key */ - private String processInstanceKey; + private String processInstanceId; - /**下一环节处理人**/ - @NotNull + /** + * 下一环节处理人 + */ private String nextStepOperator; /**票据表单**/ - private Object formData; + private String formData; } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java index efb4657..9fa6697 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardWorkTicketController.java @@ -2,13 +2,13 @@ package com.hnac.hzims.ticket.standardTicket.controller; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.IdWorker; -import com.hnac.hzims.ticket.response.WorkTicketMessageResponse; +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; import com.hnac.hzims.ticket.standardTicket.service.StandardWorkTicketService; import com.hnac.hzims.ticket.processflow.properties.TicketProperties; import com.hnac.hzims.ticket.processflow.properties.WorkTicketProperties; import com.hnac.hzims.ticket.processflow.strategy.entity.WorkflowQueue; -import com.hnac.hzims.ticket.processflow.strategy.service.TicketService; -import com.hnac.hzims.ticket.processflow.strategy.core.TicketIdWorker; +import com.hnac.hzims.ticket.processflow.strategy.service.ProcessService; +import com.hnac.hzims.ticket.processflow.strategy.core.ProcessIdWorker; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -43,11 +43,11 @@ public class StandardWorkTicketController { @Autowired - private TicketIdWorker standardTicketIdWorker; + private ProcessIdWorker standardTicketIdWorker; @Autowired - List ticketService; + List ticketService; @Autowired @@ -56,7 +56,7 @@ public class StandardWorkTicketController { @ApiOperation("测试开票") @PostMapping("/createTicket") public R createTicket() { - WorkTicketMessageResponse workTicketMessageResponse = new WorkTicketMessageResponse(); + ProcessWorkFlowResponse workTicketMessageResponse = new ProcessWorkFlowResponse(); workTicketMessageResponse.setTaskId(IdWorker.get32UUID()); workTicketMessageResponse.setTaskName("工作流"); String jsonString = JSON.toJSONString(workTicketMessageResponse); @@ -79,11 +79,11 @@ public class StandardWorkTicketController { @GetMapping("/hello/{type}") public R hello(@PathVariable String type) { WorkflowQueue ticket = new WorkflowQueue(); - ticket.setDeploymentId(type); - TicketService service = ticketService.stream().filter(item -> item.isWorkflowTicket(ticket)) + ticket.setProcessDefinitionKey(type); + ProcessService service = ticketService.stream().filter(item -> item.isWorkflowProcess(ticket)) .findFirst().orElse(null); - String calculate = service.calculate(new WorkTicketMessageResponse()); - return R.data(calculate); + service.calculate(new ProcessWorkFlowResponse()); + return R.data("hello"); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java new file mode 100644 index 0000000..5185416 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/mapper/WorkTicketInfoMapper.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.ticket.twoTicket.mapper; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:29 + */ +@Repository +public interface WorkTicketInfoMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java new file mode 100644 index 0000000..0c134f2 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.ticket.twoTicket.service; + +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; + +/** + * 开票处理流程接口 + * @Author dfy + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:08 + */ +public interface TicketProcessService { + + /** + * 启动开票流程 + * @param response + */ + void startUp(ProcessWorkFlowResponse response); +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java new file mode 100644 index 0000000..bfd29d3 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/WorkTicketInfoService.java @@ -0,0 +1,14 @@ +package com.hnac.hzims.ticket.twoTicket.service; + +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:31 + */ +public interface WorkTicketInfoService extends BaseService { + +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java new file mode 100644 index 0000000..995459f --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java @@ -0,0 +1,38 @@ +package com.hnac.hzims.ticket.twoTicket.service.impl; + +import com.hnac.hzims.ticket.response.ProcessWorkFlowResponse; +import com.hnac.hzims.ticket.twoTicket.service.TicketProcessService; +import com.hnac.hzims.ticket.twoTicket.service.WorkTicketInfoService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.flow.core.feign.IFlowClient; +import org.springframework.stereotype.Service; + +/** + * 开票处理流程实现类 + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:11 + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class TicketProcessServiceImpl implements TicketProcessService { + + + private final IFlowClient flowClient; + + + private final WorkTicketInfoService workTicketInfoService; + + /** + * 启动开票流程 + * + * @param response + */ + @Override + public void startUp(ProcessWorkFlowResponse response) { + + } +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java new file mode 100644 index 0000000..276a347 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/WorkTicketInfoServiceImpl.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.ticket.twoTicket.service.impl; + +import com.hnac.hzims.ticket.twoTicket.mapper.WorkTicketInfoMapper; +import com.hnac.hzims.ticket.twoTicket.service.WorkTicketInfoService; +import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @Author WL + * @Version v1.0 + * @Serial 1.0 + * @Date 2023/4/8 11:32 + */ +@Service +public class WorkTicketInfoServiceImpl extends BaseServiceImpl implements WorkTicketInfoService { +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/SafetyMeasuresVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/SafetyMeasuresVo.java similarity index 92% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/SafetyMeasuresVo.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/SafetyMeasuresVo.java index 31b9d91..410dfb3 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/SafetyMeasuresVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/SafetyMeasuresVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.ticket.processflow.vo; +package com.hnac.hzims.ticket.twoTicket.vo.process; import lombok.Data; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamGroupVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamGroupVo.java similarity index 94% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamGroupVo.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamGroupVo.java index 60f6c9e..ddb5af3 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamGroupVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamGroupVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.ticket.processflow.vo; +package com.hnac.hzims.ticket.twoTicket.vo.process; import lombok.Data; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamPersonnelVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamPersonnelVo.java similarity index 88% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamPersonnelVo.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamPersonnelVo.java index 464c49a..e39e8b6 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/TeamPersonnelVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/TeamPersonnelVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.ticket.processflow.vo; +package com.hnac.hzims.ticket.twoTicket.vo.process; import lombok.Data; diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/WorkTicketVo.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java similarity index 97% rename from hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/WorkTicketVo.java rename to hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java index ff458fb..8cb78cb 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/vo/WorkTicketVo.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/vo/process/WorkTicketVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.ticket.processflow.vo; +package com.hnac.hzims.ticket.twoTicket.vo.process; import lombok.Data;