fix:数据处理方法-生成虚拟采购单(已发货未绑定采购单的数据)
parent
c246975914
commit
015ba6da70
|
|
@ -65,8 +65,8 @@
|
|||
<el-table-column label="制造商" align="center" prop="vendorName" show-overflow-tooltip/>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-document" @click="handleInnerLog(scope.row)">入库记录</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-document" @click="handleOuterLog(scope.row)">出库记录</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-download" @click="handleInnerLog(scope.row)">入库记录</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-upload2" @click="handleOuterLog(scope.row)">出库记录</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ export default {
|
|||
id: null,
|
||||
purchaseNo: null,
|
||||
buyerName: '紫光汇智信息技术有限公司',
|
||||
buyerAddress: '重庆市南岸区广福大道12号行政中心B区3号楼14-17',
|
||||
buyerAddress: '重庆市两江新区云杉南路6号涉外商务区B6栋7楼',
|
||||
vendorId: null,
|
||||
currency: 'RMB',
|
||||
purchaserId: null,
|
||||
|
|
|
|||
|
|
@ -36,10 +36,18 @@ public class DataProcessController {
|
|||
dataProcessService.generateServiceBillsWhenAllDelivered(orderCode);
|
||||
}
|
||||
|
||||
//项目推送CRM
|
||||
@Anonymous
|
||||
@GetMapping("/projectPushCRM")
|
||||
public void projectSendCRM(@RequestParam("projectId") Long projectId) {
|
||||
dataProcessService.projectSendCRM(projectId);
|
||||
}
|
||||
|
||||
//生成虚拟采购单(已发货未绑定采购单的数据)
|
||||
@Anonymous
|
||||
@GetMapping("/generateVirtualPurchase")
|
||||
public void generateVirtualPurchase() {
|
||||
dataProcessService.generateVirtualPurchase();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,71 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UnboundPurchaseOrderProductDto {
|
||||
|
||||
/** 项目编号 */
|
||||
private String projectCode;
|
||||
|
||||
/** 项目名称 */
|
||||
private String projectName;
|
||||
|
||||
/** 合同编号 */
|
||||
private String orderCode;
|
||||
|
||||
/** 合同ID */
|
||||
private String orderId;
|
||||
|
||||
/** 产品编码 */
|
||||
private String productCode;
|
||||
|
||||
/** 入库单号 */
|
||||
private String innerCode;
|
||||
|
||||
/** 单价 */
|
||||
private BigDecimal price;
|
||||
|
||||
/** 含税金额 */
|
||||
private BigDecimal allPrice;
|
||||
|
||||
/** 数量 */
|
||||
private BigDecimal quantity;
|
||||
|
||||
/** 税率 */
|
||||
private BigDecimal taxRate;
|
||||
|
||||
/** 税额 */
|
||||
private BigDecimal taxTotal;
|
||||
|
||||
/** 产品类型 */
|
||||
private String type;
|
||||
|
||||
/** 产品型号 */
|
||||
private String model;
|
||||
|
||||
/** 产品描述 */
|
||||
private String productDesc;
|
||||
|
||||
/** 采购员ID */
|
||||
private Long userId;
|
||||
|
||||
/** 采购员姓名 */
|
||||
private String userName;
|
||||
|
||||
/** 采购员邮箱 */
|
||||
private String email;
|
||||
|
||||
/** 采购员电话 */
|
||||
private String phonenumber;
|
||||
|
||||
/** 制造商ID */
|
||||
private Long vendorId;
|
||||
|
||||
/** 仓库ID */
|
||||
private Long warehouseId;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.sip.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.sip.domain.InventoryDelivery;
|
||||
|
|
@ -120,4 +121,12 @@ public interface ProjectOrderInfoMapper
|
|||
|
||||
List<UnboundPurchaseOrderProductDto> selectUnboundPurchaseOrderProductList();
|
||||
|
||||
int insertUnboundPurchaseOrderProductMap(@Param("orderId") String orderId,
|
||||
@Param("productCode") String productCode,
|
||||
@Param("purchaseId") Long purchaseId,
|
||||
@Param("quantity") BigDecimal quantity);
|
||||
|
||||
int updateInventoryInnerPurchaseNo(@Param("purchaseNo") String purchaseNo,
|
||||
@Param("innerCode") String innerCode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,6 @@ public interface IDataProcessService {
|
|||
|
||||
void projectSendCRM(Long projectId);
|
||||
|
||||
void generateVirtualPurchase();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
package com.ruoyi.sip.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.enums.ApproveStatusEnum;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.domain.InventoryInfo;
|
||||
import com.ruoyi.sip.domain.OmsInventoryInner;
|
||||
import com.ruoyi.sip.domain.OmsPayableBill;
|
||||
import com.ruoyi.sip.domain.ProductInfo;
|
||||
import com.ruoyi.sip.domain.VendorInfo;
|
||||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.dto.ProjectTransferRequest;
|
||||
import com.ruoyi.sip.dto.UnboundPurchaseOrderProductDto;
|
||||
import com.ruoyi.sip.dto.inventory.OmsPurchaseOrderItemDto;
|
||||
import com.ruoyi.sip.mapper.InventoryInfoMapper;
|
||||
import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectUserCollectInfoMapper;
|
||||
import com.ruoyi.sip.mapper.*;
|
||||
import com.ruoyi.sip.service.*;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||
|
|
@ -26,17 +23,16 @@ import org.apache.shiro.util.ThreadContext;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class DataProcessServiceImpl implements IDataProcessService {
|
||||
|
||||
@Resource
|
||||
|
|
@ -72,6 +68,12 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|||
@Autowired
|
||||
private IInventoryDeliveryService inventoryDeliveryService;
|
||||
|
||||
@Autowired
|
||||
private ICnareaService cnareaService;
|
||||
|
||||
@Resource
|
||||
private OmsPurchaseOrderMapper omsPurchaseOrderMapper;
|
||||
|
||||
@Value("${oms.inventory.innerTax:0.13}")
|
||||
private String defaultTax;
|
||||
|
||||
|
|
@ -173,5 +175,141 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|||
public void projectSendCRM(Long projectId) {
|
||||
projectInfoService.scheduleOpportunityUpdateByProjectId(projectId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateVirtualPurchase() {
|
||||
bindShiroUser(1L, "admin", "平台管理员");
|
||||
List<UnboundPurchaseOrderProductDto> unboundList = projectOrderInfoMapper.selectUnboundPurchaseOrderProductList();
|
||||
for (UnboundPurchaseOrderProductDto unboundDto : unboundList) {
|
||||
/*
|
||||
---------- 组装新建参数
|
||||
*/
|
||||
OmsPurchaseOrder omsPurchaseOrder = new OmsPurchaseOrder();
|
||||
omsPurchaseOrder.setApproveStatus("0");
|
||||
omsPurchaseOrder.setBuyerAddress("重庆市两江新区云杉南路6号涉外商务区B6栋7楼");
|
||||
omsPurchaseOrder.setBuyerName("紫光汇智信息技术有限公司");
|
||||
omsPurchaseOrder.setCurrency("RMB");
|
||||
omsPurchaseOrder.setIsVirtual(true);
|
||||
//采购单子项
|
||||
List<OmsPurchaseOrderItem> purechaseItems = new ArrayList<>();
|
||||
OmsPurchaseOrderItem purchaseItem = new OmsPurchaseOrderItem();
|
||||
purchaseItem.setAmountTotal(unboundDto.getAllPrice());
|
||||
purchaseItem.setPrice(unboundDto.getPrice());
|
||||
purchaseItem.setProductCode(unboundDto.getProductCode());
|
||||
purchaseItem.setProductDescription(unboundDto.getProductDesc());
|
||||
purchaseItem.setProductModel(unboundDto.getModel());
|
||||
purchaseItem.setProductType(unboundDto.getType());
|
||||
purchaseItem.setQuantity(unboundDto.getQuantity());
|
||||
purchaseItem.setTaxRate(unboundDto.getTaxRate());
|
||||
purchaseItem.setTaxTotal(unboundDto.getTaxTotal());
|
||||
purechaseItems.add(purchaseItem);
|
||||
omsPurchaseOrder.setOmsPurchaseOrderItemList(purechaseItems);
|
||||
omsPurchaseOrder.setPayMethod("1");
|
||||
omsPurchaseOrder.setPurchaserId(unboundDto.getUserId());
|
||||
omsPurchaseOrder.setPurchaserEmail(unboundDto.getEmail());
|
||||
omsPurchaseOrder.setPurchaserMobile(unboundDto.getPhonenumber());
|
||||
omsPurchaseOrder.setPurchaserName(unboundDto.getUserName());
|
||||
omsPurchaseOrder.setRemark(unboundDto.getProductCode() + " " + unboundDto.getProjectName());
|
||||
omsPurchaseOrder.setStatus(0);
|
||||
omsPurchaseOrder.setTotalAmount(unboundDto.getAllPrice());
|
||||
omsPurchaseOrder.setVendorId(unboundDto.getVendorId());
|
||||
omsPurchaseOrder.setWarehouseId(unboundDto.getWarehouseId());
|
||||
|
||||
/*
|
||||
---------- 采购单保存
|
||||
*/
|
||||
// 如果 ownerId 或 ownerName 为空,则使用当前登录用户
|
||||
if (omsPurchaseOrder.getOwnerId() == null) {
|
||||
omsPurchaseOrder.setOwnerId(ShiroUtils.getSysUser().getUserId());
|
||||
}
|
||||
if (omsPurchaseOrder.getOwnerName() == null) {
|
||||
omsPurchaseOrder.setOwnerName(ShiroUtils.getSysUser().getUserName());
|
||||
}
|
||||
omsPurchaseOrder.setCreateTime(DateUtils.getNowDate());
|
||||
String purchaseNo = generatePurchaseNo(omsPurchaseOrder.getVendorId(), Boolean.TRUE.equals(omsPurchaseOrder.getIsVirtual()));
|
||||
if (Boolean.TRUE.equals(omsPurchaseOrder.getIsVirtual())) {
|
||||
omsPurchaseOrder.setApproveStatus(ApproveStatusEnum.APPROVE_COMPLETE.getCode());
|
||||
omsPurchaseOrder.setConfirmStatus(OmsPurchaseOrder.ConfirmStatusEnum.CONFIRM.getCode());
|
||||
omsPurchaseOrder.setFlowType(OmsPurchaseOrder.FlowTypeEnum.ONLINE.getCode());
|
||||
}
|
||||
omsPurchaseOrder.setPurchaseNo(purchaseNo);
|
||||
// 设置初始版本号为 1
|
||||
omsPurchaseOrder.setVersion(1);
|
||||
omsPurchaseOrder.setStatus(OmsPurchaseOrder.StatusEnum.COMPLETED.getCode());
|
||||
omsPurchaseOrderMapper.insertOmsPurchaseOrder(omsPurchaseOrder);
|
||||
insertOmsPurchaseOrderItem(omsPurchaseOrder);
|
||||
|
||||
/*
|
||||
---------- 订单绑定采购单,采购单明细数据修改
|
||||
*/
|
||||
projectOrderInfoMapper.insertUnboundPurchaseOrderProductMap(unboundDto.getOrderId()
|
||||
, unboundDto.getProductCode()
|
||||
, omsPurchaseOrder.getId()
|
||||
, unboundDto.getQuantity());
|
||||
projectOrderInfoMapper.updateInventoryInnerPurchaseNo(purchaseNo, unboundDto.getInnerCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单编号
|
||||
*
|
||||
* @param vendorId 制造商ID
|
||||
* @param isVirtual 是否为虚拟采购单
|
||||
* @return 订单编号
|
||||
*/
|
||||
|
||||
private String generatePurchaseNo(Long vendorId, boolean isVirtual) {
|
||||
VendorInfo vendorInfo = vendorInfoService.selectVendorInfoByVendorId(vendorId);
|
||||
if (vendorInfo==null || StringUtils.isEmpty(vendorInfo.getProvince())) {
|
||||
throw new ServiceException("制造商所属省为空,无法生成订单编号");
|
||||
}
|
||||
// 获取当前时间,格式为yyyyMMdd
|
||||
String currentDate = DateUtils.dateTimeNow("yyyyMMdd");
|
||||
Cnarea cnarea = new Cnarea();
|
||||
cnarea.setName(vendorInfo.getProvince());
|
||||
cnarea.setLevel("1");
|
||||
List<Cnarea> cnareas = cnareaService.queryAll(cnarea);
|
||||
if (CollUtil.isEmpty(cnareas)) {
|
||||
throw new ServiceException("省市未配置,生成订单编号出错,请联系管理员");
|
||||
}
|
||||
String shortCode = cnareas.get(0).getShortCode();
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (isVirtual) {
|
||||
result.append("XN-");
|
||||
}
|
||||
result.append("ZGCV-").append(currentDate).append(shortCode);
|
||||
// 查询当天已有的订单数量,用于生成顺序编码
|
||||
int count = omsPurchaseOrderMapper.selectMaxOrderCode(result.toString());
|
||||
// 生成顺序编码,不足三位补零
|
||||
String sequence = String.format("%03d", count + 1);
|
||||
result.append(sequence);
|
||||
// 拼接订单编号
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采购单明细表信息
|
||||
*
|
||||
* @param omsPurchaseOrder 采购单主表对象
|
||||
*/
|
||||
public void insertOmsPurchaseOrderItem(OmsPurchaseOrder omsPurchaseOrder)
|
||||
{
|
||||
List<OmsPurchaseOrderItem> omsPurchaseOrderItemList = omsPurchaseOrder.getOmsPurchaseOrderItemList();
|
||||
Long id = omsPurchaseOrder.getId();
|
||||
if (StringUtils.isNotNull(omsPurchaseOrderItemList))
|
||||
{
|
||||
List<OmsPurchaseOrderItem> list = new ArrayList<OmsPurchaseOrderItem>();
|
||||
for (OmsPurchaseOrderItem omsPurchaseOrderItem : omsPurchaseOrderItemList)
|
||||
{
|
||||
omsPurchaseOrderItem.setPurchaseId(id);
|
||||
omsPurchaseOrderItem.setInnerQuantity(omsPurchaseOrderItem.getQuantity());
|
||||
list.add(omsPurchaseOrderItem);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
omsPurchaseOrderMapper.batchOmsPurchaseOrderItem(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1064,14 +1064,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectUnboundPurchaseOrderProductList" resultType="com.ruoyi.sip.dto.UnboundPurchaseOrderProductDto">
|
||||
select
|
||||
t5.project_code,
|
||||
t5.project_name,
|
||||
t2.id as order_id,
|
||||
t1.order_code,
|
||||
t1.product_code,
|
||||
t1.inner_code
|
||||
t1.inner_code,
|
||||
t3.price,
|
||||
cast(t3.price * count(1) as decimal(10,2)) as all_price,
|
||||
count(1) as quantity,
|
||||
t3.tax_rate / 100 as tax_rate,
|
||||
cast(cast(t3.price * count(1) as decimal(10,2)) - cast(t3.price * count(1) as decimal(10,2)) / (1 + t3.tax_rate / 100) as decimal(10,2)) as tax_total,
|
||||
t4.type,
|
||||
t3.model,
|
||||
t3.product_desc,
|
||||
t6.user_id,
|
||||
t6.user_name,
|
||||
t6.email,
|
||||
t6.phonenumber,
|
||||
t7.vendor_id,
|
||||
t1.warehouse_id
|
||||
from oms_inventory_info as t1
|
||||
inner join project_order_info as t2
|
||||
on t1.order_code = t2.order_code
|
||||
where t2.id not in (select order_id from oms_purchase_order_map)
|
||||
inner join project_order_info as t2 on t1.order_code = t2.order_code
|
||||
inner join project_product_info as t3 on t2.project_id = t3.project_id and t1.product_code = t3.product_bom_code
|
||||
inner join product_info as t4 on t1.product_code = t4.product_code
|
||||
inner join project_info as t5 on t2.project_id = t5.id
|
||||
left join sys_user as t6 on t2.duty = t6.user_id
|
||||
left join oms_vendor_info as t7 on t7.vendor_code = t4.vendor_code
|
||||
where not exists (select order_id from oms_purchase_order_map as tt where tt.order_id = t2.id and tt.product_code = t1.product_code)
|
||||
group by t1.order_code, t1.product_code, t1.inner_code
|
||||
</select>
|
||||
|
||||
<insert id="insertUnboundPurchaseOrderProductMap">
|
||||
insert into oms_purchase_order_map(order_id,purchase_id,product_code,bind_num) values(${orderId},${purchaseId},#{productCode},${quantity})
|
||||
</insert>
|
||||
|
||||
<update id="updateInventoryInnerPurchaseNo">
|
||||
update oms_inventory_inner set purchase_no = #{purchaseNo} where inner_code = #{innerCode}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue