|
@@ -8,6 +8,7 @@ import com.steerinfo.dil.model.WmspSendReceive;
|
|
|
import com.steerinfo.dil.service.IWmspSendReceiveService;
|
|
|
import com.steerinfo.dil.util.DataChange;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -161,70 +162,74 @@ public class WmspSendReceiveServiceImpl implements IWmspSendReceiveService {
|
|
|
*/
|
|
|
//零点生成前一天的入库、出库、库存
|
|
|
@Override
|
|
|
+ @Scheduled(cron = "1 45 23 * * ? ")
|
|
|
public int addSendReceive(){
|
|
|
-
|
|
|
int i = 0;
|
|
|
- //高线库,一棒库,二棒库,配送库
|
|
|
- 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) {
|
|
|
- WmspSendReceive wmspSendReceive = new WmspSendReceive();
|
|
|
- //收发层主键自增
|
|
|
- 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);
|
|
|
-
|
|
|
- Map<String,Object> map2 = new HashMap<>();
|
|
|
- map2.put("warehouseId",warehouseId);
|
|
|
- map2.put("materialId",materialId);
|
|
|
- //统计今天的入库总数(只统计当前仓库没有预留的数量,不统计预留库的数量)
|
|
|
- BigDecimal sendReceiveThisdayInbound = wmspSendReceiveMapper.countSndReceiveThisdayInbound(map2);
|
|
|
- if(sendReceiveThisdayInbound == null){
|
|
|
- wmspSendReceive.setSendReceiveThisdayInbound(new BigDecimal(0));
|
|
|
- }else{
|
|
|
- wmspSendReceive.setSendReceiveThisdayInbound(sendReceiveThisdayInbound);
|
|
|
- }
|
|
|
- BigDecimal sendReceiveThisdayInbound1 = wmspSendReceive.getSendReceiveThisdayInbound();
|
|
|
- //统计今天天的出库总数
|
|
|
- BigDecimal sendReceiveThisdayOutbound = wmspSendReceiveMapper.countSendReceiveThisdayOutbound(map2);
|
|
|
- if(sendReceiveThisdayOutbound == null){
|
|
|
- wmspSendReceive.setSendReceiveThisdayOutbound(new BigDecimal(0));
|
|
|
- }else {
|
|
|
- wmspSendReceive.setSendReceiveThisdayOutbound(sendReceiveThisdayOutbound);
|
|
|
- }
|
|
|
- BigDecimal sendReceiveThisdayOutbound1 = wmspSendReceive.getSendReceiveThisdayOutbound();
|
|
|
- //昨天库存
|
|
|
- BigDecimal sendReceiveLastdayInventory = wmspSendReceiveMapper.getSendReceiveLastdayInventory(map2);
|
|
|
- if(sendReceiveLastdayInventory == null){
|
|
|
- wmspSendReceive.setSendReceiveLastdayInventory(new BigDecimal(0));
|
|
|
- }else{
|
|
|
- wmspSendReceive.setSendReceiveLastdayInventory(sendReceiveLastdayInventory);
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal sendReceiveLastdayInventory1 = wmspSendReceive.getSendReceiveLastdayInventory();
|
|
|
+ int count = wmspSendReceiveMapper.getTodaySendReceiveCount();
|
|
|
+ if(count == 0){
|
|
|
+ //高线库,一棒库,二棒库,配送库
|
|
|
+ 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) {
|
|
|
+ WmspSendReceive wmspSendReceive = new WmspSendReceive();
|
|
|
+ //收发层主键自增
|
|
|
+ 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);
|
|
|
+
|
|
|
+ Map<String,Object> map2 = new HashMap<>();
|
|
|
+ map2.put("warehouseId",warehouseId);
|
|
|
+ map2.put("materialId",materialId);
|
|
|
+ //统计今天的入库总数(只统计当前仓库没有预留的数量,不统计预留库的数量)
|
|
|
+ BigDecimal sendReceiveThisdayInbound = wmspSendReceiveMapper.countSndReceiveThisdayInbound(map2);
|
|
|
+ if(sendReceiveThisdayInbound == null){
|
|
|
+ wmspSendReceive.setSendReceiveThisdayInbound(new BigDecimal(0));
|
|
|
+ }else{
|
|
|
+ wmspSendReceive.setSendReceiveThisdayInbound(sendReceiveThisdayInbound);
|
|
|
+ }
|
|
|
+ BigDecimal sendReceiveThisdayInbound1 = wmspSendReceive.getSendReceiveThisdayInbound();
|
|
|
+ //统计今天天的出库总数
|
|
|
+ BigDecimal sendReceiveThisdayOutbound = wmspSendReceiveMapper.countSendReceiveThisdayOutbound(map2);
|
|
|
+ if(sendReceiveThisdayOutbound == null){
|
|
|
+ wmspSendReceive.setSendReceiveThisdayOutbound(new BigDecimal(0));
|
|
|
+ }else {
|
|
|
+ wmspSendReceive.setSendReceiveThisdayOutbound(sendReceiveThisdayOutbound);
|
|
|
+ }
|
|
|
+ BigDecimal sendReceiveThisdayOutbound1 = wmspSendReceive.getSendReceiveThisdayOutbound();
|
|
|
+ //昨天库存
|
|
|
+ BigDecimal sendReceiveLastdayInventory = wmspSendReceiveMapper.getSendReceiveLastdayInventory(map2);
|
|
|
+ if(sendReceiveLastdayInventory == null){
|
|
|
+ wmspSendReceive.setSendReceiveLastdayInventory(new BigDecimal(0));
|
|
|
+ }else{
|
|
|
+ wmspSendReceive.setSendReceiveLastdayInventory(sendReceiveLastdayInventory);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal sendReceiveLastdayInventory1 = wmspSendReceive.getSendReceiveLastdayInventory();
|
|
|
|
|
|
//今天库存
|
|
|
- BigDecimal sendReceiveThisdayInventory = new BigDecimal(sendReceiveLastdayInventory1.intValue()
|
|
|
- +sendReceiveThisdayInbound1.intValue()-sendReceiveThisdayOutbound1.intValue());
|
|
|
+ BigDecimal sendReceiveThisdayInventory = new BigDecimal(sendReceiveLastdayInventory1.intValue()
|
|
|
+ +sendReceiveThisdayInbound1.intValue()-sendReceiveThisdayOutbound1.intValue());
|
|
|
|
|
|
wmspSendReceive.setSendReceiveThisdayInventory(sendReceiveThisdayInventory);
|
|
|
|
|
|
- wmspSendReceive.setInsertUsername("admin");
|
|
|
- wmspSendReceive.setInsertTime(new Date());
|
|
|
- wmspSendReceive.setDeleted(new BigDecimal(1));
|
|
|
- i+=wmspSendReceiveMapper.insertSelective(wmspSendReceive);
|
|
|
+ wmspSendReceive.setInsertUsername("admin");
|
|
|
+ wmspSendReceive.setInsertTime(new Date());
|
|
|
+ wmspSendReceive.setDeleted(new BigDecimal(1));
|
|
|
+ i+=wmspSendReceiveMapper.insertSelective(wmspSendReceive);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return i;
|
|
|
}
|
|
|
|