同步代码

This commit is contained in:
lulz1 2024-03-01 21:19:41 +08:00
parent 9109b125e6
commit a0626e722b
13 changed files with 172 additions and 118 deletions

View File

@ -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;
}
}

View File

@ -43,4 +43,6 @@ public class LegDomainService {
} }
return legRepository.save(leg); return legRepository.save(leg);
} }
} }

View File

@ -2,16 +2,15 @@ package com.chint.domain.service.leg_event;
import com.chint.application.commands.*; import com.chint.application.commands.*;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.system.SystemCode;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.CommandException; import com.chint.domain.exceptions.CommandException;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.exceptions.OrderException; import com.chint.domain.exceptions.OrderException;
import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory; import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.*;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.value_object.ApprovalLegData; import com.chint.domain.value_object.ApprovalLegData;
import com.chint.domain.value_object.ApproveLegData; 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.constant.RouteConstant;
import com.chint.infrastructure.echo_framework.dispatch.ResultContainer; import com.chint.infrastructure.echo_framework.dispatch.ResultContainer;
import com.chint.infrastructure.util.BaseContext; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Optional; 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.DataMessageConstant.ORDER_STATUS_ERROR;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL; import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL;
@ -59,6 +64,12 @@ public class LegEventHandler implements LegEventService {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
@Autowired
private SystemCodeRepository systemCodeRepository;
@Autowired
private BPMRequest bpmRequest;
@Transactional @Transactional
@Override @Override
public void prepareLeg(LegPrepareCommand command) { public void prepareLeg(LegPrepareCommand command) {
@ -227,4 +238,30 @@ public class LegEventHandler implements LegEventService {
routeOrder.addApprovalEvent(approvalEvent); routeOrder.addApprovalEvent(approvalEvent);
routeRepository.save(routeOrder); 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);
}
}
} }

View File

@ -26,4 +26,6 @@ public interface LegEventService {
void finishLeg(LegFinishedCommand command); void finishLeg(LegFinishedCommand command);
void rejectLeg(LegRejectCommand command); void rejectLeg(LegRejectCommand command);
void pushChangeLegToBpm(BPMLegChangeCommand command);
} }

View File

@ -74,4 +74,9 @@ public class LegEventServiceImpl implements LegEventService {
public void rejectLeg(LegRejectCommand command) { public void rejectLeg(LegRejectCommand command) {
legEventHandler.rejectLeg(command); legEventHandler.rejectLeg(command);
} }
@Override
public void pushChangeLegToBpm(BPMLegChangeCommand command) {
legEventHandler.pushChangeLegToBpm(command);
}
} }

View File

@ -3,8 +3,12 @@ package com.chint.infrastructure.constant;
public class BPMConstant { public class BPMConstant {
//BPM //BPM
public static final String H3BPM = "H3BPM"; public static final String H3_BPM = "H3BPM";
public static final String XNBPM = "XNBPM"; 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 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_TOKEN_URL = "/api/login/crm/ajax";//新能云枢获取token和用户id
public static final String XNBPM_EXCEED_STANDARD_URL = "/api/openapi/v3/workflow/start";//新能云枢发起流程 public static final String XNBPM_EXCEED_STANDARD_URL = "/api/openapi/v3/workflow/start";//新能云枢发起流程

View File

@ -5,7 +5,7 @@ public class LegConstant {
public static final int LEG_STATUS_PREPARE = 0; public static final int LEG_STATUS_PREPARE = 0;
public static final String LEG_STATUS_PREPARE_NAME = "规划中"; public static final String LEG_STATUS_PREPARE_NAME = "规划中";
public static final int LEG_STATUS_APPROVAL = 1; 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 int LEG_STATUS_NOT_ORDERED = 2;
public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单"; public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单";
public static final int LEG_STATUS_ORDERED = 3; public static final int LEG_STATUS_ORDERED = 3;

View File

@ -14,42 +14,9 @@ public class JTH3ChangeDto {
private String StartTime;//出差开始时间 是否必填 private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填 private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填 private String Reason;//出差说明 是否必填
private List<NewTrip> JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 private List<LegNewTrip> JT_FI_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<OldTrip> JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 private List<LegOldTrip> JT_FI_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<ChangeTrip> JT_FI_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 private List<LegChangeTrip> 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;//新增行程原因 是否必填
}
} }

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -10,42 +10,9 @@ public class XNChangeDto {
private String StartTime;//出差开始时间 是否必填 private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填 private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填 private String Reason;//出差说明 是否必填
private List<JTH3ChangeDto.NewTrip> XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 private List<LegNewTrip> XN_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<JTH3ChangeDto.OldTrip> XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 private List<LegOldTrip> XN_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<JTH3ChangeDto.ChangeTrip> XN_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 private List<LegChangeTrip> 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;//新增行程原因 是否必填
}
} }

View File

@ -11,42 +11,7 @@ public class ZWChangeDto {
private String StartTime;//出差开始时间 是否必填 private String StartTime;//出差开始时间 是否必填
private String EndTime;//出差结束时间 是否必填 private String EndTime;//出差结束时间 是否必填
private String Reason;//出差说明 是否必填 private String Reason;//出差说明 是否必填
private List<JTH3ChangeDto.NewTrip> ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填 private List<LegNewTrip> ZW_AS_CLBGSQ_ITEM_NewTrip;//新增行程信息 是否必填
private List<JTH3ChangeDto.OldTrip> ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填 private List<LegOldTrip> ZW_AS_CLBGSQ_ITEM_OldTrip;//原行程信息 是否必填
private List<JTH3ChangeDto.ChangeTrip> ZW_AS_CLBGSQ_ITEM_ChangeTrip;//变更行程信息 是否必填 private List<LegChangeTrip> 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;//新增行程原因 是否必填
}
} }