123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.RmsWarehouseMapper;
- import com.steerinfo.dil.mapper.WmspInventoryCloseMapper;
- import com.steerinfo.dil.model.WmspInventoryClose;
- import com.steerinfo.dil.service.IWmspInventoryCloseService;
- import com.steerinfo.dil.util.DataChange;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.math.BigDecimal;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- @Service
- public class WmspInventoryCloseServiceImpl implements IWmspInventoryCloseService {
- @Autowired
- WmspInventoryCloseMapper wmspInventoryCloseMapper;
- @Autowired
- RmsWarehouseMapper rmsWarehouseMapper;
- @Override
- public List<Map<String, Object>> getWmspInventoryClose(Map<String, Object> mapValue) {
- List<Map<String, Object>> maps = wmspInventoryCloseMapper.selectWmspInventoryClose(mapValue);
- return maps;
- }
- @Override
- public int addInventoryClose() {
- int i = 0;
-
- List<Map<String, Object>> mapList = rmsWarehouseMapper.getWarehouseName();
-
- for(Map<String,Object> map:mapList) {
- BigDecimal warehouseId = DataChange.dataToBigDecimal(map.get("id"));
-
- List<Map<String,Object>> materialList = wmspInventoryCloseMapper.selectSendReceive(warehouseId);
- for(Map<String,Object> map1:materialList){
- WmspInventoryClose wmspInventoryClose = new WmspInventoryClose();
-
- BigDecimal inventoryCloseId = wmspInventoryCloseMapper.addInventoryCloseId();
- wmspInventoryClose.setCloseId(inventoryCloseId);
-
- wmspInventoryClose.setWarehouseId(warehouseId);
-
- BigDecimal materialId = DataChange.dataToBigDecimal(map1.get("materialId"));
- wmspInventoryClose.setMaterialId(materialId);
-
- BigDecimal closeThismonthInbound = wmspInventoryCloseMapper.selectCloseThismonthInbound(warehouseId,materialId);
- if(closeThismonthInbound == null){
- wmspInventoryClose.setCloseThismonthInbound(new BigDecimal(0));
- }else {
- wmspInventoryClose.setCloseThismonthInbound(closeThismonthInbound);
- }
- BigDecimal closeThismonthInbound1 = wmspInventoryClose.getCloseThismonthInbound();
-
- BigDecimal closeThismonthOutbound = wmspInventoryCloseMapper.selectCloseThismonthOutbound(warehouseId,materialId);
- if(closeThismonthOutbound == null){
- wmspInventoryClose.setCloseThismonthOutbound(new BigDecimal(0));
- }else {
- wmspInventoryClose.setCloseThismonthOutbound(closeThismonthOutbound);
- }
- BigDecimal closeThismonthOutbound1 = wmspInventoryClose.getCloseThismonthOutbound();
-
- BigDecimal closeLastmonthInventory = wmspInventoryCloseMapper.selectCloseLastmonthInventory(warehouseId,materialId);
- if(closeLastmonthInventory==null){
- wmspInventoryClose.setCloseLastmonthInventory(new BigDecimal(0));
- }else {
- wmspInventoryClose.setCloseLastmonthInventory(closeLastmonthInventory);
- }
-
- BigDecimal closeLastmonthInventory1 = wmspInventoryClose.getCloseLastmonthInventory();
- BigDecimal closeThismonthInventory =
- new BigDecimal(closeThismonthInbound1.intValue() - closeThismonthOutbound1.intValue() + closeLastmonthInventory1.intValue());
- wmspInventoryClose.setCloseThismonthInventory(closeThismonthInventory);
- wmspInventoryClose.setInsertTime(new Date());
- wmspInventoryClose.setInsertUsername("admin");
- wmspInventoryClose.setDeleted(new BigDecimal(1));
- i+=wmspInventoryCloseMapper.insertSelective(wmspInventoryClose);
- }
- }
- return i;
- }
- @Override
- public int getClose() {
- return wmspInventoryCloseMapper.getClose();
- }
- }
|