jiazx0107@163.com
2023-06-29 db4391557295bd8fd9fff3d1e95fa0d69f780e38
igds-core/src/main/java/com/ld/igds/common/impl/CommonDataServiceImpl.java
@@ -7,10 +7,7 @@
import com.ld.igds.common.dto.THDto;
import com.ld.igds.common.mapper.CommonMapper;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotStatus;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.models.Depot;
import com.ld.igds.models.DepotConf;
import com.ld.igds.models.DepotStore;
@@ -51,7 +48,6 @@
    @Override
    public List<Depot> getCacheDepotList(String companyId) {
        String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT);
        Set<String> keys = redisUtil.keys(patten);
@@ -72,6 +68,7 @@
    public List<Depot> getCacheDepotList(String companyId, String deptId) {
        if (null == deptId) return null;
        String patten = RedisConst.buildKey(companyId, RedisConst.KEY_DEPOT);
        Set<String> keys = redisUtil.keys(patten);
        if (null == keys) return null;
@@ -313,61 +310,6 @@
        String key = RedisConst.buildKey(Constant.DEFAULT_PARENT_CODE, "COMPANY_LIST");
        return (List<DefaultCompany>) redisUtil.get(key);
    }
    @Override
    public void initInoutDepotStore(InoutData data) {
        String depotStatus = DepotStatus.STATUS_03.getCode();
        if (InoutConstant.TYPE_OUT.equals(data.getType())) {
            depotStatus = DepotStatus.STATUS_04.getCode();
        }
        //先从缓存中获取下信息,查看是否已经初始化过数据,如果有则直接跳过,如果没有则重新验证
        String key = RedisConst.buildKey(data.getDepotId(), "DEPOT_STORE", depotStatus);
        String tag = (String) redisUtil.get(key);
        if (null != tag) return;
        //获取当前仓库最后一个库存记录
        DepotStore depotStore = getLastDepotStore(data.getDepotId());
        //如果有数据,并且状态类一致,表示缓存没有了,但是已经做过初始化
        if (null != depotStore && depotStatus.equals(depotStore.getDepotStatus())) {
            redisUtil.set(key, depotStatus, 5 * 24 * 60 * 60);
            return;
        }
        //从来没有做个库存管理调整
        if (null == depotStore) {
            Depot depot = this.getCacheDepot(data.getCompanyId(), data.getDepotId());
            depotStore = new DepotStore(depot, depotStatus);
            if (null != data.getFoodYear()) {
                depotStore.setFoodYear(data.getFoodYear());
            }
        } else { //有记录,但是状态与当前作业不一致,也需要初始化
            depotStore.setDepotStatus(depotStatus);
            depotStore.setUpdateDate(new Date());
            depotStore.setUpdateUser(null);
        }
        depotStore.setId(null);
        if (InoutConstant.TYPE_OUT.equals(data.getType())) {
            depotStore.setOutDate(new Date());
        } else {
            depotStore.setStoreDate(new Date());
        }
        if (null != data.getFoodYear()) {
            depotStore.setFoodYear(data.getFoodYear());
        }
        depotStore.setRemark("系统生成记录,确认调整");
        addDepotStore(depotStore, false);
        commonMapper.updateDepotStatus(depotStore.getCompanyId(), depotStore.getDepotId(), depotStore.getDepotStatus());
        redisUtil.set(key, depotStatus, 5 * 24 * 60 * 60);
    }
    @Override