Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
hewencai
2025-11-11 09:29:22 +08:00
13 changed files with 223 additions and 102 deletions

View File

@@ -82,6 +82,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

View File

@@ -35,4 +35,6 @@ public class ElementPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "排序")
private Integer sort;
}

View File

@@ -44,4 +44,6 @@ public class ElementRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "排序")
private Integer sort;
}

View File

@@ -34,4 +34,7 @@ public class ElementSaveReqVO {
@NotEmpty(message = "品位单位不能为空")
private String gradeUnit;
@Schema(description = "排序")
private Integer sort;
}

View File

@@ -94,4 +94,7 @@ public class ElementDO extends BusinessBaseDO {
@TableField("UPDATER_NAME")
private String updaterName;
@TableField("SORT")
private Integer sort;
}

View File

@@ -26,13 +26,14 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
.likeIfPresent(ElementDO::getCoding, reqVO.getCoding())
.eqIfPresent(ElementDO::getGradeUnit, reqVO.getGradeUnit())
.betweenIfPresent(ElementDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(ElementDO::getId));
.orderByDesc(ElementDO::getSort));
}
String selectMaxCode();
default List<ElementDO> getElementNoPage() {
return selectList(new LambdaQueryWrapperX<ElementDO>()
.orderByDesc(ElementDO::getId));
.eq(ElementDO::getIsEnable, 1)
.orderByDesc(ElementDO::getSort));
}
}

View File

@@ -9,6 +9,7 @@ import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDT
import com.zt.plat.module.contractorder.api.dto.order.SalesOrdDtlDTO;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntPushContractReqVO;
import com.zt.plat.module.contractorder.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -44,7 +45,7 @@ public interface ContractApi {
@PostMapping(PREFIX + "/push")
@Operation(summary = "国贸2.0系统推送合同")
CommonResult<Boolean> push(@Valid @RequestBody IntContract reqVO);
void push(@Valid @RequestBody IntPushContractReqVO pushReqVO);
@GetMapping(PREFIX + "/logistics/list/page")
@Operation(summary = "国贸2.0系统合同分页查询")

View File

@@ -0,0 +1,24 @@
package com.zt.plat.module.contractorder.api.vo.contract.international;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "国贸2.0系统推送合同 Request VO")
@Data
public class IntPushContractReqVO {
@Schema(description = "接口请求号")
private String __requestId_;
@Schema(description = "接口类型")
private String __interfaceType__;
@Schema(description = "操作标志")
private String operateFlag;
@Schema(description = "发送时间 yyyyMMddHHmmss")
private String datetime;
@Schema(description = "单据号")
private String busiBillCode;
@Schema(description = "发送方系统")
private String system;
@Schema(description = "发送数据")
private IntContract data;
}

View File

@@ -0,0 +1,29 @@
package com.zt.plat.module.contractorder.api.vo.contract.international;
import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "国贸2.0系统推送合同 Response VO")
@Data
public class IntPushContractRespVO {
@Schema(description = "接口请求号")
private String __requestId_;
@Schema(description = "接口类型")
private String __interfaceType__;
@Schema(description = "单据号")
private String busiBillCode;
@Schema(description = "返回状态")
private Integer code;
@Schema(description = "返回信息")
private String message;
@Schema(description = "返回时间 yyyyMMddHHmmss")
private String datetime;
@Schema(description = "返回方系统")
private String system;
@Schema(description = "操作标志")
private String operateFlag;
@Schema(description = "返回数据")
private JSONObject data;
}

View File

@@ -11,9 +11,7 @@ import com.zt.plat.module.contractorder.api.dto.contract.ContractRespDTO;
import com.zt.plat.module.contractorder.api.dto.order.PrchOrdDtlDTO;
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
import com.zt.plat.module.contractorder.api.dto.order.SalesOrdDtlDTO;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
import com.zt.plat.module.contractorder.api.vo.contract.international.Partner;
import com.zt.plat.module.contractorder.api.vo.contract.international.*;
import com.zt.plat.module.contractorder.controller.admin.purchaseorder.vo.PurchaseOrderDetailsRespVO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractOtherFieldDO;
@@ -33,10 +31,12 @@ import com.zt.plat.module.contractorder.dal.mysql.salesorder.SalesOrderMapper;
import com.zt.plat.module.contractorder.enums.contract.DictEnum;
import com.zt.plat.module.contractorder.service.contract.ContractService;
import com.zt.plat.module.contractorder.service.purchaseorder.PurchaseOrderService;
import com.zt.plat.module.contractorder.util.ShareServiceUtil;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
@@ -73,6 +73,8 @@ public class ContractApiImpl implements ContractApi {
private ContractOtherFieldMapper contractOtherFieldMapper;
@Resource
private SystemRelativityMapper systemRelativityMapper;
@Autowired
private ShareServiceUtil shareServiceUtil;
@Override
public ContractRespDTO getContractByPaperNumber(String contractPaperNumber) {
@@ -158,100 +160,106 @@ public class ContractApiImpl implements ContractApi {
@Transactional
@Override
public CommonResult<Boolean> push(@RequestBody IntContract reqVO) {
public void push(@RequestBody IntPushContractReqVO pushReqVO) {
// 合同主信息表映射
ContractMainDO contractMainDO = internationalToMainDO(reqVO);
log.info("接受到国贸系统推送的合同数据:{}", new JSONObject(pushReqVO));
try {
// 合同主信息表映射
ContractMainDO contractMainDO = internationalToMainDO(pushReqVO.getData());
// 逻辑处理
// 操作标志 I 新增/更新D 删除
String operateFlag = reqVO.getOperateFlag();
// 合同唯一键
String externalId = reqVO.getContractId();
// 系统合同ID
Long contractId = null;
// 查询系统关联合同
SystemRelativityDO systemRelativityDO = systemRelativityMapper.selectOne("UP_ID", externalId);
if ("I".equals(operateFlag)) {
if (systemRelativityDO != null && systemRelativityDO.getDownId() != null) { // 修改合同
// 逻辑处理
// 操作标志 I 新增/更新D 删除
String operateFlag = pushReqVO.getData().getOperateFlag();
// 合同唯一键
String externalId = pushReqVO.getData().getContractId();
// 系统合同ID
Long contractId = null;
// 查询系统关联合同
SystemRelativityDO systemRelativityDO = systemRelativityMapper.selectOne("UP_ID", externalId);
if ("I".equals(operateFlag)) {
if (systemRelativityDO != null && systemRelativityDO.getDownId() != null) { // 修改合同
contractId = systemRelativityDO.getDownId();
contractMainDO.setId(contractId);
contractMainMapper.updateById(contractMainDO);
} else { // 新增合同
contractMainMapper.insert(contractMainDO);
contractId = contractMainDO.getId();
// 生成关联数据
SystemRelativityDO saveRelation = new SystemRelativityDO();
saveRelation.setUpId(Long.parseLong(externalId));
saveRelation.setDownId(contractId);
saveRelation.setWay(DictEnum.BSE_SYS_REL_WY_EXTERNAL.getCode());
saveRelation.setStatus(DictEnum.BSE_SYS_REL_TP_CONTRACT.getCode());
systemRelativityMapper.insert(saveRelation);
}
} else if ("D".equals(operateFlag)) {
if (systemRelativityDO == null || systemRelativityDO.getDownId() == null) throw exception(CONTRACT_NOT_EXISTS);
contractId = systemRelativityDO.getDownId();
contractMainDO.setId(contractId);
contractMainMapper.updateById(contractMainDO);
} else { // 新增合同
contractMainMapper.insert(contractMainDO);
contractId = contractMainDO.getId();
// 生成关联数据
SystemRelativityDO saveRelation = new SystemRelativityDO();
saveRelation.setUpId(Long.parseLong(externalId));
saveRelation.setDownId(contractId);
saveRelation.setWay(DictEnum.BSE_SYS_REL_WY_EXTERNAL.getCode());
saveRelation.setStatus(DictEnum.BSE_SYS_REL_TP_CONTRACT.getCode());
systemRelativityMapper.insert(saveRelation);
contractMainMapper.deleteById(contractId);
// 删除动态条款信息
contractOtherFormMapper.delete("CTRT_MAIN_ID", contractId.toString());
contractOtherFieldMapper.delete("CTRT_MAIN_ID", contractId.toString());
pushResult(pushReqVO, 1, null);
} else {
throw exception(CONTRACT_UNKNOWN_OPERATE);
}
} else if ("D".equals(operateFlag)) {
if (systemRelativityDO == null || systemRelativityDO.getDownId() == null) throw exception(CONTRACT_NOT_EXISTS);
contractId = systemRelativityDO.getDownId();
contractMainMapper.deleteById(contractId);
// 根据客商信息列表提交多个合同映射到erp
if (pushReqVO.getData().getPartnerList() == null || pushReqVO.getData().getPartnerList().isEmpty()) {
throw exception(CONTRACT_PARTNER_NOT_EXISTS);
}
// 合同主信息-合同编号
String contractPaperNumber = contractMainDO.getContractPaperNumber();
// 合同主信息-合同名称
String contractName = contractMainDO.getContractName();
for (int i = 0; i < pushReqVO.getData().getPartnerList().size(); i++) {
Partner partner = pushReqVO.getData().getPartnerList().get(i);
// 根据客商信息设置合同信息
// 合同编号
contractMainDO.setContractPaperNumber(contractPaperNumber + "_" + String.format("%03d", (i+1)));
pushReqVO.getData().getPartnerList().get(i)
.setErpContractPaperNumber(contractPaperNumber + "_" + String.format("%03d", (i+1)));
// 合同名称
contractMainDO.setContractName(contractName + "_" + String.format("%03d", (i+1)));
// 境内/境外 -> 客商信息:境内/外
contractMainDO.setIsDomestic(partner.getDomesticOrOverseas());
// 乙方公司编号(销售方) -> 客商信息:供应商代码
contractMainDO.setSalesCompanyNumber(partner.getPartnerCode());
// ERP乙方公司编码
contractMainDO.setErpSalesCompanyNumber(partner.getPartnerCode());
// 乙方公司名称 -> 客商信息:供应商名称
contractMainDO.setSalesCompanyName(partner.getPartnerName());
// ERP乙方公司名称
contractMainDO.setErpSalesCompanyName(partner.getPartnerName());
// 生成ERP合同映射表
ErpContractSaveReqVO erpContractVO = contractService.getErpContract(contractMainDO);
// 调用ERP模块
JSONObject erpResult = contractService.sendToErp(erpContractVO);
log.info("合同提交ERP结果{}", erpResult);
// 调用ERP失败
if (!erpResult.getBool("success")) {
throw exception(CONTRACT_SUBMIT_ERP_FAIL, erpResult.getStr("errMsg"));
}
}
// 删除动态条款信息
contractOtherFormMapper.delete("CTRT_MAIN_ID", contractId.toString());
contractOtherFieldMapper.delete("CTRT_MAIN_ID", contractId.toString());
return success(true);
} else {
throw exception(CONTRACT_UNKNOWN_OPERATE);
// 请求参数保存到动态条款
saveIntContractFields(pushReqVO.getData(), contractId);
pushResult(pushReqVO, 1, null);
} catch (Exception e) {
log.info("国贸系统推送合同异常:{}", e.getMessage(), e);
pushResult(pushReqVO, -1, e.getMessage());
}
// 根据客商信息列表提交多个合同映射到erp
if (reqVO.getPartnerList() == null || reqVO.getPartnerList().isEmpty()) {
throw exception(CONTRACT_PARTNER_NOT_EXISTS);
}
// 合同主信息-合同编号
String contractPaperNumber = contractMainDO.getContractPaperNumber();
// 合同主信息-合同名称
String contractName = contractMainDO.getContractName();
for (int i = 0; i < reqVO.getPartnerList().size(); i++) {
Partner partner = reqVO.getPartnerList().get(i);
// 根据客商信息设置合同信息
// 合同编号
contractMainDO.setContractPaperNumber(contractPaperNumber + "_" + String.format("%03d", (i+1)));
reqVO.getPartnerList().get(i)
.setErpContractPaperNumber(contractPaperNumber + "_" + String.format("%03d", (i+1)));
// 合同名称
contractMainDO.setContractName(contractName + "_" + String.format("%03d", (i+1)));
// 境内/境外 -> 客商信息:境内/外
contractMainDO.setIsDomestic(partner.getDomesticOrOverseas());
// 乙方公司编号(销售方) -> 客商信息:供应商代码
contractMainDO.setSalesCompanyNumber(partner.getPartnerCode());
// ERP乙方公司编码
contractMainDO.setErpSalesCompanyNumber(partner.getPartnerCode());
// 乙方公司名称 -> 客商信息:供应商名称
contractMainDO.setSalesCompanyName(partner.getPartnerName());
// ERP乙方公司名称
contractMainDO.setErpSalesCompanyName(partner.getPartnerName());
// 生成ERP合同映射表
ErpContractSaveReqVO erpContractVO = contractService.getErpContract(contractMainDO);
// 调用ERP模块
JSONObject erpResult = contractService.sendToErp(erpContractVO);
log.info("合同提交ERP结果{}", erpResult);
// 调用ERP失败
if (!erpResult.getBool("success")) {
throw exception(CONTRACT_SUBMIT_ERP_FAIL, erpResult.getStr("errMsg"));
}
}
// 删除动态条款信息
contractOtherFormMapper.delete("CTRT_MAIN_ID", contractId.toString());
contractOtherFieldMapper.delete("CTRT_MAIN_ID", contractId.toString());
// 请求参数保存到动态条款
saveIntContractFields(reqVO, contractId);
return success(true);
}
/**
@@ -365,6 +373,32 @@ public class ContractApiImpl implements ContractApi {
}
}
private void pushResult(IntPushContractReqVO pushReqVO, Integer code, String msg) {
// 返回数据
IntPushContractRespVO body = new IntPushContractRespVO();
body.set__requestId_(pushReqVO.get__requestId_());
body.set__interfaceType__(pushReqVO.get__interfaceType__());
body.setBusiBillCode(pushReqVO.getBusiBillCode());
body.setCode(code);
body.setMessage(String.format("推送合同[%s]%s", pushReqVO.getData().getContractCode(), code >= 0 ? "成功" : "失败:" + msg));
body.setDatetime(DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(LocalDateTime.now()));
body.setSystem("JYGK");
body.setOperateFlag(pushReqVO.getOperateFlag());
// 回调参数
JSONObject req = new JSONObject();
req.set("messageKey", pushReqVO.getBusiBillCode());
req.set("messageBody", body);
try {
log.info("国贸系统推送合同回调参数:{}",req);
String res = shareServiceUtil.callShareService("S_EPLAT_04", req.toString());
log.info("国贸系统推送合同回调成功:{}",res);
} catch (Exception e) {
log.error("国贸系统推送合同回调失败:{}",e.getMessage(), e);
}
}
@Override
public CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq) {

View File

@@ -6,9 +6,11 @@ import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.contractorder.api.ContractApi;
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
import com.zt.plat.module.contractorder.api.vo.contract.*;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContract;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntContractPageReq;
import com.zt.plat.module.contractorder.api.vo.contract.international.IntPushContractReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.contract.ContractMainDO;
import com.zt.plat.module.contractorder.service.contract.ContractService;
import io.swagger.v3.oas.annotations.Operation;
@@ -195,14 +197,21 @@ public class ContractController implements BusinessControllerMarker {
@PostMapping("/push")
@Operation(summary = "国贸2.0系统推送合同")
@PreAuthorize("@ss.hasPermission('base:contract:create')")
CommonResult<Boolean> push(@Valid @RequestBody IntContract reqVO) {
return contractApi.push(reqVO);
public void push(@Valid @RequestBody IntPushContractReqVO pushReqVO) {
contractApi.push(pushReqVO);
}
@PostMapping("/logistics/list/page")
@Operation(summary = "国贸2.0系统合同分页查询")
@PreAuthorize("@ss.hasPermission('base:contract:query')")
CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq) {
public CommonResult<PageResult<IntContract>> logisticsListPage(IntContractPageReq pageReq) {
return contractApi.logisticsListPage(pageReq);
}
@PostMapping("/order-by-order-no")
@Operation(summary = "通过订单编号获取订单信息", description = "通过订单编号获取订单信息")
@PreAuthorize("@ss.hasPermission('base:contract:query')")
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderNo(@RequestBody List<String> orderNoS){
return contractApi.getOrderByOrderNo(orderNoS);
};
}

View File

@@ -1,13 +1,16 @@
package com.zt.plat.module.contractorder.controller.admin.contractorder;
import com.zt.plat.module.contractorder.api.dto.order.PurchaseOrderWithDetailsDTO;
import com.zt.plat.module.contractorder.service.contract.ContractService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import com.zt.plat.framework.common.pojo.CommonResult;
import java.util.List;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
/**
@@ -20,10 +23,12 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success;
@RequestMapping("/admin/contract-order/contract-order")
public class ContractOrderController {
@Resource
private ContractService contractService;
@GetMapping("/hello")
@Operation(summary = "Hello ContractOrder")
public CommonResult<String> hello() {
return success("Hello, ContractOrder!");
}
}

View File

@@ -14,8 +14,6 @@ import org.springframework.web.client.RestTemplate;
/**
* ePlat共享服务调用工具类
* @author ChenZhaoxue
* @date 2025/3/27
*/
@Slf4j
@Configuration
@@ -43,7 +41,7 @@ public class ShareServiceUtil {
* ePlat共享服务调用
* @param serviceNo 服务号
* @param request 请求json字符串
* @return
* @return 调用结果
*/
public String callShareService(String serviceNo, String request) {
String url = String.format("%s/service/%s", urlPrex, serviceNo);