CZT
2023-10-30 e9260e2cac4ad51b6d785af4f0e147fc5d918ae5
增加4.0版本计划及计划详细
已修改2个文件
已添加6个文件
442 ■■■■■ 文件已修改
src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java 96 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java
@@ -3,6 +3,7 @@
import com.fzzy.api.Constant;
import com.fzzy.api.entity.*;
import com.fzzy.api.service.ApiCommonService;
import com.fzzy.api.service.ApiTriggerService;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.api.view.repository.Api1404Rep;
import com.fzzy.api.view.repository.ApiLogRep;
@@ -33,6 +34,8 @@
    private Fzzy35Sync1404Rep fzzy35Sync1404Rep;
    @Autowired
    private ApiCommonService commonService;
    @Autowired
    private ApiTriggerService apiTriggerService;
    @Autowired
    private Api1404Rep api1404Rep;
    @Autowired
@@ -81,11 +84,13 @@
                    api1404 = new Api1404();
                    api1404.setLhjhdh(kqdm.substring(0, 18) + fz35PlanDetail.getPlanId().split("_")[1] + fz35PlanDetail.getPlanId().split("_")[2]);
                    api1404.setJhmxdh(api1404.getLhjhdh() + kqdm + String.valueOf(index).substring(1));
                    api1404.setLspzdm(fz35PlanDetail.getFoodVariety());
                    String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35PlanDetail.getFoodVariety().substring(0,3));
                    api1404.setLspzdm(mappingCode);
                    api1404.setLsdjdm(fz35PlanDetail.getFoodLevel());
                    api1404.setLsxzdm(fz35PlanDetail.getFoodType());
                    mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35PlanDetail.getFoodType());
                    api1404.setLsxzdm(mappingCode);
                    api1404.setShnd(StringUtils.isEmpty(fz35PlanDetail.getYear())?fz35Plan.getYear():fz35PlanDetail.getYear());
                    api1404.setLhhwdm(fz35PlanDetail.getDepotId());
                    api1404.setLhhwdm(api1105.getHwdm());
                    api1404.setLhsl(fz35PlanDetail.getPlanNum());
                    api1404.setLhlx(fz35PlanDetail.getType());
                    api1404.setZhgxsj(new Date());
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java
@@ -3,6 +3,9 @@
import com.fzzy.api.data.ApiParam;
import com.fzzy.api.data.SyncProtocol;
import com.fzzy.api.service.SyncService14;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1403;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1404;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@@ -10,6 +13,12 @@
 */
@Component
public class Fzzy40SyncService14 implements SyncService14 {
    @Autowired
    private Fzzy40Sync1403 fzzy40Sync1403;
    @Autowired
    private Fzzy40Sync1404 fzzy40Sync1404;
    @Override
    public String getProtocol() {
@@ -19,10 +28,11 @@
    @Override
    public void syncData(ApiParam param) {
        //TODO è½®æ¢è®¡åˆ’同步
        //轮换计划同步
        fzzy40Sync1403.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd());
        //TODO è½®æ¢è®¡åˆ’明细同步
        //轮换计划明细同步
        fzzy40Sync1404.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd());
    }
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,87 @@
package com.fzzy.async.fzzy40.entity;
import com.bstek.dorado.annotation.PropertyDef;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * è®¡åˆ’管理-主表
 * <p>
 * åŒ…括:收购计划,销售计划,轮换记录,计划执行
 *
 * @author: andy.jia
 * @description: ç‰ˆæœ¬4.0字段已审
 * @version:
 * @data:2020å¹´5月27日
 */
@Data
@Entity
@Table(name = "D_INOUT_PLAN")
public class Fz40InoutPlan implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_", length = 40)
    @PropertyDef(label = "计划编码")
    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 = "TYPE_", length = 10)
    @PropertyDef(label = "计划类型")
    private String type;
    @Column(name = "NAME_", length = 50)
    @PropertyDef(label = "计划名称")
    private String name;
    @Column(name = "REFERENCE_NUMBER_", length = 40)
    @PropertyDef(label = "计划文号")
    private String referenceNumber;
    @Column(name = "YEAR_", length = 10)
    @PropertyDef(label = "年份")
    private String year;
    @Column(name = "BEGIN_TIME_")
    @PropertyDef(label = "开始时间")
    private Date beginTime;
    @Column(name = "END_TIME_")
    @PropertyDef(label = "截止时间")
    private Date endTime;
    @PropertyDef(label = "计划下达单位")
    @Column(name = "jhxddw", length = 18)
    private String jhxddw;
    @PropertyDef(label = "计划下达时间")
    @Column(name = "jhxdsj")
    private Date jhxdsj;
    @Column(name = "CREATE_USER_", length = 30)
    @PropertyDef(label = "创建人")
    private String createUser;
    @Column(name = "CREATE_TIME_")
    @PropertyDef(label = "创建时间")
    private Date createTime;
    @Column(name = "UPDATE_TIME_")
    @PropertyDef(label = "数据更新时间")
    private Date updateTime;
    @Column(name = "REMARK_", length = 250)
    @PropertyDef(label = "备注")
    private String remark;
}
src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
package com.fzzy.async.fzzy40.entity;
import com.bstek.dorado.annotation.PropertyDef;
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 ç‰ˆæœ¬4.0 éªŒè¯
 */
@Data
@Entity
@Table(name = "D_INOUT_PLAN_DETAIL")
public class Fz40InoutPlanDetail implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_", length = 40)
    @PropertyDef(label = "计划明细号")
    private String id;
    @Column(name = "PLAN_ID_", length = 40)
    @PropertyDef(label = "计划编码")
    private String planId;
    @Column(name = "FOOD_VARIETY_", length = 10)
    @PropertyDef(label = "粮食品种")
    private String foodVariety;
    @Column(name = "FOOD_TYPE_", length = 10)
    @PropertyDef(label = "粮食性质")
    private String foodType;
    @Column(name = "FOOD_LEVEL_", length = 10)
    @PropertyDef(label = "粮食等级")
    private String foodLevel;
    @Column(name = "YEAR_", length = 10)
    @PropertyDef(label = "收获年度")
    private String year;
    @Column(name = "DEPOT_ID_", length = 50)
    @PropertyDef(label = "仓库")
    private String depotId;
    @Column(name = "PLAN_NUM_", precision = 16, scale = 2)
    @PropertyDef(label = "计划数量", description = "单位:吨")
    private Double planNum;
    @Column(name = "TYPE_", length = 4)
    @PropertyDef(label = "计划类型")
    private String type;
    @Column(name = "UPDATE_TIME_")
    @PropertyDef(label = "数据更新时间")
    private Date updateTime;
}
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,96 @@
package com.fzzy.async.fzzy40.impl;
import com.fzzy.api.Constant;
import com.fzzy.api.entity.Api1101;
import com.fzzy.api.entity.Api1403;
import com.fzzy.api.entity.ApiLog;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.api.view.repository.Api1101Rep;
import com.fzzy.api.view.repository.Api1403Rep;
import com.fzzy.api.view.repository.ApiLogRep;
import com.fzzy.async.fzzy40.entity.Fz40InoutPlan;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1403Rep;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
 * è½®æ¢è®¡åˆ’同步
 *
 * @author czt
 * @date 2023-10-30 09:55
 */
@Slf4j
@Component
public class Fzzy40Sync1403 {
    @Autowired
    private Fzzy40Sync1403Rep fzzy40Sync1403Rep;
    @Autowired
    private Api1101Rep api1101Rep;
    @Autowired
    private Api1403Rep api1403Rep;
    @Autowired
    private ApiLogRep apiLogRep;
    /**
     * åŒæ­¥å¹¶å°è£…保存轮换计划数据
     *
     * @param deptId ç³»ç»Ÿå¯¹åº”库区编码
     * @param start  èµ·å§‹æ—¶é—´
     * @param end    æˆªæ­¢æ—¶é—´
     */
    public void syncData(String kqdm, String deptId, Date start, Date end) {
        log.info("-------------1403接口数据开始同步------------------");
        //同步数据,只记录失败的信息
        ApiLog apiLog = new ApiLog();
        apiLog.setType(ApiLog.TYPE_SYNC);
        apiLog.setKqdm(deptId);
        apiLog.setUploadTime(new Date());
        apiLog.setInteId(Constant.API_CODE_1304);
        apiLog.setStatus(99);
        apiLog.setId(ContextUtil.getUUID());
        try {
            List<Fz40InoutPlan> list = fzzy40Sync1403Rep.findDate("3", start, end);
            if (null == list || list.isEmpty()) {
                return;
            }
            Api1403 api1403;
            List<Api1101> api1101List;
            List<Api1403> api1403List;
            for (Fz40InoutPlan fz35Plan : list) {
                api1403 = new Api1403();
                api1403.setLhjhdh(kqdm.substring(0, 18) + fz35Plan.getId().split("_")[1] + fz35Plan.getId().split("_")[2]);
                api1403.setJhwh(fz35Plan.getReferenceNumber());
                api1403.setJhmc(fz35Plan.getName());
                api1403.setJhnd(fz35Plan.getYear());
                api1403.setKszxrq(fz35Plan.getBeginTime());
                api1403.setJzzxrq(fz35Plan.getEndTime());
                api1101List = api1101Rep.findPushData(kqdm);
                if(null != api1101List && api1101List.size() > 0){
                    api1403.setJhxddw(api1101List.get(0).getDwdm());
                }
                api1403.setJhxdsj(fz35Plan.getCreateTime());
                api1403.setZhgxsj(new Date());
                api1403.setKqdm(kqdm);
                api1403.setBizId(fz35Plan.getId());
                api1403List = api1403Rep.getDataByLhjhdh(api1403.getLhjhdh());
                if(null == api1403List || api1403List.isEmpty()){
                    api1403.setCzbz(Constant.CZBZ_I);
                }else {
                    api1403.setCzbz(api1403List.get(0).getCzbz());
                }
                api1403Rep.save(api1403);
            }
        } catch (Exception e) {
            log.error("---同步失败----{}", e);
            apiLog.setResult("同步失败:" + e.getMessage());
            apiLogRep.save(apiLog);
        }
    }
}
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,119 @@
package com.fzzy.async.fzzy40.impl;
import com.fzzy.api.Constant;
import com.fzzy.api.entity.Api1105;
import com.fzzy.api.entity.Api1404;
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.Api1404Rep;
import com.fzzy.api.view.repository.ApiLogRep;
import com.fzzy.async.fzzy40.entity.Fz40InoutPlan;
import com.fzzy.async.fzzy40.entity.Fz40InoutPlanDetail;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1403Rep;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1404Rep;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
 * è½®æ¢è®¡åˆ’明细
 *
 * @author czt
 * @date 2023-10-30 09:55
 */
@Slf4j
@Component
public class Fzzy40Sync1404 {
    @Autowired
    private Fzzy40Sync1403Rep fzzy35Sync1403Rep;
    @Autowired
    private Fzzy40Sync1404Rep fzzy35Sync1404Rep;
    @Autowired
    private ApiCommonService commonService;
    @Autowired
    private ApiTriggerService apiTriggerService;
    @Autowired
    private Api1404Rep api1404Rep;
    @Autowired
    private ApiLogRep apiLogRep;
    /**
     * åŒæ­¥å¹¶å°è£…保存质检数据
     *
     * @param deptId ç³»ç»Ÿå¯¹åº”库区编码
     * @param start  èµ·å§‹æ—¶é—´
     * @param end    æˆªæ­¢æ—¶é—´
     */
    public void syncData(String kqdm, String deptId, Date start, Date end) {
        log.info("-------------1404接口数据开始同步------------------");
        //同步数据,只记录失败的信息
        ApiLog apiLog = new ApiLog();
        apiLog.setType(ApiLog.TYPE_SYNC);
        apiLog.setKqdm(deptId);
        apiLog.setUploadTime(new Date());
        apiLog.setInteId(Constant.API_CODE_1304);
        apiLog.setStatus(99);
        apiLog.setId(ContextUtil.getUUID());
        try {
            List<Fz40InoutPlan> list = fzzy35Sync1403Rep.findDate("3", start, end);
            if (null == list || list.isEmpty()) {
                return;
            }
            Api1404 api1404;
            List<Fz40InoutPlanDetail> fz35PlanDetails;
            Api1105 api1105;
            List<Api1404> api1404List;
            for (Fz40InoutPlan fz35Plan : list) {
                fz35PlanDetails = fzzy35Sync1404Rep.findDate(fz35Plan.getId());
                if (null == fz35PlanDetails || fz35PlanDetails.isEmpty()) {
                    continue;
                }
                int index = 10001;
                for (Fz40InoutPlanDetail fz35PlanDetail : fz35PlanDetails) {
                    api1105 = commonService.getApi1105Cache(fz35PlanDetail.getDepotId());
                    if (null == api1105) {
                        continue;
                    }
                    api1404 = new Api1404();
                    api1404.setLhjhdh(kqdm.substring(0, 18) + fz35PlanDetail.getPlanId().split("_")[1] + fz35PlanDetail.getPlanId().split("_")[2]);
                    api1404.setJhmxdh(api1404.getLhjhdh() + kqdm + String.valueOf(index).substring(1));
                    String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35PlanDetail.getFoodVariety().substring(0,3));
                    api1404.setLspzdm(mappingCode);
                    api1404.setLsdjdm(fz35PlanDetail.getFoodLevel());
                    mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35PlanDetail.getFoodType());
                    api1404.setLsxzdm(mappingCode);
                    api1404.setShnd(StringUtils.isEmpty(fz35PlanDetail.getYear())?fz35Plan.getYear():fz35PlanDetail.getYear());
                    api1404.setLhhwdm(api1105.getHwdm());
                    api1404.setLhsl(fz35PlanDetail.getPlanNum());
                    api1404.setLhlx(fz35PlanDetail.getType());
                    api1404.setZhgxsj(new Date());
                    api1404.setKqdm(kqdm);
                    api1404.setBizId(fz35PlanDetail.getId());
                    api1404List = api1404Rep.getDataByJhmxdh(api1404.getJhmxdh());
                    if(null == api1404List || api1404List.isEmpty()){
                        api1404.setCzbz(Constant.CZBZ_I);
                    }else {
                        api1404.setCzbz(api1404List.get(0).getCzbz());
                    }
                    api1404Rep.save(api1404);
                    index ++;
                }
            }
        } catch (Exception e) {
            log.error("---同步失败----{}", e);
            apiLog.setResult("同步失败:" + e.getMessage());
            apiLogRep.save(apiLog);
        }
    }
}
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.fzzy.async.fzzy40.repository;
import com.fzzy.async.fzzy40.entity.Fz40InoutPlan;
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;
/**
 * æŸ¥è¯¢è½®æ¢è®¡åˆ’详细
 *
 * @author czt
 * @date 2023-10-30 09:55
 */
public interface Fzzy40Sync1403Rep extends JpaRepository<Fz40InoutPlan, String> {
    /**
     *
     * @param start
     * @param end
     * @return
     */
    @Query("from Fz40InoutPlan where type =:planType and createTime >=:start and createTime <:end order by createTime ")
    List<Fz40InoutPlan> findDate(@Param("planType") String planType, @Param("start") Date start, @Param("end") Date end);
}
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.fzzy.async.fzzy40.repository;
import com.fzzy.async.fzzy40.entity.Fz40InoutPlanDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
/**
 * æŸ¥è¯¢è½®æ¢è®¡åˆ’详细
 *
 * @author czt
 * @date 2023-10-30 09:55
 */
public interface Fzzy40Sync1404Rep extends JpaRepository<Fz40InoutPlanDetail, String> {
    /**
     *
     * @return
     */
    @Query("from Fz40InoutPlanDetail where planId =:planId ")
    List<Fz40InoutPlanDetail> findDate(@Param("planId") String planId);
}