|  |  |  | 
|---|
|  |  |  | import com.fzzy.api.utils.ContextUtil; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.Api1304Rep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.ApiLogRep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.entity.Gas; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.entity.Fz35Gas; | 
|---|
|  |  |  | import com.fzzy.async.fzzy35.repository.Fzzy35Sync1304Rep; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 虫害检测数据同步 | 
|---|
|  |  |  | 
|---|
|  |  |  | apiLog.setStatus(99); | 
|---|
|  |  |  | apiLog.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | List<Gas> list = fzzySync1304Rep.findByReceiveDate(start, end); | 
|---|
|  |  |  | List<Fz35Gas> list = fzzySync1304Rep.findByReceiveDate(start, end); | 
|---|
|  |  |  | if (null == list || list.isEmpty()) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Date syncTime = new Date(); | 
|---|
|  |  |  | Api1304 api1304; | 
|---|
|  |  |  | Api1105 api1105; | 
|---|
|  |  |  | // int index = 10001; | 
|---|
|  |  |  | for (Gas gas : list) { | 
|---|
|  |  |  | List<Api1304> api1304List; | 
|---|
|  |  |  | for (Fz35Gas fz35Gas : list) { | 
|---|
|  |  |  | //获取货位信息 | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(gas.getDepotId()); | 
|---|
|  |  |  | api1105 = commonService.getApi1105Cache(fz35Gas.getDepotId()); | 
|---|
|  |  |  | if (null == api1105) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1304 = new Api1304(); | 
|---|
|  |  |  | // api1304.setQtndjcdh(api1105.getHwdm() + DateFormatUtils.format(gas.getReceiveDate(), "yyyyMMdd") + String.valueOf(index).substring(1)); | 
|---|
|  |  |  | api1304.setQtndjcdh(api1105.getHwdm() + gas.getBatchId()); | 
|---|
|  |  |  | api1304.setJcsj(gas.getReceiveDate()); | 
|---|
|  |  |  | api1304.setQtndjcdh(api1105.getHwdm() + fz35Gas.getBatchId()); | 
|---|
|  |  |  | api1304.setJcsj(fz35Gas.getReceiveDate()); | 
|---|
|  |  |  | api1304.setHwdm(api1105.getHwdm()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1304 = updateGasInfo(api1304, gas.getPoints()); | 
|---|
|  |  |  | api1304 = updateGasInfo(api1304, fz35Gas.getPoints()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1304.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | api1304.setZhgxsj(syncTime); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | api1304.setBizId(gas.getBatchId()); | 
|---|
|  |  |  | api1304.setBizId(fz35Gas.getBatchId()); | 
|---|
|  |  |  | api1304.setKqdm(api1105.getKqdm()); | 
|---|
|  |  |  | api1304.setSyncTime(syncTime); | 
|---|
|  |  |  | api1304List = api1304Rep.getDataByQtndjcdh(api1304.getQtndjcdh()); | 
|---|
|  |  |  | if(null == api1304List || api1304List.isEmpty()){ | 
|---|
|  |  |  | api1304.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | api1304.setCzbz(api1304List.get(0).getCzbz()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | api1304Rep.save(api1304); | 
|---|
|  |  |  | //   index++; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("---同步失败----{}", e); | 
|---|