| | |
| | | package org.jeecg.modules.lsw.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.lsw.entity.LswMaterial; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialInventory; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialOutbound; |
| | | import org.jeecg.modules.lsw.enums.MaterialInventoryStatusEnum; |
| | | import org.jeecg.modules.lsw.mapper.LswMaterialOutboundMapper; |
| | | 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; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 物料出库单 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-06-30 |
| | | * @Date: 2025-06-30 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service |
| | | public class LswMaterialOutboundServiceImpl extends ServiceImpl<LswMaterialOutboundMapper, LswMaterialOutbound> implements ILswMaterialOutboundService { |
| | | @Autowired |
| | | private ILswMaterialService materialService; |
| | | @Autowired |
| | | private ILswMaterialInventoryService materialInventoryService; |
| | | |
| | | @Override |
| | | public IPage<Map<String, Object>> getlswMaterialOutboundListData(Integer pageNo, Integer pageSize, HttpServletRequest req) { |
| | | IPage<Map> pageData = new Page<Map>(pageNo, pageSize); |
| | | Map<String, String> paramMap = new HashMap<String, String>(); |
| | | Map<String, String[]> parameterMap = req.getParameterMap(); |
| | | if (null != parameterMap) { |
| | | if (parameterMap.containsKey("materialNumber") && StringUtils.isNotBlank(parameterMap.get("materialNumber")[0])) { |
| | | paramMap.put("materialNumber", parameterMap.get("materialNumber")[0]); |
| | | } |
| | | if (parameterMap.containsKey("materialName") && StringUtils.isNotBlank(parameterMap.get("materialName")[0])) { |
| | | paramMap.put("materialName", parameterMap.get("materialName")[0].trim()); |
| | | } |
| | | if (parameterMap.containsKey("batchNumber") && StringUtils.isNotBlank(parameterMap.get("batchNumber")[0])) { |
| | | paramMap.put("batchNumber", parameterMap.get("batchNumber")[0].trim()); |
| | | } |
| | | } |
| | | return super.getBaseMapper().getlswMaterialOutboundListData(pageData, paramMap); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean outboundMaterial(LswMaterialOutbound outbound) { |
| | | if (StringUtils.isBlank(outbound.getMaterialNumber()) |
| | | || StringUtils.isBlank(outbound.getFactoryId()) |
| | | || StringUtils.isBlank(outbound.getWarehouseId()) |
| | | || outbound.getQuantity() == null |
| | | || outbound.getQuantity().intValue() > 0 |
| | | || StringUtils.isBlank(outbound.getBatchNumber()) |
| | | || StringUtils.isBlank(outbound.getInventoryId())) { |
| | | return false; |
| | | } |
| | | LswMaterialInventory inventory = materialInventoryService.getById(outbound.getInventoryId()); |
| | | if(inventory == null) { |
| | | return false; |
| | | } |
| | | //更新库存状态 |
| | | inventory.setInventoryStatus(MaterialInventoryStatusEnum.OUTBOUND.name()); |
| | | materialInventoryService.updateById(inventory); |
| | | //保存出库信息 |
| | | outbound.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | outbound.setOutboundTime(new Date()); |
| | | super.save(outbound); |
| | | return true; |
| | | } |
| | | } |