fix:同步新华三接口调整,数据处理功能
parent
9a8fe13f28
commit
b7067082ed
|
|
@ -0,0 +1,122 @@
|
||||||
|
package com.ruoyi.sip.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.sip.domain.*;
|
||||||
|
import com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto;
|
||||||
|
import com.ruoyi.sip.mapper.InventoryInfoMapper;
|
||||||
|
import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
||||||
|
import com.ruoyi.sip.service.IOmsPayableBillService;
|
||||||
|
import com.ruoyi.sip.service.IOmsPurchaseOrderService;
|
||||||
|
import com.ruoyi.sip.service.IProductInfoService;
|
||||||
|
import com.ruoyi.sip.service.IVendorInfoService;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||||
|
import org.apache.shiro.mgt.SecurityManager;
|
||||||
|
import org.apache.shiro.subject.Subject;
|
||||||
|
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||||
|
import org.apache.shiro.util.ThreadContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据处理控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sip/dataProcess")
|
||||||
|
public class DataProcessController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OmsInventoryInnerMapper omsInventoryInnerMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private InventoryInfoMapper inventoryInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IProductInfoService productInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOmsPurchaseOrderService purchaseOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOmsPayableBillService payableBillService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IVendorInfoService vendorInfoService;
|
||||||
|
|
||||||
|
@Value("${oms.inventory.innerTax:0.13}")
|
||||||
|
private String defaultTax;
|
||||||
|
|
||||||
|
//入库单生成应付单
|
||||||
|
@GetMapping("/inventoryInnerGeneratePayableBill")
|
||||||
|
void inventoryInnerGeneratePayableBill(@RequestParam("innerId") Long innerId) {
|
||||||
|
bindShiroUser(1L, "admin", "平台管理员");
|
||||||
|
OmsInventoryInner omsInventoryInner = omsInventoryInnerMapper.selectOmsInventoryInnerById(innerId);
|
||||||
|
List<InventoryInfo> inventoryInfoList = inventoryInfoMapper.selectInventoryInfoByInnerCodeList(Arrays.asList(omsInventoryInner.getInnerCode()));
|
||||||
|
List<String> productCodeList = inventoryInfoList.stream().map(InventoryInfo::getProductCode).distinct().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
||||||
|
List<ProductInfo> productInfos = productInfoService.selectProductInfoByCodeList(productCodeList);
|
||||||
|
String vendorCode = productInfos.get(0).getVendorCode();
|
||||||
|
OmsPayableBill payableBill = new OmsPayableBill();
|
||||||
|
VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorCode(vendorCode);
|
||||||
|
|
||||||
|
BigDecimal reduce = inventoryInfoList.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
//服务金额为单价* 数量 没有具体的详情
|
||||||
|
BigDecimal totalPriceWithTax = Arrays.asList("3", "22").contains(omsInventoryInner.getProductType()) ?
|
||||||
|
reduce.multiply(new BigDecimal(omsInventoryInner.getQuantity())).setScale(2, RoundingMode.HALF_UP)
|
||||||
|
: reduce;
|
||||||
|
//生成应付单
|
||||||
|
payableBill.setInventoryCode(omsInventoryInner.getInnerCode());
|
||||||
|
payableBill.setVendorCode(omsInventoryInner.getVendorCode());
|
||||||
|
payableBill.setProductType(productInfos.get(0).getType());
|
||||||
|
payableBill.setProductCode(omsInventoryInner.getProductCode());
|
||||||
|
payableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||||
|
payableBill.setOrderCode(omsInventoryInner.getOrderCode());
|
||||||
|
payableBill.setProjectCode(omsInventoryInner.getProductCode());
|
||||||
|
payableBill.setProjectName(omsInventoryInner.getProjectName());
|
||||||
|
String purchaseNo = omsInventoryInner.getPurchaseNo();
|
||||||
|
BigDecimal taxRate = null;
|
||||||
|
if (StringUtils.isNotEmpty(purchaseNo)) {
|
||||||
|
OmsPurchaseOrderItemDto query = new OmsPurchaseOrderItemDto();
|
||||||
|
query.setPurchaseNo(purchaseNo);
|
||||||
|
List<OmsPurchaseOrderItemDto> omsPurchaseOrderItemDtos = purchaseOrderService.listItem(query);
|
||||||
|
Map<String, BigDecimal> decimalMap = omsPurchaseOrderItemDtos.stream().collect(Collectors.toMap(OmsPurchaseOrderItemDto::getProductCode, OmsPurchaseOrderItemDto::getTaxRate, (v1, v2) -> v1));
|
||||||
|
taxRate = decimalMap.get(omsInventoryInner.getProductCode());
|
||||||
|
|
||||||
|
}
|
||||||
|
BigDecimal finalTaxRate = taxRate == null ? new BigDecimal(defaultTax) : taxRate;
|
||||||
|
BigDecimal withoutTax = inventoryInfoList.stream().reduce(BigDecimal.ZERO, (a, b) -> a.add(b.getInnerPrice().divide(BigDecimal.ONE.add(finalTaxRate), 2, RoundingMode.HALF_UP)), BigDecimal::add);
|
||||||
|
payableBill.setTotalPriceWithoutTax(withoutTax);
|
||||||
|
payableBill.setTaxRate(finalTaxRate);
|
||||||
|
payableBill.setTaxAmount(totalPriceWithTax);
|
||||||
|
payableBill.setTaxAmount(totalPriceWithTax.subtract(payableBill.getTotalPriceWithoutTax()));
|
||||||
|
payableBillService.insertOmsPayableBill(payableBill, vendorInfo.getPayConfigDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindShiroUser(Long userId, String loginName, String userName) {
|
||||||
|
SecurityManager securityManager = new DefaultSecurityManager();
|
||||||
|
SecurityUtils.setSecurityManager(securityManager);
|
||||||
|
ThreadContext.bind(securityManager);
|
||||||
|
|
||||||
|
SysUser user = new SysUser();
|
||||||
|
user.setUserId(userId);
|
||||||
|
user.setLoginName(loginName);
|
||||||
|
user.setUserName(userName);
|
||||||
|
Subject subject = new Subject.Builder(securityManager)
|
||||||
|
.principals(new SimplePrincipalCollection(user, "testRealm"))
|
||||||
|
.buildSubject();
|
||||||
|
ThreadContext.bind(subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -336,17 +336,11 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
||||||
return inventoryDeliveryMapper.deleteInventoryDeliveryById(id);
|
return inventoryDeliveryMapper.deleteInventoryDeliveryById(id);
|
||||||
} else {
|
} else {
|
||||||
// 2026-03-19:新逻辑,仅修改发货单状态为撤回,不删除库存表
|
// 2026-03-19:新逻辑,仅修改发货单状态为撤回,不删除库存表
|
||||||
int rows = 0;
|
InventoryDelivery updateDelivery = new InventoryDelivery();
|
||||||
List<InventoryDelivery> inventoryDeliveries = inventoryDeliveryMapper.selectQuantityByOrderCodeStatus(orderCode, InventoryDelivery.DeliveryStatusEnum.CONFIRM_DELIVERY.getCode());
|
updateDelivery.setId(id);
|
||||||
if (CollUtil.isNotEmpty(inventoryDeliveries)) {
|
updateDelivery.setDeliveryStatus(InventoryDelivery.DeliveryStatusEnum.RECALL_DELIVERY.getCode());
|
||||||
for (InventoryDelivery inventoryDeliverie : inventoryDeliveries) {
|
updateDelivery.setUpdateTime(DateUtils.getNowDate());
|
||||||
InventoryDelivery updateDelivery = new InventoryDelivery();
|
int rows = inventoryDeliveryMapper.updateInventoryDelivery(updateDelivery);
|
||||||
updateDelivery.setId(inventoryDeliverie.getId());
|
|
||||||
updateDelivery.setDeliveryStatus(InventoryDelivery.DeliveryStatusEnum.RECALL_DELIVERY.getCode());
|
|
||||||
updateDelivery.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
rows += inventoryDeliveryMapper.updateInventoryDelivery(updateDelivery);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN agent_info t3 ON t2.agent_code = t3.agent_code
|
LEFT JOIN agent_info t3 ON t2.agent_code = t3.agent_code
|
||||||
LEFT JOIN customer_info t4 ON t2.customer_code = t4.customer_code
|
LEFT JOIN customer_info t4 ON t2.customer_code = t4.customer_code
|
||||||
where (
|
where (
|
||||||
CAST(ifnull(t1.version_code,0) + ifnull(t1.operation_version,0) AS SIGNED) > 1 or
|
(CAST(ifnull(t1.version_code,0) + ifnull(t1.operation_version,0) AS SIGNED) > 1 and t1.order_status = '2') or
|
||||||
t1.order_code in ( select DISTINCT order_code from oms_inventory_outer where outer_code in (SELECT outer_code from oms_inventory_delivery where delivery_status=1))
|
t1.order_code in ( select DISTINCT order_code from oms_inventory_outer where outer_code in (SELECT outer_code from oms_inventory_delivery where delivery_status=1))
|
||||||
)
|
)
|
||||||
<choose>
|
<choose>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue