czt
2025-06-11 283da741b2429cf5a53786e5ee1b5528b757fdf6
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package com.fzzy.igds.sys;
 
import com.fzzy.igds.dzhwk.domain.DepotStatusConfirm;
import com.fzzy.igds.dzhwk.domain.DepotStore;
import com.fzzy.igds.sys.repository.DepotStoreRepository;
import com.fzzy.igds.util.ContextUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
 
/**
 * @Description
 * @Author CZT
 * @Date 2024/11/23 11:29
 */
@Slf4j
@Service("sys.depotStoreService")
public class DepotStoreService {
 
    @Resource
    private DepotStoreRepository depotStoreRepository;
 
    /**
     * JPA分页查询数据
     *
     * @param specification
     * @param pageable
     * @return
     */
    public Page<DepotStore> findAll(Specification<DepotStore> specification, Pageable pageable) {
        return depotStoreRepository.findAll(specification, pageable);
    }
 
    /**
     * JPA更新保存数据
     * @param data
     */
    public void saveDepotStore(DepotStore data) {
        if (StringUtils.isEmpty(data.getCompanyId())) {
            data.setCompanyId(ContextUtil.getCompanyId());
        }
        if (StringUtils.isEmpty(data.getDeptId())) {
            data.setDeptId(ContextUtil.subDeptId(null));
        }
        data.setUpdateUser(ContextUtil.getLoginUserCName());
        data.setUpdateDate(new Date());
 
        data.setId(data.getDepotId() + "_" + DateFormatUtils.format(data.getStoreDate(), "yyyyMMddHHmmss") + "_" + DateFormatUtils.format(data.getUpdateDate(), "yyyyMMddHHmmss"));
        data.setCreateDate(new Date());
        data.setRemark("系统生成");
 
        depotStoreRepository.save(data);
    }
 
    /**
     * JPA删除数据
     * @param data
     * @return
     */
    public String delDepotStore(DepotStore data) {
        depotStoreRepository.delete(data);
        return null;
    }
 
    /**
     * JPA获取仓库最后一条库存数据
     * @param depotId
     * @param time
     * @return
     */
    public DepotStore getLastData(String depotId, Date time) {
        List<DepotStore> list = depotStoreRepository.getDataByDepotId(depotId, time);
        if(null == list || list.isEmpty()){
            return null;
        }
        return list.get(0);
    }
 
    /**
     * 根据封仓确认单信息增加库存
     * @param data
     */
    public void depotStoreStatus(DepotStatusConfirm data) {
        // 根据最后一车进行汇总统计,开始时间是仓库库存最后一个时间截止到当前
        DepotStore lastStore = this.getLastData(data.getDepotId(), new Date());
 
        lastStore.setRemark("封仓确认");
        lastStore.setFullDate(data.getFcrq());
        lastStore.setDepotStatus("3");
        lastStore.setUpdateUser("系统管理员");
        lastStore.setStorageReal(data.getFcsl());
        lastStore.setUpdateDate(new Date());
        lastStore.setCreateDate(new Date());
        lastStore.setId(null);
        this.saveDepotStore(lastStore);
    }
 
    public void addDepotStore(DepotStore store, boolean updateDepot) {
//        if (null == store.getUpdateDate()) store.setUpdateDate(new Date());
//        if (null == store.getId()) store.setId(ContextUtil.getUUID());
//        if (null == store.getManageType() || "".equals(store.getManageType())) {
//            store.setManageType("01");
//        }
//
//        commonMapper.addDepotStore(store);
//
//
//        if (updateDepot) {
//            DepotParam param = new DepotParam();
//            param.setCompanyId(store.getCompanyId());
//            param.setDepotId(store.getDepotId());
//            param.setWeight(store.getStorageReal());
//            param.setDepotStatus(store.getDepotStatus());
//
//            commonMapper.updateDepotStorage(param);
//        }
    }
 
 
 
}