123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.*;
- import com.steerinfo.dil.model.WmspCheckWarehouse;
- import com.steerinfo.dil.model.WmspGridMaterial;
- import com.steerinfo.dil.model.WmspRestackMakeResult;
- import com.steerinfo.dil.model.WmspRestackScanResult;
- import com.steerinfo.dil.service.IWmspGridMaterialService;
- import com.steerinfo.dil.util.DataChange;
- import com.steerinfo.dil.vo.OutBoundMaterialDetailedInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.math.BigDecimal;
- import java.util.*;
- /**
- * WmspGridMaterial服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-09-08 06:02
- * 类描述
- * 修订历史:
- * 日期:2021-09-08
- * 作者:generator
- * 参考:
- * 描述:WmspGridMaterial服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service
- public class WmspGridMaterialServiceImpl implements IWmspGridMaterialService {
- @Autowired
- private WmspGridMaterialMapper wmspGridMaterialMapper;
- @Autowired
- private RmsStackingMapper rmsStackingMapper;
- @Autowired
- private RmsPwarehouseGridMapper rmsPwarehouseGridMapper;
- @Autowired
- private WmspRestackScanResultMapper wmspRestackScanResultMapper;
- @Autowired
- private WmspRestackMakeResultMapper wmspRestackMakeResultMapper;
- @Autowired
- private WmspCheckWarehouseMapper wmspCheckWarehouseMapper;
- //新增
- @Override
- public int insertSelective(WmspGridMaterial wmspGridMaterial) {
- // long id;
- // BigDecimal MAXid=wmspGridMaterial.getGmId();
- // if (MAXid==null){
- // id=1;
- // }else {
- // id=MAXid.longValue()+1;
- // }
- // wmspGridMaterial.setGmId(new BigDecimal(id));
- return wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
- }
- //更新
- @Override
- public int updateByPrimaryKeySelective(WmspGridMaterial wmspGridMaterial) {
- return wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
- }
- //查询实时库存数据
- @Override
- public List<Map<String, Object>> selectGridMaterial(Map<String, Object> mapval) {
- return wmspGridMaterialMapper.selectGridMaterial(mapval);
- }
- //根据仓储网格统计数据
- @Override
- public Long countByGmId() {
- return wmspGridMaterialMapper.countByGmId();
- }
- @Override
- public List<Map<String, Object>> selectInboundTimeAndThreshold(BigDecimal gridId) {
- return wmspGridMaterialMapper.selectInboundTimeAndThreshold(gridId);
- }
- @Override
- public Integer insertWmspGridMaterial(WmspGridMaterial wmspGridMaterial) {
- return wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
- }
- @Override
- public List<Map<String, Object>> selectGridMaterialListByGridId(Map<String, Object> mapval) {
- return wmspGridMaterialMapper.selectGridMaterialListByGridId(mapval);
- }
- @Override
- public int updateRmsMaterialSteelDemotion(Map<String, Object> map) {
- String gridId = map.get("gridId").toString();
- BigDecimal materialSteelId = wmspGridMaterialMapper.selectMaterialSteelIdByGridId(new BigDecimal(gridId));
- map.put("materialSteelId",materialSteelId);
- //逻辑删除物资钢材表的这个钢材数据并修改其质量是否合格状态
- wmspGridMaterialMapper.updateRmsMaterialSteelDemotion(map);
- //逻辑删除物资为当前钢材的钢材仓库网格物资存放关系表数据(用对象)
- WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
- wmspGridMaterial.setGridId(new BigDecimal(gridId));
- wmspGridMaterial.setDeleted(new BigDecimal(0));
- wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
- //逻辑删除入库作业实绩以及相关联的所有表数据
- //通过钢材Id获取入库作业实绩Id
- BigDecimal inboundId = wmspGridMaterialMapper.selectInboundIdByMaterialSteelId(materialSteelId);
- //通过入库实绩ID逻辑删除库管员纠正吊牌实绩数据
- wmspGridMaterialMapper.updateInboundCorrectByInboundId(inboundId);
- //通过入库实绩ID逻辑删除行车工吊装入库实绩数据
- wmspGridMaterialMapper.updateInboundDrivingByInboundId(inboundId);
- //通过入库实绩ID逻辑删除吊钢工扫描吊牌实绩数据
- wmspGridMaterialMapper.updateInboundScanByInboundId(inboundId);
- //通过入库实绩ID逻辑删除系统/库管员选择垛位实绩数据
- return wmspGridMaterialMapper.updateInboundStackByInboundId(inboundId);
- }
- /**
- * 创建实时库存
- * @param item
- * @param houseGrid
- */
- @Override
- public void initInsertWmspGridMaterial(Map<String, Object> item, BigDecimal houseGrid) {
- /*
- 插入一条网格物资中间表
- */
- WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
- //设置主键ID
- wmspGridMaterial.setGmId(wmspGridMaterialMapper.getCount());
- wmspGridMaterial.setGridId(houseGrid);
- wmspGridMaterial.setGmNumber(new BigDecimal(1));
- wmspGridMaterial.setStandardDataId(new BigDecimal(1));
- //设置网格物资表里面的物资ID
- BigDecimal materialId= DataChange.dataToBigDecimal(item.get("materialId"));
- wmspGridMaterial.setMaterialId(materialId);
- //设置逻辑删除字段
- wmspGridMaterial.setDeleted(new BigDecimal(0));
- //设置常规字段
- wmspGridMaterial.setInsertUsername("admin");
- wmspGridMaterial.setInsertTime(new Date());
- wmspGridMaterial.setUpdateUsername("admin");
- wmspGridMaterial.setInsertUpdateRemark("无");
- wmspGridMaterial.setStatus(new BigDecimal(2));
- insertWmspGridMaterial(wmspGridMaterial);
- }
- @Override
- public Map<String, Object> getReboundScanResultByResultMaterial(String material,String materialOnlyCode) {
- return wmspGridMaterialMapper.getReboundScanResultByResultMaterial(material,materialOnlyCode);
- }
- //修改实时库存(倒垛)
- /**
- * 所需要参数:原来的仓储网格id,修改后的垛位
- * @param map
- * @return
- */
- @Override
- public int updateWmspGridMaterial(List<Map<String, Object>> map,String restackMake) {
- int CC=0;
- int MN=0;
- int CX=0;
- int i =0;
- //获取物资唯一编码
- // List<Map<String,Object>> contents=(List<Map<String, Object>>) map.get("contents");
- for (Map<String,Object> map1:map) {
- String content =(String) map1.get("contents");
- //截取
- String[] split = content.split("-");
- String materialOnlyCode = split[7];
- //获取原来的垛位,修改垛位剩余物资数量
- //根据物资唯一编码查找原来垛位的仓储网格id
- BigDecimal GirdId = wmspGridMaterialMapper.slelectGridIdByMaterialOnlyCode(materialOnlyCode);
- //根据物资唯一编码和物资编码去查找物资现存仓存网格
- Map<String,Object> stringObjectMap = wmspGridMaterialMapper.selectGmIdByMaterialOnlyCode(GirdId);
- BigDecimal gmId = DataChange.dataToBigDecimal(stringObjectMap.get("gmId"));
- WmspGridMaterial wmspGridMaterial=new WmspGridMaterial();
- wmspGridMaterial.setGmId(gmId);
- //设置为删除且锁定的状态
- wmspGridMaterial.setDeleted(new BigDecimal(1));
- wmspGridMaterial.setStatus(new BigDecimal(1));
- wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
- //获取垛位id
- BigDecimal stackingId = DataChange.dataToBigDecimal(map1.get("stackingId"));
- //根据最新的垛位
- //计算仓储网格id
- //获取物资数
- MN=rmsStackingMapper.selectMaterialNumber(map1);
- //计算层次号
- CC=(MN)/24+1;
- //计算层序号
- CX=(MN)%24+1;
- //根据原来的仓储网格id查询仓库id
- BigDecimal warehouseId = DataChange.dataToBigDecimal(stringObjectMap.get("warehouseId"));
- Map<String,Object> map2=new HashMap<>();
- map2.put("gradationNumber",CC);
- map2.put("sequenceNumber",CX);
- map2.put("stackingID",stackingId);
- map2.put("warehouseId",warehouseId);
- BigDecimal GridId = rmsPwarehouseGridMapper.selectGridId(map2);
- BigDecimal gmNumber =(BigDecimal) stringObjectMap.get("gmNumber");
- BigDecimal weight = (BigDecimal) stringObjectMap.get("weight");
- BigDecimal materialId =(BigDecimal) stringObjectMap.get("materialId");
- //新增实时库存
- wmspGridMaterial.setGmId(wmspGridMaterialMapper.getCount());
- wmspGridMaterial.setGridId(GridId);
- wmspGridMaterial.setMaterialId(materialId);
- wmspGridMaterial.setGmNumber(gmNumber);
- wmspGridMaterial.setGmWeight(weight);
- wmspGridMaterial.setInsertTime(new Date());
- wmspGridMaterial.setInsertUsername("admin");
- wmspGridMaterial.setDeleted(new BigDecimal(0));
- wmspGridMaterial.setStatus(new BigDecimal(2));
- wmspGridMaterial.setStandardDataId(new BigDecimal(1));
- wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
- // 4、改变当前订单中已经稽核的吊牌的状态,改为已倒垛
- // 根据吊牌扫描结果查找对应的吊牌扫描实绩Id
- BigDecimal resultId=wmspRestackScanResultMapper.getResultId(content);
- WmspRestackScanResult wmspRestackScanResult = new WmspRestackScanResult();
- wmspRestackScanResult.setResultId(resultId);
- wmspRestackScanResult.setStatus(new BigDecimal(1));
- i += wmspRestackScanResultMapper.updateByPrimaryKeySelective(wmspRestackScanResult);
- // 3、将当前订单的总数量减去上面当前订单中已经稽核的吊牌
- WmspRestackMakeResult wmspRestackMakeResult = new WmspRestackMakeResult();
- wmspRestackMakeResult.setResultId(new BigDecimal(restackMake));
- BigDecimal quantity=wmspRestackMakeResultMapper.getQuantity(restackMake);
- // 判断当前订单的总数量是否小于或等于0
- if (quantity.compareTo(new BigDecimal(1))==-1){
- // 当存在时直接结束当前循环
- break;
- }
- // 将当前订单的总数量减一
- wmspRestackMakeResult.setQuantity(quantity.subtract(new BigDecimal(1)));
- i += wmspRestackMakeResultMapper.updateByPrimaryKeySelective(wmspRestackMakeResult);
- }
- return i;
- }
- public List<Map<String, Object>> getMaterialTypeList(String warehouseid, BigDecimal stackingId, BigDecimal gradtionNumber) {
- return wmspGridMaterialMapper.getMaterialTypeList(warehouseid,stackingId,gradtionNumber);
- }
- // 新增库存盘点实绩
- @Override
- public int insertStockTaking(String warehouseId, String materialCode, Integer quantity) {
- // 根据仓库id和物资类型编码,查询当前的今日库存以及今天入库和出库数量
- int count = wmspGridMaterialMapper.getStockTakingList(warehouseId,materialCode);
- // 调用插入库存盘点实绩接口
- // 创建库存盘点实绩类
- WmspCheckWarehouse wmspCheckWarehouse = new WmspCheckWarehouse();
- // 添加仓库id
- wmspCheckWarehouse.setWarehouseId(new BigDecimal(warehouseId));
- // 添加物资ID
- BigDecimal materialId = wmspGridMaterialMapper.getMaterialIds(materialCode);
- wmspCheckWarehouse.setMaterialId(materialId);
- // 添加实际数量
- wmspCheckWarehouse.setElectronicsMaterialAmount(new BigDecimal(count));
- // 添加盘点数量
- wmspCheckWarehouse.setRealMaterialAmount(new BigDecimal(quantity));
- // 添加盈亏数
- Integer checkProfitloss = count - quantity;
- wmspCheckWarehouse.setCheckProfitloss(new BigDecimal(checkProfitloss));
- wmspCheckWarehouse.setInsertTime(new Date());
- wmspCheckWarehouse.setInsertUsername("admin");
- // 查找当前盘点库存实绩表的最大Id
- BigDecimal checkId = wmspCheckWarehouseMapper.getMaxId();
- wmspCheckWarehouse.setCheckId(checkId);
- int result = wmspCheckWarehouseMapper.insertSelective(wmspCheckWarehouse);
- return result;
- }
- @Override
- public List<Map<String, Object>> getStockTakingList() {
- return wmspCheckWarehouseMapper.getStockTakingList();
- }
- @Override
- public List<Map<String, Object>> getSteelMaterialList() {
- return wmspCheckWarehouseMapper.getSteelMaterialList();
- }
- @Override
- public int deleteGridMaterial(List<OutBoundMaterialDetailedInfo> thisMaterialDetailedInfos) {
- return wmspGridMaterialMapper.deleteGridMaterial(thisMaterialDetailedInfos,new Date());
- }
- }
|