MES:
1、生产任务暂停和继续
WMS:
1、原材料库存转销售订单
2、成品库存转销售订单
master
xs 10 months ago
parent 3c84d4d15a
commit 926d049353

@ -9,6 +9,7 @@ import com.hw.mes.api.domain.MesBaseProcessInfo;
import com.hw.mes.api.domain.MesBaseStationInfo; import com.hw.mes.api.domain.MesBaseStationInfo;
import com.hw.mes.api.domain.vo.MesBaseMaterialInfoVo; import com.hw.mes.api.domain.vo.MesBaseMaterialInfoVo;
import com.hw.mes.api.domain.vo.MesPdaProductPlanVo; import com.hw.mes.api.domain.vo.MesPdaProductPlanVo;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import com.hw.mes.api.factory.RemoteMesFallbackFactory; import com.hw.mes.api.factory.RemoteMesFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -114,4 +115,26 @@ public interface RemoteMesService {
@PostMapping("/productplan/complete5thFloorInstall") @PostMapping("/productplan/complete5thFloorInstall")
public R<?> complete5thFloorInstall(@RequestBody MesPdaProductPlanVo mesPdaProductPlanVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); public R<?> complete5thFloorInstall(@RequestBody MesPdaProductPlanVo mesPdaProductPlanVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
*
* @param mesBaseBarcodeInfos
* @param source
* @return
*/
@PostMapping("/barcode/transferBaseBarcodeInfos")
public R<Boolean> transferBaseBarcodeInfos(@RequestBody List<MesBaseBarcodeInfo> mesBaseBarcodeInfos, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
*
* @param mesSaleOrderTransferVo VO
* @param source
* @return
*/
@PostMapping("/saleOrder/transferSaleOrders")
public R<Boolean> transferSaleOrders(@RequestBody MesSaleOrderTransferVo mesSaleOrderTransferVo, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
} }

@ -0,0 +1,37 @@
package com.hw.mes.api.domain.vo;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
/**
* @Description: VO
* @ClassName: MesSaleOrderTransferVo
* @Author : xins
* @Date :2024-09-04 14:21
* @Version :1.0
*/
@Data
public class MesSaleOrderTransferVo {
//转换的条码信息
@NotNull(message = "条码信息不能为空")
private List<MesBaseBarcodeInfo> mesBaseBarcodeInfos;
//转换数量
@NotNull(message = "转换不能为空")
private BigDecimal transferAmount;
//老的销售订单ID
@NotNull(message = "老销售订单Id必须输入")
private Long oldSaleOrderId;
//新的销售订单ID
@NotNull(message = "新销售订单Id必须输入")
private Long newSaleOrderId;
}

@ -8,6 +8,7 @@ import com.hw.mes.api.domain.MesBaseProcessInfo;
import com.hw.mes.api.domain.MesBaseStationInfo; import com.hw.mes.api.domain.MesBaseStationInfo;
import com.hw.mes.api.domain.vo.MesBaseMaterialInfoVo; import com.hw.mes.api.domain.vo.MesBaseMaterialInfoVo;
import com.hw.mes.api.domain.vo.MesPdaProductPlanVo; import com.hw.mes.api.domain.vo.MesPdaProductPlanVo;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.cloud.openfeign.FallbackFactory;
@ -72,6 +73,16 @@ public class RemoteMesFallbackFactory implements FallbackFactory<RemoteMesServic
public R<?> complete5thFloorInstall(MesPdaProductPlanVo mesPdaProductPlanVo, String source) { public R<?> complete5thFloorInstall(MesPdaProductPlanVo mesPdaProductPlanVo, String source) {
return R.fail("完成五楼组装工序失败:" + throwable.getMessage()); return R.fail("完成五楼组装工序失败:" + throwable.getMessage());
} }
@Override
public R<Boolean> transferBaseBarcodeInfos(List<MesBaseBarcodeInfo> mesBaseBarcodeInfos, String source) {
return R.fail("转换条码信息失败:" + throwable.getMessage());
}
@Override
public R<Boolean> transferSaleOrders(MesSaleOrderTransferVo mesSaleOrderTransferVo, String source) {
return R.fail("销售订单信息转换失败:" + throwable.getMessage());
}
}; };
} }
} }

@ -143,13 +143,32 @@ public class WmsConstants {
/** /**
* * (1:,2:,3:,4:5:68使,9)
*/ */
public static final String WMS_BASE_LOCATION_STATUS_NORMAL = "1";//正常 public static final String WMS_BASE_LOCATION_STATUS_NORMAL = "1";//正常
public static final String WMS_BASE_LOCATION_STATUS_AUTO_LOCK = "2";//自动锁定 public static final String WMS_BASE_LOCATION_STATUS_AUTO_LOCK = "2";//自动锁定
public static final String WMS_BASE_LOCATION_STATUS_MANUAL_LOCK = "3";//人工锁定 public static final String WMS_BASE_LOCATION_STATUS_MANUAL_LOCK = "3";//人工锁定
public static final String WMS_BASE_LOCATION_STATUS_MOVE_LOCK = "4";//移库锁定 public static final String WMS_BASE_LOCATION_STATUS_MOVE_LOCK = "4";//移库锁定
public static final String WMS_BASE_LOCATION_STATUS_MERGE_LOCK = "5";//合库锁定 public static final String WMS_BASE_LOCATION_STATUS_MERGE_LOCK = "5";//合库锁定
public static final String WMS_BASE_LOCATION_STATUS_OUT_STOCK = "6";//出库锁定
public static final String WMS_BASE_LOCATION_STATUS_DEEP_ABNORMAL = "8";//深库位异常
public static final String WMS_BASE_LOCATION_STATUS_ABNORMAL = "9";//异常
public static final Map<String, String> LOCATION_STATUS_PROMPT_MAP = new HashMap<>();
static {
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_NORMAL, "正常");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_AUTO_LOCK, "自动锁定");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_MANUAL_LOCK, "人工锁定");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_MOVE_LOCK, "移库锁定");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_MERGE_LOCK, "合库锁定");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_OUT_STOCK, "出库锁定");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_DEEP_ABNORMAL, "深库位异常");
LOCATION_STATUS_PROMPT_MAP.put(WMS_BASE_LOCATION_STATUS_ABNORMAL, "异常");
// 初始化其他映射...
}
/** /**
* *
@ -213,12 +232,6 @@ public class WmsConstants {
public static final String WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT = "1";//申请审核退库 public static final String WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT = "1";//申请审核退库
public static final String WMS_RAW_STOCK_COMPLETE_FLAY_YES = "1";//完整
public static final String WMS_RAW_STOCK_COMPLETE_FLAY_NO = "0";//拆分后的
/*移库记录(明细)执行状态*/ /*移库记录(明细)执行状态*/
public static final String WMS_MOVE_EXECUTE_STATUS_TOEXECUTE = "0";//待执行 public static final String WMS_MOVE_EXECUTE_STATUS_TOEXECUTE = "0";//待执行
public static final String WMS_MOVE_EXECUTE_STATUS_EXECUTING = "1";//执行中 public static final String WMS_MOVE_EXECUTE_STATUS_EXECUTING = "1";//执行中

@ -158,4 +158,9 @@ public enum BusinessType
* *
*/ */
RECALL, RECALL,
/**
*
*/
PAUSE,
} }

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.hw.common.core.constant.MesConstants; import com.hw.common.core.constant.MesConstants;
import com.hw.common.core.domain.R;
import com.hw.common.security.annotation.InnerAuth; import com.hw.common.security.annotation.InnerAuth;
import com.hw.common.security.utils.SecurityUtils; import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo; import com.hw.mes.api.domain.MesBaseBarcodeInfo;
@ -347,4 +348,16 @@ public class MesBaseBarcodeInfoController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
*
*/
@InnerAuth
@Log(title = "条码信息", businessType = BusinessType.TRANSFER)
@PostMapping(value="/transferBaseBarcodeInfos")
public R<Boolean> transferBaseBarcodeInfos(@RequestBody List<MesBaseBarcodeInfo> mesBaseBarcodeInfos)
{
return R.ok(mesBaseBarcodeInfoService.transferBaseBarcodeInfos(mesBaseBarcodeInfos));
}
} }

@ -196,4 +196,24 @@ public class MesProductOrderController extends BaseController {
} }
/**
*
*/
@Log(title = "生产工单", businessType = BusinessType.PAUSE)
@RequiresPermissions("mes:productOrder:pause")
@PostMapping("/productOrderPause")
public AjaxResult productOrderPause(@RequestBody MesProductOrder mesProductOrder) {
return toAjax(mesProductOrderService.productOrderPause(mesProductOrder));
}
/**
*
*/
@Log(title = "生产工单", businessType = BusinessType.PAUSE)
@RequiresPermissions("mes:productOrder:continue")
@PostMapping("/productOrderContinue")
public AjaxResult productOrderContinue(@RequestBody MesProductOrder mesProductOrder) {
return toAjax(mesProductOrderService.productOrderContinue(mesProductOrder));
}
} }

@ -151,7 +151,7 @@ public class MesPurchaseOrderController extends BaseController
* @param mesPurchaseOrder * @param mesPurchaseOrder
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:saleOrder:bind")
@GetMapping("/unbindPurchaseOrderList") @GetMapping("/unbindPurchaseOrderList")
public TableDataInfo unbindPurchaseOrderList(MesPurchaseOrder mesPurchaseOrder) public TableDataInfo unbindPurchaseOrderList(MesPurchaseOrder mesPurchaseOrder)
{ {
@ -165,7 +165,7 @@ public class MesPurchaseOrderController extends BaseController
* @param mesPurchaseOrder * @param mesPurchaseOrder
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:saleOrder:bind")
@GetMapping("/saleBindPurchaseOrderList") @GetMapping("/saleBindPurchaseOrderList")
public TableDataInfo saleBindPurchaseOrderList(MesPurchaseOrder mesPurchaseOrder) public TableDataInfo saleBindPurchaseOrderList(MesPurchaseOrder mesPurchaseOrder)
{ {
@ -179,7 +179,7 @@ public class MesPurchaseOrderController extends BaseController
* @param mesSaleOrder * @param mesSaleOrder
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:saleOrder:bind")
@Log(title = "采购订单信息", businessType = BusinessType.ALLOCATE) @Log(title = "采购订单信息", businessType = BusinessType.ALLOCATE)
@PutMapping("/saveSalesBindPurchase") @PutMapping("/saveSalesBindPurchase")
public AjaxResult saveSalesBindPurchase(@RequestBody MesSaleOrder mesSaleOrder) { public AjaxResult saveSalesBindPurchase(@RequestBody MesSaleOrder mesSaleOrder) {
@ -193,7 +193,7 @@ public class MesPurchaseOrderController extends BaseController
* @param purchaseOrderIds * @param purchaseOrderIds
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:saleOrder:bind")
@Log(title = "采购订单信息", businessType = BusinessType.UNALLOCATE) @Log(title = "采购订单信息", businessType = BusinessType.UNALLOCATE)
@PostMapping("/removeSalesBindPurchase") @PostMapping("/removeSalesBindPurchase")
public AjaxResult removeSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) { public AjaxResult removeSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) {
@ -204,7 +204,7 @@ public class MesPurchaseOrderController extends BaseController
/** /**
* *
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:saleOrder:bind")
@Log(title = "采购订单板顶信息", businessType = BusinessType.DELETE) @Log(title = "采购订单板顶信息", businessType = BusinessType.DELETE)
@GetMapping("/deleteOrderBind/{orderBindIds}") @GetMapping("/deleteOrderBind/{orderBindIds}")
public AjaxResult deleteOrderBind(@PathVariable Long[] orderBindIds) public AjaxResult deleteOrderBind(@PathVariable Long[] orderBindIds)

@ -1,8 +1,11 @@
package com.hw.mes.controller; package com.hw.mes.controller;
import java.util.List; import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.hw.common.core.domain.R;
import com.hw.common.security.annotation.InnerAuth;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -102,4 +105,18 @@ public class MesSaleOrderController extends BaseController
{ {
return toAjax(mesSaleOrderService.deleteMesSaleOrderBySaleOrderIds(saleOrderIds)); return toAjax(mesSaleOrderService.deleteMesSaleOrderBySaleOrderIds(saleOrderIds));
} }
/**
*
*/
@InnerAuth
@Log(title = "销售订单信息", businessType = BusinessType.TRANSFER)
@PostMapping(value="/transferSaleOrders")
public R<Boolean> transferSaleOrders(@RequestBody MesSaleOrderTransferVo mesSaleOrderTransferVo)
{
return R.ok(mesSaleOrderService.transferSaleOrders(mesSaleOrderTransferVo));
}
} }

@ -108,6 +108,17 @@ public class MesSaleOrder extends BaseEntity {
@Excel(name = "已发布数量", readConverterExp = "或=叫已派工数量") @Excel(name = "已发布数量", readConverterExp = "或=叫已派工数量")
private BigDecimal releaseQty; private BigDecimal releaseQty;
/**
*
*/
private BigDecimal transferInAmount;
/**
*
*/
private BigDecimal transferOutAmount;
/** /**
* 1-0- * 1-0-
*/ */
@ -301,6 +312,22 @@ public class MesSaleOrder extends BaseEntity {
return releaseQty; return releaseQty;
} }
public BigDecimal getTransferInAmount() {
return transferInAmount;
}
public void setTransferInAmount(BigDecimal transferInAmount) {
this.transferInAmount = transferInAmount;
}
public BigDecimal getTransferOutAmount() {
return transferOutAmount;
}
public void setTransferOutAmount(BigDecimal transferOutAmount) {
this.transferOutAmount = transferOutAmount;
}
public void setIsRelease(String isRelease) { public void setIsRelease(String isRelease) {
this.isRelease = isRelease; this.isRelease = isRelease;
} }

@ -185,4 +185,12 @@ public interface IMesBaseBarcodeInfoService
* @return * @return
*/ */
public int check4thFloorProduceOutstock(String materialBarcode); public int check4thFloorProduceOutstock(String materialBarcode);
/**
*
*
* @param mesBaseBarcodeInfos
* @return
*/
public boolean transferBaseBarcodeInfos(List<MesBaseBarcodeInfo> mesBaseBarcodeInfos);
} }

@ -1,7 +1,11 @@
package com.hw.mes.service; package com.hw.mes.service;
import java.util.Date;
import java.util.List; import java.util.List;
import com.hw.common.core.constant.MesConstants;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductOrder;
@ -91,6 +95,22 @@ public interface IMesProductOrderService
*/ */
public int productOrderPublish(MesProductOrder mesProductOrder); public int productOrderPublish(MesProductOrder mesProductOrder);
/**
*
*
* @param mesProductOrder
* @return
*/
public int productOrderPause(MesProductOrder mesProductOrder);
/**
*
*
* @param mesProductOrder
* @return
*/
public int productOrderContinue(MesProductOrder mesProductOrder);
/** /**
* BOM * BOM
* @param materialBomId * @param materialBomId

@ -1,6 +1,8 @@
package com.hw.mes.service; package com.hw.mes.service;
import java.util.List; import java.util.List;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import com.hw.mes.domain.MesSaleOrder; import com.hw.mes.domain.MesSaleOrder;
/** /**
@ -66,4 +68,11 @@ public interface IMesSaleOrderService
* @return * @return
*/ */
public List<MesSaleOrder> selectMesSaleOrderJoinMaterialList(MesSaleOrder mesSaleOrder); public List<MesSaleOrder> selectMesSaleOrderJoinMaterialList(MesSaleOrder mesSaleOrder);
/**
*
* @param mesSaleOrderTransferVo
* @return
*/
public boolean transferSaleOrders(MesSaleOrderTransferVo mesSaleOrderTransferVo);
} }

@ -1090,4 +1090,28 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
return 1; return 1;
} }
/**
*
*
* @param mesBaseBarcodeInfos
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean transferBaseBarcodeInfos(List<MesBaseBarcodeInfo> mesBaseBarcodeInfos) {
int updateSize = 0;
for (MesBaseBarcodeInfo mesBaseBarcodeInfo : mesBaseBarcodeInfos) {
MesBaseBarcodeInfo dbMesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(mesBaseBarcodeInfo.getBarcodeInfo());
if (dbMesBaseBarcodeInfo == null) {
return false;
}
mesBaseBarcodeInfo.setBarcodeId(dbMesBaseBarcodeInfo.getBarcodeId());
mesBaseBarcodeInfo.setUpdateBy(SecurityUtils.getUsername());
mesBaseBarcodeInfo.setUpdateTime(DateUtils.getNowDate());
updateSize += mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
}
return updateSize > 0;
}
} }

@ -311,6 +311,59 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
return this.updateMesProductOrder(productOrder); return this.updateMesProductOrder(productOrder);
} }
/**
*
*
* @param mesProductOrder
* @return
*/
@Override
public int productOrderPause(MesProductOrder mesProductOrder) {
MesProductOrder dbProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(mesProductOrder.getProductOrderId());
String productOrderStatus = dbProductOrder.getOrderStatus();
// 工单状态0-待发布1-已发布2-已完成3-已开始4-暂停8-已撤回9-已删除
//已发布和已开始的可以改为暂停
if(!productOrderStatus.equals(MesConstants.PUBLISHED) &&
!productOrderStatus.equals(MesConstants.BEGIN)){
String orderStatusPrompt = MesConstants.ORDER_STATUS_PROMPT_MAP.get(productOrderStatus);
throw new ServiceException(String.format("此生产任务已经%s,不能暂停!", orderStatusPrompt));
}
MesProductOrder productOrder = new MesProductOrder();
productOrder.setProductOrderId(mesProductOrder.getProductOrderId());
productOrder.setOrderStatus(MesConstants.PAUSE);
productOrder.setUpdateTime(new Date());
productOrder.setUpdateBy(SecurityUtils.getUsername());
return mesProductOrderMapper.updateMesProductOrder(productOrder);
}
/**
*
*
* @param mesProductOrder
* @return
*/
@Override
public int productOrderContinue(MesProductOrder mesProductOrder) {
MesProductOrder dbProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(mesProductOrder.getProductOrderId());
String productOrderStatus = dbProductOrder.getOrderStatus();
// 工单状态0-待发布1-已发布2-已完成3-已开始4-暂停8-已撤回9-已删除
//已暂停的可以改为已开始
if(!productOrderStatus.equals(MesConstants.PAUSE)){
String orderStatusPrompt = MesConstants.ORDER_STATUS_PROMPT_MAP.get(productOrderStatus);
throw new ServiceException(String.format("此生产任务已经%s,不能继续开始!", orderStatusPrompt));
}
MesProductOrder productOrder = new MesProductOrder();
productOrder.setProductOrderId(mesProductOrder.getProductOrderId());
productOrder.setOrderStatus(MesConstants.BEGIN);
productOrder.setUpdateTime(new Date());
productOrder.setUpdateBy(SecurityUtils.getUsername());
return mesProductOrderMapper.updateMesProductOrder(productOrder);
}
/** /**
* BOM * BOM
* *

@ -1,13 +1,21 @@
package com.hw.mes.service.impl; package com.hw.mes.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import com.hw.mes.mapper.MesBaseBarcodeInfoMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hw.mes.mapper.MesSaleOrderMapper; import com.hw.mes.mapper.MesSaleOrderMapper;
import com.hw.mes.domain.MesSaleOrder; import com.hw.mes.domain.MesSaleOrder;
import com.hw.mes.service.IMesSaleOrderService; import com.hw.mes.service.IMesSaleOrderService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Service * Service
@ -16,11 +24,13 @@ import com.hw.mes.service.IMesSaleOrderService;
* @date 2024-02-19 * @date 2024-02-19
*/ */
@Service @Service
public class MesSaleOrderServiceImpl implements IMesSaleOrderService public class MesSaleOrderServiceImpl implements IMesSaleOrderService {
{
@Autowired @Autowired
private MesSaleOrderMapper mesSaleOrderMapper; private MesSaleOrderMapper mesSaleOrderMapper;
@Autowired
private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper;
/** /**
* *
* *
@ -28,8 +38,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public MesSaleOrder selectMesSaleOrderBySaleOrderId(Long saleOrderId) public MesSaleOrder selectMesSaleOrderBySaleOrderId(Long saleOrderId) {
{
return mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(saleOrderId); return mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(saleOrderId);
} }
@ -40,8 +49,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public List<MesSaleOrder> selectMesSaleOrderList(MesSaleOrder mesSaleOrder) public List<MesSaleOrder> selectMesSaleOrderList(MesSaleOrder mesSaleOrder) {
{
return mesSaleOrderMapper.selectMesSaleOrderList(mesSaleOrder); return mesSaleOrderMapper.selectMesSaleOrderList(mesSaleOrder);
} }
@ -52,8 +60,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public int insertMesSaleOrder(MesSaleOrder mesSaleOrder) public int insertMesSaleOrder(MesSaleOrder mesSaleOrder) {
{
mesSaleOrder.setCreateTime(DateUtils.getNowDate()); mesSaleOrder.setCreateTime(DateUtils.getNowDate());
return mesSaleOrderMapper.insertMesSaleOrder(mesSaleOrder); return mesSaleOrderMapper.insertMesSaleOrder(mesSaleOrder);
} }
@ -65,8 +72,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public int updateMesSaleOrder(MesSaleOrder mesSaleOrder) public int updateMesSaleOrder(MesSaleOrder mesSaleOrder) {
{
mesSaleOrder.setUpdateTime(DateUtils.getNowDate()); mesSaleOrder.setUpdateTime(DateUtils.getNowDate());
return mesSaleOrderMapper.updateMesSaleOrder(mesSaleOrder); return mesSaleOrderMapper.updateMesSaleOrder(mesSaleOrder);
} }
@ -78,8 +84,7 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds) public int deleteMesSaleOrderBySaleOrderIds(Long[] saleOrderIds) {
{
return mesSaleOrderMapper.deleteMesSaleOrderBySaleOrderIds(saleOrderIds); return mesSaleOrderMapper.deleteMesSaleOrderBySaleOrderIds(saleOrderIds);
} }
@ -90,13 +95,11 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public int deleteMesSaleOrderBySaleOrderId(Long saleOrderId) public int deleteMesSaleOrderBySaleOrderId(Long saleOrderId) {
{
return mesSaleOrderMapper.deleteMesSaleOrderBySaleOrderId(saleOrderId); return mesSaleOrderMapper.deleteMesSaleOrderBySaleOrderId(saleOrderId);
} }
/** /**
* ,Join mes_base_material_info(material_idmes_base_material_infomaterial_id) * ,Join mes_base_material_info(material_idmes_base_material_infomaterial_id)
* *
@ -104,10 +107,57 @@ public class MesSaleOrderServiceImpl implements IMesSaleOrderService
* @return * @return
*/ */
@Override @Override
public List<MesSaleOrder> selectMesSaleOrderJoinMaterialList(MesSaleOrder mesSaleOrder) public List<MesSaleOrder> selectMesSaleOrderJoinMaterialList(MesSaleOrder mesSaleOrder) {
{
mesSaleOrder.setMaterialSpec(StringUtils.isNotEmpty(mesSaleOrder.getMaterialSpec()) mesSaleOrder.setMaterialSpec(StringUtils.isNotEmpty(mesSaleOrder.getMaterialSpec())
? mesSaleOrder.getMaterialSpec().replaceAll("\\s+", "") : ""); ? mesSaleOrder.getMaterialSpec().replaceAll("\\s+", "") : "");
return mesSaleOrderMapper.selectMesSaleOrderJoinMaterialList(mesSaleOrder); return mesSaleOrderMapper.selectMesSaleOrderJoinMaterialList(mesSaleOrder);
} }
/**
*
*
* @param mesSaleOrderTransferVo
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean transferSaleOrders(MesSaleOrderTransferVo mesSaleOrderTransferVo) {
Long oldSaleOrderId = mesSaleOrderTransferVo.getOldSaleOrderId();
Long newSaleOrderId = mesSaleOrderTransferVo.getNewSaleOrderId();
BigDecimal transferAmount = mesSaleOrderTransferVo.getTransferAmount();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
if (oldSaleOrderId != null && !oldSaleOrderId.equals(0L)) {
MesSaleOrder oldSaleOrder = mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(oldSaleOrderId);
oldSaleOrder.setTransferOutAmount(transferAmount);
oldSaleOrder.setUpdateBy(userName);
oldSaleOrder.setUpdateTime(currentDate);
mesSaleOrderMapper.updateMesSaleOrder(oldSaleOrder);
}
if (newSaleOrderId != null && !newSaleOrderId.equals(0L)) {
MesSaleOrder newSaleOrder = mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(newSaleOrderId);
newSaleOrder.setTransferInAmount(transferAmount);
newSaleOrder.setUpdateBy(userName);
newSaleOrder.setUpdateTime(currentDate);
mesSaleOrderMapper.updateMesSaleOrder(newSaleOrder);
}
List<MesBaseBarcodeInfo> mesBaseBarcodeInfos = mesSaleOrderTransferVo.getMesBaseBarcodeInfos();
int updateSize = 0;
for (MesBaseBarcodeInfo mesBaseBarcodeInfo : mesBaseBarcodeInfos) {
MesBaseBarcodeInfo dbMesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(mesBaseBarcodeInfo.getBarcodeInfo());
if (dbMesBaseBarcodeInfo == null) {
return false;
}
mesBaseBarcodeInfo.setBarcodeId(dbMesBaseBarcodeInfo.getBarcodeId());
mesBaseBarcodeInfo.setUpdateBy(SecurityUtils.getUsername());
mesBaseBarcodeInfo.setUpdateTime(DateUtils.getNowDate());
updateSize += mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
}
return updateSize > 0;
}
} }

@ -266,6 +266,7 @@
<if test="planDetailCode != null">plan_detail_code = #{planDetailCode},</if> <if test="planDetailCode != null">plan_detail_code = #{planDetailCode},</if>
<if test="saleOrderId != null">sale_order_id = #{saleOrderId},</if> <if test="saleOrderId != null">sale_order_id = #{saleOrderId},</if>
<if test="saleorderCode != null">saleorder_code = #{saleorderCode},</if> <if test="saleorderCode != null">saleorder_code = #{saleorderCode},</if>
<if test="safeFlag != null and safeFlag != ''">safe_flag = #{safeFlag},</if>
<if test="projectNo != null">project_no = #{projectNo},</if> <if test="projectNo != null">project_no = #{projectNo},</if>
<if test="transferredPlanDetailCode != null">transferred_plan_detail_code = #{transferredPlanDetailCode},</if> <if test="transferredPlanDetailCode != null">transferred_plan_detail_code = #{transferredPlanDetailCode},</if>
<if test="serialNumber != null">serial_number = #{serialNumber},</if> <if test="serialNumber != null">serial_number = #{serialNumber},</if>

@ -45,6 +45,7 @@
<result property="produceMaterialSpec" column="produce_material_spec"/> <result property="produceMaterialSpec" column="produce_material_spec"/>
<result property="productionTime" column="production_time"/> <result property="productionTime" column="production_time"/>
<result property="preOrderId" column="pre_order_id"/> <result property="preOrderId" column="pre_order_id"/>
<result property="preOrderCode" column="pre_order_code"/>
</resultMap> </resultMap>
<sql id="selectMesProductOrderVo"> <sql id="selectMesProductOrderVo">
@ -87,6 +88,7 @@
mpo.update_by, mpo.update_by,
mpo.update_time, mpo.update_time,
mpo.pre_order_id, mpo.pre_order_id,
mpo.pre_order_code,
mbr.production_time mbr.production_time
from mes_product_order mpo from mes_product_order mpo
left join (select a.route_id, left join (select a.route_id,
@ -179,6 +181,7 @@
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="planDeliveryDate != null">plan_delivery_date,</if> <if test="planDeliveryDate != null">plan_delivery_date,</if>
<if test="preOrderId != null">pre_order_id,</if> <if test="preOrderId != null">pre_order_id,</if>
<if test="preOrderCode != null">pre_order_code,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderCode != null and orderCode != ''">#{orderCode},</if> <if test="orderCode != null and orderCode != ''">#{orderCode},</if>
@ -211,6 +214,7 @@
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="planDeliveryDate != null">#{planDeliveryDate},</if> <if test="planDeliveryDate != null">#{planDeliveryDate},</if>
<if test="preOrderId != null">#{preOrderId},</if> <if test="preOrderId != null">#{preOrderId},</if>
<if test="preOrderCode != null">#{preOrderCode},</if>
</trim> </trim>
</insert> </insert>
@ -247,6 +251,7 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="planDeliveryDate != null">plan_delivery_date = #{planDeliveryDate},</if> <if test="planDeliveryDate != null">plan_delivery_date = #{planDeliveryDate},</if>
<if test="preOrderId != null">pre_order_id = #{preOrderId},</if> <if test="preOrderId != null">pre_order_id = #{preOrderId},</if>
<if test="preOrderCode != null">pre_order_code = #{preOrderCode},</if>
</trim> </trim>
where product_order_id = #{productOrderId} where product_order_id = #{productOrderId}
</update> </update>
@ -286,4 +291,93 @@
where mpo.pre_order_id = #{productOrderId} where mpo.pre_order_id = #{productOrderId}
</select> </select>
<select id="selectMesProductOrderJoinList" parameterType="MesProductOrder" resultMap="MesProductOrderResult">
select mpo.product_order_id,
mpo.order_code,
mpo.sale_order_id,
mpo.saleorder_code,
mpo.saleorder_linenumber,
mpo.project_no,
mpo.sale_type,
mpo.material_id,
mpo.material_bom_id,
mpo.produce_material_id,
concat(mb.material_name, '-', mb.material_bom_desc) material_bom_desc,
mpo.dispatch_type,
mpo.dispatch_id,
mbr.route_name dispatchName,
bmi.material_code,
bmi.material_name,
bmi.material_spec,
mpo.sale_amount,
mpo.plan_amount,
mpo.dispatch_amount,
mpo.complete_amount,
mpo.release_time,
mpo.plan_begin_time,
mpo.plan_end_time,
mpo.real_begin_time,
mpo.real_end_time,
mpo.order_status,
mpo.stock_lock_flag,
mpo.sale_order_flag,
mpo.plan_delivery_date,
mpo.remark,
mpo.create_by,
mpo.create_time,
mpo.update_by,
mpo.update_time,
mpo.pre_order_id,
mpo.pre_order_code
from mes_product_order mpo
left join mes_base_route mbr on mbr.route_id = mpo.dispatch_id
left join mes_base_material_info bmi on bmi.material_id = mpo.material_id
left join mes_material_bom mb on mb.material_bom_id = mpo.material_bom_id
<where>
mpo.order_status not in ('9')
<if test="orderCode != null and orderCode != ''">and mpo.order_code like concat('%', #{orderCode},'%')</if>
<if test="preOrderCode != null and preOrderCode != ''">and mpo.pre_order_code like concat('%', #{preOrderCode},'%')</if>
<if test="saleorderCode != null and saleorderCode != ''">and mpo.saleorder_code like concat('%', #{saleorderCode},'%')</if>
<if test="materialCode != null and materialCode != ''">and bmi.material_code like concat('%', #{materialCode},'%')</if>
<if test="materialName != null and materialName != ''">and bmi.material_name like concat('%', #{materialName},
'%')
</if>
<if test="materialSpec != null and materialSpec != ''">and replace(bmi.material_spec,' ','') like concat('%', #{materialSpec},
'%')</if>
<if test="projectNo != null and projectNo != ''">and mpo.project_no = #{projectNo}</if>
<if test="materialId != null ">and mpo.material_id = #{materialId}</if>
<if test="materialBomId != null ">and mpo.material_bom_id = #{materialBomId}</if>
<if test="dispatchType != null and dispatchType != ''">and mpo.dispatch_type = #{dispatchType}</if>
<if test="dispatchId != null ">and mpo.dispatch_id = #{dispatchId}</if>
<if test="saleAmount != null ">and mpo.sale_amount = #{saleAmount}</if>
<if test="planAmount != null ">and mpo.plan_amount = #{planAmount}</if>
<if test="dispatchAmount != null ">and mpo.dispatch_amount = #{dispatchAmount}</if>
<if test="completeAmount != null ">and mpo.complete_amount = #{completeAmount}</if>
<if test="releaseTime != null ">and mpo.release_time = #{releaseTime}</if>
<if test="planBeginTime != null ">and mpo.plan_begin_time = #{planBeginTime}</if>
<if test="planEndTime != null ">and mpo.plan_end_time = #{planEndTime}</if>
<if test="realBeginTime != null ">and mpo.real_begin_time = #{realBeginTime}</if>
<if test="realEndTime != null ">and mpo.real_end_time = #{realEndTime}</if>
<if test="orderStatus != null and orderStatus != ''">and mpo.order_status = #{orderStatus}</if>
<if test="stockLockFlag != null and stockLockFlag != ''">and mpo.stock_lock_flag = #{stockLockFlag}</if>
<if test="saleOrderFlag != null and saleOrderFlag != ''">and mpo.sale_order_flag = #{saleOrderFlag}</if>
<if test="preOrderId != null and preOrderId != ''">and mpo.pre_order_id = #{preOrderId}</if>
<if test="createBy != null and createBy != ''">and mpo.create_by = #{createBy}</if>
<if test="createTime != null ">and mpo.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and mpo.update_by = #{updateBy}</if>
<if test="updateTime != null ">and mpo.update_time = #{updateTime}</if>
<if test="params.planBeginTime != null and params.planEndTime != null">
AND (plan_begin_time &lt;= #{params.planEndTime} AND plan_end_time &gt;= #{params.planBeginTime})
</if>
</where>
order by mpo.plan_begin_time,order_status
</select>
</mapper> </mapper>

@ -20,6 +20,8 @@
<result property="orderAmount" column="order_amount"/> <result property="orderAmount" column="order_amount"/>
<result property="completeAmount" column="complete_amount"/> <result property="completeAmount" column="complete_amount"/>
<result property="releaseQty" column="release_qty"/> <result property="releaseQty" column="release_qty"/>
<result property="transferInAmount" column="transfer_in_amount"/>
<result property="transferOutAmount" column="transfer_out_amount"/>
<result property="isRelease" column="is_release"/> <result property="isRelease" column="is_release"/>
<result property="approveDate" column="approve_date"/> <result property="approveDate" column="approve_date"/>
<result property="erpModifyDate" column="erp_modify_date"/> <result property="erpModifyDate" column="erp_modify_date"/>
@ -187,6 +189,8 @@
<if test="orderAmount != null">order_amount = #{orderAmount},</if> <if test="orderAmount != null">order_amount = #{orderAmount},</if>
<if test="completeAmount != null">complete_amount = #{completeAmount},</if> <if test="completeAmount != null">complete_amount = #{completeAmount},</if>
<if test="releaseQty != null">release_qty = #{releaseQty},</if> <if test="releaseQty != null">release_qty = #{releaseQty},</if>
<if test="transferInAmount != null">transfer_in_amount = #{transferInAmount},</if>
<if test="transferOutAmount != null">transfer_out_amount = #{transferOutAmount},</if>
<if test="isRelease != null">is_release = #{isRelease},</if> <if test="isRelease != null">is_release = #{isRelease},</if>
<if test="approveDate != null">approve_date = #{approveDate},</if> <if test="approveDate != null">approve_date = #{approveDate},</if>
<if test="erpModifyDate != null">erp_modify_date = #{erpModifyDate},</if> <if test="erpModifyDate != null">erp_modify_date = #{erpModifyDate},</if>
@ -235,6 +239,8 @@
mso.order_amount, mso.order_amount,
mso.complete_amount, mso.complete_amount,
mso.release_qty, mso.release_qty,
mso.transfer_in_amount,
mso.transfer_out_amount,
mso.is_release, mso.is_release,
mso.plan_delivery_date, mso.plan_delivery_date,
mso.approve_date, mso.approve_date,

@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.constant.WmsConstants;
import com.hw.wms.domain.WmsBaseWarehouse; import com.hw.wms.domain.WmsBaseWarehouse;
import com.hw.wms.domain.vo.WmsStockTotalTransferVo;
import com.hw.wms.domain.vo.WmsStockTransferVo;
import com.hw.wms.service.IWmsBaseWarehouseService; import com.hw.wms.service.IWmsBaseWarehouseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -130,4 +132,39 @@ public class WmsStockTotalController extends BaseController
JSONObject returnObj = wmsStockTotalService.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal); JSONObject returnObj = wmsStockTotalService.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal);
return success(returnObj); return success(returnObj);
} }
/**
*
*/
@RequiresPermissions("wms:stocktotal:transfer")
@Log(title = "原材料库存", businessType = BusinessType.TRANSFER)
@PostMapping("/transferRaw")
public AjaxResult transferRaw(@RequestBody WmsStockTransferVo wmsStockTransferVo)
{
return toAjax(wmsStockTotalService.transferRaw(wmsStockTransferVo));
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:transfer")
@Log(title = "原材料库存", businessType = BusinessType.TRANSFER)
@PostMapping("/transferRawStockTotal")
public AjaxResult transferRawStockTotal(@RequestBody WmsStockTotalTransferVo wmsStockTotalTransferVo)
{
return toAjax(wmsStockTotalService.transferRawStockTotal(wmsStockTotalTransferVo));
}
/**
*
*/
@RequiresPermissions("wms:stocktotal:transferProduct")
@Log(title = "原材料库存", businessType = BusinessType.TRANSFER)
@PostMapping("/transferProductStockTotal")
public AjaxResult transferProductStockTotal(@RequestBody WmsStockTotalTransferVo wmsStockTotalTransferVo)
{
return toAjax(wmsStockTotalService.transferProductStockTotal(wmsStockTotalTransferVo));
}
} }

@ -110,6 +110,8 @@ public class WmsStockTotal extends BaseEntity {
private String materialSpec; private String materialSpec;
private String batchFlag;
private String materialCodeNameSpec; private String materialCodeNameSpec;
private BigDecimal outstockAmount;//已申请数量 private BigDecimal outstockAmount;//已申请数量
@ -266,6 +268,14 @@ public class WmsStockTotal extends BaseEntity {
this.materialSpec = materialSpec; this.materialSpec = materialSpec;
} }
public String getBatchFlag() {
return batchFlag;
}
public void setBatchFlag(String batchFlag) {
this.batchFlag = batchFlag;
}
public String getMaterialCodeNameSpec() { public String getMaterialCodeNameSpec() {
return materialCodeNameSpec; return materialCodeNameSpec;
} }

@ -0,0 +1,42 @@
package com.hw.wms.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* @Description: VO
* @ClassName: WmsStockTotalTransferVo
* @Author : xins
* @Date :2024-9-3 14:05
* @Version :1.0
*/
@Data
public class WmsStockTotalTransferVo {
//安全库存标识
@NotBlank(message = "安全库存标识必须输入")
private String safeFlag;
//销售订单ID
@NotNull(message = "销售订单ID必须输入")
private Long saleOrderId;
//销售订单号
@NotBlank(message = "销售订单号必须输入")
private String saleorderCode;
//总库存ID
@NotNull(message = "总库存ID必须输入")
private Long stockTotalId;
//转库存数量
@NotNull(message = "转库存数量必须输入")
private BigDecimal transferAmount;
//序号
@NotNull(message = "序号必须输入")
private int index;
}

@ -0,0 +1,34 @@
package com.hw.wms.domain.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Description: VO
* @ClassName: WmsStockTransferVo
* @Author : xins
* @Date :2024-9-2 15:58
* @Version :1.0
*/
@Data
public class WmsStockTransferVo {
//安全库存标识
@NotBlank(message = "安全库存标识必须输入")
private String safeFlag;
//销售订单ID
@NotNull(message = "销售订单ID必须输入")
private Long saleOrderId;
//销售订单号
@NotBlank(message = "销售订单号必须输入")
private String saleorderCode;
//序号(中间加-库存ID
@NotBlank(message = "序号-库存ID必须输入")
private String[] indexStockIds;
}

@ -123,4 +123,13 @@ public interface WmsProductStockMapper
*/ */
public List<WmsProductStock> selectOnlyWmsProductStockInList(WmsProductStock wmsProductStock); public List<WmsProductStock> selectOnlyWmsProductStockInList(WmsProductStock wmsProductStock);
/**
*
*
* @param wmsProductStock
* @return
*/
public List<WmsProductStock> selectWmsProductStocks4Transfer(WmsProductStock wmsProductStock);
} }

@ -109,4 +109,13 @@ public interface WmsRawStockMapper {
*/ */
public List<WmsRawStock> selectWmsRawStockJoinList(WmsRawStock wmsRawStock); public List<WmsRawStock> selectWmsRawStockJoinList(WmsRawStock wmsRawStock);
/**
* ,使
*
* @param wmsRawStock
* @return
*/
public List<WmsRawStock> selectWmsRawStocks4Transfer(WmsRawStock wmsRawStock);
} }

@ -6,6 +6,9 @@ import java.util.Map;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.hw.wms.domain.WmsStockTotal; import com.hw.wms.domain.WmsStockTotal;
import com.hw.wms.domain.vo.WmsStockTotalTransferVo;
import com.hw.wms.domain.vo.WmsStockTransferVo;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Service * Service
@ -96,4 +99,24 @@ public interface IWmsStockTotalService
* @return * @return
*/ */
public List<WmsStockTotal> selectWmsStockTotalList4ProductApply(WmsStockTotal wmsStockTotal); public List<WmsStockTotal> selectWmsStockTotalList4ProductApply(WmsStockTotal wmsStockTotal);
/**
*
* @param wmsStockTransferVo
*/
public int transferRaw(WmsStockTransferVo wmsStockTransferVo);
/**
*
*
* @param wmsStockTotalTransferVo
*/
public int transferRawStockTotal(WmsStockTotalTransferVo wmsStockTotalTransferVo);
/**
*
*
* @param wmsStockTotalTransferVo
*/
public int transferProductStockTotal(WmsStockTotalTransferVo wmsStockTotalTransferVo);
} }

@ -195,9 +195,9 @@ public class WmsRawInstockServiceImpl implements IWmsRawInstockService {
wmsRawInstock.setApplyBy(userName); wmsRawInstock.setApplyBy(userName);
wmsRawInstock.setApplyDate(currentDate); wmsRawInstock.setApplyDate(currentDate);
if (!baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW_REGULAR)) { // if (!baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW_REGULAR)) {
wmsRawInstock.setMaterialBarcode(wmsRawInstockVo.getMaterialBarcode()); wmsRawInstock.setMaterialBarcode(wmsRawInstockVo.getMaterialBarcode());
} // }
wmsRawInstock.setMaterialBatchCode(baseBarcodeInfo.getBatchCode()); wmsRawInstock.setMaterialBatchCode(baseBarcodeInfo.getBatchCode());
wmsRawInstock.setMaterialId(baseBarcodeInfo.getMaterialId()); wmsRawInstock.setMaterialId(baseBarcodeInfo.getMaterialId());
wmsRawInstock.setInstockAmount(wmsRawInstockVo.getInstockAmount()); wmsRawInstock.setInstockAmount(wmsRawInstockVo.getInstockAmount());

@ -60,7 +60,7 @@ public class WmsRawStockServiceImpl implements IWmsRawStockService {
wmsRawStock.setSafeFlag(null); wmsRawStock.setSafeFlag(null);
} }
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStockJoinList(wmsRawStock); List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStockJoinList(wmsRawStock);
;
return wmsRawStocks; return wmsRawStocks;
} }

@ -1,20 +1,33 @@
package com.hw.wms.service.impl; package com.hw.wms.service.impl;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.SecurityConstants;
import com.hw.common.core.constant.WmsConstants; import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.domain.R;
import com.hw.common.core.exception.ServiceException; import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.RemoteMesService;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.api.domain.vo.MesSaleOrderTransferVo;
import com.hw.wms.domain.WmsBaseLocation;
import com.hw.wms.domain.WmsProductStock; import com.hw.wms.domain.WmsProductStock;
import com.hw.wms.domain.WmsRawStock;
import com.hw.wms.domain.vo.WmsStockTotalTransferVo;
import com.hw.wms.domain.vo.WmsStockTransferVo;
import com.hw.wms.mapper.WmsBaseLocationMapper;
import com.hw.wms.mapper.WmsProductStockMapper;
import com.hw.wms.mapper.WmsRawStockMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsStockTotalMapper; import com.hw.wms.mapper.WmsStockTotalMapper;
import com.hw.wms.domain.WmsStockTotal; import com.hw.wms.domain.WmsStockTotal;
import com.hw.wms.service.IWmsStockTotalService; import com.hw.wms.service.IWmsStockTotalService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Service * Service
@ -23,11 +36,25 @@ import com.hw.wms.service.IWmsStockTotalService;
* @date 2024-03-14 * @date 2024-03-14
*/ */
@Service @Service
public class WmsStockTotalServiceImpl implements IWmsStockTotalService public class WmsStockTotalServiceImpl implements IWmsStockTotalService {
{
@Autowired @Autowired
private WmsStockTotalMapper wmsStockTotalMapper; private WmsStockTotalMapper wmsStockTotalMapper;
@Autowired
private WmsRawStockMapper wmsRawStockMapper;
@Autowired
private WmsProductStockMapper wmsProductStockMapper;
@Autowired
private WmsBaseLocationMapper wmsBaseLocationMapper;
@Autowired
private RemoteMesService remoteMesService;
public static final int TRANSFER_TYPE_RAW_STOCK = 1;
public static final int TRANSFER_TYPE_STOCK_TOTAL = 2;
/** /**
* *
* *
@ -35,8 +62,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public WmsStockTotal selectWmsStockTotalByStockTotalId(Long stockTotalId) public WmsStockTotal selectWmsStockTotalByStockTotalId(Long stockTotalId) {
{
return wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(stockTotalId); return wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(stockTotalId);
} }
@ -47,8 +73,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public List<WmsStockTotal> selectWmsStockTotalList(WmsStockTotal wmsStockTotal) public List<WmsStockTotal> selectWmsStockTotalList(WmsStockTotal wmsStockTotal) {
{
return wmsStockTotalMapper.selectWmsStockTotalList(wmsStockTotal); return wmsStockTotalMapper.selectWmsStockTotalList(wmsStockTotal);
} }
@ -59,8 +84,9 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public List<WmsStockTotal> selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal) public List<WmsStockTotal> selectWmsStockTotalJoinList(WmsStockTotal wmsStockTotal) {
{ wmsStockTotal.setMaterialSpec(StringUtils.isNotEmpty(wmsStockTotal.getMaterialSpec())
? wmsStockTotal.getMaterialSpec().replaceAll("\\s+", "") : "");
return wmsStockTotalMapper.selectWmsStockTotalJoinList(wmsStockTotal); return wmsStockTotalMapper.selectWmsStockTotalJoinList(wmsStockTotal);
} }
@ -72,8 +98,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public int insertWmsStockTotal(WmsStockTotal wmsStockTotal) public int insertWmsStockTotal(WmsStockTotal wmsStockTotal) {
{
return wmsStockTotalMapper.insertWmsStockTotal(wmsStockTotal); return wmsStockTotalMapper.insertWmsStockTotal(wmsStockTotal);
} }
@ -84,8 +109,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public int updateWmsStockTotal(WmsStockTotal wmsStockTotal) public int updateWmsStockTotal(WmsStockTotal wmsStockTotal) {
{
return wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal); return wmsStockTotalMapper.updateWmsStockTotal(wmsStockTotal);
} }
@ -96,8 +120,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds) public int deleteWmsStockTotalByStockTotalIds(Long[] stockTotalIds) {
{
return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalIds(stockTotalIds); return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalIds(stockTotalIds);
} }
@ -108,17 +131,11 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public int deleteWmsStockTotalByStockTotalId(Long stockTotalId) public int deleteWmsStockTotalByStockTotalId(Long stockTotalId) {
{
return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalId(stockTotalId); return wmsStockTotalMapper.deleteWmsStockTotalByStockTotalId(stockTotalId);
} }
/** /**
* (plancodeplandetailcode),Join material * (plancodeplandetailcode),Join material
* *
@ -126,8 +143,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public List<WmsStockTotal> selectWmsStockTotalJoinListBySaleOrder(WmsStockTotal wmsStockTotal) public List<WmsStockTotal> selectWmsStockTotalJoinListBySaleOrder(WmsStockTotal wmsStockTotal) {
{
return wmsStockTotalMapper.selectWmsStockTotalJoinListBySaleOrder(wmsStockTotal); return wmsStockTotalMapper.selectWmsStockTotalJoinListBySaleOrder(wmsStockTotal);
} }
@ -138,41 +154,39 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
* @return * @return
*/ */
@Override @Override
public JSONObject selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal) public JSONObject selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal) {
{ List<WmsStockTotal> wmsStockTotals = wmsStockTotalMapper.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal);
List<WmsStockTotal> wmsStockTotals = wmsStockTotalMapper.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal);
// 使用流处理合并所有列表并计数(计算每个物料总库存数量) // 使用流处理合并所有列表并计数(计算每个物料总库存数量)
Map<Long, BigDecimal> totalAmountMap = wmsStockTotals.stream().filter(w->w.getTotalAmount()!=null) Map<Long, BigDecimal> totalAmountMap = wmsStockTotals.stream().filter(w -> w.getTotalAmount() != null)
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组 WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0 Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getTotalAmount, BigDecimal::add))); WmsStockTotal::getTotalAmount, BigDecimal::add)));
// 使用流处理合并所有列表并计数(计算每个物料总占用数量) // 使用流处理合并所有列表并计数(计算每个物料总占用数量)
Map<Long, BigDecimal> occupyAmountMap = wmsStockTotals.stream().filter(w->w.getOccupyAmount()!=null) Map<Long, BigDecimal> occupyAmountMap = wmsStockTotals.stream().filter(w -> w.getOccupyAmount() != null)
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组 WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0 Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getOccupyAmount, BigDecimal::add))); WmsStockTotal::getOccupyAmount, BigDecimal::add)));
// 使用流处理合并所有列表并计数(计算每个物料总使用数量) // 使用流处理合并所有列表并计数(计算每个物料总使用数量)
Map<Long, BigDecimal> realOutstockAmountMap = wmsStockTotals.stream().filter(w->w.getOutstockAmount()!=null) Map<Long, BigDecimal> realOutstockAmountMap = wmsStockTotals.stream().filter(w -> w.getOutstockAmount() != null)
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组 WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0 Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getOutstockAmount, BigDecimal::add))); WmsStockTotal::getOutstockAmount, BigDecimal::add)));
JSONObject returnObj = new JSONObject(); JSONObject returnObj = new JSONObject();
returnObj.put("totalAmountMap",totalAmountMap); returnObj.put("totalAmountMap", totalAmountMap);
returnObj.put("occupyAmountMap",occupyAmountMap); returnObj.put("occupyAmountMap", occupyAmountMap);
returnObj.put("outstockAmountMap",realOutstockAmountMap); returnObj.put("outstockAmountMap", realOutstockAmountMap);
return returnObj; return returnObj;
} }
/** /**
* Join material,warehouse,saleorder,totalAmount>0 * Join material,warehouse,saleorder,totalAmount>0
* *
@ -192,4 +206,246 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
} }
/**
*
*
* @param wmsStockTransferVo
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int transferRaw(WmsStockTransferVo wmsStockTransferVo) {
String[] indexStockIds = wmsStockTransferVo.getIndexStockIds();
String safeFlag = wmsStockTransferVo.getSafeFlag();
Long saleOrderId = wmsStockTransferVo.getSaleOrderId();
String saleorderCode = wmsStockTransferVo.getSaleorderCode();
List<MesBaseBarcodeInfo> mesBaseBarcodeInfos = new ArrayList<>();
for (String indexStockId : indexStockIds) {
String[] indexStockIdArr = indexStockId.split("-");
int index = Integer.parseInt(indexStockIdArr[0]) + 1;
Long rawStockId = Long.valueOf(indexStockIdArr[1]);
WmsRawStock wmsRawStock = wmsRawStockMapper.selectWmsRawStockByRawStockId(rawStockId);
if (!WmsConstants.WMS_RAW_STOCK_COMPLETE_FLAG_YES.equals(wmsRawStock.getCompleteFlag())) {
throw new ServiceException(String.format("序号%s,库存为拆分的物料,不能转", index));
}
MesBaseBarcodeInfo mesBaseBarcodeInfo = this.transferRawStock(wmsRawStock, saleOrderId, saleorderCode, safeFlag, index, TRANSFER_TYPE_RAW_STOCK);
mesBaseBarcodeInfos.add(mesBaseBarcodeInfo);
}
R<Boolean> transferBaseBarcodeInfosResult = remoteMesService.transferBaseBarcodeInfos(mesBaseBarcodeInfos, SecurityConstants.INNER);
if (!transferBaseBarcodeInfosResult.getData()) {
throw new RuntimeException("更新条码失败");
}
return 1;
}
public MesBaseBarcodeInfo transferRawStock(WmsRawStock wmsRawStock, Long saleOrderId, String saleorderCode, String safeFlag, int index, int transferType) {
if (transferType == TRANSFER_TYPE_RAW_STOCK) {
Long dbSaleOrderId = wmsRawStock.getSaleOrderId();
String dbSafeFlag = wmsRawStock.getSafeFlag();
if (dbSaleOrderId.equals(saleOrderId)) {
if (dbSafeFlag.equals(WmsConstants.WMS_SAFE_FLAG_YES)) {
throw new ServiceException(String.format("序号%s,库存已经是安全库存", index));
} else {
throw new ServiceException(String.format("序号%s,库存销售订单跟转库存的销售订单相同", index));
}
}
}
BigDecimal stockOccupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount();
BigDecimal stockFrozenAmount = wmsRawStock.getFrozenAmount() == null ? BigDecimal.ZERO : wmsRawStock.getFrozenAmount();
if (stockOccupyAmount.compareTo(BigDecimal.ZERO) > 0 || stockFrozenAmount.compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException(String.format("序号%s,库存有占用数量,不能转库存", index));
}
WmsStockTotal wmsStockTotal = this.getWmsStockTotalByUI(wmsRawStock);
BigDecimal stockTotalOccupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();
BigDecimal stockTotalFrozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();
if (stockTotalOccupyAmount.compareTo(BigDecimal.ZERO) > 0 || stockTotalFrozenAmount.compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException(String.format("序号%s,库存有占用数量,不能转库存", index));
}
if (transferType == TRANSFER_TYPE_RAW_STOCK) {
WmsBaseLocation baseLocation = wmsBaseLocationMapper.selectWmsBaseLocationByLocationCode(wmsRawStock.getLocationCode());
if (!baseLocation.getLocationStatus().equals(WmsConstants.WMS_BASE_LOCATION_STATUS_NORMAL)) {
String statusPrompt = WmsConstants.LOCATION_STATUS_PROMPT_MAP.get(baseLocation.getLocationStatus());
throw new ServiceException(String.format("序号%s,库位状态为%s", index, statusPrompt));
}
}
MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo();
mesBaseBarcodeInfo.setSaleOrderId(saleOrderId);
mesBaseBarcodeInfo.setSaleorderCode(saleorderCode);
mesBaseBarcodeInfo.setSafeFlag(safeFlag);
mesBaseBarcodeInfo.setBarcodeInfo(wmsRawStock.getInstockBatch());
wmsRawStock.setSafeFlag(safeFlag);
wmsRawStock.setSaleOrderId(saleOrderId);
wmsRawStock.setSaleorderCode(saleorderCode);
wmsRawStock.setUpdateDate(new Date());
wmsRawStock.setUpdateBy(SecurityUtils.getUsername());
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
return mesBaseBarcodeInfo;
}
private WmsStockTotal getWmsStockTotalByUI(WmsRawStock wmsRawStock) {
WmsStockTotal queryStockTotal = new WmsStockTotal();
queryStockTotal.setWarehouseId(wmsRawStock.getWarehouseId());
queryStockTotal.setMaterialId(wmsRawStock.getMaterialId());
queryStockTotal.setSaleOrderId(wmsRawStock.getSaleOrderId());
List<WmsStockTotal> wmsStockTotals = wmsStockTotalMapper.selectOnlyWmsStockTotalList(queryStockTotal);
return wmsStockTotals != null && !wmsStockTotals.isEmpty() ? wmsStockTotals.get(0) : null;
}
/**
*
*
* @param wmsStockTotalTransferVo
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int transferRawStockTotal(WmsStockTotalTransferVo wmsStockTotalTransferVo) {
BigDecimal transferAmount = wmsStockTotalTransferVo.getTransferAmount();
String safeFlag = wmsStockTotalTransferVo.getSafeFlag();
Long saleOrderId = wmsStockTotalTransferVo.getSaleOrderId();
String saleorderCode = wmsStockTotalTransferVo.getSaleorderCode();
WmsStockTotal wmsStockTotal = wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(wmsStockTotalTransferVo.getStockTotalId());
if (!wmsStockTotal.getStockType().equals(WmsConstants.RWA_STOCK_STOCK_TYPE_RAW)) {
throw new ServiceException("物料类型不对");
}
BigDecimal totalAmount = wmsStockTotal.getTotalAmount();
BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();
BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();
BigDecimal availableAmount = totalAmount.subtract(occupyAmount).subtract(frozenAmount);
if (transferAmount.compareTo(availableAmount) > 0) {
throw new ServiceException("转库存数量不能大于可用数量" + availableAmount);
}
if (wmsStockTotal.getSaleOrderId().equals(saleOrderId)) {
if (wmsStockTotal.getSafeFlag().equals(WmsConstants.WMS_SAFE_FLAG_YES)) {
throw new ServiceException(String.format("序号%s,库存已经是安全库存", wmsStockTotalTransferVo.getIndex()));
} else {
throw new ServiceException(String.format("序号%s,库存销售订单跟转库存的销售订单相同", wmsStockTotalTransferVo.getIndex()));
}
}
Long warehouseId = wmsStockTotal.getWarehouseId();
Long materialId = wmsStockTotal.getMaterialId();
WmsRawStock queryRawStock = new WmsRawStock();
queryRawStock.setMaterialId(materialId);
queryRawStock.setWarehouseId(warehouseId);
queryRawStock.setSaleOrderId(wmsStockTotal.getSaleOrderId());
Map<String, Object> params = new HashMap<>();
params.put("limit", transferAmount);
queryRawStock.setParams(params);
//先找浅库位,再找浅库位对应的深库位
List<WmsRawStock> wmsRawStocks = wmsRawStockMapper.selectWmsRawStocks4Transfer(queryRawStock);
if (wmsRawStocks == null || wmsRawStocks.isEmpty()) {
throw new ServiceException("没有可转库存明细");
}
if (wmsRawStocks.size() < transferAmount.intValue()) {
throw new ServiceException("可转库存明细数量为%s", wmsRawStocks.size());
}
List<MesBaseBarcodeInfo> mesBaseBarcodeInfos = new ArrayList<>();
for (WmsRawStock wmsRawStock : wmsRawStocks) {
MesBaseBarcodeInfo mesBaseBarcodeInfo = this.transferRawStock(wmsRawStock, saleOrderId, saleorderCode, safeFlag, wmsStockTotalTransferVo.getIndex(), TRANSFER_TYPE_STOCK_TOTAL);
mesBaseBarcodeInfos.add(mesBaseBarcodeInfo);
}
R<Boolean> transferBaseBarcodeInfosResult = remoteMesService.transferBaseBarcodeInfos(mesBaseBarcodeInfos, SecurityConstants.INNER);
if (!transferBaseBarcodeInfosResult.getData()) {
throw new RuntimeException("更新条码失败");
}
return 1;
}
/**
*
*
* @param wmsStockTotalTransferVo
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int transferProductStockTotal(WmsStockTotalTransferVo wmsStockTotalTransferVo) {
BigDecimal transferAmount = wmsStockTotalTransferVo.getTransferAmount();
String safeFlag = wmsStockTotalTransferVo.getSafeFlag();
Long saleOrderId = wmsStockTotalTransferVo.getSaleOrderId();
String saleorderCode = wmsStockTotalTransferVo.getSaleorderCode();
WmsStockTotal wmsStockTotal = wmsStockTotalMapper.selectWmsStockTotalByStockTotalId(wmsStockTotalTransferVo.getStockTotalId());
BigDecimal totalAmount = wmsStockTotal.getTotalAmount();
BigDecimal occupyAmount = wmsStockTotal.getOccupyAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getOccupyAmount();
BigDecimal frozenAmount = wmsStockTotal.getFrozenAmount() == null ? BigDecimal.ZERO : wmsStockTotal.getFrozenAmount();
BigDecimal availableAmount = totalAmount.subtract(occupyAmount).subtract(frozenAmount);
if (transferAmount.compareTo(availableAmount) > 0) {
throw new ServiceException("转库存数量不能大于可用数量" + availableAmount);
}
if (wmsStockTotal.getSaleOrderId().equals(saleOrderId)) {
if (wmsStockTotal.getSafeFlag().equals(WmsConstants.WMS_SAFE_FLAG_YES)) {
throw new ServiceException(String.format("序号%s,库存已经是安全库存", wmsStockTotalTransferVo.getIndex()));
} else {
throw new ServiceException(String.format("序号%s,库存销售订单跟转库存的销售订单相同", wmsStockTotalTransferVo.getIndex()));
}
}
Long warehouseId = wmsStockTotal.getWarehouseId();
Long materialId = wmsStockTotal.getMaterialId();
WmsProductStock queryProductStock = new WmsProductStock();
queryProductStock.setProductId(materialId);
queryProductStock.setWarehouseId(warehouseId);
queryProductStock.setSaleOrderId(wmsStockTotal.getSaleOrderId());
Map<String, Object> params = new HashMap<>();
params.put("limit", transferAmount);
queryProductStock.setParams(params);
//先找浅库位,再找浅库位对应的深库位
List<WmsProductStock> wmsProductStocks = wmsProductStockMapper.selectWmsProductStocks4Transfer(queryProductStock);
if (wmsProductStocks == null || wmsProductStocks.isEmpty()) {
throw new ServiceException("没有可转库存明细");
}
if (wmsProductStocks.size() < transferAmount.intValue()) {
throw new ServiceException("可转库存明细数量为%s", wmsProductStocks.size());
}
List<MesBaseBarcodeInfo> mesBaseBarcodeInfos = new ArrayList<>();
for (WmsProductStock wmsProductStock : wmsProductStocks) {
MesBaseBarcodeInfo mesBaseBarcodeInfo = new MesBaseBarcodeInfo();
mesBaseBarcodeInfo.setSaleOrderId(saleOrderId);
mesBaseBarcodeInfo.setSaleorderCode(saleorderCode);
mesBaseBarcodeInfo.setSafeFlag(safeFlag);
mesBaseBarcodeInfo.setBarcodeInfo(wmsProductStock.getProductBatch());
mesBaseBarcodeInfos.add(mesBaseBarcodeInfo);
wmsProductStock.setSafeFlag(safeFlag);
wmsProductStock.setSaleOrderId(saleOrderId);
wmsProductStock.setSaleorderCode(saleorderCode);
wmsProductStock.setUpdateDate(new Date());
wmsProductStock.setUpdateBy(SecurityUtils.getUsername());
wmsProductStockMapper.updateWmsProductStock(wmsProductStock);
}
MesSaleOrderTransferVo mesSaleOrderTransferVo = new MesSaleOrderTransferVo();
mesSaleOrderTransferVo.setTransferAmount(transferAmount);
mesSaleOrderTransferVo.setOldSaleOrderId(wmsStockTotal.getSaleOrderId());
mesSaleOrderTransferVo.setNewSaleOrderId(saleOrderId);
mesSaleOrderTransferVo.setMesBaseBarcodeInfos(mesBaseBarcodeInfos);
R<Boolean> transferBaseBarcodeInfosResult = remoteMesService.transferSaleOrders(mesSaleOrderTransferVo, SecurityConstants.INNER);
if (!transferBaseBarcodeInfosResult.getData()) {
throw new RuntimeException("销售订单信息转换失败");
}
return 1;
}
} }

@ -327,6 +327,21 @@
</select> </select>
<select id="selectWmsProductStocks4Transfer" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
select wps.product_stock_id,wps.sale_order_id,wps.product_batch
from wms_product_stock wps left join wms_base_location wbl on wps.location_code =wbl.location_code
<where>
and wps.total_amount=1 and wps.occupy_amount &lt;= 0 and wps.frozen_amount &lt;= 0 and wbl.location_status='1'
<if test="warehouseId != null ">and wps.warehouse_id = #{warehouseId}</if>
<if test="productId != null ">and wps.product_id = #{productId}</if>
<if test="saleOrderId != null and saleOrderId != ''">and wps.sale_order_id = #{saleOrderId}</if>
</where>
order by wbl.loc_column asc, wbl.loc_deep desc limit #{params.limit}
</select>
<!--select id="selectWmsProductStocksBySaleorder" parameterType="WmsProductStock" resultMap="WmsProductStockResult"> <!--select id="selectWmsProductStocksBySaleorder" parameterType="WmsProductStock" resultMap="WmsProductStockResult">
select wgb.warehouse_id,wgb.saleorder_code,wgb.product_id,mso.order_amount,wgb.total_amount,wgb.frozen_amount,wgb.occupy_amount,wbw.warehouse_name,mbmi.material_code,mbmi.material_name from mes_sale_order mso left join select wgb.warehouse_id,wgb.saleorder_code,wgb.product_id,mso.order_amount,wgb.total_amount,wgb.frozen_amount,wgb.occupy_amount,wbw.warehouse_name,mbmi.material_code,mbmi.material_name from mes_sale_order mso left join
(select wps.warehouse_id,wps.saleorder_code,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount from wms_product_stock wps where wps.total_amount>0 and wps.stock_type='3' (select wps.warehouse_id,wps.saleorder_code,wps.product_id,sum(total_amount) total_amount,sum(frozen_amount) frozen_amount,sum(occupy_amount) occupy_amount from wms_product_stock wps where wps.total_amount>0 and wps.stock_type='3'

@ -155,6 +155,8 @@
<if test="locationCode != null and locationCode != ''">location_code = #{locationCode},</if> <if test="locationCode != null and locationCode != ''">location_code = #{locationCode},</if>
<if test="stockType != null and stockType != ''">stock_type = #{stockType},</if> <if test="stockType != null and stockType != ''">stock_type = #{stockType},</if>
<if test="materialId != null">material_id = #{materialId},</if> <if test="materialId != null">material_id = #{materialId},</if>
<if test="saleOrderId != null">sale_order_id = #{saleOrderId},</if>
<if test="safeFlag != null and safeFlag != ''">safe_flag = #{safeFlag},</if>
<if test="instockBatch != null and instockBatch != ''">instock_batch = #{instockBatch},</if> <if test="instockBatch != null and instockBatch != ''">instock_batch = #{instockBatch},</if>
<if test="instockDate != null">instock_date = #{instockDate},</if> <if test="instockDate != null">instock_date = #{instockDate},</if>
<if test="lastOutstockTime != null">last_outstock_time = #{lastOutstockTime},</if> <if test="lastOutstockTime != null">last_outstock_time = #{lastOutstockTime},</if>
@ -349,4 +351,19 @@
order by wrs.instock_date desc order by wrs.instock_date desc
</select> </select>
<select id="selectWmsRawStocks4Transfer" parameterType="WmsRawStock" resultMap="WmsRawStockResult">
select wrs.raw_stock_id,wrs.sale_order_id,wrs.safe_flag,wrs.instock_batch from wms_raw_stock wrs left join wms_base_location wbl on wrs.location_code =wbl.location_code
<where>
and wrs.total_amount=1 and wrs.occupy_amount &lt;= 0 and wrs.frozen_amount &lt;= 0 and wbl.location_status='1'
<if test="warehouseId != null ">and wrs.warehouse_id = #{warehouseId}</if>
<if test="materialId != null ">and wrs.material_id = #{materialId}</if>
<if test="saleOrderId != null and saleOrderId != ''">and wrs.sale_order_id = #{saleOrderId}</if>
</where>
order by wbl.loc_column asc, wbl.loc_deep desc limit #{params.limit}
</select>
</mapper> </mapper>

@ -24,6 +24,7 @@
<result property="materialName" column="material_name"/> <result property="materialName" column="material_name"/>
<result property="materialSpec" column="material_spec"/> <result property="materialSpec" column="material_spec"/>
<result property="warehouseName" column="warehouse_name"/> <result property="warehouseName" column="warehouse_name"/>
<result property="batchFlag" column="batch_flag"/>
<result property="outstockAmount" column="outstock_amount"/> <result property="outstockAmount" column="outstock_amount"/>
<result property="saleorderCode" column="saleorder_code"/> <result property="saleorderCode" column="saleorder_code"/>
</resultMap> </resultMap>
@ -63,6 +64,7 @@
wst.stock_type, wst.stock_type,
wst.material_id, wst.material_id,
wst.sale_order_id, wst.sale_order_id,
wst.safe_flag,
mbmi.material_code, mbmi.material_code,
mbmi.material_name, mbmi.material_name,
wst.total_amount, wst.total_amount,
@ -231,6 +233,7 @@
mbmi.material_code, mbmi.material_code,
mbmi.material_name, mbmi.material_name,
mbmi.material_spec, mbmi.material_spec,
mbmi.batch_flag,
wst.total_amount, wst.total_amount,
wst.frozen_amount, wst.frozen_amount,
wst.occupy_amount, wst.occupy_amount,

@ -61,6 +61,25 @@ export function productOrderPublish(data) {
}) })
} }
//暂停
export function productOrderPause(data) {
return request({
url: '/mes/productOrder/productOrderPause',
method: 'post',
data: data
})
}
//继续
export function productOrderContinue(data) {
return request({
url: '/mes/productOrder/productOrderContinue',
method: 'post',
data: data
})
}
//撤回 //撤回
export function productOrderRecall(data) { export function productOrderRecall(data) {
return request({ return request({

@ -60,3 +60,32 @@ export function listProductstock(query) {
params: query params: query
}) })
} }
// 原材料库位库存转销售订单或安全库存
export function transferRaw(data) {
return request({
url: '/wms/stocktotal/transferRaw',
method: 'post',
data: data
})
}
// 原材料总库存转销售订单或安全库存
export function transferRawStockTotal(data) {
return request({
url: '/wms/stocktotal/transferRawStockTotal',
method: 'post',
data: data
})
}
// 成品总库存转销售订单或安全库存
export function transferProductStockTotal(data) {
return request({
url: '/wms/stocktotal/transferProductStockTotal',
method: 'post',
data: data
})
}

@ -91,7 +91,7 @@
<!-- v-hasPermi="['mes:saleOrder:export']"--> <!-- v-hasPermi="['mes:saleOrder:export']"-->
<!-- >导出</el-button>--> <!-- >导出</el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>-->
</el-row> </el-row>
<el-table v-loading="loading" :data="saleOrderList" @selection-change="handleSelectionChange" <el-table v-loading="loading" :data="saleOrderList" @selection-change="handleSelectionChange"

@ -247,7 +247,7 @@
size="mini" size="mini"
type="text" type="text"
icon="el-icon-video-pause" icon="el-icon-video-pause"
v-if="scope.row.orderStatus===MES_ORDER_STATUS.STARTED" v-if="scope.row.orderStatus===MES_ORDER_STATUS.STARTED || scope.row.orderStatus === MES_ORDER_STATUS.PUBLISHED"
@click="handlePause(scope.row)" @click="handlePause(scope.row)"
v-hasPermi="['mes:productOrder:pause']" v-hasPermi="['mes:productOrder:pause']"
>暂停 >暂停
@ -567,7 +567,7 @@ import {
addProductOrder, addProductOrder,
updateProductOrder, updateProductOrder,
getMaterialUsages, getStockTotalWithRawOutstocks, getMaterialUsages, getStockTotalWithRawOutstocks,
getOrderCode, productOrderLockInventory, productOrderPublish, productOrderRecall getOrderCode, productOrderLockInventory, productOrderPublish, productOrderPause,productOrderContinue,productOrderRecall
} from "@/api/mes/productOrder"; } from "@/api/mes/productOrder";
import addSaleOrder from '@//views/mes/productOrder/addSaleOrder.vue'; import addSaleOrder from '@//views/mes/productOrder/addSaleOrder.vue';
import {getMaterialVisionList} from "@//api/mes/materialBom"; import {getMaterialVisionList} from "@//api/mes/materialBom";
@ -771,9 +771,10 @@ export default {
}; };
}, },
activated() { activated() {
if (this.$route.query.queryParams != null) { if (this.$route.query.queryParams != null && this.$route.query.queryParams.pageSize) {
this.queryParams = {...this.$route.query.queryParams} this.queryParams = {...this.$route.query.queryParams}
} }
this.getList(); this.getList();
}, },
created() { created() {
@ -1188,11 +1189,31 @@ export default {
/** 暂停 */ /** 暂停 */
handlePause(row) { handlePause(row) {
this.form.productOrderId = row.productOrderId;
this.$modal.confirm('是否确认暂停生产任务编号为"' + row.orderCode + '"的数据项?').then(function () {
return true;
}).then(() => {
productOrderPause(this.form).then(response => {
this.getList();
this.$modal.msgSuccess("暂停成功");
});
}).catch(() => {
this.getList();
});
}, },
handleContinue(row) { handleContinue(row) {
this.form.productOrderId = row.productOrderId;
this.$modal.confirm('是否确认继续开始生产任务编号为"' + row.orderCode + '"的数据项?').then(function () {
return true;
}).then(() => {
productOrderContinue(this.form).then(response => {
this.getList();
this.$modal.msgSuccess("继续开始成功");
});
}).catch(() => {
this.getList();
});
}, },
// handlePublish(row) { // handlePublish(row) {

@ -1,10 +1,10 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">--> <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">-->
<!-- <el-form-item label="工单编号" prop="orderCode">--> <!-- <el-form-item label="任务编号" prop="orderCode">-->
<!-- <el-input--> <!-- <el-input-->
<!-- v-model="queryParams.orderCode"--> <!-- v-model="queryParams.orderCode"-->
<!-- placeholder="请输入工单编号"--> <!-- placeholder="请输入任务编号"-->
<!-- clearable--> <!-- clearable-->
<!-- @keyup.enter.native="handleQuery"--> <!-- @keyup.enter.native="handleQuery"-->
<!-- />--> <!-- />-->
@ -54,7 +54,6 @@
>关闭 >关闭
</el-button> </el-button>
</el-col> </el-col>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-radio-group v-model="arrangeType">--> <!-- <el-radio-group v-model="arrangeType">-->
<!-- <el-radio--> <!-- <el-radio-->
@ -76,9 +75,27 @@
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<el-table-column label="工单编号" prop="orderCode" v-if="columns[1].visible" width="250"/> <el-table-column label="任务编号" prop="orderCode" v-if="columns[1].visible" width="250"/>
<el-table-column label="销售类型" align="center" prop="saleType" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_sale_type" :value="scope.row.saleType"/>
</template>
</el-table-column>
<el-table-column label="销售订单编号" align="center" prop="saleorderCode" width="100"/>
<el-table-column label="成品编号" align="center" prop="materialCode" width="100"/>
<el-table-column label="成品名称" align="center" prop="materialName" width="100"/>
<el-table-column label="成品规格" align="center" prop="materialSpec" width="100"/>
<el-table-column label="成品BOM" align="center" prop="materialBomDesc" width="120"/>
<el-table-column label="工艺路线" align="center" prop="dispatchName" width="120"/>
<el-table-column label="计划编号" prop="planCode" v-if="columns[31].visible" width="180"/> <el-table-column label="计划编号" prop="planCode" v-if="columns[31].visible" width="180"/>
<el-table-column label="前置生产工单编号" align="center" prop="preOrderCode" v-if="columns[32].visible" width="180"/> <el-table-column label="前置任务编号" align="center" prop="preOrderCode" v-if="columns[32].visible" width="180"/>
<el-table-column label="销售订单ID" align="center" prop="saleOrderId" v-if="columns[2].visible" width="100"/> <el-table-column label="销售订单ID" align="center" prop="saleOrderId" v-if="columns[2].visible" width="100"/>
<el-table-column label="销售订单标识" align="center" prop="saleOrderFlag" v-if="columns[3].visible" width="100"/> <el-table-column label="销售订单标识" align="center" prop="saleOrderFlag" v-if="columns[3].visible" width="100"/>
<el-table-column label="销售订单编号" align="center" prop="saleorderCode" v-if="columns[4].visible" width="120"/> <el-table-column label="销售订单编号" align="center" prop="saleorderCode" v-if="columns[4].visible" width="120"/>
@ -146,10 +163,10 @@
<span>{{ parseTime(scope.row.realEndTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span> <span>{{ parseTime(scope.row.realEndTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="工单状态" align="center" prop="orderStatus" v-if="columns[22].visible"/> <el-table-column label="任务状态" align="center" prop="orderStatus" v-if="columns[22].visible"/>
<el-table-column label="库存锁定标识" align="center" prop="stockLockFlag" v-if="columns[23].visible"/> <el-table-column label="库存锁定标识" align="center" prop="stockLockFlag" v-if="columns[23].visible"/>
<el-table-column label="备注" align="center" prop="remark" v-if="columns[24].visible"/> <el-table-column label="备注" align="center" prop="remark" v-if="columns[24].visible"/>
<el-table-column label="前置生产工单ID" align="center" prop="preOrderId" v-if="columns[29].visible"/> <el-table-column label="前置生产任务ID" align="center" prop="preOrderId" v-if="columns[29].visible"/>
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">--> <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- <el-button--> <!-- <el-button-->
@ -177,11 +194,11 @@
<!-- </el-table-column>--> <!-- </el-table-column>-->
</el-table> </el-table>
<!-- 添加或修改生产工单;生产工单对话框 --> <!-- 添加或修改生产任务;生产任务对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="工单编号" prop="orderCode"> <el-form-item label="任务编号" prop="orderCode">
<el-input v-model="form.orderCode" placeholder="请输入工单编号"/> <el-input v-model="form.orderCode" placeholder="请输入任务编号"/>
</el-form-item> </el-form-item>
<el-form-item label="销售订单ID" prop="saleOrderId"> <el-form-item label="销售订单ID" prop="saleOrderId">
<el-input v-model="form.saleOrderId" placeholder="请输入销售订单ID"/> <el-input v-model="form.saleOrderId" placeholder="请输入销售订单ID"/>
@ -279,9 +296,9 @@
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item> </el-form-item>
<el-form-item label="前置生产工单ID" prop="preOrderId"> <el-form-item label="前置生产任务ID" prop="preOrderId">
<treeselect v-model="form.preOrderId" :options="productOrderOptions" :normalizer="normalizer" <treeselect v-model="form.preOrderId" :options="productOrderOptions" :normalizer="normalizer"
placeholder="请选择前置生产工单ID" placeholder="请选择前置生产任务ID"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -794,9 +811,9 @@ export default {
loading: true, loading: true,
// //
showSearch: true, showSearch: true,
// ; // ;
productOrderList: [], productOrderList: [],
// ; // ;
productOrderOptions: [], productOrderOptions: [],
// //
title: '', title: '',
@ -843,7 +860,7 @@ export default {
// //
rules: { rules: {
orderCode: [ orderCode: [
{ required: true, message: '工单编号不能为空', trigger: 'blur' } { required: true, message: '任务编号不能为空', trigger: 'blur' }
], ],
saleOrderFlag: [ saleOrderFlag: [
{ required: true, message: '销售订单标识不能为空', trigger: 'blur' } { required: true, message: '销售订单标识不能为空', trigger: 'blur' }
@ -854,7 +871,7 @@ export default {
}, },
columns: [ columns: [
{ key: 0, label: `主键标识`, visible: false }, { key: 0, label: `主键标识`, visible: false },
{ key: 1, label: `工单编号`, visible: true }, { key: 1, label: `任务编号`, visible: true },
{ key: 2, label: `销售订单ID`, visible: false }, { key: 2, label: `销售订单ID`, visible: false },
{ key: 3, label: `销售订单标识`, visible: false }, { key: 3, label: `销售订单标识`, visible: false },
{ key: 4, label: `销售订单编号`, visible: false }, { key: 4, label: `销售订单编号`, visible: false },
@ -875,17 +892,17 @@ export default {
{ key: 19, label: `计划结束时间`, visible: false }, { key: 19, label: `计划结束时间`, visible: false },
{ key: 20, label: `开始时间`, visible: false }, { key: 20, label: `开始时间`, visible: false },
{ key: 21, label: `完成时间`, visible: false }, { key: 21, label: `完成时间`, visible: false },
{ key: 22, label: `工单状态`, visible: false }, { key: 22, label: `任务状态`, visible: false },
{ key: 23, label: `库存锁定标识`, visible: false }, { key: 23, label: `库存锁定标识`, visible: false },
{ key: 24, label: `备注`, visible: false }, { key: 24, label: `备注`, visible: false },
{ key: 25, label: `创建人`, visible: false }, { key: 25, label: `创建人`, visible: false },
{ key: 26, label: `创建时间`, visible: false }, { key: 26, label: `创建时间`, visible: false },
{ key: 27, label: `更新人`, visible: false }, { key: 27, label: `更新人`, visible: false },
{ key: 28, label: `更新时间`, visible: false }, { key: 28, label: `更新时间`, visible: false },
{ key: 29, label: `前置生产工单ID`, visible: false }, { key: 29, label: `前置生产任务ID`, visible: false },
{ key: 30, label: `工期(天)`, visible: true }, { key: 30, label: `工期(天)`, visible: true },
{ key: 31, label: `计划编号`, visible: true }, { key: 31, label: `计划编号`, visible: true },
{ key: 32, label: `前置生产工单编号`, visible: true }, { key: 32, label: `前置生产任务编号`, visible: true },
{ key: 33, label: `计划开始结束时间`, visible: true } { key: 33, label: `计划开始结束时间`, visible: true }
] ]
} }
@ -907,7 +924,7 @@ export default {
} }
}, },
methods: { methods: {
/** 查询生产工单;生产工单列表 */ /** 查询生产任务;生产任务列表 */
getList() { getList() {
this.loading = true this.loading = true
allListProductOrder(this.queryParams).then(response => { allListProductOrder(this.queryParams).then(response => {
@ -916,7 +933,7 @@ export default {
this.loading = false this.loading = false
}); });
}, },
/** 转换生产工单;生产工单数据结构 */ /** 转换生产任务;生产任务数据结构 */
normalizer(node) { normalizer(node) {
if (node.children && !node.children.length) { if (node.children && !node.children.length) {
delete node.children delete node.children
@ -927,7 +944,7 @@ export default {
children: node.children children: node.children
} }
}, },
/** 查询生产工单;生产工单下拉树结构 */ /** 查询生产任务;生产任务下拉树结构 */
getTreeselect() { getTreeselect() {
// allListProductOrder().then(response => { // allListProductOrder().then(response => {
let response = a let response = a
@ -1006,7 +1023,7 @@ export default {
this.form.preOrderId = 0 this.form.preOrderId = 0
} }
this.open = true this.open = true
this.title = '添加生产工单' this.title = '添加生产任务'
}, },
/** 保存按钮操作 */ /** 保存按钮操作 */
handleSave() { handleSave() {
@ -1017,7 +1034,7 @@ export default {
this.getList(); this.getList();
}); });
}else{ }else{
this.$modal.msgError('生产派工单计划时间范围超出生产工单计划时间范围!') this.$modal.msgError('生产派工计划时间范围超出生产任务计划时间范围!')
} }
}, },
extractFields(data) { extractFields(data) {
@ -1080,7 +1097,7 @@ export default {
getProductOrder(row.productOrderId).then(response => { getProductOrder(row.productOrderId).then(response => {
this.form = response.data this.form = response.data
this.open = true this.open = true
this.title = '修改生产工单' this.title = '修改生产任务'
}) })
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -1105,7 +1122,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm('是否确认删除生产工单;生产工单编号为"' + row.productOrderId + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除生产任务;生产任务编号为"' + row.productOrderId + '"的数据项?').then(function() {
return delProductOrder(row.productOrderId) return delProductOrder(row.productOrderId)
}).then(() => { }).then(() => {
this.getList() this.getList()

@ -101,15 +101,21 @@
<!--el-table-column type="selection" width="55" align="center"/--> <!--el-table-column type="selection" width="55" align="center"/-->
<!-- <el-table-column label="总库存ID" align="center" prop="stockTotalId"/>--> <!-- <el-table-column label="总库存ID" align="center" prop="stockTotalId"/>-->
<!-- <el-table-column label="仓库ID" align="center" prop="warehouseId"/>--> <!-- <el-table-column label="仓库ID" align="center" prop="warehouseId"/>-->
<el-table-column label="序号" type="index" align="center"/>
<el-table-column label="仓库名称" align="center" prop="warehouseName"/> <el-table-column label="仓库名称" align="center" prop="warehouseName"/>
<el-table-column label="仓库楼层" align="center" prop="warehouseFloor"/> <el-table-column label="仓库楼层" align="center" prop="warehouseFloor"/>
<!-- <el-table-column label="库存类型" align="center" prop="stockType"/>--> <!-- <el-table-column label="库存类型" align="center" prop="stockType"/>-->
<el-table-column label="物料编码" align="center" prop="materialCode"/> <el-table-column label="物料编码" align="center" prop="materialCode"/>
<el-table-column label="物料名称" align="center" prop="materialName"/> <el-table-column label="物料名称" align="center" prop="materialName"/>
<el-table-column label="物料规格" align="center" prop="materialSpec"/> <el-table-column label="物料规格" align="center" prop="materialSpec"/>
<el-table-column label="批次标识" align="center" prop="batchFlag">
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_material_batch_flag" :value="scope.row.batchFlag"/>
</template>
</el-table-column>
<el-table-column label="安全库存" align="center" prop="safeFlag" width="80"> <el-table-column label="安全库存" align="center" prop="safeFlag" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.saleOrderId === 0 ? "是" :"否"}} {{ scope.row.saleOrderId === 0 ? "是" : "否" }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="销售订单" align="center" prop="saleorderCode"/> <el-table-column label="销售订单" align="center" prop="saleorderCode"/>
@ -127,6 +133,29 @@
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<!-- <el-table-column label="有效标记" align="center" prop="activeFlag"/>--> <!-- <el-table-column label="有效标记" align="center" prop="activeFlag"/>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-shopping-cart-1"
v-if="scope.row.batchFlag === BATCH_FLAG.NO && type === STOCK_TYPE.RAW"
@click="handleStockTotalTransfer(scope.row)"
v-hasPermi="['wms:stocktotal:transfer']"
>转库存
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-shopping-cart-1"
v-if="scope.row.batchFlag === BATCH_FLAG.NO && type === STOCK_TYPE.PRODUCT"
@click="handleStockTotalTransfer(scope.row)"
v-hasPermi="['wms:stocktotal:transferProduct']"
>转库存
</el-button>
</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="total>0" v-show="total>0"
@ -141,9 +170,27 @@
<el-col :span="20" :offset="4" :xs="20"> <el-col :span="20" :offset="4" :xs="20">
<el-divider content-position="center">库位库存明细信息</el-divider> <el-divider content-position="center">库位库存明细信息</el-divider>
<el-table v-loading="loadingTwo" :data="rawstockList" @selection-change="handleSelectionChange"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-shopping-cart-1"
size="mini"
@click="handleTransfer"
v-hasPermi="['wms:stocktotal:transfer']"
v-if="type === STOCK_TYPE.RAW"
>转库存
</el-button>
</el-col>
</el-row>
<el-table v-loading="loadingTwo" :data="rawstockList" @selection-change="handleRawStockSelectionChange">
<!-- <el-table-column label="原材料库存ID" align="center" prop="rawStockId" />--> <!-- <el-table-column label="原材料库存ID" align="center" prop="rawStockId" />-->
<!-- <el-table-column label="仓库ID" align="center" prop="warehouseId"/>--> <!-- <el-table-column label="仓库ID" align="center" prop="warehouseId"/>-->
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="序号" type="index" align="center" />
<el-table-column label="仓库名称" align="center" prop="warehouseName" width="120" v-if="columns[0].visible"/> <el-table-column label="仓库名称" align="center" prop="warehouseName" width="120" v-if="columns[0].visible"/>
<el-table-column label="库位编码" align="center" prop="locationCode" v-if="columns[2].visible"/> <el-table-column label="库位编码" align="center" prop="locationCode" v-if="columns[2].visible"/>
<!-- <el-table-column label="库存类型" align="center" prop="stockType"/>--> <!-- <el-table-column label="库存类型" align="center" prop="stockType"/>-->
@ -159,10 +206,10 @@
<el-table-column label="安全库存" align="center" prop="safeFlag" width="80" <el-table-column label="安全库存" align="center" prop="safeFlag" width="80"
v-if="columns[15].visible"> v-if="columns[15].visible">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.saleOrderId === 0 ? "是" :"否"}} {{ scope.row.saleOrderId === 0 ? "是" : "否" }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="物料条码" align="center" prop="instockBatch" width="100" v-if="columns[5].visible"/> <el-table-column label="物料条码" align="center" :prop="columns[5].prop" width="100" v-if="columns[5].visible"/>
<el-table-column label="容器码" align="center" prop="palletInfoCode" width="120" <el-table-column label="容器码" align="center" prop="palletInfoCode" width="120"
v-if="columns[6].visible"/> v-if="columns[6].visible"/>
<el-table-column label="入库时间" align="center" prop="instockDate" width="180"> <el-table-column label="入库时间" align="center" prop="instockDate" width="180">
@ -173,7 +220,7 @@
<el-table-column label="总数量" align="center" prop="totalAmount" v-if="columns[7].visible"/> <el-table-column label="总数量" align="center" prop="totalAmount" v-if="columns[7].visible"/>
<el-table-column label="完整标识" align="center" prop="completeFlag" v-if="columns[17].visible"> <el-table-column label="完整标识" align="center" prop="completeFlag" v-if="columns[17].visible">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.wms_stock_complete_flag" :value="scope.row.safeFlag"/> <dict-tag :options="dict.type.wms_stock_complete_flag" :value="scope.row.completeFlag"/>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -187,24 +234,79 @@
</el-col> </el-col>
</el-row> </el-row>
<!-- 添加或修改库位对话框 -->
<el-dialog title="转库存" :visible.sync="open" width="660px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-form-item label="安全库存标识" prop="safeFlag">
<el-radio-group v-model="form.safeFlag">
<el-radio
v-for="dict in dict.type.mes_safe_flag"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="销售订单号" prop="saleorderCode" v-if="form.safeFlag === SAFE_FLAG.NO">
<el-input v-model="form.saleorderCode" placeholder="请点击右侧检索采购订单" readonly>
<el-button slot="append" icon="el-icon-search" @click="handleSaleOrderSelect"></el-button>
</el-input>
</el-form-item>
<el-form-item label="待转数量" prop="transferAmount" v-if="this.transferType==='1'">
<el-input-number v-model="form.transferAmount" placeholder="请输入待转库存数量"/>
</el-form-item>
<!--el-form-item label="销售订单ID" prop="saleOrderId">
<el-input v-model="form.saleOrderId"/>
</el-form-item-->
<el-form-item label="待转库信息" prop="saleOrderId">
<span v-html="rawStockInfosStr"></span>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 选择销售订单对话框 -->
<el-dialog title="选择销售订单" :visible.sync="selectSaleOrderVisible" append-to-body>
<select-sale-order ref="selectSaleOrderRef" v-if="selectSaleOrderVisible"></select-sale-order>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitSelectSaleOrderForm"> </el-button>
<el-button @click="selectSaleOrderVisible = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { import {
listStocktotal, listStocktotal,
getStocktotal,
delStocktotal, delStocktotal,
addStocktotal,
updateStocktotal,
listRawstock, listRawstock,
listProductstock listProductstock,
transferRaw,
transferRawStockTotal,
transferProductStockTotal
} from "@/api/wms/stocktotal"; } from "@/api/wms/stocktotal";
import {getWarehouses} from "@//api/wms/wmslocation"; import {addWmslocation, getWarehouses, updateWmslocation} from "@//api/wms/wmslocation";
import selectSaleOrder from '@//views/mes/saleOrder/selectSaleOrder.vue';
export default { export default {
name: "Stocktotal", name: "Stocktotal",
dicts: ['mes_safe_flag', 'wms_stock_complete_flag'], components: {
'select-sale-order': selectSaleOrder
},
dicts: ['mes_safe_flag', 'wms_stock_complete_flag','mes_material_batch_flag'],
data() { data() {
return { return {
// //
@ -228,6 +330,9 @@ export default {
title: "", title: "",
// //
open: false, open: false,
//
transferType: '',
rowIndex:0,
// =1=2 // =1=2
type: null, type: null,
// List // List
@ -240,6 +345,9 @@ export default {
children: "children", children: "children",
label: "warehouseName" label: "warehouseName"
}, },
rawStockIds: [],
rawStockInfos: [],
rawStockInfosStr: '',
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -265,6 +373,16 @@ export default {
}, },
// //
form: {}, form: {},
//
rules: {
safeFlag: [
{required: true, message: "安全库存标识不能为空", trigger: "change"}
],
saleorderCode: [
{required: true, message: "销售订单不能为空", trigger: "change"}
],
},
// //
rawstockList: [], rawstockList: [],
// //
@ -273,7 +391,18 @@ export default {
RAW: "1", RAW: "1",
SEMI: "2", SEMI: "2",
PRODUCT: "3", PRODUCT: "3",
} },
SAFE_FLAG: {
YES: "1",
NO: "0"
},
BATCH_FLAG: {
YES: "1",
NO: "0"
}, //
selectSaleOrderVisible: false,
}; };
}, },
watch: { watch: {
@ -294,7 +423,7 @@ export default {
{key: 2, label: `库位编码`, visible: true}, {key: 2, label: `库位编码`, visible: true},
{key: 3, label: `物料编码`, visible: true}, {key: 3, label: `物料编码`, visible: true},
{key: 4, label: `物料名称`, visible: true}, {key: 4, label: `物料名称`, visible: true},
{key: 5, label: `物料条码`, visible: true}, {key: 5, label: `物料条码`, visible: true, prop:'instockBatch'},
{key: 6, label: `托盘码`, visible: true}, {key: 6, label: `托盘码`, visible: true},
{key: 7, label: `总数量`, visible: true}, {key: 7, label: `总数量`, visible: true},
{key: 8, label: `占用数量`, visible: true}, {key: 8, label: `占用数量`, visible: true},
@ -310,7 +439,7 @@ export default {
] ]
} }
if (this.type === this.STOCK_TYPE.PRODUCT) { if (this.type === this.STOCK_TYPE.PRODUCT) {
this.queryParams.stockTypeStr = this.STOCK_TYPE.SEMI +","+ this.STOCK_TYPE.PRODUCT; this.queryParams.stockTypeStr = this.STOCK_TYPE.SEMI + "," + this.STOCK_TYPE.PRODUCT;
this.columns = this.columns =
[ [
{key: 0, label: `仓库名称`, visible: true}, {key: 0, label: `仓库名称`, visible: true},
@ -318,7 +447,7 @@ export default {
{key: 2, label: `库位编码`, visible: true}, {key: 2, label: `库位编码`, visible: true},
{key: 3, label: `物料编码`, visible: true}, {key: 3, label: `物料编码`, visible: true},
{key: 4, label: `物料名称`, visible: true}, {key: 4, label: `物料名称`, visible: true},
{key: 5, label: `物料条码`, visible: true}, {key: 5, label: `物料条码`, visible: true,prop:'productBatch'},
{key: 6, label: `托盘码`, visible: true}, {key: 6, label: `托盘码`, visible: true},
{key: 7, label: `总数量`, visible: true}, {key: 7, label: `总数量`, visible: true},
{key: 8, label: `占用数量`, visible: true}, {key: 8, label: `占用数量`, visible: true},
@ -377,25 +506,7 @@ export default {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
//
reset() {
this.form = {
stockTotalId: null,
warehouseId: null,
warehouseFloor: null,
stockType: null,
materialId: null,
totalAmount: null,
frozenAmount: null,
occupyAmount: null,
createBy: null,
createDate: null,
updateBy: null,
updateDate: null,
activeFlag: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
@ -435,10 +546,10 @@ export default {
this.loading = true; this.loading = true;
this.loadingTwo = true; this.loadingTwo = true;
let query; let query;
if(this.type === this.STOCK_TYPE.RAW){ if (this.type === this.STOCK_TYPE.RAW) {
query = {warehouseInstockType: this.type} query = {warehouseInstockType: this.type}
}else if(this.type===this.STOCK_TYPE.PRODUCT){ } else if (this.type === this.STOCK_TYPE.PRODUCT) {
query = {warehouseInstockTypeStr: this.STOCK_TYPE.SEMI+","+this.STOCK_TYPE.PRODUCT} query = {warehouseInstockTypeStr: this.STOCK_TYPE.SEMI + "," + this.STOCK_TYPE.PRODUCT}
} }
getWarehouses(query).then(response => { getWarehouses(query).then(response => {
@ -467,7 +578,105 @@ export default {
this.download('wms/stocktotal/export', { this.download('wms/stocktotal/export', {
...this.queryParams ...this.queryParams
}, `stocktotal_${new Date().getTime()}.xlsx`) }, `stocktotal_${new Date().getTime()}.xlsx`)
} },
//
reset() {
this.form = {
safeFlag: null,
saleorderCode: null,
saleOrderId: null,
stockTotalId: null,
transferAmount: null,
index:null,
};
this.resetForm("form");
},
//
handleRawStockSelectionChange(selection) {
this.rawStockIds = selection.map((item, index) => index + "-" + item.rawStockId);
this.rawStockInfos = selection.map((item, index) => "序号:" + (index + 1) + " 物料编码:" + item.materialCode + " 物料名称:" + item.materialName + " 物料规格:" + item.materialSpec + " 数量:" + item.totalAmount + " 销售订单:" + (item.saleorderCode ? item.saleorderCode : "无"))
this.single = selection.length !== 1
this.multiple = !selection.length
},
handleTransfer() {
this.reset();
this.transferType = "2";
this.rawStockInfosStr = this.rawStockInfos.join("<br>");
this.open = true;
},
handleSaleOrderSelect() {
this.selectSaleOrderVisible = true;
},
/** 提交选择销售订单按钮 */
submitSelectSaleOrderForm() {
let selectedRow = this.$refs.selectSaleOrderRef.selectedRow;
this.$set(this.form, "saleorderCode", selectedRow.saleorderCode);
this.$set(this.form, "saleOrderId", selectedRow.saleOrderId);
this.selectSaleOrderVisible = false;
},
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.safeFlag === this.SAFE_FLAG.YES) {
this.form.saleOrderId = 0;
this.form.saleorderCode = null;
}
if (this.type === this.STOCK_TYPE.PRODUCT){
transferProductStockTotal(this.form).then(response => {
this.$modal.msgSuccess("转库存成功");
this.open = false;
this.getList();
this.getTwoList();
});
}else if (this.type === this.STOCK_TYPE.RAW){
if(this.transferType==='1'){
transferRawStockTotal(this.form).then(response => {
this.$modal.msgSuccess("转库存成功");
this.open = false;
this.getList();
this.getTwoList();
});
}else if(this.transferType==='2'){
this.form.indexStockIds = this.rawStockIds;
transferRaw(this.form).then(response => {
this.$modal.msgSuccess("转库存成功");
this.open = false;
this.getList();
this.getTwoList();
});
}
}
}
});
},
handleStockTotalTransfer(row) {
this.reset();
this.transferType = "1";
this.form.index = (this.stocktotalList.findIndex(item => item.stockTotalId === row.stockTotalId))+1;
this.form.stockTotalId = row.stockTotalId;
this.rawStockInfosStr = "序号:"+this.form.index+" 物料编码:" + row.materialCode + " 物料名称:" + row.materialName + " 物料规格:" + row.materialSpec + " 可转数量:" + (row.totalAmount - (row.occupyAmount ? row.occupyAmount : 0)) + " 销售订单:" + (row.saleorderCode ? row.saleorderCode : "无");
this.open = true;
},
} }
}; };
</script> </script>
<style lang="less" scoped>
.app-container{
overflow: auto;
height: calc(100vh - 83px);
}
</style>

Loading…
Cancel
Save