feat(wip):内返
This commit is contained in:
parent
753ebe4331
commit
d4b5cff5b4
@ -0,0 +1,20 @@
|
||||
package com.foreverwin.iep.wip.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author syngna
|
||||
* @since 2024/11/27
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum NlvInternalReturnTypeEnum {
|
||||
|
||||
CHANGE_LABEL("CHANGE_LABEL", "换标签"),
|
||||
REWINDING("REWINDING", "复卷");
|
||||
|
||||
private String code;
|
||||
|
||||
private String description;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package com.foreverwin.iep.wip.domain;
|
||||
|
||||
import com.foreverwin.iep.wip.constant.NlvInternalReturnTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 内返请求参数
|
||||
*/
|
||||
@Data
|
||||
public class NlvLotInternalReturnRequest {
|
||||
|
||||
private String site;
|
||||
|
||||
private String user;
|
||||
|
||||
private String operation;
|
||||
|
||||
private String resrce;
|
||||
|
||||
private String shopOrder;
|
||||
|
||||
private String lotNo;
|
||||
|
||||
private NlvInternalReturnTypeEnum returnType;
|
||||
}
|
||||
@ -0,0 +1,126 @@
|
||||
package com.foreverwin.iep.wip.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 io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 内返记录
|
||||
*
|
||||
* @author syngna
|
||||
* @date 2024-11-27 19:41:52
|
||||
*/
|
||||
@Data
|
||||
@TableName("z_lot_internal_return_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel(value = "内返记录")
|
||||
public class ZLotInternalReturnLog extends Model<ZLotInternalReturnLog> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 唯一标识符
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "唯一标识符")
|
||||
private String handle;
|
||||
|
||||
/**
|
||||
* 工厂
|
||||
*/
|
||||
@ApiModelProperty(value = "工厂")
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* 生产批号
|
||||
*/
|
||||
@ApiModelProperty(value = "生产批号")
|
||||
private String lotNo;
|
||||
|
||||
/**
|
||||
* 新生产批号
|
||||
*/
|
||||
@ApiModelProperty(value = "新生产批号")
|
||||
private String sourceLotNo;
|
||||
|
||||
/**
|
||||
* 原生产批序号
|
||||
*/
|
||||
@ApiModelProperty(value = "原生产批序号")
|
||||
private String sourceLotSerial;
|
||||
|
||||
/**
|
||||
* 新产批序号
|
||||
*/
|
||||
@ApiModelProperty(value = "新产批序号")
|
||||
private String targetLotSerial;
|
||||
|
||||
/**
|
||||
* 原工单号
|
||||
*/
|
||||
@ApiModelProperty(value = "原工单号")
|
||||
private String sourceShopOrder;
|
||||
|
||||
/**
|
||||
* 新工单号
|
||||
*/
|
||||
@ApiModelProperty(value = "新工单号")
|
||||
private String targetShopOrder;
|
||||
|
||||
/**
|
||||
* 原料号
|
||||
*/
|
||||
@ApiModelProperty(value = "原料号")
|
||||
private String sourceItemBo;
|
||||
|
||||
/**
|
||||
* 新料号
|
||||
*/
|
||||
@ApiModelProperty(value = "新料号")
|
||||
private String targetItemBo;
|
||||
|
||||
/**
|
||||
* 原BOM
|
||||
*/
|
||||
@ApiModelProperty(value = "原BOM")
|
||||
private String sourceBomBo;
|
||||
|
||||
/**
|
||||
* 新BOM
|
||||
*/
|
||||
@ApiModelProperty(value = "新BOM")
|
||||
private String targetBomBo;
|
||||
|
||||
/**
|
||||
* 原工艺路线
|
||||
*/
|
||||
@ApiModelProperty(value = "原工艺路线")
|
||||
private String sourceRouterBo;
|
||||
|
||||
/**
|
||||
* 新工艺路线
|
||||
*/
|
||||
@ApiModelProperty(value = "新工艺路线")
|
||||
private String targetRouterBo;
|
||||
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private LocalDateTime dateCreate;
|
||||
|
||||
/**
|
||||
* 创建人员
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人员")
|
||||
private String creator;
|
||||
|
||||
}
|
||||
@ -705,7 +705,7 @@ public class ShopOrderServiceImpl extends ServiceImpl<ShopOrderMapper, ShopOrder
|
||||
Item item = itemService.getById(itemBo);
|
||||
itemBo = item.getHandle();
|
||||
ProductConfig productConfig = productConfigService.getById(ProductConfig.genHandle(itemBo));
|
||||
BigDecimal lotSize = productConfig.getLotSize();
|
||||
BigDecimal lotSize = productConfig == null ? BigDecimal.ONE : productConfig.getLotSize();
|
||||
if (ObjectUtil.isNull(lotSize) || lotSize.compareTo(BigDecimal.ZERO) == 0) {
|
||||
lotSize = BigDecimal.ONE;
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package com.foreverwin.iep.wip.controller;
|
||||
|
||||
import com.foreverwin.iep.common.exceptions.ProductionException;
|
||||
import com.foreverwin.iep.wip.domain.NlvLotInternalReturnRequest;
|
||||
import com.foreverwin.iep.wip.service.NlvWipCommonService;
|
||||
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 io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 纳琳威在制品Controller
|
||||
*
|
||||
* @author mom code generator
|
||||
* @date 2024-11-27 11:02:14
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/nlv-wip")
|
||||
@Api(value = "nlv-wip", tags = "纳琳威在制品Controller")
|
||||
public class NlvWipController {
|
||||
|
||||
private final NlvWipCommonService nlvWipCommonService;
|
||||
|
||||
/**
|
||||
* 内返
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/internal-return")
|
||||
public R internalReturn(@RequestBody NlvLotInternalReturnRequest request) {
|
||||
String site = TenantContextHolder.getTenantId();
|
||||
String user = SecurityUtils.getUserName();
|
||||
request.setSite(site);
|
||||
request.setUser(user);
|
||||
try {
|
||||
return R.ok(nlvWipCommonService.internalReturn(request));
|
||||
} catch (ProductionException e) {
|
||||
return R.failed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,10 @@
|
||||
package com.foreverwin.iep.wip.service;
|
||||
|
||||
import com.foreverwin.iep.common.exceptions.ProductionException;
|
||||
import com.foreverwin.iep.wip.domain.NlvLotInternalReturnRequest;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutDTO;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutListDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -14,4 +19,6 @@ public interface NlvWipCommonService {
|
||||
|
||||
List<String> genOpNextNumber(String site, String operation, String resrce, String shopOrder,
|
||||
Map<String, Object> customData, Integer numberOfValues);
|
||||
|
||||
OperationOutListDTO internalReturn(NlvLotInternalReturnRequest request) throws ProductionException;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package com.foreverwin.iep.wip.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.foreverwin.iep.wip.entity.ZLotInternalReturnLog;
|
||||
|
||||
/**
|
||||
* 内返记录
|
||||
*
|
||||
* @author syngna
|
||||
* @date 2024-11-27 19:41:52
|
||||
*/
|
||||
public interface ZLotInternalReturnLogService extends IService<ZLotInternalReturnLog> {
|
||||
|
||||
}
|
||||
@ -4,32 +4,65 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.foreverwin.iep.common.constant.BaseConstants;
|
||||
import com.foreverwin.iep.common.exceptions.ProductionException;
|
||||
import com.foreverwin.iep.common.model.CustomValue;
|
||||
import com.foreverwin.iep.common.utils.HandleBoProcessor;
|
||||
import com.foreverwin.iep.prd.constant.OperationCustomFieldsConstants;
|
||||
import com.foreverwin.iep.prd.constant.ShopOrderCustomFieldsConstants;
|
||||
import com.foreverwin.iep.prd.domain.ReleaseShopOrderResponse;
|
||||
import com.foreverwin.iep.prd.dto.ShopOrderDTO;
|
||||
import com.foreverwin.iep.prd.entity.CustomFields;
|
||||
import com.foreverwin.iep.prd.entity.Operation;
|
||||
import com.foreverwin.iep.prd.entity.RouterStep;
|
||||
import com.foreverwin.iep.prd.entity.ShopOrder;
|
||||
import com.foreverwin.iep.prd.service.CustomFieldsService;
|
||||
import com.foreverwin.iep.prd.service.ShopOrderService;
|
||||
import com.foreverwin.iep.prd.service.UserWorkShiftService;
|
||||
import com.foreverwin.iep.smd.entity.Resrce;
|
||||
import com.foreverwin.iep.sys.service.ZNextNumberService;
|
||||
import com.foreverwin.iep.wip.constant.NlvInternalReturnTypeEnum;
|
||||
import com.foreverwin.iep.wip.domain.EqpFeedingLotItemGroupInfo;
|
||||
import com.foreverwin.iep.wip.domain.NlvLotInternalReturnRequest;
|
||||
import com.foreverwin.iep.wip.domain.SpecifyReleaseLotInfo;
|
||||
import com.foreverwin.iep.wip.domain.StartRequest;
|
||||
import com.foreverwin.iep.wip.domain.StartResponse;
|
||||
import com.foreverwin.iep.wip.domain.ValidationRequest;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutBomComponentDTO;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutDTO;
|
||||
import com.foreverwin.iep.wip.dto.OperationOutListDTO;
|
||||
import com.foreverwin.iep.wip.entity.LotBasis;
|
||||
import com.foreverwin.iep.wip.entity.LotMaterial;
|
||||
import com.foreverwin.iep.wip.entity.LotRouter;
|
||||
import com.foreverwin.iep.wip.entity.LotState;
|
||||
import com.foreverwin.iep.wip.entity.ZLotInternalReturnLog;
|
||||
import com.foreverwin.iep.wip.mapper.NlvWipCommonMapper;
|
||||
import com.foreverwin.iep.wip.mapper.OperationOutMapper;
|
||||
import com.foreverwin.iep.wip.service.LotBasisService;
|
||||
import com.foreverwin.iep.wip.service.LotMaterialService;
|
||||
import com.foreverwin.iep.wip.service.LotRouterService;
|
||||
import com.foreverwin.iep.wip.service.LotStateService;
|
||||
import com.foreverwin.iep.wip.service.NlvWipCommonService;
|
||||
import com.foreverwin.iep.wms.entity.WmsInventory;
|
||||
import com.foreverwin.iep.wms.service.WmsInventoryService;
|
||||
import com.foreverwin.iep.wip.service.ProcessService;
|
||||
import com.foreverwin.iep.wip.service.ValidationService;
|
||||
import com.foreverwin.iep.wip.service.ZLotInternalReturnLogService;
|
||||
import com.foreverwin.mom.admin.api.entity.SysDictItem;
|
||||
import com.foreverwin.mom.admin.api.feign.RemoteDictService;
|
||||
import com.foreverwin.mom.admin.api.feign.RemoteParamService;
|
||||
import com.foreverwin.mom.common.core.constant.SecurityConstants;
|
||||
import com.foreverwin.mom.common.core.exception.BusinessException;
|
||||
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
|
||||
import com.foreverwin.mom.common.security.util.SecurityUtils;
|
||||
import com.foreverwin.mom.wms.api.feign.RemoteWmsInventoryService;
|
||||
import com.foreverwin.mom.wms.dto.InventoryDto;
|
||||
import com.foreverwin.mom.wms.entity.Inventory;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -60,6 +93,22 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
|
||||
private final RemoteWmsInventoryService remoteWmsInventoryService;
|
||||
|
||||
private final LotStateService lotStateService;
|
||||
|
||||
private final LotBasisService lotBasisService;
|
||||
|
||||
private final LotRouterService lotRouterService;
|
||||
|
||||
private final ValidationService validationService;
|
||||
|
||||
private final ProcessService processService;
|
||||
|
||||
private final LotMaterialService lotMaterialService;
|
||||
|
||||
private final OperationOutMapper operationOutMapper;
|
||||
|
||||
private final ZLotInternalReturnLogService zLotInternalReturnLogService;
|
||||
|
||||
public static final String EQ_SUFFIX = "EQ_SUFFIX";
|
||||
|
||||
public static final String EQ_SUFFIX_ALPHA = "EQ_SUFFIX_ALPHA";
|
||||
@ -74,6 +123,7 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
|
||||
/**
|
||||
* 获取各工序编号规则对应的编号
|
||||
*
|
||||
* @param site
|
||||
* @param operation
|
||||
* @param resrce
|
||||
@ -83,21 +133,21 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> genOpNextNumber(String site, String operation, String resrce, String shopOrder,
|
||||
Map<String, Object> customData, Integer numberOfValues) {
|
||||
if(customData == null) {
|
||||
public List<String> genOpNextNumber(String site, String operation, String resrce, String shopOrder, Map<String, Object> customData, Integer numberOfValues) {
|
||||
if (customData == null) {
|
||||
customData = new HashMap<>();
|
||||
}
|
||||
// 获取工序自定义字段NEXT_NUMBER_TYPE
|
||||
String operationBo = Operation.genHandle(site, operation, "#");
|
||||
List<CustomValue> operationCustomValueList = customFieldsService.retrieveCustomValues(operationBo);
|
||||
String nextNumberTypeErrorMsg = "工序[" + operation + "]未配置自定义字段NEXT_NUMBER_TYPE";
|
||||
if(operationCustomValueList == null || operationCustomValueList.isEmpty()) {
|
||||
if (operationCustomValueList == null || operationCustomValueList.isEmpty()) {
|
||||
throw BusinessException.build(nextNumberTypeErrorMsg);
|
||||
}
|
||||
// 获取customValueList中fieldName='NEXT_NUMBER_TYPE'的记录
|
||||
CustomValue numberTypeCustomValue = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.NEXT_NUMBER_TYPE.equals(c.getFieldName())).findFirst().orElse(null);
|
||||
if(numberTypeCustomValue == null || StrUtil.isBlank(numberTypeCustomValue.getFieldValue())) {
|
||||
CustomValue numberTypeCustomValue = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.NEXT_NUMBER_TYPE.equals(c.getFieldName())).findFirst()
|
||||
.orElse(null);
|
||||
if (numberTypeCustomValue == null || StrUtil.isBlank(numberTypeCustomValue.getFieldValue())) {
|
||||
throw BusinessException.build(nextNumberTypeErrorMsg);
|
||||
}
|
||||
// 获取resrce后两位,如果少于2位,则为空
|
||||
@ -110,21 +160,20 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
customData.put(EQ_SUFFIX, eqSuffix);
|
||||
// 将eqSuffix转换为A、B、C、D...的形式,01转换为空,02转换为A,03转换为B...
|
||||
String result = NumberUtil.isNumber(eqSuffix) ? String.valueOf((char) ('A' + Integer.parseInt(eqSuffix) - 1)) : eqSuffix;
|
||||
if("01".equals(eqSuffix)) {
|
||||
if ("01".equals(eqSuffix)) {
|
||||
result = "";
|
||||
}
|
||||
customData.put(EQ_SUFFIX_ALPHA, result);
|
||||
if(StrUtil.isNotBlank(shopOrder)) {
|
||||
if (StrUtil.isNotBlank(shopOrder)) {
|
||||
// 修复涂料类型:取工单计划物料在自定表中自定义字段为XF_ITEM_TYPE对应的值
|
||||
String shopOrderBo = ShopOrder.genHandle(site, shopOrder);
|
||||
ShopOrder shopOrderData = shopOrderService.getById(shopOrderBo);
|
||||
if(shopOrderData == null) {
|
||||
if (shopOrderData == null) {
|
||||
throw BusinessException.build("工单[" + shopOrder + "]不存在");
|
||||
}
|
||||
CustomFields shopOrderCustomFields = customFieldsService.getOne(Wrappers.<CustomFields>lambdaQuery()
|
||||
.eq(CustomFields::getHandle, shopOrderData.getPlannedItemBo())
|
||||
CustomFields shopOrderCustomFields = customFieldsService.getOne(Wrappers.<CustomFields>lambdaQuery().eq(CustomFields::getHandle, shopOrderData.getPlannedItemBo())
|
||||
.eq(CustomFields::getFieldName, ShopOrderCustomFieldsConstants.XF_ITEM_TYPE), false);
|
||||
if(shopOrderCustomFields != null && !StrUtil.isBlank(shopOrderCustomFields.getFieldValue())) {
|
||||
if (shopOrderCustomFields != null && !StrUtil.isBlank(shopOrderCustomFields.getFieldValue())) {
|
||||
customData.put(ShopOrderCustomFieldsConstants.XF_ITEM_TYPE, shopOrderCustomFields.getFieldValue());
|
||||
}
|
||||
}
|
||||
@ -132,33 +181,35 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
customData.put(SHIFT, userWorkShift == null ? "" : userWorkShift);
|
||||
// 设置涂布大卷的值
|
||||
// 获取customValueList中fieldName='IS_FIND_PARENT'的记录,为Y的需要获取涂布大卷
|
||||
CustomValue isFindParentCustomValue = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.IS_FIND_PARENT.equals(c.getFieldName())).findFirst().orElse(null);
|
||||
if(isFindParentCustomValue != null && BaseConstants.Y.equals(isFindParentCustomValue.getFieldValue())) {
|
||||
CustomValue isFindParentCustomValue = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.IS_FIND_PARENT.equals(c.getFieldName())).findFirst()
|
||||
.orElse(null);
|
||||
if (isFindParentCustomValue != null && BaseConstants.Y.equals(isFindParentCustomValue.getFieldValue())) {
|
||||
String materialLot = null;
|
||||
List<EqpFeedingLotItemGroupInfo> eqpFeedingLotItemGroupInfoList = nlvWipCommonMapper.findResourceParentLotNo(Resrce.genHandle(site, resrce));
|
||||
if(eqpFeedingLotItemGroupInfoList == null || eqpFeedingLotItemGroupInfoList.isEmpty()) {
|
||||
if (eqpFeedingLotItemGroupInfoList == null || eqpFeedingLotItemGroupInfoList.isEmpty()) {
|
||||
throw BusinessException.build("资源[" + resrce + "]未找到已上料的涂布大卷");
|
||||
}
|
||||
List<SysDictItem> sysDictItem = remoteDictService.getDictByType("OUT_ITEM_TYPE", SecurityConstants.FROM_IN).getData();
|
||||
if(sysDictItem == null || sysDictItem.isEmpty()) {
|
||||
if (sysDictItem == null || sysDictItem.isEmpty()) {
|
||||
throw BusinessException.build("未找到字典项OUT_ITEM_TYPE");
|
||||
}
|
||||
for(SysDictItem item : sysDictItem) {
|
||||
for(EqpFeedingLotItemGroupInfo info : eqpFeedingLotItemGroupInfoList) {
|
||||
if(info.getItemGroup() != null && info.getItemGroup().equals(item.getItemValue())) {
|
||||
for (SysDictItem item : sysDictItem) {
|
||||
for (EqpFeedingLotItemGroupInfo info : eqpFeedingLotItemGroupInfoList) {
|
||||
if (info.getItemGroup() != null && info.getItemGroup().equals(item.getItemValue())) {
|
||||
materialLot = info.getMaterialLot();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(materialLot == null) {
|
||||
if (materialLot == null) {
|
||||
throw BusinessException.build("资源[" + resrce + "]未找到已上料的涂布大卷");
|
||||
}
|
||||
customData.put(TBDJ, materialLot);
|
||||
// 类别代码:取上述涂布大卷在WMS_INVENTORY表中的ROLL_TYPE的值
|
||||
CustomValue isFindRollType = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.IS_FIND_ROLL_TYPE.equals(c.getFieldName())).findFirst().orElse(null);
|
||||
if(isFindRollType != null && BaseConstants.Y.equals(isFindRollType.getFieldValue())) {
|
||||
CustomValue isFindRollType = operationCustomValueList.stream().filter(c -> OperationCustomFieldsConstants.IS_FIND_ROLL_TYPE.equals(c.getFieldName())).findFirst()
|
||||
.orElse(null);
|
||||
if (isFindRollType != null && BaseConstants.Y.equals(isFindRollType.getFieldValue())) {
|
||||
Inventory wmsInventory = remoteWmsInventoryService.getInventoryDto(Inventory.genHandle(site, materialLot)).getData();
|
||||
if(wmsInventory == null) {
|
||||
if (wmsInventory == null) {
|
||||
throw BusinessException.build("编号规则OP-FQ生成失败:" + "WMS_INVENTORY未找到涂布大卷批次[" + materialLot + "]");
|
||||
}
|
||||
String rollType = wmsInventory.getRollType();
|
||||
@ -171,4 +222,167 @@ public class NlvWipCommonServiceImpl implements NlvWipCommonService {
|
||||
List<String> ids = nextNumberService.getNextNumber(site, numberTypeCustomValue.getFieldValue(), numberOfValues, customData);
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 内返执行
|
||||
*
|
||||
* @param request
|
||||
* @throws ProductionException
|
||||
*/
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public OperationOutListDTO internalReturn(NlvLotInternalReturnRequest request) throws ProductionException {
|
||||
String site = StrUtil.isBlank(request.getSite()) ? TenantContextHolder.getTenantId() : request.getSite();
|
||||
String user = StrUtil.isBlank(request.getUser()) ? SecurityUtils.getUserName() : request.getUser();
|
||||
String operation = request.getOperation();
|
||||
String resource = request.getResrce();
|
||||
String shopOrderNo = request.getShopOrder();
|
||||
String lotNo = request.getLotNo();
|
||||
Enum returnType = request.getReturnType();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
ShopOrder shopOrder = shopOrderService.getById(ShopOrder.genHandle(site, shopOrderNo));
|
||||
if (shopOrder == null) {
|
||||
throw BusinessException.build("工单[" + shopOrderNo + "]不存在");
|
||||
}
|
||||
Inventory wmsInventory = remoteWmsInventoryService.getInventoryDto(Inventory.genHandle(site, lotNo)).getData();
|
||||
if (wmsInventory == null) {
|
||||
throw BusinessException.build("库存" + lotNo + "不存在");
|
||||
}
|
||||
if (wmsInventory.getStatus() == null || !"1001".equals(wmsInventory.getStatus())) {
|
||||
throw BusinessException.build("库存" + lotNo + "状态不可用");
|
||||
}
|
||||
if (wmsInventory.getQtyOnHand() == null || wmsInventory.getQtyOnHand().compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw BusinessException.build("库存" + lotNo + "可用数量为0");
|
||||
}
|
||||
String itemBo = StrUtil.isBlank(shopOrder.getItemBo()) ? shopOrder.getPlannedItemBo() : shopOrder.getItemBo();
|
||||
String newLot = lotNo;
|
||||
String lotBasisBo = LotBasis.genHandle(site, lotNo);
|
||||
LotState origLotState = lotStateService.getById(LotState.genHandle(lotBasisBo));
|
||||
LotBasis origLotBasis = lotBasisService.getById(lotBasisBo);
|
||||
if (NlvInternalReturnTypeEnum.CHANGE_LABEL.equals(returnType)) {
|
||||
// 校验卷号库存ID对应的物料是否与内返生产订单物料号一致
|
||||
if (!itemBo.equals(wmsInventory.getItemBo())) {
|
||||
throw BusinessException.build("库存" + lotNo + "对应的物料[" + HandleBoProcessor.trimHandle(wmsInventory.getItemBo()) + "]与内返生产订单物料号不一致");
|
||||
}
|
||||
// 1. 如果是换标则更新lotBasis和lotState(删除旧数据重新下达)
|
||||
lotBasisService.removeById(lotBasisBo);
|
||||
lotStateService.removeById(LotState.genHandle(lotBasisBo));
|
||||
lotRouterService.remove(Wrappers.<LotRouter>lambdaQuery().eq(LotRouter::getLotStateBo, LotState.genHandle(lotBasisBo)));
|
||||
} else {
|
||||
List<String> ids = this.genOpNextNumber(site, operation, resource, shopOrderNo, null, 1);
|
||||
newLot = ids.get(0);
|
||||
}
|
||||
// 2. 更新原库存数量为0
|
||||
InventoryDto inventory = new InventoryDto();
|
||||
inventory.setHandle(wmsInventory.getHandle());
|
||||
remoteWmsInventoryService.internalReturn(inventory);
|
||||
// 3. 将lot下达至指定工单
|
||||
ShopOrderDTO dto = new ShopOrderDTO();
|
||||
BeanUtils.copyProperties(shopOrder, dto);
|
||||
List<SpecifyReleaseLotInfo> specifyReleaseLotInfoList = new ArrayList<>();
|
||||
SpecifyReleaseLotInfo info = new SpecifyReleaseLotInfo();
|
||||
info.setLotNo(newLot);
|
||||
info.setQty(wmsInventory.getQtyOnHand());
|
||||
info.setItemBo(itemBo);
|
||||
specifyReleaseLotInfoList.add(info);
|
||||
dto.setSpecifyReleaseLotList(specifyReleaseLotInfoList);
|
||||
dto.setReleaseQty(wmsInventory.getQtyOnHand().toPlainString());
|
||||
ReleaseShopOrderResponse releaseResponse = shopOrderService.releaseShopOrder(site, user, dto);
|
||||
List<LotState> lotStateList = releaseResponse.getLotStateList();
|
||||
LotState lotState = lotStateList.get(0);
|
||||
// 4. 物料消耗
|
||||
this.consumeLotMaterial(site, user, now, operation, resource, shopOrderNo, lotState, wmsInventory);
|
||||
// 5. 自动进站
|
||||
StartRequest startRequest = new StartRequest();
|
||||
BeanUtils.copyProperties(request, startRequest);
|
||||
startRequest.setSite(site);
|
||||
startRequest.setOperation(operation);
|
||||
startRequest.setResource(resource);
|
||||
startRequest.setLotNo(newLot);
|
||||
startRequest.setShopOrder(shopOrderNo);
|
||||
ValidationRequest validationRequest = new ValidationRequest();
|
||||
BeanUtils.copyProperties(startRequest, validationRequest);
|
||||
boolean needCheck = validationService.validationCheck(validationRequest);
|
||||
if (needCheck) {
|
||||
validationService.validationStart(validationRequest);
|
||||
}
|
||||
StartResponse startResponse = processService.start(startRequest);
|
||||
// 6. 记录内返信息
|
||||
this.recordLotInternalReturnLog(site, user, now, shopOrder, origLotBasis, origLotState, startResponse.getLotStateList().get(0));
|
||||
OperationOutDTO operationOutDTO = new OperationOutDTO();
|
||||
operationOutDTO.setSite(site);
|
||||
operationOutDTO.setOperation(operation);
|
||||
operationOutDTO.setResrce(resource);
|
||||
operationOutDTO.setBarCode(newLot);
|
||||
OperationOutListDTO operationOutListDTO = operationOutMapper.readOperationOutByBarCode(operationOutDTO);
|
||||
return operationOutListDTO;
|
||||
}
|
||||
|
||||
private void recordLotInternalReturnLog(String site, String user, LocalDateTime date, ShopOrder shopOrder, LotBasis origLotBasis, LotState origLotState, LotState newLotState) {
|
||||
ShopOrder origShopOrder;
|
||||
ZLotInternalReturnLog log = new ZLotInternalReturnLog();
|
||||
log.setHandle(StrUtil.uuid());
|
||||
log.setSite(site);
|
||||
log.setLotNo(newLotState.getLotNo());
|
||||
log.setTargetLotSerial(newLotState.getLotSerial());
|
||||
if (origLotBasis != null) {
|
||||
origShopOrder = shopOrderService.getById(origLotBasis.getShopOrderBo());
|
||||
log.setSourceLotNo(origLotBasis.getLotNo());
|
||||
log.setSourceItemBo(origLotBasis.getItemBo());
|
||||
log.setSourceShopOrder(HandleBoProcessor.trimHandle(origLotBasis.getShopOrderBo()));
|
||||
if (origShopOrder != null) {
|
||||
log.setSourceBomBo(StrUtil.isBlank(origShopOrder.getBomBo()) ? origShopOrder.getPlannedBomBo() : origShopOrder.getBomBo());
|
||||
}
|
||||
}
|
||||
if (origLotState != null) {
|
||||
log.setSourceLotSerial(origLotState.getLotSerial());
|
||||
log.setSourceRouterBo(RouterStep.getRouterBo(origLotState.getRouterStepBo()));
|
||||
}
|
||||
log.setTargetItemBo(StrUtil.isBlank(shopOrder.getItemBo()) ? shopOrder.getPlannedItemBo() : shopOrder.getItemBo());
|
||||
log.setTargetBomBo(StrUtil.isBlank(shopOrder.getBomBo()) ? shopOrder.getPlannedBomBo() : shopOrder.getBomBo());
|
||||
log.setTargetRouterBo(RouterStep.getRouterBo(newLotState.getRouterStepBo()));
|
||||
log.setTargetShopOrder(shopOrder.getShopOrder());
|
||||
log.setDateCreate(date);
|
||||
log.setCreator(user);
|
||||
zLotInternalReturnLogService.save(log);
|
||||
}
|
||||
|
||||
private void consumeLotMaterial(String site, String user, LocalDateTime date, String operation, String resource, String shopOrderNo, LotState lotState, Inventory wmsInventory) {
|
||||
String operationBo = Operation.genHandle(site, operation, BaseConstants.CURRENT_REVISION);
|
||||
String reserved = null;
|
||||
String reservedSeq = null;
|
||||
List<OperationOutBomComponentDTO> bomComponentList = operationOutMapper.readBomComponent(site, shopOrderNo, operationBo);
|
||||
if (bomComponentList != null && bomComponentList.size() > 0) {
|
||||
for (OperationOutBomComponentDTO bomComponent : bomComponentList) {
|
||||
if (HandleBoProcessor.trimHandle(wmsInventory.getItemBo()).equals(bomComponent.getItem())) {
|
||||
reserved = bomComponent.getReserved();
|
||||
reservedSeq = bomComponent.getReservedSeq();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
LotMaterial lotMaterial = new LotMaterial();
|
||||
lotMaterial.setSid(StrUtil.uuid());
|
||||
lotMaterial.setLotStateBo(lotState.getHandle());
|
||||
lotMaterial.setLotSerial(lotState.getLotSerial());
|
||||
lotMaterial.setItemBo(wmsInventory.getItemBo());
|
||||
lotMaterial.setFeedingQty(wmsInventory.getQtyOnHand());
|
||||
lotMaterial.setConsumeQty(wmsInventory.getQtyOnHand());
|
||||
lotMaterial.setQty(wmsInventory.getQtyOnHand());
|
||||
lotMaterial.setMaterialLot(wmsInventory.getInventoryId());
|
||||
lotMaterial.setWmsWarehouseBo(wmsInventory.getHandle());
|
||||
lotMaterial.setWmsStorageBinBo(wmsInventory.getWmsStorageBinBo());
|
||||
lotMaterial.setDateMfg(wmsInventory.getProductionDate());
|
||||
lotMaterial.setDateExp(wmsInventory.getExpireDate());
|
||||
lotMaterial.setDateCreate(date);
|
||||
lotMaterial.setCreator(user);
|
||||
lotMaterial.setOperationBo(Operation.genHandle(site, operation, BaseConstants.CURRENT_REVISION));
|
||||
lotMaterial.setShopOrderBo(ShopOrder.genHandle(site, shopOrderNo));
|
||||
lotMaterial.setReserved(reserved);
|
||||
lotMaterial.setReservedSeq(reservedSeq);
|
||||
lotMaterial.setSpecialRemark(null);
|
||||
lotMaterial.setResourceBo(Resrce.genHandle(site, resource));
|
||||
lotMaterial.setBatchNo(wmsInventory.getBatchNo());
|
||||
lotMaterialService.save(lotMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ public class OperationOutServiceImpl extends ServiceImpl<OperationOutMapper, Ope
|
||||
wmsInventory.setDnOrder(salesOrder);
|
||||
wmsInventory.setDnOrderSeq(salesOrderLine);
|
||||
wmsInventory.setInventorySpecialMarking(specialRemark);
|
||||
remoteWmsInventoryService.createInventory(wmsInventory);
|
||||
remoteWmsInventoryService.createOrAddInventory(wmsInventory);
|
||||
}
|
||||
|
||||
private WmsStorageLocation findWarehouseBo(String workCenterBo) {
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
package com.foreverwin.iep.wip.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.foreverwin.iep.wip.entity.ZLotInternalReturnLog;
|
||||
import com.foreverwin.iep.wip.mapper.ZLotInternalReturnLogMapper;
|
||||
import com.foreverwin.iep.wip.service.ZLotInternalReturnLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 内返记录
|
||||
*
|
||||
* @author syngna
|
||||
* @date 2024-11-27 19:41:52
|
||||
*/
|
||||
@Service
|
||||
public class ZLotInternalReturnLogServiceImpl extends ServiceImpl<ZLotInternalReturnLogMapper, ZLotInternalReturnLog> implements ZLotInternalReturnLogService {
|
||||
|
||||
}
|
||||
@ -25,4 +25,6 @@ public interface NlvLotStartMapper {
|
||||
List<ShopOrderReleaseItemInfo> selectInQueueLotList(@Param("site") String site, @Param("operation") String operation, @Param("lotNo") String lotNo);
|
||||
|
||||
List<ShopOrderReleaseItemInfo> selectReleaseItemInfoByLotList(@Param("lotStateBoList") List<String> lotStateBoList);
|
||||
|
||||
List<ShopOrderReleaseItemInfo> selectByLotNo(@Param("site") String site, @Param("lotNo") String lotNo);
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
package com.foreverwin.iep.wip.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.foreverwin.iep.wip.entity.ZLotInternalReturnLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 内返记录
|
||||
*
|
||||
* @author syngna
|
||||
* @date 2024-11-27 19:41:52
|
||||
*/
|
||||
@Mapper
|
||||
public interface ZLotInternalReturnLogMapper extends BaseMapper<ZLotInternalReturnLog> {
|
||||
|
||||
}
|
||||
@ -122,4 +122,10 @@
|
||||
</foreach>
|
||||
ORDER BY LS.LOT_NO
|
||||
</select>
|
||||
|
||||
<select id="selectByLotNo" resultMap="shopOrderReleaseItemMap">
|
||||
<include refid="selectLotStateItemInfo"></include>
|
||||
WHERE LB.LOT_NO = #{lotNo}
|
||||
AND LB.SITE = #{site}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
<?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.foreverwin.iep.wip.mapper.ZLotInternalReturnLogMapper">
|
||||
|
||||
<resultMap id="zLotInternalReturnLogMap" type="com.foreverwin.iep.wip.entity.ZLotInternalReturnLog">
|
||||
<id property="handle" column="HANDLE"/>
|
||||
<result property="site" column="SITE"/>
|
||||
<result property="lotNo" column="LOT_NO"/>
|
||||
<result property="sourceLotNo" column="SOURCE_LOT_NO"/>
|
||||
<result property="sourceLotSerial" column="SOURCE_LOT_SERIAL"/>
|
||||
<result property="targetLotSerial" column="TARGET_LOT_SERIAL"/>
|
||||
<result property="sourceShopOrder" column="SOURCE_SHOP_ORDER"/>
|
||||
<result property="targetShopOrder" column="TARGET_SHOP_ORDER"/>
|
||||
<result property="sourceItemBo" column="SOURCE_ITEM_BO"/>
|
||||
<result property="targetItemBo" column="TARGET_ITEM_BO"/>
|
||||
<result property="sourceBomBo" column="SOURCE_BOM_BO"/>
|
||||
<result property="targetBomBo" column="TARGET_BOM_BO"/>
|
||||
<result property="sourceRouterBo" column="SOURCE_ROUTER_BO"/>
|
||||
<result property="targetRouterBo" column="TARGET_ROUTER_BO"/>
|
||||
<result property="dateCreate" column="DATE_CREATE"/>
|
||||
<result property="creator" column="CREATOR"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
10
pom.xml
10
pom.xml
@ -129,4 +129,14 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nalinv</id>
|
||||
<url>http://192.168.100.8:9090/repository/maven-public/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>nalinv</id>
|
||||
<url>http://192.168.100.8:9090/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user