package com.fzzy.async.fzzy35.impl;
|
|
import com.fzzy.api.Constant;
|
import com.fzzy.api.entity.*;
|
import com.fzzy.api.utils.ContextUtil;
|
import com.fzzy.api.view.repository.*;
|
import com.fzzy.async.fzzy35.entity.Fz35Plan;
|
import com.fzzy.async.fzzy35.repository.Fzzy35Sync1403Rep;
|
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 chen
|
* @date 2023-05-14 19:51
|
*/
|
@Slf4j
|
@Component
|
public class Fzzy35Sync1403 {
|
|
@Autowired
|
private Fzzy35Sync1403Rep fzzy35Sync1403Rep;
|
@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<Fz35Plan> list = fzzy35Sync1403Rep.findDate("3", start, end);
|
if (null == list || list.isEmpty()) {
|
return;
|
}
|
|
Api1403 api1403;
|
List<Api1101> api1101List;
|
List<Api1403> api1403List;
|
for (Fz35Plan fz35Plan : list) {
|
api1403 = new Api1403();
|
api1403.setLhjhdh(fz35Plan.getId());
|
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);
|
}
|
}
|
|
}
|