Browse Source

委外申请单

master
shenzhouyu 10 months ago
parent
commit
6b9ef6402a
  1. 78
      src/main/java/com/gaotao/modules/outsourcing/controller/OutsourcingNotifyController.java
  2. 35
      src/main/java/com/gaotao/modules/outsourcing/dao/OutsourcingNotifyMapper.java
  3. 14
      src/main/java/com/gaotao/modules/outsourcing/entity/dto/OutsourcingIssueNotifyDto.java
  4. 167
      src/main/java/com/gaotao/modules/outsourcing/entity/vo/OutsourcingAndMaterialVo.java
  5. 23
      src/main/java/com/gaotao/modules/outsourcing/service/OutsourcingNotifyService.java
  6. 392
      src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java
  7. 113
      src/main/resources/mapper/outsourcing/OutsourcingNotifyMapper.xml

78
src/main/java/com/gaotao/modules/outsourcing/controller/OutsourcingNotifyController.java

@ -1,12 +1,19 @@
package com.gaotao.modules.outsourcing.controller;
import com.gaotao.common.utils.PageUtils;
import com.gaotao.common.utils.PartAttributeUtil;
import com.gaotao.common.utils.R;
import com.gaotao.modules.api.entity.IfsShopOrder;
import com.gaotao.modules.base.entity.SOScheduledRoutingData;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderListData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListData;
import com.gaotao.modules.notify.entity.dto.NewSoIssueNotifyDto;
import com.gaotao.modules.notify.entity.vo.ShopOrderAndMaterialVo;
import com.gaotao.modules.outsourcing.entity.dto.IfsOutsourcingOrderDto;
import com.gaotao.modules.outsourcing.entity.dto.OutsourcingIssueNotifyDto;
import com.gaotao.modules.outsourcing.entity.vo.OutsourcingAndMaterialVo;
import com.gaotao.modules.outsourcing.service.OutsourcingNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -20,6 +27,8 @@ public class OutsourcingNotifyController {
@Autowired
private OutsourcingNotifyService outsourcingNotifyService;
@Autowired
private PartAttributeUtil partAttributeUtil;
@PostMapping(value="/getUserNotifyPo")
@ResponseBody
@ -44,11 +53,78 @@ public class OutsourcingNotifyController {
@PostMapping(value="/getShopOrderAndMaterialByShoporder")
public R getShopOrderAndMaterialByShoporder(@RequestBody IfsOutsourcingOrderDto data) throws Exception {
List<ShopOrderAndMaterialVo> rows = outsourcingNotifyService.getShopOrderAndMaterialByShoporder(data);
List<OutsourcingAndMaterialVo> rows = outsourcingNotifyService.getShopOrderAndMaterialByShoporder(data);
if(rows != null && rows.size() > 0){
return R.ok().put("rows", rows);
}
return R.error("未找到对应的工单物料信息");
}
@PostMapping(value="/deleteOutsourcingNotifyHeader")
@ResponseBody
public R deleteOutsourcingNotifyHeader(@RequestBody SOIssueNotifyHeaderData data) {
outsourcingNotifyService.deleteOutsourcingNotifyHeader(data);
return R.ok("删除成功");
}
@PostMapping(value="/saveNewOutsourcingIssueNotify")
public R saveNewOutsourcingIssueNotify(@RequestBody OutsourcingIssueNotifyDto data) throws Exception {
String rows = outsourcingNotifyService.saveNewOutsourcingIssueNotify(data);
if("200".equals(rows)){
return R.ok("操作成功");
}
return R.error("操作失败");
}
@PostMapping(value="/getOutsouringForIssureNew")
@ResponseBody
public R getOutsouringForIssureNew(@RequestBody SOScheduledRoutingData data) throws Exception{
List<SOIssueNotifyOrderMaterialListData> rows = outsourcingNotifyService.getOutsouringForIssureNew(data);
if(rows != null && rows.size() > 0){
// 提前赋值用componentPartNo赋值给partQuerypartNo保持原值不变 - rqrq
for (SOIssueNotifyOrderMaterialListData row : rows) {
row.setPartQuery(row.getComponentPartNo()); // componentPartNo用于fillIsInWh查询 - rqrq
}
// 批量填充isInWh字段 - rqrq
partAttributeUtil.fillIsInWh(rows);
}
return R.ok().put("rows", rows);
}
@PostMapping(value="/saveMaterialDetail")
@ResponseBody
public R saveMaterialDetail(@RequestBody List<SOIssueNotifyOrderMaterialListData> data) {
outsourcingNotifyService.saveMaterialDetail(data);
return R.ok();
}
@PostMapping(value="/deleteNotifySOS")
@ResponseBody
public R deleteNotifySOS(@RequestBody SOIssueNotifyOrderListData data) {
outsourcingNotifyService.deleteNotifySOS(data);
return R.ok();
}
@PostMapping(value="/xiadaNotify")
@ResponseBody
public R xiadaNotifyHeader(@RequestBody SOIssueNotifyHeaderData data) {
outsourcingNotifyService.xiadaNotifyHeader(data);
return R.ok();
}
@PostMapping(value="/searchNotifyHeaderNew")
public R searchNotifyHeaderNew(@RequestBody SOIssueNotifyHeaderData data) {
PageUtils page = outsourcingNotifyService.searchNotifyHeaderNew(data);
return R.ok().put("page", page);
}
@PostMapping(value="/deleteNotifySOSPlus")
@ResponseBody
public R deleteNotifySOSPlus(@RequestBody SOIssueNotifyOrderListData data) throws Exception{
outsourcingNotifyService.deleteNotifySOSPlus(data);
return R.ok("刪除成功");
}
}

35
src/main/java/com/gaotao/modules/outsourcing/dao/OutsourcingNotifyMapper.java

@ -1,11 +1,14 @@
package com.gaotao.modules.outsourcing.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeader;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderListData;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gaotao.modules.base.entity.SOScheduledRoutingData;
import com.gaotao.modules.notify.entity.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
@Mapper
@ -13,4 +16,30 @@ public interface OutsourcingNotifyMapper extends BaseMapper<SOIssueNotifyHeader>
SOIssueNotifyHeaderData getUserNotifyPo(SOIssueNotifyHeaderData data);
List<SOIssueNotifyOrderListData> getNotifyPoDetail(SOIssueNotifyHeaderData data);
int deleteOutsourcingNotifyHeader(SOIssueNotifyHeaderData data);
BigDecimal getNextItemForSOIssueNotifyOrderList(SOIssueNotifyOrderList parentData);
String getProductAreaByPlanner(@Param("site") String site,@Param("planner")String planner);
int saveSOIssueNotifyOrderList(SOIssueNotifyOrderList parentItem);
int deleteSOIssueNotifyOrderMaterialInList(@Param("notifyNo") String notifyNo,@Param("site") String site,@Param("items") List<String> items);
int batchSaveSOIssueNotifyOrderMaterialList(List<SOIssueNotifyOrderMaterialList> childList);
List<SOIssueNotifyOrderMaterialListData> getSOSBOMForIssureNew(SOScheduledRoutingData data);
int deleteOutNotifyOrderMaterialListData(SOIssueNotifyOrderMaterialListData soIssueNotifyOrderMaterialListData);
void batchSaveOutNotifyOrderMaterialListData(@Param("data")List<SOIssueNotifyOrderMaterialListData> data);
int deleteNotifySOS(SOIssueNotifyOrderListData data);
int deleteSOIssueNotifyOrderMaterialListData(SOIssueNotifyOrderMaterialListData deleteData);
int xiadaNotifyHeader(SOIssueNotifyHeaderData data);
IPage<SOIssueNotifyHeaderData> searchNotifyHeaderNew(Page<SOIssueNotifyHeaderData> page, @Param("query") SOIssueNotifyHeaderData data);
}

14
src/main/java/com/gaotao/modules/outsourcing/entity/dto/OutsourcingIssueNotifyDto.java

@ -0,0 +1,14 @@
package com.gaotao.modules.outsourcing.entity.dto;
import com.gaotao.modules.outsourcing.entity.vo.OutsourcingAndMaterialVo;
import lombok.Data;
import java.util.List;
@Data
public class OutsourcingIssueNotifyDto {
private String site;
private String outsourcingNo;
private String notifyNo;
List<OutsourcingAndMaterialVo> materialList;
}

167
src/main/java/com/gaotao/modules/outsourcing/entity/vo/OutsourcingAndMaterialVo.java

@ -0,0 +1,167 @@
package com.gaotao.modules.outsourcing.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class OutsourcingAndMaterialVo {
/**--------------------------------------详情Materical---------------------------------------------*/
// 订单编号关联的父订单编号
private String orderNo;
// 合同编号所属合同标识
private String contract;
// 行号在订单中的行项目编号
private String lineNo;
// 释放编号订单释放的批次编号
private String releaseNo;
// 结构行号在BOM结构中的行号null表示无结构关联
private String lineItemNo;
// 组件物料编号所需物料的编码
private String componentPartNo;
// 组件物料描述所需物料的详细说明
private String componentPartDescription;
// 需求数量该物料的总需求量
private BigDecimal qtyRequired;
// 已预留数量已从库存中预留的数量
private BigDecimal reservedQty;
// 计量单位数量的计量单位
private String uom;
// 需求日期物料需要到位的日期时间
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date dateRequired;
// 已发放数量已实际发放的物料数量
private BigDecimal qtyIssued;
// 倒冲标识是否启用倒冲领料FALSE表示不启用
private String backflush;
// 单位数量可能表示每个父项所需的子项数量
private BigDecimal qpa;
// 组件损耗率物料在生产过程中的损耗百分比
private BigDecimal componentScrap;
// 报废因子可能用于计算损耗的系数
private BigDecimal scrapFactor;
private BigDecimal applyQty;
/**----------------------------------------PurchaseOrderLine-------------------------------------------*/
// 转换因子不同单位间的转换比例
private BigDecimal convFactor;
// 物料描述物料的详细说明信息
private String description;
// 库存数量当前库存中的物料数量
private BigDecimal inventoryQty;
// 库存单位库存数量的计量单位
private String inventoryUOM;
// 待接收库存数量需要接收至库存的数量
private BigDecimal invQtyToReceive;
// 物料编号采购的物料编码
private String partNo;
// 计划交货日期物料的计划交付日期时间
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date plannedDeliveryDate;
// 采购数量订单中该物料的总采购数量
private BigDecimal purchaseQty;
// 采购单位采购数量的计量单位
private String purchaseUOM;
// 待接收数量需要接收的物料总数量
private BigDecimal qtyToReceive;
// 接收方式文字描述的接收处理方式
private String receiveCase;
// 站点编号业务所属的站点/组织
private String site;
// 状态行项目的当前状态
private String status;
// 接收方式代码数据库中存储的接收方式编码
private String receiveCaseDB;
// 订单状态所属订单的整体状态
private String orderStatus;
// 库存物料标识是否为库存物料的文字标识
private String inventoryPartDB;
// 需求类型文字描述的需求类型
private String demandCode;
// 需求类型代码数据库中存储的需求类型编码
private String demandCodeDB;
private String samplePercent;
private String sampleQty;
/**--------------------------------------------PurchaseOrder--------------------------------------------------*/
// 供应商编号提供货物的供应商编码
private String supplierNo;
// 供应商名称提供货物的供应商全称
private String supplierName;
// 收货日期货物接收的日期时间
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date receiptDate;
// 采购员编码负责该订单的采购员标识
private String buyerCode;
// 地址1供应商/收货地址第一行信息
private String address1;
// 地址2供应商/收货地址第二行信息
private String address2;
// 地址3供应商/收货地址第三行信息
private String address3;
// 地址4供应商/收货地址第四行信息
private String address4;
// 地址5供应商/收货地址第五行信息
private String address5;
// 地址6供应商/收货地址第六行信息
private String address6;
// 城市所在城市
private String city;
// 邮政编码地址对应的邮政编码
private String zipCode;
// 对象状态与status可能一致部分系统用于内部状态管理
private String objstate;
private String authorizationRequired;
}

23
src/main/java/com/gaotao/modules/outsourcing/service/OutsourcingNotifyService.java

@ -1,10 +1,15 @@
package com.gaotao.modules.outsourcing.service;
import com.gaotao.common.utils.PageUtils;
import com.gaotao.modules.api.entity.IfsShopOrder;
import com.gaotao.modules.base.entity.SOScheduledRoutingData;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderListData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListData;
import com.gaotao.modules.notify.entity.vo.ShopOrderAndMaterialVo;
import com.gaotao.modules.outsourcing.entity.dto.IfsOutsourcingOrderDto;
import com.gaotao.modules.outsourcing.entity.dto.OutsourcingIssueNotifyDto;
import com.gaotao.modules.outsourcing.entity.vo.OutsourcingAndMaterialVo;
import java.util.List;
@ -15,5 +20,21 @@ public interface OutsourcingNotifyService {
List<SOIssueNotifyOrderListData> getNotifyPoDetail(SOIssueNotifyHeaderData data);
List<ShopOrderAndMaterialVo> getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data)throws Exception;
List<OutsourcingAndMaterialVo> getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data)throws Exception;
void deleteOutsourcingNotifyHeader(SOIssueNotifyHeaderData data);
String saveNewOutsourcingIssueNotify(OutsourcingIssueNotifyDto data) throws Exception;
List<SOIssueNotifyOrderMaterialListData> getOutsouringForIssureNew(SOScheduledRoutingData data)throws Exception;
void saveMaterialDetail(List<SOIssueNotifyOrderMaterialListData> data);
void deleteNotifySOS(SOIssueNotifyOrderListData data);
void xiadaNotifyHeader(SOIssueNotifyHeaderData data);
PageUtils searchNotifyHeaderNew(SOIssueNotifyHeaderData data);
void deleteNotifySOSPlus(SOIssueNotifyOrderListData data)throws Exception;
}

392
src/main/java/com/gaotao/modules/outsourcing/service/impl/OutsourcingNotifyServiceImpl.java

@ -1,27 +1,44 @@
package com.gaotao.modules.outsourcing.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gaotao.common.utils.PageUtils;
import com.gaotao.modules.api.entity.IfsInventoryPart;
import com.gaotao.modules.api.entity.IfsShopOrder;
import com.gaotao.modules.api.entity.issueAndReturnVo.POLineSupplierMaterialVo;
import com.gaotao.modules.api.entity.issueAndReturnVo.PurchaseOrderLineVo;
import com.gaotao.modules.api.entity.issueAndReturnVo.PurchaseOrderVo;
import com.gaotao.modules.api.service.IfsApiIssueAndReturnService;
import com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData;
import com.gaotao.modules.notify.entity.SOIssueNotifyOrderListData;
import com.gaotao.modules.api.service.IfsApiService;
import com.gaotao.modules.base.entity.SOScheduledRoutingData;
import com.gaotao.modules.notify.entity.*;
import com.gaotao.modules.notify.entity.dto.GroupKey;
import com.gaotao.modules.notify.entity.dto.NewSoIssueNotifyDto;
import com.gaotao.modules.notify.entity.dto.ShoporderAndMaterialDto;
import com.gaotao.modules.notify.entity.vo.ShopOrderAndMaterialVo;
import com.gaotao.modules.notify.entity.vo.ShopOrderMaterialVo;
import com.gaotao.modules.outsourcing.dao.OutsourcingNotifyMapper;
import com.gaotao.modules.outsourcing.entity.dto.IfsOutsourcingOrderDto;
import com.gaotao.modules.outsourcing.entity.dto.OutsourcingIssueNotifyDto;
import com.gaotao.modules.outsourcing.entity.vo.OutsourcingAndMaterialVo;
import com.gaotao.modules.outsourcing.service.OutsourcingNotifyService;
import com.gaotao.modules.sys.entity.SysUserEntity;
import com.gaotao.modules.trans.entity.TransNoControl;
import com.gaotao.modules.trans.service.Consts;
import com.gaotao.modules.trans.service.TransNoControlService;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class OutsourcingNotifyServiceImpl implements OutsourcingNotifyService {
@ -31,6 +48,8 @@ public class OutsourcingNotifyServiceImpl implements OutsourcingNotifyService {
private TransNoControlService transNoService;
@Autowired
private IfsApiIssueAndReturnService ifsApiIssueAndReturnService;
@Autowired
private IfsApiService ifsApiService;
@Override
public SOIssueNotifyHeaderData getUserNotifyPo(SOIssueNotifyHeaderData data) {
SOIssueNotifyHeaderData headerData = outsourcingNotifyMapper.getUserNotifyPo(data);
@ -72,17 +91,376 @@ public class OutsourcingNotifyServiceImpl implements OutsourcingNotifyService {
}
@Override
public List<ShopOrderAndMaterialVo> getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data) throws Exception{
public List<OutsourcingAndMaterialVo> getShopOrderAndMaterialByShoporder(IfsOutsourcingOrderDto data) throws Exception{
List<PurchaseOrderVo> purchaseOrder = ifsApiIssueAndReturnService.getPurchaseOrder(data.getOutsourcingNo(), data.getSite());
List<PurchaseOrderLineVo> purchaseOrderLine = ifsApiIssueAndReturnService.getPurchaseOrderLine(data.getOutsourcingNo(), data.getSite());
List<OutsourcingAndMaterialVo> resultList = new ArrayList<>();
if(purchaseOrderLine != null && purchaseOrderLine.size()>0) {
List<POLineSupplierMaterialVo> poLineSupplierMaterial = ifsApiIssueAndReturnService.getPOLineSupplierMaterial(data.getOutsourcingNo(), data.getSite());
for(POLineSupplierMaterialVo materialVo:poLineSupplierMaterial){
// 建立 purchaseOrderLine 的索引用于快速查找
// key: orderNo + "|" + site + "|" + releaseNo + "|" + lineNo
Map<String, PurchaseOrderLineVo> purchaseOrderLineMap = purchaseOrderLine.stream()
.collect(Collectors.toMap(
line -> line.getOrderNo() + "|" + line.getSite() + "|" +
(line.getReleaseNo() != null ? line.getReleaseNo() : "") + "|" +
(line.getLineNo() != null ? line.getLineNo() : ""),
line -> line,
(existing, replacement) -> existing
));
// 建立 purchaseOrder 的索引用于快速查找
// key: orderNo + "|" + site
Map<String, PurchaseOrderVo> purchaseOrderMap = purchaseOrder.stream()
.collect(Collectors.toMap(
order -> order.getOrderNo() + "|" + order.getSite(),
order -> order,
(existing, replacement) -> existing
));
// 遍历最小的子类 poLineSupplierMaterial关联父类数据
for(POLineSupplierMaterialVo materialVo : poLineSupplierMaterial) {
// 构建查找 purchaseOrderLine key
// 关联条件子类的orderNo=父类的orderNo 子类的contract=父类的site 子类releaseNo=父类releaseNo 子类lineItemNo=父类lineNo
String lineKey = materialVo.getOrderNo() + "|" +
(materialVo.getContract() != null ? materialVo.getContract() : "") + "|" +
(materialVo.getReleaseNo() != null ? materialVo.getReleaseNo() : "") + "|" +
(materialVo.getLineItemNo() != null ? materialVo.getLineItemNo() : "");
PurchaseOrderLineVo matchedLine = purchaseOrderLineMap.get(lineKey);
if(matchedLine != null) {
// 通过 purchaseOrderLine 查找 purchaseOrder
// 关联条件purchaseOrderLine.orderNo = purchaseOrder.orderNo purchaseOrderLine.site = purchaseOrder.site
String orderKey = matchedLine.getOrderNo() + "|" + matchedLine.getSite();
PurchaseOrderVo matchedOrder = purchaseOrderMap.get(orderKey);
// 创建返回对象
OutsourcingAndMaterialVo vo = new OutsourcingAndMaterialVo();
// 从最小的子类 poLineSupplierMaterial 复制数据
BeanUtils.copyProperties(materialVo, vo);
/*vo.setOrderNo(materialVo.getOrderNo());
vo.setReleaseNo(materialVo.getReleaseNo());
vo.setContract(materialVo.getContract());
vo.setLineNo(materialVo.getLineNo());
if(materialVo.getLineItemNo() != null) {
try {
vo.setLineItemNo(materialVo.getLineItemNo());
} catch (NumberFormatException e) {
// 如果转换失败设置为null
vo.setLineItemNo(null);
}
}
vo.setComponentPartNo(materialVo.getComponentPartNo());
vo.setComponentPartDescription(materialVo.getComponentPartDescription());
vo.setQtyRequired(materialVo.getQtyRequired());
vo.setReservedQty(materialVo.getReservedQty());
vo.setQtyIssued(materialVo.getQtyIssued());
vo.setUom(materialVo.getUom());
if(materialVo.getDateRequired() != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
vo.setDateRequired(materialVo.getDateRequired());
}*/
// purchaseOrderLine 复制数据
vo.setConvFactor(matchedLine.getConvFactor());
vo.setDescription(matchedLine.getDescription());
vo.setInventoryQty(matchedLine.getInventoryQty());
vo.setInventoryUOM(matchedLine.getInventoryUOM());
vo.setInvQtyToReceive(matchedLine.getInvQtyToReceive());
if(matchedLine.getPartNo() != null) {
vo.setPartNo(matchedLine.getPartNo());
}
if(matchedLine.getPlannedDeliveryDate() != null) {
vo.setPlannedDeliveryDate(matchedLine.getPlannedDeliveryDate());
}
vo.setPurchaseQty(matchedLine.getPurchaseQty());
vo.setPurchaseUOM(matchedLine.getPurchaseUOM());
vo.setQtyToReceive(matchedLine.getQtyToReceive());
vo.setReceiveCase(matchedLine.getReceiveCase());
vo.setReceiveCaseDB(matchedLine.getReceiveCaseDB());
if(matchedLine.getStatus() != null) {
vo.setStatus(matchedLine.getStatus());
}
vo.setSite(matchedLine.getSite());
vo.setOrderStatus(matchedLine.getOrderStatus());
vo.setInventoryPartDB(matchedLine.getInventoryPartDB());
vo.setDemandCode(matchedLine.getDemandCode());
vo.setDemandCodeDB(matchedLine.getDemandCodeDB());
// purchaseOrder 复制数据如果需要
if(matchedOrder != null) {
if(StringUtils.isBlank(vo.getStatus()) && matchedOrder.getStatus() != null) {
vo.setStatus(matchedOrder.getStatus());
}
if(matchedOrder.getObjstate() != null) {
vo.setObjstate(matchedOrder.getObjstate());
}
if(matchedOrder.getAuthorizationRequired() != null) {
vo.setAuthorizationRequired(matchedOrder.getAuthorizationRequired());
}
vo.setSupplierNo(matchedOrder.getSupplierNo());
vo.setSupplierName(matchedOrder.getSupplierName());
vo.setReceiptDate(matchedOrder.getReceiptDate());
vo.setBuyerCode(matchedOrder.getBuyerCode());
vo.setAddress1(matchedOrder.getAddress1());
vo.setAddress2(matchedOrder.getAddress2());
vo.setAddress3(matchedOrder.getAddress3());
vo.setAddress4(matchedOrder.getAddress4());
vo.setAddress5(matchedOrder.getAddress5());
vo.setAddress6(matchedOrder.getAddress6());
vo.setCity(matchedOrder.getCity());
vo.setZipCode(matchedOrder.getZipCode());
vo.setCity(matchedOrder.getCity());
}
resultList.add(vo);
}
}
}
return resultList;
}
@Override
public void deleteOutsourcingNotifyHeader(SOIssueNotifyHeaderData data) {
outsourcingNotifyMapper.deleteOutsourcingNotifyHeader(data);
}
@Transactional
@Override
public String saveNewOutsourcingIssueNotify(OutsourcingIssueNotifyDto data) throws Exception {
if(data.getMaterialList() != null && data.getMaterialList().size() > 0){
Map<GroupKey, List<OutsourcingAndMaterialVo>> mainGroupMap = data.getMaterialList().stream()
.collect(Collectors.groupingBy(
dto -> new GroupKey(
dto.getOrderNo(),
dto.getReleaseNo(),
dto.getLineItemNo()
)
));
// 用于存储最终结果父集合和子集合
List<SOIssueNotifyOrderList> parentList = new ArrayList<>();
List<SOIssueNotifyOrderMaterialList> childList = new ArrayList<>();
int num = 0;
BigDecimal nextItem=BigDecimal.ZERO;
// 步骤2遍历每个分组生成父对象和子对象
for (Map.Entry<GroupKey, List<OutsourcingAndMaterialVo>> entry : mainGroupMap.entrySet()) {
GroupKey groupKey = entry.getKey();
List<OutsourcingAndMaterialVo> groupDtos = entry.getValue();
// 2.1 生成父对象的唯一 itemNo确保全局唯一这里用 UUID 简化
if(num == 0){
SOIssueNotifyOrderList parentData = new SOIssueNotifyOrderList();
parentData.setSite(data.getSite());
parentData.setNotifyNo(data.getNotifyNo());
nextItem = outsourcingNotifyMapper.getNextItemForSOIssueNotifyOrderList(parentData);
}else{
nextItem = nextItem.add(BigDecimal.ONE);
}
// 2.2 构建SOIssueNotifyOrderList
SOIssueNotifyOrderList parent = buildParent(data.getNotifyNo(),data.getSite(),groupKey, groupDtos, nextItem);
parentList.add(parent);
// 2.3 遍历分组内的 dto lineItemNo 生成子对象SOIssueNotifyOrderMaterialList
List<SOIssueNotifyOrderMaterialList> children = buildChildren(data.getNotifyNo(),data.getSite(),groupDtos, nextItem,parent.getOrderType());
childList.addAll(children);
num++;
}
List<String> items= new ArrayList<>();
// 保存父类
for(SOIssueNotifyOrderList parentItem : parentList){
IfsInventoryPart inventoryPart = new IfsInventoryPart();
inventoryPart.setSite(parentItem.getSite());
inventoryPart.setPartNo(parentItem.getFgPartNo());
List<IfsInventoryPart> rows = null;
try {
rows = ifsApiService.getIfsInventoryPart(inventoryPart);
} catch (Exception e) {
throw new RuntimeException(e);
}
String productionArea;
if(parentItem.getFgPartNo().startsWith("3")||parentItem.getFgPartNo().startsWith("7")) {
productionArea = "Z112";
}else {
productionArea = outsourcingNotifyMapper.getProductAreaByPlanner(parentItem.getSite(), rows.get(0).getPlannerBuyer());
}
parentItem.setProductionArea(productionArea!=null?productionArea:"Z301");
parentItem.setPushWmsFlag("N");
parentItem.setTransportFlag("N");
parentItem.setOutWorkOrderFlag("N");
int i = outsourcingNotifyMapper.saveSOIssueNotifyOrderList(parentItem);
items.add(parentItem.getItemNo().toString());
}
//保存子类
outsourcingNotifyMapper.deleteSOIssueNotifyOrderMaterialInList(data.getNotifyNo(),data.getSite(),items);
outsourcingNotifyMapper.batchSaveSOIssueNotifyOrderMaterialList(childList);
return "200";
}else{
throw new RuntimeException("物料列表不能为空");
}
}
private static SOIssueNotifyOrderList buildParent(String notifyNo,String site,GroupKey groupKey, List<OutsourcingAndMaterialVo> groupDtos, BigDecimal parentItemNo) {
SOIssueNotifyOrderList parent = new SOIssueNotifyOrderList();
parent.setNotifyNo(notifyNo);
parent.setSite(site);
parent.setItemNo(parentItemNo);
parent.setSoorderNo(groupKey.getOrderNo());
parent.setReleaseNo(groupKey.getReleaseNo());
parent.setSequenceNo(groupKey.getSequenceNo());
// 从分组内第一个 dto 提取共同属性假设同一分组内这些属性一致
OutsourcingAndMaterialVo firstDto = groupDtos.get(0);
parent.setFgPartNo(firstDto.getPartNo());
parent.setNeedDate(firstDto.getPlannedDeliveryDate());
parent.setTransportFlag("N");
parent.setOrderType("poorder");
return parent;
}
/**
* 构建子对象列表SOIssueNotifyOrderMaterialList关联父对象的 itemNo
*/
private static List<SOIssueNotifyOrderMaterialList> buildChildren(String notifyNo,String site,List<OutsourcingAndMaterialVo> groupDtos, BigDecimal parentItemNo,String parentType) {
return groupDtos.stream()
.map(dto -> {
SOIssueNotifyOrderMaterialList child = new SOIssueNotifyOrderMaterialList();
child.setNotifyNo(notifyNo);
child.setSite(site);
child.setItemNo(parentItemNo);
// 设置细分核心字段lineItemNo
child.setBOMItemNo(dto.getLineItemNo().toString());
// 提取详细属性
child.setComponentPartNo(dto.getComponentPartNo());
child.setQtyToIssue(dto.getApplyQty());
if( dto.getApplyQty()!=null){
child.setQtyToIssueOriginal(dto.getApplyQty());
}
child.setIssueType("BOM物料");
if(StringUtils.isNotBlank(parentType)){
child.setOrderType(parentType);
}else{
child.setOrderType("shoporder");
}
return child;
})
// lineItemNo 排序可选确保子项顺序
.sorted(Comparator.comparing(SOIssueNotifyOrderMaterialList::getBOMItemNo))
.collect(Collectors.toList());
}
@Override
public List<SOIssueNotifyOrderMaterialListData> getOutsouringForIssureNew(SOScheduledRoutingData data) throws Exception{
IfsShopOrder apiData=new IfsShopOrder();
apiData.setSite(data.getSite());
apiData.setOrderNo(data.getOrderNo());
//获取IFS SOBOM
List<POLineSupplierMaterialVo> poLineSupplierMaterial = ifsApiIssueAndReturnService.getPOLineSupplierMaterial(apiData.getOrderNo(), apiData.getSite());
//获取已有信息
List<SOIssueNotifyOrderMaterialListData> list = outsourcingNotifyMapper.getSOSBOMForIssureNew(data);
List<SOIssueNotifyOrderMaterialListData> result= new ArrayList<>();
for (int i = 0; i < poLineSupplierMaterial.size(); i++) {
SOIssueNotifyOrderMaterialListData entity = new SOIssueNotifyOrderMaterialListData();
entity.setSite(data.getSite());
entity.setNotifyNo(data.getNotifyNo());
entity.setItemNo(BigDecimal.valueOf(data.getItemNo()));
entity.setBOMItemNo(poLineSupplierMaterial.get(i).getLineItemNo().toString());
entity.setQtyRequired(poLineSupplierMaterial.get(i).getQtyRequired());
entity.setComponentPartNo(poLineSupplierMaterial.get(i).getComponentPartNo());
entity.setComponentPartDesc(poLineSupplierMaterial.get(i).getComponentPartDescription());
entity.setIssueType("BOM物料");
if(!list.isEmpty()){
SOIssueNotifyOrderMaterialListData selectOne=list.stream()
.filter(item ->
entity.getBOMItemNo().equals(item.getBOMItemNo()) &&
entity.getComponentPartNo().equals(item.getComponentPartNo())
)
.findFirst()
.orElse(null);
if(selectOne!=null){
entity.setQtyToIssue(selectOne.getQtyToIssue());
entity.setQtyToIssueOriginal(selectOne.getQtyToIssueOriginal());
entity.setRemark(selectOne.getRemark());
}
}
result.add( entity);
}
return result;
}
@Override
public void saveMaterialDetail(List<SOIssueNotifyOrderMaterialListData> data) {
outsourcingNotifyMapper.deleteOutNotifyOrderMaterialListData(data.get(0));
for (int i = 0; i < data.size(); i++) {
data.get(i).setIssueType("BOM物料");
data.get(i).setItemNo(data.get(0).getItemNo());
if( data.get(i).getQtyToIssue()!=null){
data.get(i).setQtyToIssueOriginal(data.get(i).getQtyToIssue());
}
}
return null;
outsourcingNotifyMapper.batchSaveOutNotifyOrderMaterialListData(data);
}
@Override
public void deleteNotifySOS(SOIssueNotifyOrderListData data) {
outsourcingNotifyMapper.deleteNotifySOS(data);
SOIssueNotifyOrderMaterialListData deleteData=new SOIssueNotifyOrderMaterialListData();
deleteData.setNotifyNo(data.getNotifyNo());
deleteData.setSite(data.getSite());
deleteData.setItemNo(data.getItemNo());
outsourcingNotifyMapper.deleteSOIssueNotifyOrderMaterialListData(deleteData);
}
@Override
public void xiadaNotifyHeader(SOIssueNotifyHeaderData data){
outsourcingNotifyMapper.xiadaNotifyHeader(data);
}
@Override
public PageUtils searchNotifyHeaderNew(SOIssueNotifyHeaderData data) {
System.out.println("开始查询申请单主表 - AI制作");
Page<SOIssueNotifyHeaderData> page = new Page<>(data.getPage(), data.getLimit());
// 按照原有模式进行分页查询
IPage<SOIssueNotifyHeaderData> resultList = outsourcingNotifyMapper.searchNotifyHeaderNew(page , data);
PageUtils pageResult = new PageUtils(resultList);
System.out.println("查询申请单主表完成,共" + resultList.getTotal() + "条记录");
return pageResult;
}
@Override
public void deleteNotifySOSPlus(SOIssueNotifyOrderListData data) throws Exception{
QueryWrapper<SOIssueNotifyHeader> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("notify_no",data.getNotifyNo());
queryWrapper.eq("site",data.getSite());
SOIssueNotifyHeader soIssueNotifyHeader = outsourcingNotifyMapper.selectOne(queryWrapper);
if(!"未推送".equals(soIssueNotifyHeader.getPushWcsFlag())){
throw new Exception("当前行不是未推送状态,不能删除!");
}
outsourcingNotifyMapper.deleteNotifySOS(data);
SOIssueNotifyOrderMaterialListData deleteData=new SOIssueNotifyOrderMaterialListData();
deleteData.setNotifyNo(data.getNotifyNo());
deleteData.setSite(data.getSite());
deleteData.setItemNo(data.getItemNo());
outsourcingNotifyMapper.deleteSOIssueNotifyOrderMaterialListData(deleteData);
}
}

113
src/main/resources/mapper/outsourcing/OutsourcingNotifyMapper.xml

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gaotao.modules.outsourcing.dao.OutsourcingNotifyMapper">
<select id="getUserNotifyPo" resultType="SOIssueNotifyHeaderData">
select top 1 a.notify_no,a.site,a.notify_date,a.username,a.entered_date,a.receiver,a.department_id,a.remark,a.credit_flag,a.issue_flag,
a.issue_result,a.plan_issue_date,a.real_issue_date,a.status,a.have_issue_record_flag,a.calc_flag,a.need_approve_flag,a.approved_flag,
@ -18,4 +19,116 @@
LEFT JOIN area ar WITH (NOLOCK) ON a.production_area = ar.area_id
WHERE a.site=#{site} AND a.notify_no=#{notifyNo}
</select>
<select id="getNextItemForSOIssueNotifyOrderList" resultType="java.math.BigDecimal">
SELECT ISNULL(MAX(item_no), 0) + 1 FROM SOIssueNotifyOrderList WHERE site=#{site} AND notify_no=#{notifyNo}
</select>
<select id="getProductAreaByPlanner" resultType="java.lang.String">
select top 1 area_type from sys_product_plannet where site=#{site} and planner=#{planner}
</select>
<delete id="deleteOutsourcingNotifyHeader">
delete from SOIssueNotifyHeader where site=#{site} and notify_no=#{notifyNo}
</delete>
<insert id="saveSOIssueNotifyOrderList">
insert into SOIssueNotifyOrderList(notify_no,site,item_no,fgpart_no,soorder_no,issure_qty,out_work_order_flag,need_date,release_no,sequence_no,
push_wms_flag,production_area,transport_flag,order_type)
values(#{notifyNo},#{site},#{itemNo},#{fgPartNo},#{soorderNo},#{issureQty,jdbcType=DECIMAL},#{outWorkOrderFlag}
,#{needDate},#{releaseNo},#{sequenceNo},#{pushWmsFlag},#{productionArea},#{transportFlag},#{orderType})
</insert>
<delete id="deleteSOIssueNotifyOrderMaterialInList">
DELETE FROM SOIssueNotifyOrderMaterialList
WHERE
notify_no = #{notifyNo}
AND site = #{site}
AND item_no IN
<foreach collection="items" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</delete>
<insert id="batchSaveSOIssueNotifyOrderMaterialList">
insert into SOIssueNotifyOrderMaterialList (notify_no,site,item_no,BOM_item_no,component_part_no,qty_to_issue,qty_to_issue_original,issue_type,remark,order_type)
values
<foreach collection="childList" separator="," item="item">
(#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType})
</foreach>
</insert>
<select id="getSOSBOMForIssureNew"
resultType="com.gaotao.modules.notify.entity.SOIssueNotifyOrderMaterialListData">
SELECT a.notify_no, a.site, a.item_no, a.BOM_item_no AS BOMItemNo, a.component_part_no AS ComponentPartNo,
a.qty_to_issue AS QtyToIssue, a.qty_to_issue_original AS QtyToIssueOriginal, a.remark
FROM SOIssueNotifyOrderMaterialList a WITH (NOLOCK)
INNER JOIN SOIssueNotifyOrderList b WITH (NOLOCK) ON a.site=b.site AND a.notify_no=b.notify_no AND a.item_no=b.item_no
WHERE a.notify_no=#{notifyNo} AND a.site=#{site} AND b.soorder_no=#{orderNo}
AND b.release_no=#{releaseNo} AND b.sequence_no=#{sequenceNo}
</select>
<delete id="deleteOutNotifyOrderMaterialListData">
delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo}
</delete>
<insert id="batchSaveOutNotifyOrderMaterialListData">
insert into SOIssueNotifyOrderMaterialList (notify_no,site,item_no,BOM_item_no,component_part_no,qty_to_issue,qty_to_issue_original,issue_type,remark,order_type)
values
<foreach collection="data" separator="," item="item">
(#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType})
</foreach>
</insert>
<delete id="deleteNotifySOS">
delete from SOIssueNotifyOrderList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo}
</delete>
<delete id="deleteSOIssueNotifyOrderMaterialListData">
delete from SOIssueNotifyOrderMaterialList where site=#{site} and notify_no=#{notifyNo} and item_no=#{itemNo}
</delete>
<update id="xiadaNotifyHeader">
UPDATE SOIssueNotifyHeader WITH (ROWLOCK)
SET plan_issue_date = #{planIssueDate}, remark = #{remark}, status = 'ISSUE'
WHERE site = #{site} AND notify_no = #{notifyNo}
</update>
<select id="searchNotifyHeaderNew" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData">
select a.notify_no as notifyNo,a.site,a.notify_date as notifyDate,a.username,a.entered_date as enteredDate,a.receiver,a.department_id as departmentId,a.remark,a.credit_flag as creditFlag,a.issue_flag as issueFlag,
a.issue_result as issueResult,a.plan_issue_date as planIssueDate,a.real_issue_date as realIssueDate,a.status,a.have_issue_record_flag as haveIssueRecordFlag,a.calc_flag as calcFlag,a.need_approve_flag as needApproveFlag,a.approved_flag as approvedFlag,
a.approver,a.approve_date as approveDate,a.warehouse_id as warehouseId,a.record_version as recordVersion,a.out_work_order_flag as outWorkOrderFlag,a.project_id as projectId,a.order_type as orderType,a.auth_rule_id as authRuleId,
a.confirm_status,
a.confirm_user_id AS confirmUserId, a.confirm_username AS confirmUsername, a.confirm_user_display AS confirmUserDisplay, a.confirm_date AS confirmDate, a.handler_username AS handlerUsername, a.handler_display AS handlerDisplay, a.push_wcs_flag AS pushWcsFlag
FROM SOIssueNotifyHeader a WITH (NOLOCK)
<where>
<if test="query.notifyNo != null and query.notifyNo != ''">
AND a.notify_no = #{query.notifyNo}
</if>
<if test="query.username != null and query.username != ''">
AND a.username LIKE '%' + #{query.username} + '%'
</if>
<if test="query.orderType != null and query.orderType != ''">
AND a.order_type = #{query.orderType}
</if>
<if test="query.status != null and query.status != ''">
AND a.status = #{query.status}
</if>
<if test="query.orderNo != null and query.orderNo != ''">
AND EXISTS (
SELECT 1
FROM SOIssueNotifyOrderList b WITH (NOLOCK)
WHERE b.site = a.site
AND b.notify_no = a.notify_no
AND b.soorder_no = #{query.orderNo}
)
</if>
<if test="query.startDate != null">
AND CONVERT(date, a.notify_date) >= CONVERT(date, #{query.startDate})
</if>
<if test="query.endDate != null">
AND CONVERT(date, a.notify_date) &lt; DATEADD(day, 1, CONVERT(date, #{query.endDate}))
</if>
<if test="query.site != null and query.site != ''">
AND a.site = #{query.site}
</if>
and a.status!='UNISSUE'
</where>
order by a.notify_no desc
</select>
</mapper>
Loading…
Cancel
Save