WS
2023-08-15 0fac4397b7655b2cc5d9a1aea8c4e901a26e218f
V4.0版本库存数据同步
已修改1个文件
已添加3个文件
364 ■■■■■ 文件已修改
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java 170 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java 161 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1208Rep.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java
@@ -3,10 +3,8 @@
import com.fzzy.api.data.ApiParam;
import com.fzzy.api.data.SyncProtocol;
import com.fzzy.api.service.SyncService12;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1201;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1202;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1205;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1212;
import com.fzzy.async.fzzy35.impl.Fzzy35Sync1208;
import com.fzzy.async.fzzy40.impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@@ -27,6 +25,8 @@
    private Fzzy40Sync1205 fzzySync1205;
    @Autowired
    private Fzzy40Sync1212 fzzySync1212;
    @Autowired
    private Fzzy40Sync1208 fzzySync1208;
    @Override
    public String getProtocol() {
@@ -68,7 +68,7 @@
        //粮食库存同步  TODO
        fzzySync1208.syncData(kqdm, deptId, start, end);
        //粮食性质转变信息同步  TODO
src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,170 @@
package com.fzzy.async.fzzy40.entity;
import com.bstek.dorado.annotation.PropertyDef;
import com.fzzy.async.fzzy30.entity.Depot;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @Desc: ç²®é£Ÿåº“存管理,根据国标标结果要求创建
 * @author: Andy
 * @update-time: 2022/11/17
 */
@Data
@Entity
@Table(name = "D_DEPOT_STORE")
public class Fz40DepotStore implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = -5548540780391804729L;
    @Id
    @Column(name = "ID_", length = 40)
    private String id;
    @Column(name = "COMPANY_ID_", length = 10)
    @PropertyDef(label = "组织编码")
    private String companyId;
    @Column(name = "DEPT_ID_", length = 40)
    @PropertyDef(label = "所属库区")
    private String deptId;
    @Column(name = "DEPOT_ID_", length = 50)
    @PropertyDef(label = "所属仓库")
    private String depotId;
    @Column(name = "COUNTRY_", length = 10)
    @PropertyDef(label = "国别")
    private String country;
    @Column(name = "STORE_TYPE_", length = 6)
    @PropertyDef(label = "储粮方式", description = "1:散装储粮 2:包装储粮 3:围包散存 9:其他")
    private String storeType;
    @Column(name = "MANAGE_TYPE_", length = 6)
    @PropertyDef(label = "管理方式", description = "01 ç›´å‚¨02 ä»£å‚¨03 ç§Ÿä»“04 å§”托")
    private String manageType;
    @Column(name = "FOOD_TYPE_", length = 10)
    @PropertyDef(label = "粮食性质")
    private String foodType;
    @Column(name = "FOOD_VARIETY_", length = 10)
    @PropertyDef(label = "粮食品种")
    private String foodVariety;
    @Column(name = "FOOD_LEVEL_", length = 10)
    @PropertyDef(label = "粮食等级")
    private String foodLevel;
    @Column(name = "FOOD_LOCATION_ID_", length = 50)
    @PropertyDef(label = "粮食产地")
    private String foodLocationId;
    @Column(name = "FOOD_LOCATION_", length = 50)
    @PropertyDef(label = "粮食产地")
    private String foodLocation;
    @Column(name = "FOOD_YEAR_", length = 10)
    @PropertyDef(label = "收货年度")
    private String foodYear;
    @Column(name = "DEPOT_STATUS_", length = 10)
    @PropertyDef(label = "仓库状态", description = "1=空仓、2=入库中、3=满仓、4=出库中、9=其他")
    private String depotStatus;
    @Column(name = "STORE_DATE_")
    @PropertyDef(label = "入库时间", description = "入库时间,第一车粮食入仓时间,格式:yyyy-MM-dd HH:mm:ss")
    private Date storeDate;
    @Column(name = "FULL_DATE_")
    @PropertyDef(label = "封仓日期", description = "当货位(油罐)状态为封仓时,此项为必填项")
    private Date fullDate;
    @Column(name = "OUT_DATE_")
    @PropertyDef(label = "出仓时间", description = "出库时间,最后一车粮食出仓完成时间,格式:yyyy-MM-dd HH:mm:ss")
    private Date outDate;
    @Column(name = "STORAGE_REAL_")
    @PropertyDef(label = "实际储量", description = "单位:KG")
    private Double storageReal;
    @Column(name = "STORE_SETTLE__")
    @PropertyDef(label = "计价数量", description = "单位:KG")
    private Double storageSettle;
    @Column(name = "GRAIN_HEIGHT_")
    @PropertyDef(label = "装粮线高", description = "单位:米")
    private Double grainHeight;
    @Column(name = "GRAIN_VOLUME_")
    @PropertyDef(label = "装粮体积", description = "单位:立方米")
    private Double grainVolume;
    @Column(name = "REMARK_", length = 250)
    @PropertyDef(label = "备注", description = "备注信息")
    private String remark;
    @Column(name = "UPDATE_USER_", length = 50)
    @PropertyDef(label = "修改人")
    private String updateUser;
    @Column(name = "UPDATE_DATE_")
    @PropertyDef(label = "修改时间")
    private Date updateDate;
    @Column(name = "CREATE_DATE_")
    private Date createDate;
    public Fz40DepotStore() {
    }
    public Fz40DepotStore(String id, String companyId, String deptId, String depotId, String storeType, String foodType, String foodVariety, String foodLevel, String foodLocation, String depotStatus, String foodYear, Date storeDate, Double storageReal, Date fullDate, Date outDate, Double grainHeight, Double grainVolume, String remark, String updateUser, Date updateDate, Date createDate) {
        this.id = id;
        this.companyId = companyId;
        this.deptId = deptId;
        this.depotId = depotId;
        this.storeType = storeType;
        this.foodType = foodType;
        this.foodVariety = foodVariety;
        this.foodLevel = foodLevel;
        this.foodLocation = foodLocation;
        this.depotStatus = depotStatus;
        this.foodYear = foodYear;
        this.storeDate = storeDate;
        this.storageReal = storageReal;
        this.fullDate = fullDate;
        this.outDate = outDate;
        this.grainHeight = grainHeight;
        this.grainVolume = grainVolume;
        this.remark = remark;
        this.updateUser = updateUser;
        this.updateDate = updateDate;
    }
    public Fz40DepotStore(Depot depot, String depotStatus) {
        this.companyId = depot.getCompanyId();
        this.deptId = depot.getDeptId();
        this.depotId = depot.getId();
        this.storeType = depot.getStoreType();
        this.foodType = depot.getFoodType();
        this.foodVariety = depot.getFoodVariety();
        this.foodLevel = depot.getFoodLevel();
        this.foodLocation = depot.getFoodLocation();
        this.depotStatus = depotStatus;
        this.foodYear = depot.getFoodYear();
        this.storageReal = depot.getStorageReal();
        this.storeDate = new Date();
        this.updateDate = new Date();
    }
}
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,161 @@
package com.fzzy.async.fzzy40.impl;
import com.fzzy.api.Constant;
import com.fzzy.api.entity.Api1102;
import com.fzzy.api.entity.Api1105;
import com.fzzy.api.entity.Api1208;
import com.fzzy.api.entity.ApiLog;
import com.fzzy.api.service.ApiCommonService;
import com.fzzy.api.service.ApiTriggerService;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.api.view.repository.Api1102Rep;
import com.fzzy.api.view.repository.Api1208Rep;
import com.fzzy.api.view.repository.ApiLogRep;
import com.fzzy.async.fzzy40.entity.Fz40DepotStore;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1208Rep;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
 * ç²®é£Ÿåº“å­˜
 */
@Slf4j
@Component
public class Fzzy40Sync1208 {
    @Autowired
    private Fzzy40Sync1208Rep fzzySync1208Rep;
    @Autowired
    private ApiTriggerService apiTriggerService;
    @Autowired
    private Api1208Rep api1208Rep;
    @Autowired
    private ApiCommonService commonService;
    @Autowired
    private Api1102Rep api1102Rep;
    @Autowired
    private ApiLogRep apiLogRep;
    /**
     * åŒæ­¥ç²®é£Ÿåº“å­˜
     *
     * @param deptId
     * @param start
     * @param end
     */
    public void syncData(String kqdm, String deptId, Date start, Date end) {
        log.info("-------------1208接口数据开始同步------------------");
        //同步数据,只记录失败的信息
        ApiLog apiLog = new ApiLog();
        apiLog.setType(ApiLog.TYPE_SYNC);
        apiLog.setKqdm(deptId);
        apiLog.setUploadTime(new Date());
        apiLog.setInteId(Constant.API_CODE_1208);
        apiLog.setStatus(99);
        apiLog.setId(ContextUtil.getUUID());
        try {
            List<Fz40DepotStore> list = fzzySync1208Rep.listDepot(deptId, start, end);
            if (null == list || list.isEmpty()) {
                log.info("-------------没有获取到粮食库存信息------------------");
                return;
            }
            //根据库区代码获取单位代码
            Api1102 api1102 = api1102Rep.findById(kqdm).get();
            Api1208 apiData;
            Api1105 api1105;
            for (Fz40DepotStore fz40DepotStore : list) {
                //获取货位信息
                api1105 = commonService.getApi1105Cache(fz40DepotStore.getDepotId());
                if (null == api1105) {
                    continue;
                }
                apiData = new Api1208();
                apiData.setHwdm(api1105.getHwdm());
                //粮食品种
                String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40DepotStore.getFoodVariety());
                apiData.setLspzdm(mappingCode);
                //粮食性质
                mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz40DepotStore.getFoodType());
                apiData.setLsxzdm(mappingCode);
                //粮食等级
                mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSDJ, fz40DepotStore.getFoodLevel());
                apiData.setLsdjdm(mappingCode);
                apiData.setShnd(fz40DepotStore.getFoodYear());
                //产地代码
                String cd = commonService.getFoodLocationIdFromCache(fz40DepotStore.getFoodLocation());
                apiData.setCd(cd);
                apiData.setBgy(api1105.getBgy());
                //粮权归属单位
                apiData.setLqgsdwdm(api1102.getDwdm());
                //粮权行政区划代码
                apiData.setLqxzqhdm(api1102.getDwdm().substring(2, 8));
                //管理方式-默认直储
                apiData.setGlfs("01");
                //收储地点-默认库内
                apiData.setScdd("1");
                //储粮方式
                apiData.setClfs(fz40DepotStore.getStoreType());
                //货位状态
                mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_HWZT, fz40DepotStore.getDepotStatus());
                apiData.setHwzt(mappingCode);
                if(null == fz40DepotStore.getStoreDate()){
                    fz40DepotStore.setStoreDate(new Date());
                }
                //入仓时间
                apiData.setRcsj(fz40DepotStore.getStoreDate());
                //封仓日期
                if("3".equals(apiData.getHwzt())){
                    apiData.setFcrq(DateUtils.addDays(fz40DepotStore.getStoreDate(), 10));
                }
                //出仓完成时间
                if("1".equals(apiData.getHwzt())){
                    apiData.setCcwcsj(DateUtils.addDays(fz40DepotStore.getStoreDate(), 5));
                }
                //国别
                apiData.setGb("156");
                apiData.setSjsl(fz40DepotStore.getStorageReal());
                apiData.setJjsl(fz40DepotStore.getStorageReal());
                apiData.setSjzlxg(6);
                apiData.setLdtj(10000);
                apiData.setZhgxsj(new Date());
                //业务id、库区编码、同步时间
                apiData.setBizId(fz40DepotStore.getId());
                apiData.setKqdm(kqdm);
                apiData.setSyncTime(new Date());
                //库存每次新增
                apiData.setCzbz(Constant.CZBZ_I);
                apiData.setId(ContextUtil.getCurTimeMillis());
                //保存数据
                api1208Rep.save(apiData);
            }
        } catch (Exception e) {
            log.error("---同步失败----{}", e);
            apiLog.setResult("同步失败:" + e.getMessage());
            apiLogRep.save(apiLog);
        }
    }
}
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1208Rep.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.fzzy.async.fzzy40.repository;
import com.fzzy.async.fzzy40.entity.Fz40DepotStore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Date;
import java.util.List;
/**
 * ç²®é£Ÿè´­é”€-粮食库存
 */
public interface Fzzy40Sync1208Rep extends JpaRepository<Fz40DepotStore, String> {
    /**
     * æ ¹æ®ä¿¡æ¯èŽ·å–ä»“åº“ä¿¡æ¯
     *
     * @return
     */
    @Query("from Fz40DepotStore where deptId=:deptId and createDate >=:start and createDate <:end order by createDate ")
    List<Fz40DepotStore> listDepot(@Param("deptId") String deptId, @Param("start") Date start, @Param("end") Date end);
}