Browse Source

出口合同代码

chen 3 weeks ago
parent
commit
29420dd4d8

+ 6 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/company/vo/CompanySaveReqVO.java

@@ -44,4 +44,10 @@ public class CompanySaveReqVO {
 
     @Schema(description = "编码")
     private String code;
+
+    @Schema(description = "英文名称")
+    private String enName;
+
+    @Schema(description = "英文地址")
+    private String enAddress;
 }

+ 27 - 1
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/controller/admin/exportContract/ExportOrderController.java

@@ -1,6 +1,8 @@
 package cn.iocoder.yudao.module.contract.controller.admin.exportContract;
 
 import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -11,15 +13,20 @@ import cn.iocoder.yudao.module.contract.controller.admin.exportContract.vo.Expor
 import cn.iocoder.yudao.module.contract.controller.admin.exportContract.vo.ExportOrderPageReqVO;
 import cn.iocoder.yudao.module.contract.controller.admin.exportContract.vo.ExportOrderRespVO;
 import cn.iocoder.yudao.module.contract.controller.admin.order.vo.*;
+import cn.iocoder.yudao.module.contract.dal.dataobject.client.ClientDO;
+import cn.iocoder.yudao.module.contract.dal.dataobject.company.CompanyDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.exportContract.ExportContractDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.invoiceContract.InvoiceContractDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDetailsDO;
 import cn.iocoder.yudao.module.contract.dal.mysql.order.OrderDetailsMapper;
+import cn.iocoder.yudao.module.contract.service.client.ClientService;
+import cn.iocoder.yudao.module.contract.service.company.CompanyService;
 import cn.iocoder.yudao.module.contract.service.exportContract.ExportContractService;
 import cn.iocoder.yudao.module.contract.service.order.OrderService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -34,6 +41,7 @@ import javax.validation.Valid;
 
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
@@ -51,6 +59,10 @@ public class ExportOrderController {
     private OrderDetailsMapper orderDetailsMapper;
     @Resource
     private ExportContractService exportContractService;
+    @Resource
+    private CompanyService companyService;
+    @Resource
+    private ClientService clientService;
 
     @GetMapping("/get")
     @Operation(summary = "获得订单")
@@ -96,11 +108,25 @@ public class ExportOrderController {
         if(ids.length!=orderList.size()){
             return error("订单数据异常");
         }
-        List<OrderDetailsDO> detailsList = orderDetailsMapper.selectList(Wrappers.<OrderDetailsDO>lambdaQuery().in(OrderDetailsDO::getOrderId,Arrays.asList(ids)).orderByAsc(OrderDetailsDO::getVbeln,OrderDetailsDO::getPosnr));
+        Map<String, List<OrderDO>> ordersMap = orderList.stream().collect(Collectors.groupingBy(item -> item.getBukrs() + "-" + item.getKunnr()+ "-" +item.getInco1()+ "-" +item.getInco2()));
+        if(ordersMap.size()>1){
+            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"请选择售达方、公司主体、国际贸易条件相同的订单数据");
+        }
         OrderDO order = orderList.stream().min(Comparator.comparing(OrderDO::getAudat).thenComparing(OrderDO::getVbeln)).get();
+        CompanyDO companyDO = companyService.getOne(Wrappers.<CompanyDO>lambdaQuery().eq(CompanyDO::getCompanyCode,order.getBukrs()));
+        if(companyDO==null || StringUtils.isBlank(companyDO.getEnAddress())){
+            return error("公司不存在或公司地址为空");
+        }
+        ClientDO clientDO = clientService.getOne(Wrappers.<ClientDO>lambdaQuery().eq(ClientDO::getClientCode,order.getKunnr()));
+        if(clientDO==null || StringUtils.isBlank(clientDO.getCollectionAddress())){
+            return error("客户不存在或客户地址为空");
+        }
+        List<OrderDetailsDO> detailsList = orderDetailsMapper.selectList(Wrappers.<OrderDetailsDO>lambdaQuery().in(OrderDetailsDO::getOrderId,Arrays.asList(ids)).orderByAsc(OrderDetailsDO::getVbeln,OrderDetailsDO::getPosnr).orderByAsc(OrderDetailsDO::getVbeln,OrderDetailsDO::getPosnr));
         ExportContractDO exportContract = BeanUtils.toBean(order,ExportContractDO.class);
         Map<String,Object> result = new HashMap<>();
         result.put("orderIds",orderIds);
+        result.put("companyEnAddress",companyDO.getEnAddress());
+        result.put("collectionAddress",clientDO.getCollectionAddress());
         result.put("exportContract",exportContract);
         result.put("detailsList",detailsList);
         return success(result);

+ 8 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/dataobject/company/CompanyDO.java

@@ -71,5 +71,13 @@ public class CompanyDO extends BaseDO {
      * 签订地点
      */
     private String signingAddress;
+    /**
+     * 英文名称
+     */
+    private String enName;
+    /**
+     * 英文地址
+     */
+    private String enAddress;
 
 }

+ 4 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/dataobject/order/OrderDetailsDO.java

@@ -159,5 +159,9 @@ public class OrderDetailsDO extends BaseDO {
      * 品种
      */
     private String zzpz;
+    /**
+     * 网络/捻向
+     */
+    private String mesh;
 
 }

+ 2 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/dal/mysql/order/OrderMapper.java

@@ -58,6 +58,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
                 .and(!ObjectUtils.isEmpty(reqVO.getVkinfo()),i -> i.like(OrderDO::getVkbur, reqVO.getVkinfo()).or().like(OrderDO::getVkburt, reqVO.getVkinfo()))
                 .and(!ObjectUtils.isEmpty(reqVO.getVkginfo()),i -> i.like(OrderDO::getVkgrp, reqVO.getVkginfo()).or().like(OrderDO::getVkgrpt, reqVO.getVkginfo()))
                 .and(!ObjectUtils.isEmpty(reqVO.getYwyinfo()),i -> i.like(OrderDO::getYwy, reqVO.getYwyinfo()).or().like(OrderDO::getYwyt, reqVO.getYwyinfo()))
+                .ne(OrderDO::getHtdymb,"Y4")
                 .orderByDesc(OrderDO::getAudat).orderByDesc(OrderDO::getVbeln));
     }
 
@@ -73,6 +74,7 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
                 .and(!ObjectUtils.isEmpty(reqVO.getVkinfo()),i -> i.like(OrderDO::getVkbur, reqVO.getVkinfo()).or().like(OrderDO::getVkburt, reqVO.getVkinfo()))
                 .and(!ObjectUtils.isEmpty(reqVO.getVkginfo()),i -> i.like(OrderDO::getVkgrp, reqVO.getVkginfo()).or().like(OrderDO::getVkgrpt, reqVO.getVkginfo()))
                 .and(!ObjectUtils.isEmpty(reqVO.getYwyinfo()),i -> i.like(OrderDO::getYwy, reqVO.getYwyinfo()).or().like(OrderDO::getYwyt, reqVO.getYwyinfo()))
+                .eq(OrderDO::getHtdymb,"Y4")
                 .orderByDesc(OrderDO::getAudat).orderByDesc(OrderDO::getVbeln));
     }
 }

+ 11 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/exportContract/ExportContractServiceImpl.java

@@ -1,8 +1,11 @@
 package cn.iocoder.yudao.module.contract.service.exportContract;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
 import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
 import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicVarietyDO;
+import cn.iocoder.yudao.module.contract.dal.dataobject.invoice.InvoiceDO;
 import cn.iocoder.yudao.module.contract.dal.dataobject.order.OrderDO;
 import cn.iocoder.yudao.module.contract.dal.mysql.basicData.BasicVarietyMapper;
 import cn.iocoder.yudao.module.contract.service.order.OrderService;
@@ -15,6 +18,8 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
+
 import cn.iocoder.yudao.module.contract.controller.admin.exportContract.vo.*;
 import cn.iocoder.yudao.module.contract.dal.dataobject.exportContract.ExportContractDO;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -94,6 +99,12 @@ public class ExportContractServiceImpl extends ServiceImpl<ExportContractMapper,
         if(ids.length!=orderList.size()){
             throw exception("订单数据异常");
         }
+
+        Map<String, List<OrderDO>> ordersMap = orderList.stream().collect(Collectors.groupingBy(item -> item.getBukrs() + "-" + item.getKunnr()+ "-" +item.getInco1()+ "-" +item.getInco2()));
+        if(ordersMap.size()>1){
+            throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"请选择售达方、公司主体、国际贸易条件相同的订单数据");
+        }
+
         if(ObjectUtil.isEmpty(exportContractGenerate.getExportContract().getId())){
             for(OrderDO orderDO : orderList){
                 if(!"0".equals(orderDO.getStatus())){

+ 6 - 0
yudao-module-contract/yudao-module-contract-biz/src/main/java/cn/iocoder/yudao/module/contract/service/order/OrderService.java

@@ -70,5 +70,11 @@ public interface OrderService extends IService<OrderDO> {
 
     IPage<OrderDetailsRespVO> getOrderDetailsPage(OrderDetailsPageReqVO pageReqVO);
 
+    /**
+     * 获得出口就订单分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 订单分页
+     */
     PageResult<OrderDO> getExportOrderPage(ExportOrderPageReqVO pageReqVO);
 }