廖井涛
2024-01-26 32b98dff004ee2b9f230f86ec3883590f9a1c31b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.example.erp.service.mm;
 
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.erp.entity.mm.FinishedGoodsInventory;
import com.example.erp.entity.mm.FinishedOperateLog;
import com.example.erp.entity.pp.FlowCard;
import com.example.erp.entity.sd.Order;
import com.example.erp.entity.sd.OrderDetail;
import com.example.erp.mapper.mm.FinishedGoodsInventoryMapper;
import com.example.erp.mapper.mm.FinishedOperateLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.sql.SQLException;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
@DS("mm")
public class FinishedGoodsInventoryService {
    @Autowired
    FinishedGoodsInventoryMapper finishedGoodsInventoryMapper;
    @Autowired
    FinishedOperateLogMapper finishedOperateLogMapper;
    public Map<String,Object> defaultDateFinishedGoodsInventory(Integer pageNum, Integer pageSize,FinishedGoodsInventory finishedGoodsInventory) {
        Integer offset = (pageNum-1)*pageSize;
        Map<String,Object> map = new HashMap<>();
        map.put("data",finishedGoodsInventoryMapper.defaultfinishedGoods(offset,pageSize,finishedGoodsInventory));
        map.put("total",finishedGoodsInventoryMapper.getPageTotal(offset,pageSize,finishedGoodsInventory));
        return map;
    }
 
    public Map<String,Object> getseletwarehousing(Integer pageNum, Integer pageSize, FlowCard flowCard) {
        Integer offset = (pageNum-1)*pageSize;
        Map<String,Object> map = new HashMap<>();
        map.put("data",finishedGoodsInventoryMapper.getseletwarehousing(offset,pageSize,flowCard));
        map.put("total",finishedGoodsInventoryMapper.getseletwarehousingPageTotal(offset,pageSize,flowCard));
 
        return map;
    }
 
    public Boolean addseletwarehousing(Map<String,Map<String,Object>> object) {
 
        Map<String,Object> maps=  object.get("finishedGoodsInventory");
        String storageRegion= maps.get("storageRegion").toString();
        String remark= maps.get("remark").toString();
        JSONObject jsonObject = new JSONObject(object.get("flowcard"));
        FlowCard flowCard = JSONObject.parseObject(JSONObject.toJSONString(jsonObject), FlowCard.class);
        System.out.println("数据2:"+flowCard);
        //添加出入库记录
        finishedOperateLogMapper.insertFinishedOperateLog(flowCard);
        System.out.println(flowCard.getOrder().getOrderId());
        Integer finishedGoodsInventorycount=finishedGoodsInventoryMapper.findOrderNumberdcount(flowCard.getOrderNumber());
        System.out.println("数量:"+finishedGoodsInventorycount);
        if(finishedGoodsInventorycount>0){
            finishedGoodsInventoryMapper.updateInventory(flowCard);
            finishedGoodsInventoryMapper.updateflowcard(flowCard);
            return true;
        }else{
            if (finishedGoodsInventoryMapper.insertFinishedGoodsInventory(flowCard,storageRegion,remark)){
                finishedGoodsInventoryMapper.updateflowcard(flowCard);
                return true;
            }else{
                return false;
            }
        }
 
 
        /*Order order=finishedGoodsInventoryMapper.findOrderId(flowCard.getOrder().getOrderId());
        OrderDetail orderDetail=finishedGoodsInventoryMapper.findOrderNumber(flowCard.getOrderNumber());*/
        /*finishedGoodsInventory.setOrder(order);
        finishedGoodsInventory.setOrderDetail(orderDetail);
        finishedGoodsInventory.setInventory(flowCard.getInventoryQuantity());
        finishedGoodsInventory.setActualSignalArea(flowCard.getOrderDetail().getHeight()*flowCard.getOrderDetail().getWidth());
        finishedGoodsInventory.setArea(flowCard.getOrderDetail().getHeight()*flowCard.getOrderDetail().getWidth()*flowCard.getInventoryQuantity());
        finishedGoodsInventory.setQuantityAvailable(flowCard.getInventoryQuantity());
        finishedGoodsInventory.setWarehouseNumber(flowCard.getOrderDetail().getBuildingNumber());
        finishedGoodsInventory.setStorageRegion(flowCard.getOrderDetail().getBuildingNumber());
        finishedGoodsInventory.setStatus(0);
        finishedGoodsInventory.setEnterStorageTime(LocalDate.now());
        finishedGoodsInventory.setUpdateTime(LocalDate.now());
        finishedGoodsInventory.setEndTime(null);
        finishedGoodsInventory.setRemark("");*/
 
 
 
    }
}