| package com.fzzy.async.whhpjl.impl; | 
|   | 
| import com.alibaba.fastjson.JSON; | 
| import com.fzzy.api.Constant; | 
| import com.fzzy.api.entity.ApiInfoData; | 
| import com.fzzy.api.entity.ApiLog; | 
| import com.fzzy.api.utils.ContextUtil; | 
| import com.fzzy.api.view.repository.ApiInfoDataRep; | 
| import com.fzzy.api.view.repository.ApiLogRep; | 
| import com.fzzy.async.whhpjl.entity.Fz40WhjlDefaultUser; | 
| import com.fzzy.async.whhpjl.repository.Fz40ToWhjlSync1103Rep; | 
| import com.fzzy.otherview.whhpjl.WhjlConstant; | 
| import com.fzzy.otherview.whhpjl.dto.WhjlApi1103; | 
| 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:YAN | 
|  */ | 
| @Slf4j | 
| @Component | 
| public class Fz40ToWhjlSync1103 { | 
|     @Autowired | 
|     private Fz40ToWhjlSync1103Rep fz40ToWhjlSync1103Rep; | 
|     @Autowired | 
|     private ApiLogRep apiLogRep; | 
|     @Autowired | 
|     private ApiInfoDataRep apiInfoDataRep; | 
|   | 
|     /** | 
|      * 军工人员信息 | 
|      * | 
|      * @param kqdm | 
|      * @param deptId | 
|      * @param start | 
|      * @param end | 
|      */ | 
|     public void syncData(String kqdm, String deptId, Date start, Date end) { | 
|   | 
|         log.info("-------------1103接口数据开始同步------------------"); | 
|   | 
|         //同步数据,只记录失败的信息 | 
|         ApiLog apiLog = new ApiLog(); | 
|         apiLog.setType(ApiLog.TYPE_SYNC); | 
|         apiLog.setKqdm(deptId); | 
|         apiLog.setUploadTime(new Date()); | 
|         apiLog.setInteId(Constant.API_CODE_1103); | 
|         apiLog.setStatus(99); | 
|         apiLog.setId(ContextUtil.getUUID()); | 
|         try { | 
|             List<Fz40WhjlDefaultUser> list = fz40ToWhjlSync1103Rep.listApi1103(deptId.substring(0, 4)); | 
|             if (null == list || list.isEmpty()) { | 
|                 log.info("-------------没有获取到单位信息------------------"); | 
|                 return; | 
|             } | 
|             List<ApiInfoData> apiInfoDataList; | 
|             WhjlApi1103 apiData; | 
|             for (Fz40WhjlDefaultUser sysData : list) { | 
|                 apiData = new WhjlApi1103(); | 
|                 apiData.setRybh(sysData.getUsername());  //人员编号 | 
|                 apiData.setJlqybh("");  //军粮企业编号 | 
|                 apiData.setJlqymc("");  //军粮企业名称 | 
|                 apiData.setJgzdbh("");  //军供站点编号 | 
|                 apiData.setJlqymc("");  //军供站点名称 | 
|                 apiData.setRyxm(sysData.getCname());  //人员姓名 | 
|                 apiData.setSfzhm("");  //身份证编码 | 
|                 apiData.setLxdh(sysData.getMobile());  //联系电话 | 
|                 apiData.setXl("本科");  //学历 | 
|                 apiData.setLxdz("");  //联系地址 | 
|                 apiData.setSfyx("是"); | 
|                 if (!sysData.isEnabled()) { | 
|                     apiData.setSfyx("否"); | 
|                 } | 
|                 apiData.setBizId(sysData.getUsername()); | 
|                 apiData.setUpdateTime(new Date()); | 
|   | 
|                 //持久化保存,单独存入非国标接口表 | 
|                 ApiInfoData infoData = new ApiInfoData(); | 
|                 infoData.setId(sysData.getUsername()); | 
|                 infoData.setKqdm(kqdm); | 
|                 infoData.setInteType(WhjlConstant.API_CATEGORY_11); | 
|                 infoData.setInteId(WhjlConstant.API_CODE_1103); | 
|                 infoData.setUpdateTime(new Date()); | 
|                 infoData.setDataId(sysData.getUsername()); | 
|                 infoData.setRemarks("备注信息"); | 
|   | 
|                 //设置操作标志 | 
|                 apiInfoDataList = apiInfoDataRep.getDataByDataId(infoData.getDataId()); | 
|                 if (null == apiInfoDataList || apiInfoDataList.isEmpty()) { | 
|                     apiData.setCzbz(Constant.CZBZ_I); | 
|                     infoData.setCzbz(Constant.CZBZ_I); | 
|                 } else { | 
|                     apiData.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|                     infoData.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|                 } | 
|   | 
|                 infoData.setData(JSON.toJSONString(apiData)); | 
|                 apiInfoDataRep.save(infoData); | 
|   | 
|   | 
|                 log.info("1103---军工人员-同步数据:{}", apiData.toString()); | 
|             } | 
|   | 
|         } catch (Exception e) { | 
|             log.error("---1103军工人员-同步数据执行失败----{}", e.getMessage()); | 
|             apiLog.setResult("1103军工人员信息同步失败:" + e.getMessage()); | 
|             apiLogRep.save(apiLog); | 
|         } | 
|     } | 
| } |