| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.modules.base.entity.LineSideWarehouse; |
| | | import org.jeecg.modules.base.service.ILineSideWarehouseService; |
| | | import org.jeecg.modules.lsw.entity.LswMaterial; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialInbound; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialInventory; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialOutbound; |
| | | import org.jeecg.modules.lsw.enums.MaterialInboundCategory; |
| | | import org.jeecg.modules.lsw.enums.MaterialInventoryCategoryEnum; |
| | | import org.jeecg.modules.lsw.enums.MaterialOutboundCategory; |
| | | import org.jeecg.modules.lsw.mapper.LswMaterialInboundMapper; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialInboundService; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialOutboundService; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private ILswMaterialInventoryService inventoryService; |
| | | @Autowired |
| | | private ILswMaterialService materialService; |
| | | @Autowired |
| | | private ILineSideWarehouseService lineSideWarehouseService; |
| | | @Autowired |
| | | private ILswMaterialOutboundService materialOutboundService; |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> getlswMaterialInboundListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { |
| | |
| | | || StringUtils.isBlank(materialInbound.getFactoryId()) |
| | | || StringUtils.isBlank(materialInbound.getWarehouseId()) |
| | | || materialInbound.getQuantity() == null |
| | | || materialInbound.getQuantity().intValue() > 0 |
| | | || StringUtils.isBlank(materialInbound.getBatchNumber())) { |
| | | return false; |
| | | || materialInbound.getQuantity().intValue() < 1 |
| | | || StringUtils.isBlank(materialInbound.getBatchNumber()) |
| | | || StringUtils.isBlank(materialInbound.getOriginalCode()) |
| | | || StringUtils.isBlank(materialInbound.getOriginalName()) |
| | | || StringUtils.isBlank(materialInbound.getInboundCategory())) { |
| | | throw new JeecgBootException("参数错误!"); |
| | | } |
| | | LswMaterial material = materialService.queryByMaterialNumber(materialInbound.getMaterialNumber()); |
| | | if(material == null) { |
| | | return false; |
| | | if (material == null) { |
| | | throw new JeecgBootException("物料编号不存在!"); |
| | | } |
| | | LineSideWarehouse warehouse = lineSideWarehouseService.getById(materialInbound.getWarehouseId()); |
| | | if (warehouse == null) { |
| | | throw new JeecgBootException("线边库不存在!"); |
| | | } |
| | | String heatTreatmentFlag = CommonConstant.STATUS_0; |
| | | if (materialInbound.getInboundCategory().equals(MaterialInboundCategory.HEAT_TREATMENT_INBOUND.name())) { |
| | | heatTreatmentFlag = CommonConstant.STATUS_1; |
| | | } |
| | | //库存类型 |
| | | String inventoryCategory = MaterialInventoryCategoryEnum.INBOUND.name(); |
| | | if (materialInbound.getInboundCategory().equals(MaterialInboundCategory.MATERIAL_INNER_TRANSFER.name())) { |
| | | inventoryCategory = MaterialInventoryCategoryEnum.TRANSFER.name(); |
| | | //查询来源线边库 |
| | | LineSideWarehouse lineSideWarehouse = lineSideWarehouseService.queryByWarehouseCode(materialInbound.getOriginalCode()); |
| | | if (lineSideWarehouse == null) { |
| | | throw new JeecgBootException("未找到来源线边库!"); |
| | | } |
| | | //调拨 出库原始库存 |
| | | LswMaterialInventory originalInventory = inventoryService.queryByMaterialNumberAndBatchNumber(materialInbound.getMaterialNumber(), materialInbound.getBatchNumber(), lineSideWarehouse.getId()); |
| | | if (originalInventory == null) { |
| | | throw new JeecgBootException("未找到来源线边库库存!"); |
| | | } |
| | | if (materialInbound.getQuantity().compareTo(originalInventory.getQuantity()) != 0) { |
| | | throw new JeecgBootException("调拨数量需要等于来源库存数量!"); |
| | | } |
| | | //出库信息 |
| | | LswMaterialOutbound outbound = new LswMaterialOutbound(); |
| | | outbound.setWarehouseId(lineSideWarehouse.getId()); |
| | | outbound.setFactoryId(lineSideWarehouse.getFactoryId()); |
| | | outbound.setOutboundStaff(materialInbound.getReceiver()); |
| | | outbound.setMaterialName(materialInbound.getMaterialName()); |
| | | outbound.setMaterialNumber(materialInbound.getMaterialNumber()); |
| | | outbound.setQuantity(originalInventory.getQuantity()); |
| | | outbound.setBatchNumber(originalInventory.getBatchNumber()); |
| | | outbound.setInventoryId(originalInventory.getId()); |
| | | outbound.setOutboundCategory(MaterialOutboundCategory.MATERIAL_INNER_TRANSFER.name()); |
| | | //调拨出库 |
| | | boolean b = materialOutboundService.outboundMaterial(outbound); |
| | | if (!b) { |
| | | throw new JeecgBootException("调拨出库失败!"); |
| | | } |
| | | } else if (materialInbound.getInboundCategory().equals(MaterialInboundCategory.PRODUCTION_UNLOADING.name())) { |
| | | inventoryCategory = MaterialInventoryCategoryEnum.UNLOADING.name(); |
| | | } |
| | | //保存入库信息 |
| | | materialInbound.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | materialInbound.setReceiveTime(new Date()); |
| | | super.save(materialInbound); |
| | | //保存库存信息 |
| | | LswMaterialInventory lswMaterialInventory = new LswMaterialInventory(materialInbound, material.getId(), material.getMaterialCategory()); |
| | | LswMaterialInventory lswMaterialInventory = new LswMaterialInventory(materialInbound, material.getId(), inventoryCategory, heatTreatmentFlag); |
| | | inventoryService.save(lswMaterialInventory); |
| | | return true; |
| | | } |