| package com.zy.asrs.service.impl; | 
|   | 
| import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
| import com.baomidou.mybatisplus.plugins.Page; | 
| import com.baomidou.mybatisplus.service.impl.ServiceImpl; | 
| import com.core.exception.CoolException; | 
| import com.zy.asrs.entity.*; | 
| import com.zy.asrs.entity.param.LocDetlAdjustParam; | 
| import com.zy.asrs.entity.result.StockVo; | 
| import com.zy.asrs.mapper.ManLocDetlMapper; | 
| import com.zy.asrs.service.ManLocDetlService; | 
| import com.zy.asrs.service.MatService; | 
| import com.zy.asrs.service.NodeService; | 
| import com.zy.asrs.utils.SaasUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
|   | 
| import java.util.*; | 
|   | 
| @Service("manLocDetlService") | 
| public class ManLocDetlServiceImpl extends ServiceImpl<ManLocDetlMapper, ManLocDetl> implements ManLocDetlService { | 
|     @Autowired | 
|     private MatService matService; | 
|     @Autowired | 
|     private NodeService nodeService; | 
|   | 
|     @Override | 
|     public Page<ManLocDetl> getPage(Page<ManLocDetl> page) { | 
|         Map<String, Object> condition = page.getCondition(); | 
|         List<ManLocDetl> manLocDetls = baseMapper.listByPage(condition); | 
|         page.setRecords(manLocDetls); | 
|         page.setTotal(baseMapper.listByPageCount(page.getCondition())); | 
|         return page; | 
|     } | 
|   | 
|     @Override | 
|     public Page<ManLocDetl> getStockOut(Page<ManLocDetl> page) { | 
|         page.setRecords(baseMapper.getStockOutPage(page.getCondition())); | 
|         page.setTotal(baseMapper.getStockOutPageCount(page.getCondition())); | 
|         return page; | 
|     } | 
|   | 
|     @Override | 
|     public boolean updateAnfme(Double anfme, String locNo, String matnr, String batch) { | 
|         if (anfme <= 0) { | 
|             return this.baseMapper.deleteItem(locNo, matnr, batch) > 0; | 
|         } else { | 
|             return baseMapper.updateAnfme(anfme, locNo, matnr, batch) > 0; | 
|         } | 
|     } | 
|   | 
|   | 
|     @Override | 
|     public boolean updateLocNo(String newLocNo, String oldLocNo) { | 
|         return baseMapper.updateLocNo(newLocNo, oldLocNo) > 0; | 
|     } | 
|   | 
|     @Override | 
|     public List<String> getSameDetlToday(String matnr, Integer start, Integer end) { | 
|         return this.baseMapper.selectSameDetlToday(matnr, start, end); | 
|     } | 
|   | 
|   | 
|     @Override | 
|     public Page<ManLocDetl> getStockStatis(Page<ManLocDetl> page) { | 
|         page.setRecords(baseMapper.getStockStatis(page.getCondition())); | 
|         page.setTotal(baseMapper.getStockStatisCount(page.getCondition())); | 
|         return page; | 
|     } | 
|   | 
|     @Override | 
|     public Double getSumAnfme(String matnr) { | 
|         return this.baseMapper.selectSumAnfmeByMatnr(matnr); | 
|     } | 
|   | 
|     @Override | 
|     public List<ManLocDetl> selectPakoutByRule(String matnr) { | 
|         return this.baseMapper.selectPakoutByRule(matnr); | 
|     } | 
|   | 
|     @Override | 
|     public List<ManLocDetl> getAsrsLocDetl(String matnr) { | 
|         return this.baseMapper.getAsrsLocDetl(matnr); | 
|     } | 
|   | 
|     @Override | 
|     public Integer countLocNoNum(String locNo) { | 
|         return this.baseMapper.countLocNoNum(locNo); | 
|     } | 
|   | 
|     @Override | 
|     public List<ManLocDetl> queryStock(String matnr, String batch, String orderNo, Set<String> locNos) { | 
|         return this.baseMapper.queryStock(matnr, batch, orderNo, locNos); | 
|     } | 
|   | 
|     @Override | 
|     public Double queryStockAnfme(String matnr, String batch) { | 
|         return this.baseMapper.queryStockAnfme(matnr, batch); | 
|     } | 
|   | 
|     @Override | 
|     public List<StockVo> queryStockTotal() { | 
|         return this.baseMapper.queryStockTotal(); | 
|     } | 
|   | 
|     /** | 
|      * 获取库存总数 | 
|      * | 
|      * @return | 
|      */ | 
|     @Override | 
|     public Integer sum() { | 
|   | 
|         return this.baseMapper.sum(); | 
|     } | 
|   | 
|     @Override | 
|     public List<ManLocDetl> unreason() { | 
|         return this.baseMapper.unreason(); | 
|     } | 
|   | 
|   | 
|     @Override | 
|     public ManLocDetl selectItem(String locNo, String matnr, String batch) { | 
|         return this.baseMapper.selectItem(locNo, matnr, batch); | 
|     } | 
|   | 
|     @Override | 
|     public Double getLocDetlSumQty(String locNo) { | 
|         return this.baseMapper.selectLocDetlSumQty(locNo); | 
|     } | 
|   | 
|     @Override | 
|     public Page<ManLocDetl> getOutPage(Page<ManLocDetl> manLocDetlPage) { | 
|         Map<String, Object> condition = manLocDetlPage.getCondition(); | 
|         List<ManLocDetl> manLocDetls = baseMapper.listByOutPage(condition); | 
|         manLocDetlPage.setRecords(manLocDetls); | 
|         manLocDetlPage.setTotal(baseMapper.listByOutPageCount(manLocDetlPage.getCondition())); | 
|         return manLocDetlPage; | 
|     } | 
|   | 
|     @Transactional | 
|     @Override | 
|     public void adjustLocDetl(LocDetlAdjustParam param, Long userId) { | 
|         Date now = new Date(); | 
|         this.baseMapper.delete(new EntityWrapper<ManLocDetl>() | 
|                 .eq("loc_no", param.getLocNo())); | 
|         for (LocDetlAdjustParam.LocDetlAdjust locDetlAdjust : param.getList()) { | 
|             Mat mat = matService.selectOne(new EntityWrapper<Mat>() | 
|                     .eq("matnr", locDetlAdjust.getMatnr())); | 
|             if (mat == null) { | 
|                 throw new CoolException("无法找到需要调整的物料,请联系管理员"); | 
|             } | 
|             Node node = nodeService.selectOne(new EntityWrapper<Node>() | 
|                     .eq("uuid", param.getLocNo())); | 
|             if (node == null) { | 
|                 throw new CoolException("无法找到需要调整的库位,请联系管理员"); | 
|   | 
|             } | 
|             ManLocDetl manLocDetl = new ManLocDetl(); | 
|             manLocDetl.setLocNo(param.getLocNo()); | 
|             manLocDetl.setNodeId(node.getId()); | 
|             manLocDetl.setZpallet(mat.getBarcode()); | 
|             manLocDetl.setAnfme(locDetlAdjust.getCount()); | 
|             manLocDetl.setMatnr(mat.getMatnr()); | 
|             manLocDetl.setMaktx(mat.getMaktx()); | 
|             manLocDetl.setName(mat.getName()); | 
|             manLocDetl.setSpecs(mat.getSpecs()); | 
|             manLocDetl.setModel(mat.getModel()); | 
|             manLocDetl.setBatch(locDetlAdjust.getBatch()); | 
|             manLocDetl.setUnit(mat.getUnit()); | 
|             manLocDetl.setBarcode(mat.getBarcode()); | 
|             manLocDetl.setPrice(mat.getPrice()); | 
|             SaasUtils.insertLog(3,manLocDetl.getLocNo(), manLocDetl.getMatnr(),manLocDetl.getAnfme()); | 
|             this.baseMapper.insert(manLocDetl); | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public Page<ManLocDetl> selectAllPage(Page<ManLocDetl> param) { | 
|         Map<String, Object> condition = param.getCondition(); | 
|         List<ManLocDetl> manLocDetls = baseMapper.selectAllPage(condition); | 
|         param.setRecords(manLocDetls); | 
|         param.setTotal(baseMapper.selectAllPageSize(condition)); | 
|         return param; | 
|     } | 
|   | 
|   | 
| } |