|
@@ -1,10 +1,19 @@
|
|
package com.steerinfo.dil.service.impl;
|
|
package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
|
|
+import com.steerinfo.dil.mapper.RmsWarehouseMapper;
|
|
|
|
+import com.steerinfo.dil.mapper.WmspGridMaterialMapper;
|
|
|
|
+import com.steerinfo.dil.mapper.WmspInboundResultMapper;
|
|
import com.steerinfo.dil.mapper.WmspSendReceiveMapper;
|
|
import com.steerinfo.dil.mapper.WmspSendReceiveMapper;
|
|
|
|
+import com.steerinfo.dil.model.WmspSendReceive;
|
|
import com.steerinfo.dil.service.IWmspSendReceiveService;
|
|
import com.steerinfo.dil.service.IWmspSendReceiveService;
|
|
|
|
+import com.steerinfo.dil.util.DataChange;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -18,6 +27,15 @@ public class WmspSendReceiveServiceImpl implements IWmspSendReceiveService {
|
|
@Autowired
|
|
@Autowired
|
|
WmspSendReceiveMapper wmspSendReceiveMapper;
|
|
WmspSendReceiveMapper wmspSendReceiveMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ RmsWarehouseMapper rmsWarehouseMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ WmspGridMaterialMapper wmspGridMaterialMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ WmspInboundResultMapper wmspInboundResultMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<Map<String, Object>> getWmspSendReceiveService(Map<String, Object> mapValue) {
|
|
public List<Map<String, Object>> getWmspSendReceiveService(Map<String, Object> mapValue) {
|
|
List<Map<String, Object>> maps = wmspSendReceiveMapper.selectWmspSendReceive(mapValue);
|
|
List<Map<String, Object>> maps = wmspSendReceiveMapper.selectWmspSendReceive(mapValue);
|
|
@@ -28,4 +46,106 @@ public class WmspSendReceiveServiceImpl implements IWmspSendReceiveService {
|
|
public int count() {
|
|
public int count() {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public BigDecimal getMaterialId(BigDecimal materialSteelId) {
|
|
|
|
+ return wmspSendReceiveMapper.getMaterialId(materialSteelId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ //针对每一个仓库中的每一个物资类型新增一个收发层(初始化收发层)
|
|
|
|
+ @Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
+ public int addSendReceive() {
|
|
|
|
+ int i=0;
|
|
|
|
+ WmspSendReceive wmspSendReceive = new WmspSendReceive();
|
|
|
|
+ //高线库,一棒库,二棒库,配送库
|
|
|
|
+ List<Map<String, Object>> mapList = rmsWarehouseMapper.getWarehouseName();
|
|
|
|
+ //遍历四个仓库
|
|
|
|
+ for(Map<String,Object> map:mapList){
|
|
|
|
+ BigDecimal warehouseId = DataChange.dataToBigDecimal(map.get("id"));
|
|
|
|
+ //查询去重实时库存中的物资id
|
|
|
|
+ List<Map<String,Object>> materialIdList = wmspGridMaterialMapper.getMaterialId(warehouseId);
|
|
|
|
+ for(Map<String,Object> map1:materialIdList){
|
|
|
|
+ //收发层主键自增
|
|
|
|
+ BigDecimal sendReceiveId = wmspSendReceiveMapper.getSendReceiveId();
|
|
|
|
+ wmspSendReceive.setSendReceiveId(sendReceiveId);
|
|
|
|
+ //仓库id
|
|
|
|
+ wmspSendReceive.setWarehouseId(warehouseId);
|
|
|
|
+ //收发层日期
|
|
|
|
+ wmspSendReceive.setSendReceiveDate(new Date());
|
|
|
|
+ //物资id
|
|
|
|
+ BigDecimal materialId = DataChange.dataToBigDecimal(map1.get("materialId"));
|
|
|
|
+ wmspSendReceive.setMaterialId(materialId);
|
|
|
|
+ //今天入库(今天生产入库+今天退货入库+今天盘盈 = 今天入库)暂只管出入库
|
|
|
|
+ //从零点开始每入库一件就增加一件
|
|
|
|
+ //sendReceiveThisdayInbound = wmspSendReceiveMapper.updateSendReceiveThisdayInbound(materialId);
|
|
|
|
+ //初始化今日入库为零
|
|
|
|
+ wmspSendReceive.setSendReceiveThisdayInbound(new BigDecimal(0));
|
|
|
|
+ //今天出库(今天出库+今天盘亏=今天出库)
|
|
|
|
+ //初始化出库为0
|
|
|
|
+ wmspSendReceive.setSendReceiveThisdayOutbound(new BigDecimal(0));
|
|
|
|
+ //昨天库存
|
|
|
|
+ //查询昨天库存
|
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
|
+ map2.put("warehouseId",warehouseId);
|
|
|
|
+ map2.put("materialId",materialId);
|
|
|
|
+ BigDecimal sendReceiveLastdayInventory = wmspSendReceiveMapper.getSendReceiveLastdayInventory(map2);
|
|
|
|
+ if(sendReceiveLastdayInventory == null){
|
|
|
|
+ wmspSendReceive.setSendReceiveLastdayInventory(new BigDecimal(0));
|
|
|
|
+ }else{
|
|
|
|
+ wmspSendReceive.setSendReceiveLastdayInventory(sendReceiveLastdayInventory);
|
|
|
|
+ }
|
|
|
|
+ //今天库存
|
|
|
|
+// BigDecimal sendReceiveLastdayInventory1 = wmspSendReceive.getSendReceiveLastdayInventory();
|
|
|
|
+// if(sendReceiveLastdayInventory1.intValue()==0 || sendReceiveLastdayInventory1 == null){
|
|
|
|
+// wmspSendReceive.setSendReceiveThisdayInventory(new BigDecimal(0));
|
|
|
|
+// }else {
|
|
|
|
+// addThisdayInventorySendReceive(map2);
|
|
|
|
+// }
|
|
|
|
+ wmspSendReceive.setSendReceiveThisdayInventory(wmspSendReceive.getSendReceiveLastdayInventory());
|
|
|
|
+ wmspSendReceive.setInsertUsername("admin");
|
|
|
|
+ wmspSendReceive.setInsertTime(new Date());
|
|
|
|
+ wmspSendReceive.setDeleted(new BigDecimal(1));
|
|
|
|
+ i+=wmspSendReceiveMapper.insertSelective(wmspSendReceive);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return i;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //入库的时候调用收发层
|
|
|
|
+ //传入一个map进来warehouseId,materialId
|
|
|
|
+ public int addInBoundSendReceive(Map<String,Object> map){
|
|
|
|
+ //今天入库(今天生产入库+今天退货入库+今天盘盈 = 今天入库)暂只管入库
|
|
|
|
+ return wmspSendReceiveMapper.updateSendReceiveThisdayInbound(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //出库的时候调用收发层
|
|
|
|
+ public int addOutBoundSendReceive(Map<String,Object> map){
|
|
|
|
+ //今天出库(今天出库+今天盘亏=今天出库)暂只管出库
|
|
|
|
+ return wmspSendReceiveMapper.updateSendReceiveThisdayOutbound(map);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //计算今天库存(昨天库存 + 今天入库 — 今天出库 = 今天库存),实时变动
|
|
|
|
+ public int addThisdayInventorySendReceive(Map<String,Object> map){
|
|
|
|
+ BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
|
|
|
|
+ BigDecimal warehouseId = DataChange.dataToBigDecimal(map.get("warehouseId"));
|
|
|
|
+ //今天入库
|
|
|
|
+ BigDecimal sendReceiveThisdayInbound = wmspSendReceiveMapper.selectSendReceiveThisdayInbound(map);
|
|
|
|
+ //今天出库
|
|
|
|
+ BigDecimal sendReceiveThisdayOutbound = wmspSendReceiveMapper.selectSendReceiveThisdayOutbound(map);
|
|
|
|
+ // 昨天库存
|
|
|
|
+ BigDecimal sendReceiveLastdayInventory = wmspSendReceiveMapper.getSendReceiveLastdayInventory(map);
|
|
|
|
+ if(sendReceiveLastdayInventory == null){
|
|
|
|
+ sendReceiveLastdayInventory=new BigDecimal(0);
|
|
|
|
+ }
|
|
|
|
+ //今天库存
|
|
|
|
+ BigDecimal sendReceiveThisdayInventory = new BigDecimal(sendReceiveLastdayInventory.intValue()
|
|
|
|
+ +sendReceiveThisdayInbound.intValue()-sendReceiveThisdayOutbound.intValue());
|
|
|
|
+ Map<String,Object> map1 = new HashMap<>();
|
|
|
|
+ map1.put("materialId",materialId);
|
|
|
|
+ map1.put("warehouseId",warehouseId);
|
|
|
|
+ map1.put("sendReceiveThisdayInventory",sendReceiveThisdayInventory);
|
|
|
|
+ return wmspSendReceiveMapper.updateSendReceiveThisdayInventory(map1);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|