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