WS
2023-08-17 8eae44e262f427fec2f82db0aca819b0494ae3ef
提交质检信息同步
已修改1个文件
已添加3个文件
341 ■■■■■ 文件已修改
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java 149 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java 153 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java
@@ -6,6 +6,7 @@
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1302;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1303;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1304;
import com.fzzy.async.fzzy40.impl.Fzzy40Sync1310;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -25,6 +26,8 @@
    private Fzzy40Sync1303 fzzySync1303;
    @Autowired
    private Fzzy40Sync1304 fzzySync1304;
    @Autowired
    private Fzzy40Sync1310 fzzySync1310;
    @Override
    public String getProtocol() {
@@ -34,16 +37,17 @@
    @Override
    public void syncData(ApiParam param) {
        //温湿度检测数据同步 TODO
        //温湿度检测数据同步
        fzzySync1302.syncData(param.getDeptId(), param.getStart(), param.getEnd());
        //虫害检测同步  TODO
        //虫害检测同步
        fzzySync1303.syncData(param.getDeptId(), param.getStart(), param.getEnd());
        //气体检测同步  TODO
        //气体检测同步
        fzzySync1304.syncData(param.getDeptId(), param.getStart(), param.getEnd());
        //质检同步  TODO
        //质检同步
        fzzySync1310.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd());
        //通风作业信息同步  TODO
src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,149 @@
package com.fzzy.async.fzzy40.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.bstek.dorado.annotation.PropertyDef;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
 * è´¨é‡ç®¡ç†ï¼Œ2023å¹´5月26日 æ ¹æ®æ–°å›½ç²®è§„优化调整
 *
 * @author chen
 */
@Data
@Entity
@Table(name = "D_M_QUALITY")
public class Fz40Quality implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_", length = 40)
    @PropertyDef(label = "主键ID", description = "ZJ+检验类别+年月日时分秒")
    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 = "FOOD_VARIETY_", length = 10)
    @PropertyDef(label = "粮食品种")
    private String foodVariety;
    @Column(name = "FOOD_LEVEL_", length = 10)
    @PropertyDef(label = "粮食等级")
    private String foodLevel;
    @PropertyDef(label = "入库日期")
    @Column(name = "STORE_DATE_")
    private Date storeDate;
    @Column(name = "TYPE_", length = 10)
    @PropertyDef(label = "检验类别", description = "01:入仓验收 02:出仓检验 03:3 æœˆæœ«æ™®æ£€04:9 æœˆæœ«æ™®æ£€ 05:入仓初检 06:月度检查 07:3 æœˆæœ«åº“内普查 08:9 æœˆæœ«åº“内普查")
    private String type;
    @Column(name = "TIME_")
    @PropertyDef(label = "检验时间")
    private Date time;
    @Column(name = "USER_", length = 50)
    @PropertyDef(label = "检验人", description = "检验人员姓名,若有多个保管员")
    private String user;
    @Column(name = "UNIT_", length = 50)
    @PropertyDef(label = "检验单位")
    private String unit;
    @Column(name = "STANDARD_", length = 4)
    @PropertyDef(label = "检验依据", description = "1-国标,0-其他")
    private String standard;
    @PropertyDef(label = "指标类别", description = "1: è´¨é‡æŒ‡æ ‡æ£€éªŒ2:储存品质检验3:食品安全检验 å¦‚果同时检验了多个,用#隔开,例如:1#2#3")
    @Column(name = "zblb", length = 8)
    private String zblb;
    @Column(name = "RESULT_", length = 40)
    @PropertyDef(label = "检验结论", description = "1、质量指标填写/达标/不达标 2、储存品质指标填写“宜存”、轻度不宜存”、“重度不宜存”3、食品安全指标填写“合格”、不合格” å¤šé¡¹æŒ‡æ ‡æ—¶ä»¥#分隔,例如:达标|综合判定#宜存#合格 ")
    private String result;
    @JSONField(format = "yyyy-MM-dd")
    @PropertyDef(label = "签发日期")
    @Column(name = "qfrq")
    private Date qfrq;
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @PropertyDef(label = "报告出具时间")
    @Column(name = "bgcjsj")
    private Date bgcjsj;
    @PropertyDef(label = "审核人姓名")
    @Column(name = "shrxm", length = 64)
    private String shrxm;
    @PropertyDef(label = "扦样单编号")
    @Column(name = "qydbh", length = 64)
    private String qydbh;
    @Column(name = "CHECK_TIME_")
    @PropertyDef(label = "扦样时间", required = true)
    private Date checkTime;
    @Column(name = "CHECK_AREA_", length = 50)
    @PropertyDef(label = "扦样区域")
    private String checkArea;
    @Column(name = "CHECK_USER_", length = 50)
    @PropertyDef(label = "扦样人", required = true)
    private String checkUser;
    @PropertyDef(label = "监督人姓名")
    @Column(name = "jdrxm", length = 64)
    private String jdrxm;
    @PropertyDef(label = "样品编号")
    @Column(name = "ypbh", length = 64)
    private String ypbh;
    @PropertyDef(label = "样品数量", required = true)
    @Column(name = "ypsl", precision = 20, scale = 6)
    private double ypsl;
    @PropertyDef(label = "代表数量")
    @Column(name = "dbsl", precision = 20, scale = 6)
    private double dbsl;
    @PropertyDef(label = "样品等级")
    @Column(name = "ypdj", length = 2)
    private String ypdj;
    @Column(name = "NORMAL_YEAR_", length = 10)
    @PropertyDef(label = "是否正常存储年限")
    private String normalYear;
    @Column(name = "REMARK_", length = 200)
    @PropertyDef(label = "备注", description = "备注信息")
    private String remark;
    @Column(name = "UPDATE_TIME_")
    @PropertyDef(label = "数据更新时间")
    private Date updateTime;
//
//    /**
//     * åŒ–验项目明细
//     */
//    @Transient
//    private List<CheckItemData> checkItems;
}
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,153 @@
package com.fzzy.async.fzzy40.impl;
import com.fzzy.api.Constant;
import com.fzzy.api.entity.Api1105;
import com.fzzy.api.entity.Api1310;
import com.fzzy.api.entity.ApiLog;
import com.fzzy.api.entity.GbCheckItem;
import com.fzzy.api.service.ApiCommonService;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.api.view.repository.Api1310Rep;
import com.fzzy.api.view.repository.ApiLogRep;
import com.fzzy.api.view.repository.GbCheckItemRep;
import com.fzzy.async.fzzy40.entity.Fz40CheckItem;
import com.fzzy.async.fzzy40.entity.Fz40Quality;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1203Rep;
import com.fzzy.async.fzzy40.repository.Fzzy40Sync1310Rep;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
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;
/**
 * è´¨æ£€åŒæ­¥
 *
 * @author czt
 * @date 2023-05-14 19:51
 */
@Slf4j
@Component
public class Fzzy40Sync1310 {
    @Autowired
    private Fzzy40Sync1310Rep fzzySync1310Rep;
    @Autowired
    private Fzzy40Sync1203Rep fzzySync1203Rep;
    @Autowired
    private GbCheckItemRep gbCheckItemRep;
    @Autowired
    private ApiCommonService commonService;
    @Autowired
    private Api1310Rep api1310Rep;
    @Autowired
    private ApiLogRep apiLogRep;
    /**
     * åŒæ­¥å¹¶å°è£…保存质检数据
     *
     * @param deptId ç³»ç»Ÿå¯¹åº”库区编码
     * @param start  èµ·å§‹æ—¶é—´
     * @param end    æˆªæ­¢æ—¶é—´
     */
    public void syncData(String kqdm, String deptId, Date start, Date end) {
        log.info("-------------1310接口数据开始同步------------------");
        //同步数据,只记录失败的信息
        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<Fz40Quality> list = fzzySync1310Rep.findDateByTime(start, end);
            if (null == list || list.isEmpty()) {
                return;
            }
            Api1310 api1310;
            Api1105 api1105;
            List<Fz40CheckItem> fz40CheckItems;
            List<GbCheckItem> gbCheckList;
            StringBuilder jyxm;
            StringBuilder jyxmz;
            List<Api1310> api1310List;
            int index = 10001;
            for (Fz40Quality fz40Quality : list) {
                api1105 = commonService.getApi1105Cache(fz40Quality.getDepotId());
                if (null == api1105) {
                    continue;
                }
                api1310 = new Api1310();
                api1310.setZjbgdh(fz40Quality.getType() + DateFormatUtils.format(fz40Quality.getTime(), "yyyyMMdd") + String.valueOf(index).substring(1));
                api1310.setHwdm(api1105.getHwdm());
                api1310.setKqdm(kqdm);
                api1310.setLspzdm(fz40Quality.getFoodVariety());
                api1310.setLsdjdm(fz40Quality.getFoodLevel());
                api1310.setRkrq(DateUtils.addDays(fz40Quality.getTime(), -30));
                api1310.setJylb(fz40Quality.getType());
                api1310.setJysj(fz40Quality.getTime());
                api1310.setJydw(fz40Quality.getUser());
                api1310.setJyr(fz40Quality.getUser());
                api1310.setJyyj(fz40Quality.getStandard());
                api1310.setZblb("2");
                //检测项,检测值
                jyxm = new StringBuilder();
                jyxmz = new StringBuilder();
                fz40CheckItems = fzzySync1203Rep.listInoutCheckItem(fz40Quality.getId(), deptId.substring(0, 4));
                if (null != fz40CheckItems && fz40CheckItems.size() > 0) {
                    for (Fz40CheckItem fz40CheckItem : fz40CheckItems) {
                        if(StringUtils.isEmpty(fz40CheckItem.getValue())){
                            continue;
                        }
                        gbCheckList = gbCheckItemRep.findByBizCode(fz40CheckItem.getStandardId());
                        if (gbCheckList == null || gbCheckList.isEmpty()) {
                            continue;
                        }
                        jyxm.append(",").append(gbCheckList.get(0).getCode());
                        jyxmz.append(",").append(fz40CheckItem.getValue());
                    }
                }
                api1310.setJyxm(jyxm.toString().substring(1));
                api1310.setJyxmz(jyxmz.toString().substring(1));
                api1310.setZbjgpd(fz40Quality.getResult());
                api1310.setQfrq(fz40Quality.getTime());
                api1310.setBgcjsj(fz40Quality.getTime());
                api1310.setShrxm(fz40Quality.getCheckUser());
                api1310.setQysj(fz40Quality.getCheckTime());
                api1310.setQyqy(fz40Quality.getCheckArea());
                api1310.setQyrxm(fz40Quality.getCheckUser());
                api1310.setJdrxm(fz40Quality.getCheckUser());
                api1310.setYpsl(fz40Quality.getYpsl());
                api1310.setDbsl(fz40Quality.getDbsl());
                api1310.setYpdj(StringUtils.isEmpty(fz40Quality.getYpdj())?"0": fz40Quality.getYpdj());
                api1310.setSfzcccnx(StringUtils.isEmpty(fz40Quality.getNormalYear())?"0": fz40Quality.getNormalYear());
                api1310.setBz(fz40Quality.getRemark());
                api1310.setZhgxsj(new Date());
                api1310List = api1310Rep.getDataByZjbgdh(api1310.getZjbgdh());
                if(null == api1310List || api1310List.isEmpty()){
                    api1310.setCzbz(Constant.CZBZ_I);
                }else {
                    api1310.setCzbz(api1310List.get(0).getCzbz());
                }
                api1310Rep.save(api1310);
                index ++;
            }
        } catch (Exception e) {
            log.error("---同步失败----{}", e);
            apiLog.setResult("同步失败:" + e.getMessage());
            apiLogRep.save(apiLog);
        }
    }
}
src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.fzzy.async.fzzy40.repository;
import com.fzzy.async.fzzy40.entity.Fz40Quality;
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 chen
 * @date 2023-05-14 19:55
 */
public interface Fzzy40Sync1310Rep extends JpaRepository<Fz40Quality, String> {
    /**
     * æ ¹æ®æ—¶é—´æ®µæŸ¥è¯¢ç²®æƒ…数据
     * @param start
     * @param end
     * @return
     */
    @Query("from Fz40Quality where time >=:start and time <:end order by time ")
    List<Fz40Quality> findDateByTime(@Param("start") Date start, @Param("end") Date end);
}