feat(wip):委外库存物料提交
This commit is contained in:
parent
d57bb26e09
commit
47b3c888a1
@ -0,0 +1,34 @@
|
||||
package com.foreverwin.mom.wms.api.feign;
|
||||
|
||||
import com.foreverwin.iep.smd.dto.ResrceDTO;
|
||||
import com.foreverwin.mom.common.core.constant.SecurityConstants;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @program: mom-wms-biz
|
||||
* @description: 仓库管理
|
||||
* @author: Snow
|
||||
* @create: 2024-11-20 15:20:08
|
||||
*/
|
||||
@FeignClient(contextId = "remoteWmsInventoryRecordService", value = "mom-wms-biz")
|
||||
public interface RemoteWmsInventoryRecordService {
|
||||
|
||||
@GetMapping("/wms-inventoryRecord/api/{type}")
|
||||
R<List<InventoryRecord>> getByType(@PathVariable("type") String type);
|
||||
|
||||
@GetMapping("/wms-inventoryRecord/{handle}")
|
||||
R<InventoryRecord> getById(@PathVariable("handle") String handle);
|
||||
|
||||
@PutMapping("/wms-inventoryRecord/api/updateById")
|
||||
R<Boolean> apiUpdateById(@RequestBody InventoryRecord inventoryRecord);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
package com.foreverwin.mom.wms.api.feign;
|
||||
|
||||
import com.foreverwin.iep.prd.entity.Item;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.wms.dto.InventoryDto;
|
||||
import com.foreverwin.mom.wms.dto.IqcResultNoticeDto;
|
||||
@ -23,12 +24,12 @@ public interface RemoteWmsInventoryService {
|
||||
|
||||
@PostMapping("/wms-inventory/api/createOrAddInventory")
|
||||
R createOrAddInventory(@RequestBody Inventory wmsInventory);
|
||||
|
||||
|
||||
@PostMapping("/wms-inventory/api/createInventory")
|
||||
R createInventory(@RequestBody Inventory wmsInventory);
|
||||
|
||||
@GetMapping("/wms-inventory/api/iqcGetLot/{documentNo}/{lineNo}/{itemNo}")
|
||||
R<List<Inventory>> iqcGetLot(@PathVariable("documentNo") String documentNo,@PathVariable("lineNo") String lineNo,@PathVariable("itemNo") String itemNo);
|
||||
R<List<Inventory>> iqcGetLot(@PathVariable("documentNo") String documentNo, @PathVariable("lineNo") String lineNo, @PathVariable("itemNo") String itemNo);
|
||||
|
||||
@PostMapping("/wms-inventory/api/inventoryDto")
|
||||
R<Inventory> getInventoryDto(String handle);
|
||||
@ -38,7 +39,7 @@ public interface RemoteWmsInventoryService {
|
||||
|
||||
@PostMapping("/wms-inventory/api/batch-update")
|
||||
R batchUpdate(@RequestBody List<Inventory> inventoryList);
|
||||
|
||||
|
||||
@PostMapping("/wms-inventory/api/internal-return")
|
||||
R internalReturn(@RequestBody InventoryDto inventoryDto);
|
||||
|
||||
@ -49,39 +50,49 @@ public interface RemoteWmsInventoryService {
|
||||
增加IQC检验结果回传wms的处理逻辑
|
||||
*/
|
||||
@PostMapping("/document/api/iqcResultNotice")
|
||||
R iqcResultNotice(@RequestBody IqcResultNoticeDto dto);
|
||||
R iqcResultNotice(@RequestBody IqcResultNoticeDto dto);
|
||||
|
||||
/*
|
||||
/*
|
||||
Lot合批-沿用原批号修改库存表
|
||||
*/
|
||||
@PostMapping("/wms-inventory/api/margeOriginalUpdateInventory")
|
||||
R margeOriginalUpdateInventory(@RequestBody InventoryDto dto);
|
||||
@PostMapping("/wms-inventory/api/margeOriginalUpdateInventory")
|
||||
R margeOriginalUpdateInventory(@RequestBody InventoryDto dto);
|
||||
|
||||
/*
|
||||
/*
|
||||
Lot合批-产生新批号新增或修改库存表
|
||||
*/
|
||||
@PostMapping("/wms-inventory/api/margeNewUpdateInventory")
|
||||
R margeNewUpdateInventory(@RequestBody InventoryDto dto);
|
||||
/*
|
||||
@PostMapping("/wms-inventory/api/margeNewUpdateInventory")
|
||||
R margeNewUpdateInventory(@RequestBody InventoryDto dto);
|
||||
|
||||
/*
|
||||
Lot拆批-新增并修改库存表,把母批数量改为0,新增子批库存信息
|
||||
*/
|
||||
@PostMapping("/wms-inventory/api/lotSplitAddAndUpdateInventory")
|
||||
R lotSplitAddAndUpdateInventory(@RequestBody InventoryDto dto);
|
||||
@PostMapping("/wms-inventory/api/lotSplitAddAndUpdateInventory")
|
||||
R lotSplitAddAndUpdateInventory(@RequestBody InventoryDto dto);
|
||||
|
||||
/**
|
||||
* 通过批次号获取库存
|
||||
* @param site
|
||||
* @param batchNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/wms-inventory/api/readInventoryByBatchNo/{site}/{batchNo}")
|
||||
R<List<Inventory>> readInventoryByBatchNo(@PathVariable("site") String site,@PathVariable("batchNo") String batchNo);
|
||||
/**
|
||||
* 通过批次号获取库存
|
||||
*
|
||||
* @param site
|
||||
* @param batchNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/wms-inventory/api/readInventoryByBatchNo/{site}/{batchNo}")
|
||||
R<List<Inventory>> readInventoryByBatchNo(@PathVariable("site") String site, @PathVariable("batchNo") String batchNo);
|
||||
|
||||
/**
|
||||
* 创建或更新库存,并记录日志
|
||||
*
|
||||
* @param inventoryList
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/wms-inventory/api/saveOrUpdateInventory")
|
||||
R saveOrUpdateInventory(@RequestBody List<Inventory> inventoryList);
|
||||
|
||||
@PostMapping("/wms-inventory/api/save")
|
||||
R saveInventory(@RequestBody Inventory inventoryList);
|
||||
|
||||
@GetMapping("/wms-inventory/api/{site}/{item}")
|
||||
R<Item> selectCurrentByMes(@PathVariable("site") String site, @PathVariable("item") String item);
|
||||
|
||||
}
|
||||
@ -0,0 +1,321 @@
|
||||
package com.foreverwin.mom.wms.dto;
|
||||
|
||||
|
||||
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class InventoryRecordDTO extends InventoryRecord {
|
||||
|
||||
|
||||
/**
|
||||
* 工作中心
|
||||
*/
|
||||
private String workCenter;
|
||||
|
||||
/**
|
||||
* 工单号
|
||||
*/
|
||||
private String shopOrder;
|
||||
|
||||
/**
|
||||
* 车间号
|
||||
*/
|
||||
private String workshopNumber;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String mainUom;
|
||||
|
||||
/**
|
||||
* 工序
|
||||
*/
|
||||
private String operation;
|
||||
|
||||
/**
|
||||
* 同步过账日期
|
||||
*/
|
||||
private LocalDate syncPostingDate;
|
||||
|
||||
/**
|
||||
* 完工数量
|
||||
*/
|
||||
private String qtyDone;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String date;
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
private String model;
|
||||
/**
|
||||
* 卷号
|
||||
*/
|
||||
private String rollNumber;
|
||||
|
||||
/**
|
||||
* 托盘号
|
||||
*/
|
||||
private String palletNumber;
|
||||
|
||||
/**
|
||||
* 表面处理
|
||||
*/
|
||||
private String surfaceTreatment;
|
||||
|
||||
/**
|
||||
* 厚度
|
||||
*/
|
||||
private String thickness;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private String width;
|
||||
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
private String length;
|
||||
|
||||
/**
|
||||
* 毛重
|
||||
*/
|
||||
private String grossWeight;
|
||||
|
||||
/**
|
||||
* 理论重
|
||||
*/
|
||||
private String theoreticalWeight;
|
||||
|
||||
/**
|
||||
* 净重
|
||||
*/
|
||||
private String netWeight;
|
||||
|
||||
/**
|
||||
* 标签重
|
||||
*/
|
||||
private String labelWeight;
|
||||
|
||||
/**
|
||||
* VL
|
||||
*/
|
||||
private String vl;
|
||||
|
||||
/**
|
||||
* IR
|
||||
*/
|
||||
private String ir;
|
||||
|
||||
/**
|
||||
* UV
|
||||
*/
|
||||
private String uv;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
private String grade;
|
||||
|
||||
/**
|
||||
* 客户名
|
||||
*/
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 包装方式
|
||||
*/
|
||||
private String packagingMethod;
|
||||
|
||||
/**
|
||||
* 检验员
|
||||
*/
|
||||
private String inspector;
|
||||
|
||||
/**
|
||||
* 降级原因
|
||||
*/
|
||||
private String downgradeReason;
|
||||
|
||||
/**
|
||||
* 主要原因
|
||||
*/
|
||||
private String mainReason;
|
||||
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 同步返回确认号计数器(SAP返回计数器)
|
||||
*/
|
||||
private String syncTicketLine;
|
||||
|
||||
/**
|
||||
* 同步返回确认号计数器(SAP返回计数器)
|
||||
*/
|
||||
private String syncTicketNo;
|
||||
|
||||
/**
|
||||
* 同步状态
|
||||
*/
|
||||
private String syncStatus;
|
||||
|
||||
/**
|
||||
* 同步消息识别
|
||||
*/
|
||||
private String syncMessageRemark;
|
||||
|
||||
/**
|
||||
* 同步消息识别编号
|
||||
*/
|
||||
private String syncMessageNo;
|
||||
|
||||
/**
|
||||
* 同步返回消息文本(SAP同步返回消息)
|
||||
*/
|
||||
private String syncMessageText;
|
||||
|
||||
/**
|
||||
* 同步提交人
|
||||
*/
|
||||
private String syncSubmitter;
|
||||
|
||||
/**
|
||||
* 同步时间
|
||||
*/
|
||||
private LocalDateTime syncTransDate;
|
||||
|
||||
|
||||
/**
|
||||
* 批次号,卷号
|
||||
*/
|
||||
private String lotNo;
|
||||
|
||||
/**
|
||||
* SAP的物料号MATNR,也就是ITEM的ERP_ITEM
|
||||
*/
|
||||
private String erpItem;
|
||||
|
||||
/**
|
||||
* ERP仓库编号
|
||||
*/
|
||||
private String erpInventory;
|
||||
|
||||
|
||||
/**
|
||||
* SAP批次编号(向SAP申请的批次号)
|
||||
*/
|
||||
private String sapBatchNo;
|
||||
|
||||
/**
|
||||
* 主单位完工数量
|
||||
*/
|
||||
private String mainQty;
|
||||
|
||||
/**
|
||||
* 辅单位完工数量
|
||||
*/
|
||||
private String subQty;
|
||||
|
||||
/**
|
||||
* 组件物料辅单位
|
||||
*/
|
||||
private String subUom;
|
||||
|
||||
/**
|
||||
* 预留编号
|
||||
*/
|
||||
private String reservedNo;
|
||||
|
||||
/**
|
||||
* 预留行号
|
||||
*/
|
||||
private String reservedLine;
|
||||
|
||||
/**
|
||||
* 同步系统消息编号
|
||||
*/
|
||||
private String syncMsgNo;
|
||||
|
||||
/**
|
||||
* 同步返回消息文本
|
||||
*/
|
||||
private String syncMsgText;
|
||||
|
||||
/**
|
||||
* 同步返回物料凭证编号
|
||||
*/
|
||||
private String syncVoucherNo;
|
||||
|
||||
/**
|
||||
* 销售订单行号
|
||||
*/
|
||||
private String soLineNo;
|
||||
|
||||
/**
|
||||
* 销售订单号
|
||||
*/
|
||||
private String soNo;
|
||||
|
||||
/**
|
||||
* 客户外部批次
|
||||
*/
|
||||
private String externalLot;
|
||||
|
||||
/**
|
||||
* 品质判定等级
|
||||
*/
|
||||
private String qcGrade;
|
||||
|
||||
/**
|
||||
* 表类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
|
||||
private String qtyScrapped;
|
||||
|
||||
private String laborTime;
|
||||
|
||||
private String energy;
|
||||
|
||||
private String accessories;
|
||||
|
||||
private String othersQty;
|
||||
|
||||
private String barcode;
|
||||
|
||||
private String supplierBatch;
|
||||
|
||||
private String originalQty;
|
||||
|
||||
private String currentQty;
|
||||
|
||||
private String dateOfManufacture;
|
||||
|
||||
private String standardLength;
|
||||
|
||||
private String actualLength;
|
||||
|
||||
private String specialInventoryIdentification;
|
||||
|
||||
private String itemDesc;
|
||||
|
||||
private String uom;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.foreverwin.mom.wms.dto;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ExcelIgnoreUnannotated
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class InventoryRecordImportantDTO {
|
||||
|
||||
@ExcelProperty(value = "日期", index = 0)
|
||||
private String dateOfManufacture;
|
||||
|
||||
@ExcelProperty(value = "ERP仓库编号", index = 1)
|
||||
private String erpInventory;
|
||||
|
||||
@ExcelProperty(value = "库存条码", index = 2)
|
||||
private String barcode;
|
||||
|
||||
@ExcelProperty(value = "物料描述", index = 3)
|
||||
private String supplier;
|
||||
|
||||
@ExcelProperty(value = "库存状态", index = 4)
|
||||
private String status;
|
||||
|
||||
@ExcelProperty(value = "物料编号", index = 5)
|
||||
private String workshopNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
@ExcelProperty(value = "工单号", index = 6)
|
||||
private String shopOrder;
|
||||
|
||||
@ExcelProperty(value = "工作中心", index = 7)
|
||||
private String workCenter;
|
||||
|
||||
@ExcelProperty(value = "完工数量", index = 8)
|
||||
private String qtyDone;
|
||||
|
||||
@ExcelProperty(value = "主单位完工数量", index = 9)
|
||||
private String mainQty;
|
||||
|
||||
@ExcelProperty(value = "辅单位完工数量", index = 10)
|
||||
private String subQty;
|
||||
|
||||
@ExcelProperty(value = "辅单位", index = 11)
|
||||
private String subUom;
|
||||
|
||||
@ExcelProperty(value = "基本单位", index = 12)
|
||||
private String mainUon;
|
||||
|
||||
@ExcelProperty(value = "膜卷类型", index = 13)
|
||||
private String uom;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
package com.foreverwin.mom.wms.dto;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@ExcelIgnoreUnannotated
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class MaterialConsumptionImportantDTO {
|
||||
|
||||
@ExcelProperty(value ="日期",index = 0)
|
||||
private String dateOfManufacture ;
|
||||
|
||||
@ExcelProperty(value = "工单号", index = 1)
|
||||
private String shopOrder;
|
||||
|
||||
@ExcelProperty(value = "物料描述", index = 2)
|
||||
private String supplier;
|
||||
|
||||
@ExcelProperty(value = "物料编号", index = 3)
|
||||
private String workshopNumber;
|
||||
|
||||
@ExcelProperty(value = "ERP仓库编号", index = 4)
|
||||
private String erpInventory;
|
||||
|
||||
|
||||
@ExcelProperty(value = "主单位完工数量", index = 5)
|
||||
private String mainQty;
|
||||
|
||||
@ExcelProperty(value = "基本单位", index = 6)
|
||||
private String mainUom;
|
||||
|
||||
|
||||
@ExcelProperty(value = "工作中心", index = 7)
|
||||
public String getWorkCenter;
|
||||
}
|
||||
@ -0,0 +1,368 @@
|
||||
package com.foreverwin.mom.wms.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.foreverwin.iep.common.utils.HandleBoProcessor;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 库存记录(物料批次)
|
||||
*
|
||||
* @author philip
|
||||
* @date 2022-10-29 09:03:07
|
||||
*/
|
||||
@Data
|
||||
@TableName("inventory_records")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "库存记录(物料批次)")
|
||||
public class InventoryRecord extends Model<InventoryRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String KW_WMS_INVENTORY_BO = "InventoryBO";
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty("主键")
|
||||
private String sid;
|
||||
|
||||
@ApiModelProperty("工作中心")
|
||||
private String workCenter;
|
||||
|
||||
@ApiModelProperty(value = "工单号")
|
||||
private String shopOrder;
|
||||
|
||||
@ApiModelProperty(value = "物料编号")
|
||||
private String workshopNumber;
|
||||
|
||||
@ApiModelProperty(value = "单位")
|
||||
private String mainUom;
|
||||
|
||||
@ApiModelProperty(value = "工序")
|
||||
private String operation;
|
||||
|
||||
@ApiModelProperty(value = "完工数量")
|
||||
private String qtyDone;
|
||||
|
||||
@ApiModelProperty("同步过账日期")
|
||||
private LocalDate syncPostingDate;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ApiModelProperty(value = "日期")
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
@ApiModelProperty(value = "型号")
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 卷号
|
||||
*/
|
||||
@ApiModelProperty(value = "卷号")
|
||||
private String rollNumber;
|
||||
|
||||
/**
|
||||
* 托盘号
|
||||
*/
|
||||
@ApiModelProperty(value = "托盘号")
|
||||
private String palletNumber;
|
||||
|
||||
/**
|
||||
* 表面处理
|
||||
*/
|
||||
@ApiModelProperty(value = "表面处理")
|
||||
private String surfaceTreatment;
|
||||
|
||||
/**
|
||||
* 厚度
|
||||
*/
|
||||
@ApiModelProperty(value = "厚度")
|
||||
private String thickness;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
@ApiModelProperty(value = "宽度")
|
||||
private String width;
|
||||
|
||||
/**
|
||||
* 长度
|
||||
*/
|
||||
@ApiModelProperty(value = "长度")
|
||||
private String length;
|
||||
|
||||
/**
|
||||
* 毛重
|
||||
*/
|
||||
@ApiModelProperty(value = "毛重")
|
||||
private String grossWeight;
|
||||
|
||||
/**
|
||||
* 理论重
|
||||
*/
|
||||
@ApiModelProperty(value = "理论重")
|
||||
private String theoreticalWeight;
|
||||
|
||||
/**
|
||||
* 净重
|
||||
*/
|
||||
@ApiModelProperty(value = "净重")
|
||||
private String netWeight;
|
||||
|
||||
/**
|
||||
* 标签重
|
||||
*/
|
||||
@ApiModelProperty(value = "标签重")
|
||||
private String labelWeight;
|
||||
|
||||
/**
|
||||
* VL
|
||||
*/
|
||||
@ApiModelProperty(value = "VL")
|
||||
private String vl;
|
||||
|
||||
/**
|
||||
* IR
|
||||
*/
|
||||
@ApiModelProperty(value = "IR")
|
||||
private String ir;
|
||||
|
||||
/**
|
||||
* UV
|
||||
*/
|
||||
@ApiModelProperty(value = "UV")
|
||||
private String uv;
|
||||
|
||||
/**
|
||||
* 等级
|
||||
*/
|
||||
@ApiModelProperty(value = "等级")
|
||||
private String grade;
|
||||
|
||||
/**
|
||||
* 客户名
|
||||
*/
|
||||
@ApiModelProperty(value = "客户名")
|
||||
private String customerName;
|
||||
|
||||
/**
|
||||
* 包装方式
|
||||
*/
|
||||
@ApiModelProperty(value = "包装方式")
|
||||
private String packagingMethod;
|
||||
|
||||
/**
|
||||
* 检验员
|
||||
*/
|
||||
@ApiModelProperty(value = "检验员")
|
||||
private String inspector;
|
||||
|
||||
/**
|
||||
* 降级原因
|
||||
*/
|
||||
@ApiModelProperty(value = "降级原因")
|
||||
private String downgradeReason;
|
||||
|
||||
/**
|
||||
* 主要原因
|
||||
*/
|
||||
@ApiModelProperty(value = "主要原因")
|
||||
private String mainReason;
|
||||
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private LocalDateTime createTime;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private LocalDateTime updateTime;
|
||||
/**
|
||||
* 创建人员
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人员")
|
||||
private String creator;
|
||||
/**
|
||||
* 更新人员
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人员")
|
||||
private String updater;
|
||||
|
||||
@ApiModelProperty(value = "库存状态")
|
||||
private String status;
|
||||
|
||||
|
||||
@ApiModelProperty("站点")
|
||||
private String site;
|
||||
|
||||
@ApiModelProperty("同步请求处理编号")
|
||||
private String syncTransBatch;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
@ApiModelProperty("确认时间")
|
||||
private LocalDateTime confirmedDate;
|
||||
|
||||
@ApiModelProperty("报工确认人")
|
||||
private String confirmedUser;
|
||||
|
||||
@ApiModelProperty("同步返回确认号计数器(SAP返回计数器)")
|
||||
private String syncTicketLine;
|
||||
|
||||
@ApiModelProperty("同步返回确认号(SAP同步返回凭证确认号)")
|
||||
private String syncTicketNo;
|
||||
|
||||
@ApiModelProperty("同步返回结果(SAP同步返回状态,S: 成功 E: 失败)")
|
||||
private String syncStatus;
|
||||
|
||||
@ApiModelProperty("同步消息识别")
|
||||
private String syncMessageRemark;
|
||||
|
||||
@ApiModelProperty("同步系统消息编号")
|
||||
private String syncMessageNo;
|
||||
|
||||
@ApiModelProperty("同步返回消息文本(SAP同步返回消息)")
|
||||
private String syncMessageText;
|
||||
|
||||
@ApiModelProperty("同步提交人")
|
||||
private String syncSubmitter;
|
||||
|
||||
@ApiModelProperty("同步请求处理时间")
|
||||
private LocalDateTime syncTransDate;
|
||||
|
||||
//新增
|
||||
@ApiModelProperty("生产批号,卷号")
|
||||
private String lotNo;
|
||||
|
||||
@ApiModelProperty("SAP的物料号MATNR,也就是ITEM的ERP_ITEM")
|
||||
private String erpItem;
|
||||
|
||||
@ApiModelProperty("ERP仓库编号")
|
||||
private String erpInventory;
|
||||
|
||||
@ApiModelProperty("SAP批次编号(向SAP申请的批次号)")
|
||||
private String sapBatchNo;
|
||||
|
||||
@ApiModelProperty("主单位完工数量")
|
||||
private String mainQty;
|
||||
|
||||
@ApiModelProperty("辅单位完工数量")
|
||||
private String subQty;
|
||||
|
||||
@ApiModelProperty("辅单位")
|
||||
private String subUom;
|
||||
|
||||
@ApiModelProperty("预留编号")
|
||||
private String reservedNo;
|
||||
|
||||
@ApiModelProperty("预留行号")
|
||||
private String reservedLine;
|
||||
|
||||
@ApiModelProperty("同步系统消息编号")
|
||||
private String syncMsgNo;
|
||||
|
||||
@ApiModelProperty("同步返回消息文本")
|
||||
private String syncMsgText;
|
||||
|
||||
@ApiModelProperty("同步返回物料凭证编号")
|
||||
private String syncVoucherNo;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("销售订单行号")
|
||||
private String soLineNo;
|
||||
|
||||
@ApiModelProperty("销售订单号")
|
||||
private String soNo;
|
||||
|
||||
@ApiModelProperty("客户外部批次")
|
||||
private String externalLot;
|
||||
|
||||
@ApiModelProperty("品质判定等级")
|
||||
private String qcGrade;
|
||||
|
||||
@ApiModelProperty(value = "表类型")
|
||||
private String type;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "报废数量")
|
||||
private String qtyScrapped;
|
||||
|
||||
@ApiModelProperty(value = "工时")
|
||||
private String laborTime;
|
||||
|
||||
@ApiModelProperty(value = "能耗")
|
||||
private String energy;
|
||||
|
||||
@ApiModelProperty(value = "辅料")
|
||||
private String accessories;
|
||||
|
||||
@ApiModelProperty(value = "其他")
|
||||
private String othersQty;
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "库存条码")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty(value = "供应商批次")
|
||||
private String supplierBatch;
|
||||
|
||||
@ApiModelProperty(value = "原始数量")
|
||||
private String originalQty;
|
||||
|
||||
@ApiModelProperty(value = "现有数量")
|
||||
private String currentQty;
|
||||
|
||||
@ApiModelProperty(value = "生产日期")
|
||||
private String dateOfManufacture;
|
||||
|
||||
@ApiModelProperty(value = "标准长度")
|
||||
private String standardLength;
|
||||
|
||||
@ApiModelProperty(value = "实际长度")
|
||||
private String actualLength;
|
||||
|
||||
@ApiModelProperty(value = "特殊库存标识")
|
||||
private String specialInventoryIdentification;
|
||||
|
||||
@ApiModelProperty(value = "物料描述")
|
||||
private String itemDesc;
|
||||
|
||||
@ApiModelProperty(value = "膜卷类型")
|
||||
private String uom;
|
||||
|
||||
|
||||
public static String genHandle(String site, String barcode) {
|
||||
return HandleBoProcessor.genHandle(KW_WMS_INVENTORY_BO, site, barcode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public InventoryRecord() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -28,6 +28,17 @@ public class DataImportController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/import-inventory")
|
||||
@ResponseBody
|
||||
public R importInventory(MultipartFile file, String importType, String optionValue) {
|
||||
try {
|
||||
R<String> ok = R.ok(dataImportService.importY(file, importType, null));
|
||||
return ok;
|
||||
} catch (Exception e) {
|
||||
return R.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/export-document-template")
|
||||
@ResponseBody
|
||||
public void exportTemplate(String importType) throws IOException {
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
package com.foreverwin.mom.wms.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.foreverwin.iep.common.base.FrontPage;
|
||||
import com.foreverwin.iep.smd.dto.ResrceDTO;
|
||||
import com.foreverwin.iep.smd.entity.ResourceType;
|
||||
import com.foreverwin.iep.smd.entity.WorkCenter;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.log.annotation.SysLog;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.mom.wms.dto.FreezeDto;
|
||||
import com.foreverwin.mom.wms.dto.InventoryByDocumentRequestDTO;
|
||||
import com.foreverwin.mom.wms.dto.InventoryByDocumentResponseDTO;
|
||||
import com.foreverwin.mom.wms.dto.InventoryDto;
|
||||
import com.foreverwin.mom.wms.entity.Inventory;
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import com.foreverwin.mom.wms.service.FreezeService;
|
||||
import com.foreverwin.mom.wms.service.InventoryRecordService;
|
||||
import com.foreverwin.mom.wms.service.ZWmsInventoryService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 库存(物料批次)l
|
||||
*
|
||||
* @author philip
|
||||
* @date 2022-10-29 09:03:07
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/wms-inventoryRecord")
|
||||
@Api(value = "wms-inventoryRecord", tags = "库存记录(物料批次)管理")
|
||||
public class InventoryRecordController {
|
||||
|
||||
private final ZWmsInventoryService inventoryService;
|
||||
private final FreezeService freezeService;
|
||||
private final InventoryRecordService inventoryRecordService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
||||
@GetMapping("/{handle}")
|
||||
public R getById(@PathVariable("handle") String handle) {
|
||||
return R.ok(inventoryRecordService.getById(handle));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "通过类型查询", notes = "通过类型查询")
|
||||
@GetMapping("/api/{type}")
|
||||
public R<List<InventoryRecord>> getByType(@PathVariable("type") String type) {
|
||||
return R.ok(inventoryRecordService.selectBySyncStatusAndType(type));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "修改库存(物料批次)", notes = "修改库存(物料批次)")
|
||||
@SysLog("修改库存(物料批次)")
|
||||
@PutMapping("/api/updateById")
|
||||
public R apiUpdateById(@RequestBody InventoryRecord inventoryRecord) {
|
||||
return R.ok(inventoryRecordService.updateById(inventoryRecord));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.foreverwin.mom.wms.dto.InventoryByDocumentResponseDTO;
|
||||
import com.foreverwin.mom.wms.dto.InventoryDto;
|
||||
import com.foreverwin.mom.wms.entity.Inventory;
|
||||
import com.foreverwin.mom.wms.service.FreezeService;
|
||||
import com.foreverwin.mom.wms.service.WmsItemService;
|
||||
import com.foreverwin.mom.wms.service.ZWmsInventoryService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -49,6 +50,7 @@ public class ZWmsInventoryController {
|
||||
|
||||
private final ZWmsInventoryService inventoryService;
|
||||
private final FreezeService freezeService;
|
||||
private final WmsItemService wmsItemService;
|
||||
|
||||
|
||||
@ApiOperation(value = "IQC获取LOT", notes = "IQC获取LOT")
|
||||
@ -330,6 +332,13 @@ public class ZWmsInventoryController {
|
||||
return R.ok(freezeService.updateById(site, user, inventory));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增库存(物料批次)", notes = "新增库存(物料批次)")
|
||||
@SysLog("新增库存(物料批次)")
|
||||
@PostMapping("/api/save")
|
||||
public R saveInventory(@RequestBody Inventory inventory) {
|
||||
return R.ok(inventoryService.save(inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除库存(物料批次)
|
||||
*
|
||||
@ -341,6 +350,7 @@ public class ZWmsInventoryController {
|
||||
@DeleteMapping("/{handle}")
|
||||
@PreAuthorize("@pms.hasPermission('wms_inventory_del')")
|
||||
public R removeById(@PathVariable String handle) {
|
||||
|
||||
return R.ok(inventoryService.removeById(handle));
|
||||
}
|
||||
|
||||
@ -590,4 +600,11 @@ public class ZWmsInventoryController {
|
||||
.update()
|
||||
);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "检查Item是否可用", notes = "检查Item是否可用")
|
||||
@SysLog("检查Item是否可用")
|
||||
@GetMapping("/api/{site}/{item}")
|
||||
public R selectCurrentByMes(@PathVariable("site") String site, @PathVariable("item")String item) {
|
||||
return R.ok(wmsItemService.selectCurrentByMes(site, item));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,5 +7,8 @@ import java.io.IOException;
|
||||
public interface DataImportService {
|
||||
|
||||
String importX(MultipartFile file, String importType, String optionValue) throws Exception;
|
||||
|
||||
|
||||
String importY(MultipartFile file, String importType, String optionValue) throws Exception;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
package com.foreverwin.mom.wms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface InventoryRecordService extends IService<InventoryRecord> {
|
||||
|
||||
|
||||
|
||||
|
||||
InventoryRecord getShopOrderAndWork(String shopOrder, String workshopNumber, String sapBatchNo);
|
||||
|
||||
InventoryRecord getByCode(String site, String code);
|
||||
|
||||
List<InventoryRecord> selectBySyncStatusAndType(String type);
|
||||
|
||||
boolean updateById(InventoryRecord inventoryRecord);
|
||||
}
|
||||
@ -7,6 +7,10 @@ import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.foreverwin.iep.prd.entity.ZExternalLotRecord;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutBomComponentDTO;
|
||||
import com.foreverwin.iep.wip.feign.RemoteWipService;
|
||||
import com.foreverwin.mom.common.core.util.R;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.iep.prd.entity.Item;
|
||||
@ -15,6 +19,7 @@ import com.foreverwin.mom.wms.constant.MaterialTypeEnum;
|
||||
import com.foreverwin.mom.wms.dto.*;
|
||||
import com.foreverwin.mom.wms.entity.*;
|
||||
import com.foreverwin.mom.wms.mapper.DataImportMapper;
|
||||
import com.foreverwin.mom.wms.mapper.InventoryRecordMapper;
|
||||
import com.foreverwin.mom.wms.service.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -27,6 +32,9 @@ import java.text.MessageFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeFormatterBuilder;
|
||||
import java.time.format.ResolverStyle;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -41,7 +49,9 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
private final ZWmsInventoryLogService inventoryLogService;
|
||||
private final WareHouseService wareHouseService;
|
||||
private final WmsItemService wmsItemService;
|
||||
|
||||
private final InventoryRecordMapper inventoryRecordMapper;
|
||||
private final RemoteWipService remoteWipService;
|
||||
private static LocalDateTime lastGeneratedTime = LocalDateTime.now();
|
||||
|
||||
@Override
|
||||
public String importX(MultipartFile file, String importType, String optionValue) throws Exception {
|
||||
@ -198,6 +208,10 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;请输入合法生产日期 \n", row));
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getInventoryId())){
|
||||
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
if (errorMessage.length() < 1) {
|
||||
try {
|
||||
@ -247,5 +261,471 @@ public class DataImportServiceImpl implements DataImportService {
|
||||
}
|
||||
}
|
||||
|
||||
private final InventoryRecordService inventoryRecordService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String importY(MultipartFile file, String importType, String optionValue) throws Exception {
|
||||
String errorMessage = null;
|
||||
switch (importType) {
|
||||
case "1":
|
||||
// 库存记录表导入
|
||||
errorMessage = this.importInventoryRecord(file, optionValue);
|
||||
break;
|
||||
case "2":
|
||||
// 物料表导入
|
||||
errorMessage = this.importmaterialConsumption(file, optionValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
return "导入类型不存在";
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public String importInventoryRecord(MultipartFile file, String optionValue) throws IOException {
|
||||
String site = TenantContextHolder.getTenantStrId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String user = SecurityUtils.getUserName();
|
||||
|
||||
Vector<InventoryRecord> insert = new Vector<>();
|
||||
Vector<InventoryRecord> update = new Vector<>();
|
||||
Vector<InventoryLog> logs = new Vector<>();
|
||||
StringBuffer errorMessage = new StringBuffer();
|
||||
Map<String, Integer> uniqueMap = new ConcurrentHashMap<>();
|
||||
EasyExcel.read(file.getInputStream(), InventoryRecordImportantDTO.class, new ReadListener<InventoryRecordImportantDTO>() {
|
||||
@Override
|
||||
public void invoke(InventoryRecordImportantDTO data, AnalysisContext context) {
|
||||
Integer row = context.readRowHolder().getRowIndex() + 1;
|
||||
//第二行是列子
|
||||
if (row <= 2) {
|
||||
return;
|
||||
}
|
||||
boolean isUpdate = false;
|
||||
InventoryRecord inventory = null;
|
||||
if (StrUtil.isBlank(data.getBarcode())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;条码不能为空 \n", row));
|
||||
} else {
|
||||
inventory = inventoryRecordService.getByCode(site, data.getBarcode());
|
||||
if (inventory != null) {
|
||||
isUpdate = true;
|
||||
}
|
||||
Integer row_ = uniqueMap.get(data.getBarcode());
|
||||
if (row_ == null || row_ < 0) {
|
||||
uniqueMap.put(data.getBarcode(), row);
|
||||
} else {
|
||||
errorMessage.append(MessageFormat.format("第{0}行与{1}行库存条码{2}重复 \n", row, row_, data.getBarcode()));
|
||||
}
|
||||
}
|
||||
|
||||
importInventoryRecordValidate(site, user, row, data, errorMessage, inventory != null ? update : insert, logs, inventory);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
if (errorMessage.length() < 1 && CollectionUtil.isEmpty(insert) && CollectionUtil.isEmpty(update)) {
|
||||
errorMessage.append("数据库为空不能进行导入");
|
||||
}
|
||||
}
|
||||
}).sheet().doRead();
|
||||
|
||||
if (errorMessage.length() < 1) {
|
||||
if (CollectionUtil.isNotEmpty(insert)) {
|
||||
inventoryRecordService.saveBatch(insert);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(update)) {
|
||||
inventoryRecordService.updateBatchById(update);
|
||||
}
|
||||
}
|
||||
return errorMessage.toString();
|
||||
}
|
||||
public String generateSapBatchNumber() {
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 如果当前时间与上一次生成批次号的时间相同,则增加一秒
|
||||
if (now.isEqual(lastGeneratedTime)) {
|
||||
now = lastGeneratedTime.plusSeconds(1);
|
||||
}
|
||||
|
||||
// 更新上一次生成批次号的时间
|
||||
lastGeneratedTime = now;
|
||||
|
||||
// 定义日期时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
// 格式化当前时间为字符串
|
||||
return now.format(formatter);
|
||||
}
|
||||
private void importInventoryRecordValidate(String site, String user, Integer row, InventoryRecordImportantDTO data, StringBuffer errorMessage, Vector<InventoryRecord> inventoryRecords, Vector<InventoryLog> logs, InventoryRecord inventoryRecord) {
|
||||
Item itemObj = null;
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||
DateTimeFormatter dateTimeFormatter3 = new DateTimeFormatterBuilder()
|
||||
.appendPattern("yyyy/M/d")
|
||||
.parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
|
||||
.parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
|
||||
.toFormatter()
|
||||
.withResolverStyle(ResolverStyle.STRICT);
|
||||
BigDecimal qty = BigDecimal.ZERO, originalQtyImport = BigDecimal.ZERO;
|
||||
LocalDateTime pdt = null;
|
||||
if (StrUtil.isBlank(data.getErpInventory())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;仓库不能为空 \n", row));
|
||||
} else {
|
||||
boolean exists = wareHouseService.lambdaQuery().eq(WareHouse::getHandle, WareHouse.genHandle(site, data.getErpInventory())).exists();
|
||||
if (!exists) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;仓库{1}在系统中不存在,无法进行导入 \n", row, data.getErpInventory()));
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getStatus())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;仓库状态不能为空 \n", row));
|
||||
} else {
|
||||
List<String> status = Arrays.asList(Constant.INVENTORY_STSTUS_1001, Constant.INVENTORY_STSTUS_1002, Constant.INVENTORY_STSTUS_1003, Constant.INVENTORY_STSTUS_1004, Constant.INVENTORY_STSTUS_1005);
|
||||
if (!status.contains(data.getStatus())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;输入仓库状态不合法 \n", row));
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getWorkshopNumber())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料不能为空 \n", row));
|
||||
} else {
|
||||
itemObj = wmsItemService.selectCurrentByMes(site, data.getWorkshopNumber());
|
||||
if (ObjectUtil.isEmpty(itemObj) || StrUtil.isBlank(itemObj.getHandle())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料{1}在系统中不存在 \n", row, data.getWorkshopNumber()));
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getBarcode())){
|
||||
errorMessage.append(MessageFormat.format("第{0}行;库存条码不能为空 \n", row));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (StrUtil.isBlank(data.getSupplier())){
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料描述不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getStatus())){
|
||||
errorMessage.append(MessageFormat.format("第{0}行;库存状态不能为空 \n", row));
|
||||
}
|
||||
|
||||
// if (StrUtil.isBlank(data.getSupplierBatch())) {
|
||||
// errorMessage.append(MessageFormat.format("第{0}行;供应商批次不能为空 \n", row));
|
||||
// }
|
||||
|
||||
if (StrUtil.isBlank(data.getShopOrder())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;生产工单号不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getWorkCenter())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;工作中心不能为空 \n", row));
|
||||
}
|
||||
if (StrUtil.isBlank(data.getWorkCenter())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;完工数量不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getMainQty())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;主单位完工数量不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getSubQty())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;辅单位完工数量不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getSubUom())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;组件物料辅单位不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getMainUon())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;基本单位不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getUom())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;膜卷类型不能为空 \n", row));
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
if (StrUtil.isBlank(data.getDateOfManufacture())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;生产日期不能为空 \n", row));
|
||||
} else {
|
||||
try {
|
||||
String dataTime = data.getDateOfManufacture();
|
||||
if (dataTime.contains("-")) {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter).atTime(0, 0);
|
||||
} else if (dataTime.contains("/")) {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter2).atTime(0, 0);
|
||||
}
|
||||
else {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter3).atTime(0,0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;请输入合法生产日期 \n", row));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (errorMessage.length() < 1) {
|
||||
try {
|
||||
boolean isUpdate = inventoryRecord != null;
|
||||
|
||||
// 构造 InventoryRecord 对象
|
||||
if (isUpdate) {
|
||||
inventoryRecord.setUpdater(user);
|
||||
inventoryRecord.setUpdateTime(LocalDateTime.now());
|
||||
}else {
|
||||
inventoryRecord = new InventoryRecord();
|
||||
inventoryRecord.setSite(site);
|
||||
inventoryRecord.setCreator(user);
|
||||
inventoryRecord.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
inventoryRecord.setDateOfManufacture(data.getDateOfManufacture());
|
||||
inventoryRecord.setErpInventory(data.getErpInventory());
|
||||
inventoryRecord.setBarcode(data.getBarcode());
|
||||
inventoryRecord.setItemDesc(data.getSupplier());
|
||||
inventoryRecord.setStatus(data.getStatus());
|
||||
inventoryRecord.setWorkshopNumber(data.getWorkshopNumber());
|
||||
inventoryRecord.setShopOrder(data.getShopOrder());
|
||||
inventoryRecord.setWorkCenter(data.getWorkCenter());
|
||||
inventoryRecord.setQtyDone(data.getQtyDone());
|
||||
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
inventoryRecord.setSyncPostingDate(LocalDate.parse(currentDate.format(formatter)));
|
||||
|
||||
inventoryRecord.setMainQty(data.getMainQty());
|
||||
inventoryRecord.setSubQty(data.getSubQty());
|
||||
inventoryRecord.setSubUom(data.getSubUom());
|
||||
inventoryRecord.setMainUom(data.getMainUon());
|
||||
inventoryRecord.setUom(data.getUom());
|
||||
|
||||
inventoryRecord.setMainUom(data.getMainUon());
|
||||
inventoryRecord.setType("0");
|
||||
inventoryRecords.add(inventoryRecord);
|
||||
|
||||
//SAP批次号
|
||||
inventoryRecord.setSapBatchNo(generateSapBatchNumber());
|
||||
inventoryRecord.setOperation("SR");
|
||||
inventoryRecord.setGrade("A");
|
||||
inventoryRecord.setSyncStatus("N");
|
||||
|
||||
// R<List<OperationOutBomComponentDTO>> bySiteAndShopOrder = remoteWipService.getBySiteAndShopOrder("2021", "1000000004", "1000026");
|
||||
// List<OperationOutBomComponentDTO> operationOutBomComponentDTO = bySiteAndShopOrder.getData();
|
||||
OperationOutBomComponentDTO operationOutBomComponentDTO = inventoryRecordMapper.selectOperationOutBomComponent( site, data.getShopOrder(), data.getWorkshopNumber());
|
||||
if (operationOutBomComponentDTO != null) {
|
||||
inventoryRecord.setReservedNo(operationOutBomComponentDTO.getReserved());
|
||||
inventoryRecord.setReservedLine(operationOutBomComponentDTO.getReservedSeq());
|
||||
}else {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;查找不到相对应的预留编号与预留行号 \n", row, data.getShopOrder()));
|
||||
}
|
||||
|
||||
R<List<ZExternalLotRecord>> byLotNo = remoteWipService.getByLotNo(data.getBarcode(), site);
|
||||
List<ZExternalLotRecord> data1 = byLotNo.getData();
|
||||
if (data1.size()!=0){
|
||||
ZExternalLotRecord zExternalLotRecord = data1.get(0);
|
||||
inventoryRecord.setExternalLot(zExternalLotRecord.getExternalLot());
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
errorMessage.append(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String importmaterialConsumption(MultipartFile file, String optionValue) throws IOException {
|
||||
String site = TenantContextHolder.getTenantStrId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String user = SecurityUtils.getUserName();
|
||||
|
||||
Vector<InventoryRecord> insert = new Vector<>();
|
||||
Vector<InventoryRecord> update = new Vector<>();
|
||||
Vector<InventoryLog> logs = new Vector<>();
|
||||
StringBuffer errorMessage = new StringBuffer();
|
||||
Map<String, Integer> uniqueMap = new ConcurrentHashMap<>();
|
||||
EasyExcel.read(file.getInputStream(), MaterialConsumptionImportantDTO.class, new ReadListener<MaterialConsumptionImportantDTO>() {
|
||||
@Override
|
||||
public void invoke(MaterialConsumptionImportantDTO data, AnalysisContext context) {
|
||||
Integer row = context.readRowHolder().getRowIndex() + 1;
|
||||
//第二行是列子
|
||||
if (row <= 2) {
|
||||
return;
|
||||
}
|
||||
boolean isUpdate = false;
|
||||
InventoryRecord inventory = null;
|
||||
// if (StrUtil.isBlank(data.getBarcode())) {
|
||||
// errorMessage.append(MessageFormat.format("第{0}行;条码不能为空 \n", row));
|
||||
// } else {
|
||||
// inventory = inventoryRecordService.getByCode(site, data.getBarcode());
|
||||
// if (inventory != null) {
|
||||
// isUpdate = true;
|
||||
// }
|
||||
// Integer row_ = uniqueMap.get(data.getBarcode());
|
||||
// if (row_ == null || row_ < 0) {
|
||||
// uniqueMap.put(data.getBarcode(), row);
|
||||
// } else {
|
||||
// errorMessage.append(MessageFormat.format("第{0}行与{1}行库存条码{2}重复 \n", row, row_, data.getBarcode()));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
importmaterialConsumptionValidate(site, user, row, data, errorMessage, inventory != null ? update : insert, logs, inventory);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||
if (errorMessage.length() < 1 && CollectionUtil.isEmpty(insert) && CollectionUtil.isEmpty(update)) {
|
||||
errorMessage.append("数据库为空不能进行导入");
|
||||
}
|
||||
}
|
||||
}).sheet().doRead();
|
||||
|
||||
if (errorMessage.length() < 1) {
|
||||
if (CollectionUtil.isNotEmpty(insert)) {
|
||||
inventoryRecordService.saveBatch(insert);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(update)) {
|
||||
inventoryRecordService.updateBatchById(update);
|
||||
}
|
||||
}
|
||||
return errorMessage.toString();
|
||||
}
|
||||
|
||||
|
||||
private void importmaterialConsumptionValidate(String site, String user, Integer row, MaterialConsumptionImportantDTO data, StringBuffer errorMessage, Vector<InventoryRecord> inventoryRecords, Vector<InventoryLog> logs, InventoryRecord inventoryRecord) {
|
||||
// 校验每个字段的合法性
|
||||
Item itemObj = null;
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
DateTimeFormatter dateTimeFormatter2 = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||
DateTimeFormatter dateTimeFormatter3 = new DateTimeFormatterBuilder()
|
||||
.appendPattern("yyyy/M/d")
|
||||
.parseDefaulting(ChronoField.MONTH_OF_YEAR, 1)
|
||||
.parseDefaulting(ChronoField.DAY_OF_MONTH, 1)
|
||||
.toFormatter()
|
||||
.withResolverStyle(ResolverStyle.STRICT);
|
||||
LocalDateTime pdt = null;
|
||||
|
||||
if (StrUtil.isBlank(data.getWorkshopNumber())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料不能为空 \n", row));
|
||||
} else {
|
||||
itemObj = wmsItemService.selectCurrentByMes(site, data.getWorkshopNumber());
|
||||
if (ObjectUtil.isEmpty(itemObj) || StrUtil.isBlank(itemObj.getHandle())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料{1}在系统中不存在 \n", row, data.getWorkshopNumber()));
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getErpInventory())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;仓库不能为空 \n", row));
|
||||
} else {
|
||||
boolean exists = wareHouseService.lambdaQuery().eq(WareHouse::getHandle, WareHouse.genHandle(site, data.getErpInventory())).exists();
|
||||
if (!exists) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;仓库{1}在系统中不存在,无法进行导入 \n", row, data.getErpInventory()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StrUtil.isBlank(data.getMainUom())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;基本单位不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getMainQty())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;主单位完工数量不能为空 \n", row));
|
||||
}
|
||||
if (StrUtil.isBlank(data.getMainUom())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;主单位不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getShopOrder())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;工单号不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getSupplier())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;物料描述不能为空 \n", row));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(data.getDateOfManufacture())) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;生产日期不能为空 \n", row));
|
||||
} else {
|
||||
try {
|
||||
String dataTime = data.getDateOfManufacture();
|
||||
if (dataTime.contains("-")) {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter).atTime(0, 0);
|
||||
} else if (dataTime.contains("/")) {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter2).atTime(0, 0);
|
||||
}
|
||||
else {
|
||||
pdt = LocalDate.parse(dataTime, dateTimeFormatter3).atTime(0,0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;请输入合法生产日期 \n", row));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (errorMessage.length() < 1) {
|
||||
try {
|
||||
boolean isUpdate = inventoryRecord != null;
|
||||
|
||||
// 构造 InventoryRecord 对象
|
||||
if (isUpdate) {
|
||||
inventoryRecord.setUpdater(user);
|
||||
inventoryRecord.setUpdateTime(LocalDateTime.now());
|
||||
}else {
|
||||
inventoryRecord = new InventoryRecord();
|
||||
inventoryRecord.setSite(site);
|
||||
inventoryRecord.setCreator(user);
|
||||
inventoryRecord.setCreateTime(LocalDateTime.now());
|
||||
}
|
||||
inventoryRecord.setShopOrder(data.getShopOrder());
|
||||
inventoryRecord.setDateOfManufacture(data.getDateOfManufacture());
|
||||
inventoryRecord.setItemDesc(data.getSupplier());
|
||||
inventoryRecord.setWorkshopNumber(data.getWorkshopNumber());
|
||||
inventoryRecord.setErpInventory(data.getErpInventory());
|
||||
inventoryRecord.setMainQty(data.getMainQty());
|
||||
inventoryRecord.setMainUom(data.getMainUom());
|
||||
inventoryRecord.setErpInventory(data.getErpInventory());
|
||||
inventoryRecord.setSyncPostingDate(LocalDate.now());
|
||||
inventoryRecord.setWorkCenter(data.getWorkCenter);
|
||||
|
||||
//TODO: 2023/3/21 获取物料的物料组
|
||||
// R<List<OperationOutBomComponentDTO>> bySiteAndShopOrder = remoteWipService.getBySiteAndShopOrder(site, data.getShopOrder(), data.getWorkCenter);
|
||||
// List<OperationOutBomComponentDTO> operationOutBomComponentDTO = bySiteAndShopOrder.getData();
|
||||
// OperationOutBomComponentDTO operationOutBomComponentDTO1 = operationOutBomComponentDTO.get(0);
|
||||
// if (ObjectUtil.isNotEmpty(operationOutBomComponentDTO)) {
|
||||
// inventoryRecord.setReservedNo(operationOutBomComponentDTO1.getReserved());
|
||||
// inventoryRecord.setReservedLine(operationOutBomComponentDTO1.getReservedSeq());
|
||||
// }
|
||||
|
||||
OperationOutBomComponentDTO operationOutBomComponentDTO = inventoryRecordMapper.selectOperationOutBomComponent( site, data.getShopOrder(), data.getWorkshopNumber());
|
||||
if (operationOutBomComponentDTO != null) {
|
||||
inventoryRecord.setReservedNo(operationOutBomComponentDTO.getReserved());
|
||||
inventoryRecord.setReservedLine(operationOutBomComponentDTO.getReservedSeq());
|
||||
}else {
|
||||
errorMessage.append(MessageFormat.format("第{0}行;查找不到相对应的预留编号与预留行号 \n", row, data.getShopOrder()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
inventoryRecord.setType("1");
|
||||
inventoryRecord.setSyncStatus("N");
|
||||
inventoryRecord.setSapBatchNo(generateSapBatchNumber());
|
||||
inventoryRecords.add(inventoryRecord);
|
||||
} catch (Exception e) {
|
||||
errorMessage.append(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
package com.foreverwin.mom.wms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import com.foreverwin.mom.wms.mapper.InventoryRecordMapper;
|
||||
import com.foreverwin.mom.wms.service.InventoryRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class InventoryRecordServiceImpl extends ServiceImpl<InventoryRecordMapper, InventoryRecord> implements InventoryRecordService {
|
||||
|
||||
private final InventoryRecordMapper inventoryRecordMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public InventoryRecord getShopOrderAndWork(String shopOrder, String workshopNumber, String sapBatchNo) {
|
||||
QueryWrapper<InventoryRecord> queryWrapper = Wrappers.query();
|
||||
queryWrapper.eq("shop_order", shopOrder);
|
||||
queryWrapper.eq("workshop_number", workshopNumber);
|
||||
queryWrapper.eq("sap_batch_no", sapBatchNo);
|
||||
return inventoryRecordMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryRecord getByCode(String site, String code) {
|
||||
|
||||
InventoryRecord inventoryRecord = getById(InventoryRecord.genHandle(site, code));
|
||||
return inventoryRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InventoryRecord> selectBySyncStatusAndType(String type){
|
||||
return inventoryRecordMapper.selectBySyncStatusAndType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateById(InventoryRecord inventoryRecord) {
|
||||
int i = inventoryRecordMapper.updateById(inventoryRecord);
|
||||
return i > 0 ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.foreverwin.mom.wms.mapper;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
import com.foreverwin.iep.prd.entity.ZExternalLotRecord;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutBomComponentDTO;
|
||||
import com.foreverwin.mom.wms.dto.InventoryRecordDTO;
|
||||
import com.foreverwin.mom.wms.entity.InventoryRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface InventoryRecordMapper extends BaseMapper<InventoryRecord> {
|
||||
|
||||
|
||||
@Select("SELECT * FROM inventory_records")
|
||||
List<InventoryRecord> selectList();
|
||||
|
||||
@Select("SELECT * FROM inventory_records WHERE sid = #{sid}")
|
||||
InventoryRecord selectBySid(String sid);
|
||||
|
||||
@Select("SELECT * FROM inventory_records WHERE type = #{type} and sync_status!= 'S'")
|
||||
List<InventoryRecord> selectBySyncStatusAndType(String type);
|
||||
|
||||
@Select("SELECT so.SHOP_ORDER, i.SITE, i.ITEM, CF1.FIELD_VALUE AS RESERVED, CF2.FIELD_VALUE AS RESERVED_SEQ " +
|
||||
"FROM wip.shop_order so " +
|
||||
"INNER JOIN wip.bom b ON b.handle = so.PLANNED_BOM_BO " +
|
||||
"INNER JOIN wip.bom_component bc ON bc.BOM_BO = b.HANDLE\n" +
|
||||
"left join wip.item i ON i.SITE = b.SITE and concat('ItemBO:', i.SITE, ',', i.ITEM, ',#') = bc.COMPONENT_GBO " +
|
||||
"LEFT JOIN wip.custom_fields cf1 ON CF1.HANDLE = BC.HANDLE AND cf1.FIELD_NAME = 'RESERVED' " +
|
||||
"LEFT JOIN wip.custom_fields cf2 ON CF2.HANDLE = BC.HANDLE AND cf2.FIELD_NAME = 'RESERVED_SEQ' " +
|
||||
"WHERE SO.SITE = #{site} " +
|
||||
"AND so.SHOP_ORDER = #{shopOrder} " +
|
||||
"AND i.item = #{item} " +
|
||||
"AND bc.BOM_COMPONENT_TYPE = 'N'")
|
||||
OperationOutBomComponentDTO selectOperationOutBomComponent(@Param("site") String site, @Param("shopOrder") String shopOrder, @Param("item") String item);
|
||||
|
||||
|
||||
@Select("select * from wip.z_external_lot_record WHERE SHOP_ORDER = '2000000013' AND SITE = '2031'")
|
||||
List<ZExternalLotRecord> selectBySyncStatusDTO(String type);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user