diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java index 11ebac1..44bbf5f 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/controller/WmsMobileController.java @@ -161,7 +161,7 @@ public class WmsMobileController extends BaseController { @Log(title = "原材料退库记录", businessType = BusinessType.CONFIRM) @PostMapping(("/confirmRawReturn")) public AjaxResult confirmRawReturn(@Validated @RequestBody WmsRawReturnConfirmVo wmsRawReturnConfirmVo) { - return toAjax(wmsRawReturnService.confirmWmsRawOutstock(wmsRawReturnConfirmVo)); + return toAjax(wmsRawReturnService.confirmWmsRawReturn(wmsRawReturnConfirmVo)); } } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawOutstockConfirmVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawOutstockConfirmVo.java index adbb193..785d5b1 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawOutstockConfirmVo.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawOutstockConfirmVo.java @@ -22,9 +22,9 @@ public class WmsRawOutstockConfirmVo { @NotBlank(message = "库位编码必须输入") private String locationCode; - //物料条码 - @NotBlank(message = "物料条码必须输入") - private String materialBarcode; + //物料批次 + @NotBlank(message = "批次必须输入") + private String instockBatch; //原材料出库数量 @NotNull(message = "原材料出库数量必须输入") diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawReturnConfirmVo.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawReturnConfirmVo.java index 2fdd55d..3a82ac3 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawReturnConfirmVo.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/domain/vo/WmsRawReturnConfirmVo.java @@ -23,8 +23,8 @@ public class WmsRawReturnConfirmVo { private String locationCode; //物料条码 - @NotBlank(message = "物料条码必须输入") - private String materialBarcode; + @NotBlank(message = "批次号必须输入") + private String instockBatch; //原材料出库数量 @NotNull(message = "原材料退库数量必须输入") diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawReturnService.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawReturnService.java index ac8c73f..0beb03a 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawReturnService.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/IWmsRawReturnService.java @@ -85,7 +85,7 @@ public interface IWmsRawReturnService * @param wmsRawReturnConfirmVo * @return */ - public int confirmWmsRawOutstock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo); + public int confirmWmsRawReturn(WmsRawReturnConfirmVo wmsRawReturnConfirmVo); /** * 查询原材料退记录明细列表,供手持出库使用 diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java index 37d4c4f..8b165f6 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawOutstockServiceImpl.java @@ -174,21 +174,52 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { * 审核原材料出库记录 * * @param wmsRawOutstockAuditVo + * @return */ + @Transactional @Override public int auditWmsRawOutstock(WmsRawOutstockAuditVo wmsRawOutstockAuditVo) { String auditStatus = wmsRawOutstockAuditVo.getAuditStatus(); String auditReason = wmsRawOutstockAuditVo.getAuditReason(); - if (WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_FAIL.equals(auditStatus) && StringUtils.isEmpty(auditReason)) { - throw new ServiceException("请输入审核意见"); - } - + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); WmsRawOutstock wmsRawOutstock = wmsRawOutstockMapper.selectWmsRawOutstockByRawOutstockId(wmsRawOutstockAuditVo.getRawOutstockId()); wmsRawOutstock.setAuditStatus(auditStatus); wmsRawOutstock.setAuditReason(auditReason); wmsRawOutstock.setAuditBy(SecurityUtils.getUsername()); wmsRawOutstock.setAuditDate(new Date()); + + //审核不通过,需要有审核意见,并且需要更新库位占用数量。 + if (auditStatus.equalsIgnoreCase(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_FAIL)) { + if (StringUtils.isEmpty(auditReason)) { + throw new ServiceException("请输入审核意见"); + } + List wmsRawOutstockDetails = wmsRawOutstock.getWmsRawOutstockDetailList(); + wmsRawOutstockDetails.forEach(wmsRawOutstockDetail -> { + String locationCode = wmsRawOutstockDetail.getLocationCode(); + String instockBatch = wmsRawOutstockDetail.getInstockBatch(); + BigDecimal planAmount = wmsRawOutstockDetail.getPlanAmount(); + WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch); + if (wmsRawStock != null) { + BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? + BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); + if (occupyAmount.compareTo(planAmount) >= 0) { + wmsRawStock.setOccupyAmount(occupyAmount.subtract(planAmount)); + wmsRawStock.setUpdateBy(userName); + wmsRawStock.setUpdateDate(currentDate); + } else { + wmsRawStock.setOccupyAmount(BigDecimal.ZERO); + wmsRawStock.setUpdateBy(userName); + wmsRawStock.setUpdateDate(currentDate); + } + wmsRawStockMapper.updateWmsRawStock(wmsRawStock); + } + }); + + } + return wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock); + } /** @@ -202,12 +233,12 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { public int confirmWmsRawOutstock(WmsRawOutstockConfirmVo wmsRawOutstockConfirmVo) { Long rawOutstockDetailId = wmsRawOutstockConfirmVo.getRawOutstockDetailId(); String locationCode = wmsRawOutstockConfirmVo.getLocationCode(); - String materialBarcode = wmsRawOutstockConfirmVo.getMaterialBarcode(); + String instockBatch = wmsRawOutstockConfirmVo.getInstockBatch(); BigDecimal outstockAmount = wmsRawOutstockConfirmVo.getOutstockAmount(); //判断是否有此出库任务,人工出库的同一个出库记录,同一个库位、同一个物料对应一个明细(agv的有可能是多个) WmsRawOutstockDetail queryRawOutstockDetail = new WmsRawOutstockDetail(); queryRawOutstockDetail.setLocationCode(locationCode); - queryRawOutstockDetail.setMaterialBarcode(materialBarcode); + queryRawOutstockDetail.setInstockBatch(instockBatch); List wmsRawOutstockDetails = wmsRawOutstockDetailMapper.selectWmsRawOutstockDetailList(queryRawOutstockDetail); WmsRawOutstockDetail wmsRawOutstockDetail = new WmsRawOutstockDetail(); if (wmsRawOutstockDetails == null || wmsRawOutstockDetails.isEmpty()) { @@ -262,6 +293,24 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { wmsRawOutstockDetail.setUpdateBy(userName); } + //更新原材料库存占用数量和总数量 + WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch); + if (wmsRawStock == null) { + throw new ServiceException("数据异常"); + } else { + BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount(); + BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); + BigDecimal updatedOccupyAmount = occupyAmount.subtract(outstockAmount); + BigDecimal updatedTotalAmount = totalAmount.subtract(outstockAmount); + updatedOccupyAmount = updatedOccupyAmount.compareTo(BigDecimal.ZERO) >= 0 ? updatedOccupyAmount : BigDecimal.ZERO; + updatedTotalAmount = updatedTotalAmount.compareTo(BigDecimal.ZERO) >= 0 ? updatedTotalAmount : BigDecimal.ZERO; + wmsRawStock.setOccupyAmount(updatedOccupyAmount); + wmsRawStock.setTotalAmount(updatedTotalAmount); + wmsRawStock.setUpdateDate(currentDate); + wmsRawStock.setUpdateBy(userName); + wmsRawStockMapper.updateWmsRawStock(wmsRawStock); + } + wmsRawOutstockDetailMapper.updateWmsRawOutstockDetail(wmsRawOutstockDetail); //todo 同步erp @@ -438,43 +487,4 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService { } - @Transactional - public int auditRawOutstock(WmsRawOutstock wmsRawOutstock) { - String auditStatus = wmsRawOutstock.getAuditStatus(); - String auditReason = wmsRawOutstock.getAuditReason(); - Date currentDate = new Date(); - String userName = SecurityUtils.getUsername(); - //审核不通过,需要有审核意见,并且需要更新库位占用数量。 - if (auditStatus.equalsIgnoreCase(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_FAIL)) { - if (StringUtils.isEmpty(auditReason)) { - throw new ServiceException("请输入审核意见"); - } - List wmsRawOutstockDetails = wmsRawOutstock.getWmsRawOutstockDetailList(); - wmsRawOutstockDetails.forEach(wmsRawOutstockDetail -> { - String locationCode = wmsRawOutstockDetail.getLocationCode(); - String instockBatch = wmsRawOutstockDetail.getInstockBatch(); - BigDecimal planAmount = wmsRawOutstockDetail.getPlanAmount(); - WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch); - if (wmsRawStock != null) { - BigDecimal occupyAmount = wmsRawStock.getOccupyAmount() == null ? - BigDecimal.ZERO : wmsRawStock.getOccupyAmount(); - if (occupyAmount.compareTo(planAmount) >= 0) { - wmsRawStock.setOccupyAmount(occupyAmount.subtract(planAmount)); - wmsRawStock.setUpdateBy(userName); - wmsRawStock.setUpdateDate(currentDate); - } else { - wmsRawStock.setOccupyAmount(BigDecimal.ZERO); - wmsRawStock.setUpdateBy(userName); - wmsRawStock.setUpdateDate(currentDate); - } - wmsRawStockMapper.updateWmsRawStock(wmsRawStock); - } - }); - - } - - return wmsRawOutstockMapper.updateWmsRawOutstock(wmsRawOutstock); - - } - } diff --git a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java index fefd17a..1e3b04f 100644 --- a/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java +++ b/hw-modules/hw-wms/src/main/java/com/hw/wms/service/impl/WmsRawReturnServiceImpl.java @@ -12,13 +12,13 @@ import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.api.RemoteMesService; import com.hw.mes.api.domain.MesBaseMaterialInfo; import com.hw.mes.api.domain.vo.MesBaseMaterialInfoVo; -import com.hw.wms.domain.WmsRawOutstock; -import com.hw.wms.domain.WmsRawOutstockDetail; +import com.hw.wms.domain.*; import com.hw.wms.domain.vo.WmsRawOutstockAuditVo; import com.hw.wms.domain.vo.WmsRawOutstockConfirmVo; import com.hw.wms.domain.vo.WmsRawReturnAuditVo; import com.hw.wms.domain.vo.WmsRawReturnConfirmVo; import com.hw.wms.mapper.WmsRawReturnDetailMapper; +import com.hw.wms.mapper.WmsRawStockMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -28,9 +28,7 @@ import java.util.stream.Collectors; import com.hw.common.core.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; -import com.hw.wms.domain.WmsRawReturnDetail; import com.hw.wms.mapper.WmsRawReturnMapper; -import com.hw.wms.domain.WmsRawReturn; import com.hw.wms.service.IWmsRawReturnService; import javax.annotation.Resource; @@ -49,6 +47,9 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { @Autowired private WmsRawReturnDetailMapper wmsRawReturnDetailMapper; + @Autowired + private WmsRawStockMapper wmsRawStockMapper; + @Resource private RemoteMesService remoteMesService; @@ -212,15 +213,15 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { */ @Transactional @Override - public int confirmWmsRawOutstock(WmsRawReturnConfirmVo wmsRawReturnConfirmVo) { + public int confirmWmsRawReturn(WmsRawReturnConfirmVo wmsRawReturnConfirmVo) { Long rawReturnDetailId = wmsRawReturnConfirmVo.getRawReturnDetailId(); String locationCode = wmsRawReturnConfirmVo.getLocationCode(); - String materialBarcode = wmsRawReturnConfirmVo.getMaterialBarcode(); + String instockBatch = wmsRawReturnConfirmVo.getInstockBatch(); BigDecimal returnAmount = wmsRawReturnConfirmVo.getReturnAmount(); //判断是否有此退库任务,人工退库的同一个退库记录,同一个库位、同一个物料对应一个明细(agv的有可能是多个) WmsRawReturnDetail queryRawReturnDetail = new WmsRawReturnDetail(); queryRawReturnDetail.setLocationCode(locationCode); - queryRawReturnDetail.setMaterialBarcode(materialBarcode); + queryRawReturnDetail.setInstockBatch(instockBatch); List wmsRawReturnDetails = wmsRawReturnDetailMapper.selectWmsRawReturnDetailList(queryRawReturnDetail); WmsRawReturnDetail wmsRawReturnDetail = new WmsRawReturnDetail(); if (wmsRawReturnDetails == null || wmsRawReturnDetails.isEmpty()) { @@ -277,6 +278,19 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { wmsRawReturnDetailMapper.updateWmsRawReturnDetail(wmsRawReturnDetail); + //更新原材料库存总数量 + WmsRawStock wmsRawStock = wmsRawStockMapper.selectRawStockByLocationAndBatch(locationCode, instockBatch); + if (wmsRawStock == null) { + throw new ServiceException("数据异常"); + } else { + BigDecimal totalAmount = wmsRawStock.getTotalAmount() == null ? BigDecimal.ZERO : wmsRawStock.getTotalAmount(); + BigDecimal updatedTotalAmount = totalAmount.add(returnAmount); + wmsRawStock.setTotalAmount(updatedTotalAmount); + wmsRawStock.setUpdateDate(currentDate); + wmsRawStock.setUpdateBy(userName); + wmsRawStockMapper.updateWmsRawStock(wmsRawStock); + } + //todo 同步erp return 1; } @@ -288,8 +302,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService { * @return 原材料退库记录明细 */ @Override - public List selectAuditPassRawReturnDetails(WmsRawReturnDetail wmsRawReturnDetail) - { + public List selectAuditPassRawReturnDetails(WmsRawReturnDetail wmsRawReturnDetail) { return wmsRawReturnDetailMapper.selectAuditPassRawReturnDetails(wmsRawReturnDetail); } diff --git a/hw-ui/src/api/wms/rawoutstock.js b/hw-ui/src/api/wms/rawoutstock.js new file mode 100644 index 0000000..5b0a647 --- /dev/null +++ b/hw-ui/src/api/wms/rawoutstock.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询原材料出库记录列表 +export function listRawoutstock(query) { + return request({ + url: '/wms/rawoutstock/list', + method: 'get', + params: query + }) +} + +// 查询原材料出库记录详细 +export function getRawoutstock(rawOutstockId) { + return request({ + url: '/wms/rawoutstock/' + rawOutstockId, + method: 'get' + }) +} + +// 新增原材料出库记录 +export function addRawoutstock(data) { + return request({ + url: '/wms/rawoutstock', + method: 'post', + data: data + }) +} + +// 修改原材料出库记录 +export function updateRawoutstock(data) { + return request({ + url: '/wms/rawoutstock', + method: 'put', + data: data + }) +} + +// 删除原材料出库记录 +export function delRawoutstock(rawOutstockId) { + return request({ + url: '/wms/rawoutstock/' + rawOutstockId, + method: 'delete' + }) +} diff --git a/hw-ui/src/views/wms/info/rawoutstock/index.vue b/hw-ui/src/views/wms/info/rawoutstock/index.vue new file mode 100644 index 0000000..e63a7cf --- /dev/null +++ b/hw-ui/src/views/wms/info/rawoutstock/index.vue @@ -0,0 +1,678 @@ + + + diff --git a/hw-ui/src/views/wms/rawmanagement/rawoutstock/index.vue b/hw-ui/src/views/wms/rawmanagement/rawoutstock/index.vue new file mode 100644 index 0000000..e63a7cf --- /dev/null +++ b/hw-ui/src/views/wms/rawmanagement/rawoutstock/index.vue @@ -0,0 +1,678 @@ + + +