diff --git a/src/main/java/com/chint/application/commands/BPMLegChangeCommand.java b/src/main/java/com/chint/application/commands/BPMLegChangeCommand.java new file mode 100644 index 00000000..386a39f3 --- /dev/null +++ b/src/main/java/com/chint/application/commands/BPMLegChangeCommand.java @@ -0,0 +1,16 @@ +package com.chint.application.commands; + + +import com.chint.domain.aggregates.order.Leg; +import com.chint.infrastructure.echo_framework.command.Command; +import lombok.Data; + +@Data +public class BPMLegChangeCommand extends Command { + private Leg leg; + + public BPMLegChangeCommand orderNo(Leg leg) { + this.leg = leg; + return this; + } +} diff --git a/src/main/java/com/chint/domain/service/LegDomainService.java b/src/main/java/com/chint/domain/service/LegDomainService.java index 8e34609e..e596f540 100644 --- a/src/main/java/com/chint/domain/service/LegDomainService.java +++ b/src/main/java/com/chint/domain/service/LegDomainService.java @@ -43,4 +43,6 @@ public class LegDomainService { } return legRepository.save(leg); } + + } diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index 25c9818d..edb85aa9 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -2,16 +2,15 @@ package com.chint.domain.service.leg_event; import com.chint.application.commands.*; import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.system.SystemCode; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.CommandException; +import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.OrderException; import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order_detail.OrderDetailFactory; -import com.chint.domain.repository.LegRepository; -import com.chint.domain.repository.OrderDetailRepository; -import com.chint.domain.repository.RouteRepository; -import com.chint.domain.repository.UserRepository; +import com.chint.domain.repository.*; import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.value_object.ApprovalLegData; import com.chint.domain.value_object.ApproveLegData; @@ -22,12 +21,18 @@ import com.chint.infrastructure.constant.LegConstant; import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.echo_framework.dispatch.ResultContainer; import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.bpm.BPMRequest; +import com.chint.interfaces.rest.bpm.dto.JTH3ChangeDto; +import com.chint.interfaces.rest.bpm.dto.XNChangeDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Optional; +import static com.chint.infrastructure.constant.BPMConstant.H3_BPM; +import static com.chint.infrastructure.constant.BPMConstant.XNYS_BPM; +import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND; import static com.chint.infrastructure.constant.DataMessageConstant.ORDER_STATUS_ERROR; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL; @@ -59,6 +64,12 @@ public class LegEventHandler implements LegEventService { @Autowired private UserRepository userRepository; + @Autowired + private SystemCodeRepository systemCodeRepository; + + @Autowired + private BPMRequest bpmRequest; + @Transactional @Override public void prepareLeg(LegPrepareCommand command) { @@ -227,4 +238,30 @@ public class LegEventHandler implements LegEventService { routeOrder.addApprovalEvent(approvalEvent); routeRepository.save(routeOrder); } + + @Override + public void pushChangeLegToBpm(BPMLegChangeCommand command) { + Leg leg = command.getLeg(); + Long routeId = leg.getRouteId(); + RouteOrder routeOrder = routeRepository.queryById(routeId); + String sysCode = routeOrder.getApproveOrderNo().getSysCode(); + SystemCode bySysCode = systemCodeRepository.findBySysCode(sysCode); + String bpmCode = bySysCode.getBpmCode(); + switch (bpmCode) { + case H3_BPM -> { + JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto(); +// jth3ChangeDto.set + bpmRequest.change(jth3ChangeDto, sysCode); + } + case XNYS_BPM -> { + XNChangeDto xnChangeDto = new XNChangeDto(); + bpmRequest.change(xnChangeDto, sysCode); + } +// case ANYS_BPM -> { +// JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto(); +// bpmRequest.change(jth3ChangeDto,sysCode); +// } + default -> throw new NotFoundException(DATA_NOT_FOUND); + } + } } diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java index c774ed8d..4b7b498d 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java @@ -26,4 +26,6 @@ public interface LegEventService { void finishLeg(LegFinishedCommand command); void rejectLeg(LegRejectCommand command); + + void pushChangeLegToBpm(BPMLegChangeCommand command); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index 7fe9dea3..3061dfb2 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -74,4 +74,9 @@ public class LegEventServiceImpl implements LegEventService { public void rejectLeg(LegRejectCommand command) { legEventHandler.rejectLeg(command); } + + @Override + public void pushChangeLegToBpm(BPMLegChangeCommand command) { + legEventHandler.pushChangeLegToBpm(command); + } } diff --git a/src/main/java/com/chint/infrastructure/constant/BPMConstant.java b/src/main/java/com/chint/infrastructure/constant/BPMConstant.java index 9c237024..d58ad9f0 100644 --- a/src/main/java/com/chint/infrastructure/constant/BPMConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/BPMConstant.java @@ -3,8 +3,12 @@ package com.chint.infrastructure.constant; public class BPMConstant { //BPM - public static final String H3BPM = "H3BPM"; - public static final String XNBPM = "XNBPM"; + public static final String H3_BPM = "H3BPM"; + public static final String FSSC = "FSSC"; + public static final String XN_FSSC = "XNFSSC"; + public static final String XNYS_BPM = "XNYSBPM"; + public static final String AN_FSSC = "ANFSSC"; + public static final String ANYS_BPM = "ANYSBPM"; public static final String H3BPM_EXCEED_STANDARD_URL = "/Portal/Webservices/ExternalStartService.asmx/StartWorkflowByEntityTransJson";//H3BPM public static final String XNBPM_TOKEN_URL = "/api/login/crm/ajax";//新能云枢获取token和用户id public static final String XNBPM_EXCEED_STANDARD_URL = "/api/openapi/v3/workflow/start";//新能云枢发起流程 diff --git a/src/main/java/com/chint/infrastructure/constant/LegConstant.java b/src/main/java/com/chint/infrastructure/constant/LegConstant.java index 0220090a..f6e6ba47 100644 --- a/src/main/java/com/chint/infrastructure/constant/LegConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LegConstant.java @@ -5,7 +5,7 @@ public class LegConstant { public static final int LEG_STATUS_PREPARE = 0; public static final String LEG_STATUS_PREPARE_NAME = "规划中"; public static final int LEG_STATUS_APPROVAL = 1; - public static final String LEG_STATUS_APPROVAL_NAME = "提交审批"; + public static final String LEG_STATUS_APPROVAL_NAME = "未同步"; public static final int LEG_STATUS_NOT_ORDERED = 2; public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单"; public static final int LEG_STATUS_ORDERED = 3; diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java index 229e70c6..f505c6cb 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/JTH3ChangeDto.java @@ -14,42 +14,9 @@ public class JTH3ChangeDto { private String StartTime;//出差开始时间 是否必填 是 private String EndTime;//出差结束时间 是否必填 是 private String Reason;//出差说明 是否必填 是 - private List JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 - private List JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 - private List JT_FI_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 + private List JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List JT_FI_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 - //新增行程信息 - @Data - @Accessors(chain = true) - public static class NewTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } - - //原行程信息 - @Data - @Accessors(chain = true) - public static class OldTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - } - - //变更行程信息 - @Data - @Accessors(chain = true) - public static class ChangeTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } + //新增行程信 } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/LegChangeTrip.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegChangeTrip.java new file mode 100644 index 00000000..9c9ab7c7 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegChangeTrip.java @@ -0,0 +1,30 @@ +package com.chint.interfaces.rest.bpm.dto; + +import com.chint.domain.aggregates.order.Leg; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.time.format.DateTimeFormatter; + +@Data +@Accessors(chain = true) +public class LegChangeTrip { + private String AllowProductTypes;//行程类型 是否必填 是 + private String DepartCitiesName;//出发地 是否必填 是 + private String ArriveCitiesName;//目的地 是否必填 是 + private String bsDate;//开始时间 是否必填 否 + private String edDate;//结束时间 是否必填 否 + private String Reason;//新增行程原因 是否必填 否 + + public static LegChangeTrip of(Leg leg) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LegChangeTrip legChangeTrip = new LegChangeTrip(); + legChangeTrip.setAllowProductTypes(leg.getLegTypeName()) + .setDepartCitiesName(leg.getOriginLocation().getLocationName()) + .setArriveCitiesName(leg.getDestinationLocation().getLocationName()) + .setBsDate(formatter.format(leg.getStartTime())) + .setEdDate(formatter.format(leg.getStartTime())) + .setReason(null); + return legChangeTrip; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/LegNewTrip.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegNewTrip.java new file mode 100644 index 00000000..5c25318b --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegNewTrip.java @@ -0,0 +1,30 @@ +package com.chint.interfaces.rest.bpm.dto; + +import com.chint.domain.aggregates.order.Leg; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.time.format.DateTimeFormatter; + +@Data +@Accessors(chain = true) +public class LegNewTrip { + private String AllowProductTypes;//行程类型 是否必填 是 + private String DepartCitiesName;//出发地 是否必填 是 + private String ArriveCitiesName;//目的地 是否必填 是 + private String bsDate;//开始时间 是否必填 否 + private String edDate;//结束时间 是否必填 否 + private String Reason;//新增行程原因 是否必填 否 + + public static LegNewTrip of(Leg leg) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LegNewTrip legNewTrip = new LegNewTrip(); + legNewTrip.setAllowProductTypes(leg.getLegTypeName()) + .setDepartCitiesName(leg.getOriginLocation().getLocationName()) + .setArriveCitiesName(leg.getDestinationLocation().getLocationName()) + .setBsDate(formatter.format(leg.getStartTime())) + .setEdDate(formatter.format(leg.getStartTime())) + .setReason(null); + return legNewTrip; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/LegOldTrip.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegOldTrip.java new file mode 100644 index 00000000..f4224637 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/LegOldTrip.java @@ -0,0 +1,29 @@ +package com.chint.interfaces.rest.bpm.dto; + +import com.chint.domain.aggregates.order.Leg; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.time.format.DateTimeFormatter; + +@Data +@Accessors(chain = true) +public class LegOldTrip { + private String AllowProductTypes;//行程类型 是否必填 是 + private String DepartCitiesName;//出发地 是否必填 是 + private String ArriveCitiesName;//目的地 是否必填 是 + private String bsDate;//开始时间 是否必填 否 + private String edDate;//结束时间 是否必填 否 + + public static LegChangeTrip of(Leg leg) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LegChangeTrip legChangeTrip = new LegChangeTrip(); + legChangeTrip.setAllowProductTypes(leg.getLegTypeName()) + .setDepartCitiesName(leg.getOriginLocation().getLocationName()) + .setArriveCitiesName(leg.getDestinationLocation().getLocationName()) + .setBsDate(formatter.format(leg.getStartTime())) + .setEdDate(formatter.format(leg.getStartTime())) + .setReason(null); + return legChangeTrip; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java index 3fec3b3f..72d852da 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/XNChangeDto.java @@ -10,42 +10,9 @@ public class XNChangeDto { private String StartTime;//出差开始时间 是否必填 是 private String EndTime;//出差结束时间 是否必填 是 private String Reason;//出差说明 是否必填 是 - private List XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 - private List XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 - private List XN_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 + private List XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List XN_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 //新增行程信息 - @Data - @Accessors(chain = true) - public static class NewTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } - - //原行程信息 - @Data - @Accessors(chain = true) - public static class OldTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - } - - //变更行程信息 - @Data - @Accessors(chain = true) - public static class ChangeTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java b/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java index 6aa498b2..615a827d 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/dto/ZWChangeDto.java @@ -11,42 +11,7 @@ public class ZWChangeDto { private String StartTime;//出差开始时间 是否必填 是 private String EndTime;//出差结束时间 是否必填 是 private String Reason;//出差说明 是否必填 是 - private List ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 - private List ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 - private List ZW_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 - - //新增行程信息 - @Data - @Accessors(chain = true) - public static class NewTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } - - //原行程信息 - @Data - @Accessors(chain = true) - public static class OldTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - } - - //变更行程信息 - @Data - @Accessors(chain = true) - public static class ChangeTrip { - private String AllowProductTypes;//行程类型 是否必填 是 - private String DepartCitiesName;//出发地 是否必填 是 - private String ArriveCitiesName;//目的地 是否必填 是 - private String bsDate;//开始时间 是否必填 否 - private String edDate;//结束时间 是否必填 否 - private String Reason;//新增行程原因 是否必填 否 - } + private List ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 否 + private List ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 否 + private List ZW_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 否 }