¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.fzzy.async.fzzy40.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | 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.*; |
| | | import com.fzzy.async.fzzy40.entity.Fz40DrugLogApply; |
| | | import com.fzzy.async.fzzy40.entity.Fz40DrugLogDtl; |
| | | import com.fzzy.async.fzzy40.entity.Fz40DrugLogPeople; |
| | | import com.fzzy.async.fzzy40.repository.*; |
| | | import com.fzzy.push.gd2022.ApiCodeConstant; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1023Dtl; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1023People; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1023Way; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * çè¸å¤æ¡ä¿¡æ¯ |
| | | * |
| | | * @Author:YAN |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class Fzzy40Sync9201 { |
| | | @Autowired |
| | | private Api1101Rep api1101Rep; |
| | | @Autowired |
| | | private Api1102Rep api1102Rep; |
| | | @Autowired |
| | | private Fzzy40Sync9201Rep fzzy40Sync9201Rep; |
| | | @Autowired |
| | | private Fzzy40SyncDrugLogPeopleRep drugLogPeopleRep; |
| | | @Autowired |
| | | private Fzzy40SyncDrugLogDtlRep drugLogDtlRep; |
| | | @Autowired |
| | | private ApiLogRep apiLogRep; |
| | | @Autowired |
| | | private ApiCommonService commonService; |
| | | @Autowired |
| | | private ApiTriggerService apiTriggerService; |
| | | |
| | | @Autowired |
| | | private Api9201Rep api9201Rep; |
| | | |
| | | |
| | | /** |
| | | * 忥çè¸å¤æ¡ä¿¡æ¯ |
| | | * |
| | | * @param deptId |
| | | * @param start |
| | | * @param end |
| | | */ |
| | | public void syncData(String kqdm, String deptId, Date start, Date end) { |
| | | log.info("-------------9201æ¥å£çè¸å¤æ¡ä¿¡æ¯å¼å§åæ¥------------------"); |
| | | |
| | | //åæ¥æ°æ®ï¼åªè®°å½å¤±è´¥çä¿¡æ¯ |
| | | ApiLog apiLog = new ApiLog(); |
| | | apiLog.setType(ApiLog.TYPE_SYNC); |
| | | apiLog.setKqdm(deptId); |
| | | apiLog.setUploadTime(new Date()); |
| | | apiLog.setInteId(ApiCodeConstant.API_9201); |
| | | apiLog.setStatus(99); |
| | | apiLog.setId(ContextUtil.getUUID()); |
| | | try { |
| | | List<Fz40DrugLogApply> list = fzzy40Sync9201Rep.listDrugLogApply(deptId, start, end); |
| | | |
| | | if (null == list || list.isEmpty()) { |
| | | log.info("-------------没æè·åå°çè¸å¤æ¡ä¿¡æ¯------------------"); |
| | | return; |
| | | } |
| | | List<Gd2022Api1023Dtl> dtlList; |
| | | List<Gd2022Api1023Way> wayList; |
| | | List<Gd2022Api1023People> peopleList; |
| | | |
| | | List<Api9201> api9201List; |
| | | |
| | | Api1105 api1105; |
| | | Api9201 api9201; |
| | | Gd2022Api1023Dtl api9201Dtl; |
| | | Gd2022Api1023Way api9201Way; |
| | | Gd2022Api1023People api9201People; |
| | | |
| | | for (Fz40DrugLogApply data : list) { |
| | | |
| | | api9201 = new Api9201(); |
| | | BeanUtils.copyProperties(data, api9201); |
| | | api9201.setBizId(data.getXzbm()); |
| | | api9201.setId(data.getXzbm()); |
| | | api9201.setXzbm(data.getXzbm().substring(8)); |
| | | api9201.setKqdm(kqdm); |
| | | List<Api1102> api1102List = api1102Rep.findPushData(kqdm); |
| | | if (null != api1102List && api1102List.size() > 0) { |
| | | api9201.setKqmc(api1102List.get(0).getKqmc()); |
| | | } |
| | | |
| | | api9201.setDwdm(kqdm.substring(0, 18)); |
| | | List<Api1101> api1101List = api1101Rep.findPushData(kqdm); |
| | | if (null != api1101List && api1101List.size() > 0) { |
| | | api9201.setDwmc(api1101List.get(0).getDwmc()); |
| | | } |
| | | api9201.setYjmc(data.getDrugName()); |
| | | api9201.setYjlx(data.getDrugType()); |
| | | api9201.setLqrq(data.getLqsj()); |
| | | api9201.setZhgxsj(data.getUpdateTime()); |
| | | if (data.getLqr().contains("ã")) { |
| | | api9201.setLqr(data.getLqr().replace('ã', '|')); |
| | | } |
| | | |
| | | //å¨ç²®ç²®æ
æç»è¡¨ |
| | | List<Fz40DrugLogDtl> dtls = drugLogDtlRep.listDrugLogDtl(data.getXzbm()); |
| | | |
| | | if (null != dtls && dtls.size() > 0) { |
| | | dtlList = new ArrayList<>(); |
| | | for (Fz40DrugLogDtl dtl : dtls) { |
| | | api9201Dtl = new Gd2022Api1023Dtl(); |
| | | BeanUtils.copyProperties(dtl, api9201Dtl); |
| | | api1105 = commonService.getApi1105Cache(data.getDepotId()); |
| | | if (null != api1105) { |
| | | api9201Dtl.setCfmc(api1105.getHwmc()); |
| | | api9201Dtl.setCfdm(api1105.getHwdm().substring(0, 25)); |
| | | } |
| | | |
| | | //ç²®é£åç§ |
| | | String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, data.getFoodVariety()); |
| | | api9201Dtl.setLspzdm(mappingCode); |
| | | api9201Dtl.setLsxzdm(data.getFoodType()); |
| | | api9201Dtl.setLsdjdm(data.getFoodLevel()); |
| | | api9201Dtl.setLssl(data.getNumber()); |
| | | api9201Dtl.setSf(data.getPerWet()); |
| | | api9201Dtl.setZz(data.getPerImpurity()); |
| | | dtlList.add(api9201Dtl); |
| | | } |
| | | api9201.setDtl(JSON.toJSONString(dtlList)); |
| | | api9201List = api9201Rep.getDataByBizId(api9201.getBizId()); |
| | | if (null == api9201List || api9201List.isEmpty()) { |
| | | api9201.setCzbz(Constant.CZBZ_I); |
| | | } else { |
| | | api9201.setCzbz(api9201List.get(0).getCzbz()); |
| | | } |
| | | } |
| | | // BeanUtils.copyProperties(data, api9201Dtl); |
| | | // dtlList = new ArrayList<>(); |
| | | // dtlList.add(api9201Dtl); |
| | | // api9201.setDtl(JSON.toJSONString(dtlList)); |
| | | |
| | | |
| | | api9201Way = new Gd2022Api1023Way(); |
| | | BeanUtils.copyProperties(data, api9201Way); |
| | | wayList = new ArrayList<>(); |
| | | wayList.add(api9201Way); |
| | | api9201.setWay(JSON.toJSONString(wayList)); |
| | | |
| | | List<Fz40DrugLogPeople> peoples = drugLogPeopleRep.listDrugLogPeople(data.getXzbm()); |
| | | if (null != peoples && peoples.size() > 0) { |
| | | peopleList = new ArrayList<>(); |
| | | for (Fz40DrugLogPeople people : peoples) { |
| | | api9201People = new Gd2022Api1023People(); |
| | | BeanUtils.copyProperties(people, api9201People); |
| | | api9201People.setXm(people.getMx()); |
| | | if (StringUtils.isEmpty(people.getZyzg())) { |
| | | api9201People.setZyzg("å¹è®åæ ¼"); |
| | | } |
| | | peopleList.add(api9201People); |
| | | } |
| | | api9201.setPeople(JSON.toJSONString(peopleList)); |
| | | |
| | | api9201List = api9201Rep.getDataByBizId(api9201.getBizId()); |
| | | if (null == api9201List || api9201List.isEmpty()) { |
| | | api9201.setCzbz(Constant.CZBZ_I); |
| | | } else { |
| | | api9201.setCzbz(api9201List.get(0).getCzbz()); |
| | | } |
| | | } |
| | | api9201Rep.save(api9201); |
| | | log.info("9201---åæ¥æ°æ®ï¼{}", api9201.toString()); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("---çè¸å¤æ¡åæ¥æ§è¡å¤±è´¥----{}", e.toString()); |
| | | apiLog.setResult("çè¸å¤æ¡ä¿¡æ¯åæ¥æ§è¡å¤±è´¥ï¼" + e.getMessage()); |
| | | apiLogRep.save(apiLog); |
| | | } |
| | | } |
| | | } |