|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.fzzy.api.Constant; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1102; | 
|---|
|  |  |  | import com.fzzy.api.entity.Api1105; | 
|---|
|  |  |  | import com.fzzy.api.entity.ApiInfoData; | 
|---|
|  |  |  | import com.fzzy.api.entity.ApiLog; | 
|---|
|  |  |  | import com.fzzy.api.entity.*; | 
|---|
|  |  |  | import com.fzzy.api.service.ApiCommonService; | 
|---|
|  |  |  | import com.fzzy.api.utils.ContextUtil; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.Api1102Rep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.ApiConfsRep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.ApiInfoDataRep; | 
|---|
|  |  |  | import com.fzzy.api.view.repository.ApiLogRep; | 
|---|
|  |  |  | import com.fzzy.async.fzzy40.entity.Fz40Depot; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.apache.commons.lang.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiCommonService commonService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private Api1102Rep api1102Rep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiLogRep apiLogRep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiConfsRep apiConfsRep; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApiInfoDataRep apiInfoDataRep; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | apiLog.setStatus(99); | 
|---|
|  |  |  | apiLog.setId(ContextUtil.getUUID()); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | //由于depotConf表中没有库区编码,先查询仓库表 | 
|---|
|  |  |  | List<Fz40Depot> list = fzzy40SyncDepotRep.listDepotList(deptId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == list || list.isEmpty()) { | 
|---|
|  |  |  | log.info("2103---粮情设备配置同步数据:没有查询到仓库信息"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Api1102> api1102List = api1102Rep.findPushData(kqdm); | 
|---|
|  |  |  | List<ApiConfs> apiConf = apiConfsRep.getDataByKqdm(kqdm); | 
|---|
|  |  |  | String bjw = ""; | 
|---|
|  |  |  | if(null != api1102List && api1102List.size() > 0){ | 
|---|
|  |  |  | bjw = ShAreaBjw.getBjw(api1102List.get(0).getXzqhdm()); | 
|---|
|  |  |  | if (null != apiConf && apiConf.size() > 0) { | 
|---|
|  |  |  | bjw = apiConf.get(0).getUserName(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SH2023Api2103 sh2023Api2103; | 
|---|
|  |  |  | 
|---|
|  |  |  | for (Fz40Depot fz40Depot : list) { | 
|---|
|  |  |  | //根据仓库编码获取配置信息 | 
|---|
|  |  |  | depotConfList = fzzy40SyncDepotConfRep.findDataByDepotId(fz40Depot.getId()); | 
|---|
|  |  |  | if(null == depotConfList || depotConfList.isEmpty()){ | 
|---|
|  |  |  | if (null == depotConfList || depotConfList.isEmpty()) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //获取货位信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | sh2023Api2103.setDlcs(strs[0]); | 
|---|
|  |  |  | sh2023Api2103.setDlhs(strs[1]); | 
|---|
|  |  |  | sh2023Api2103.setDlls(strs[2]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否有层行转换 | 
|---|
|  |  |  | if(null != depotConf.getStartConvert() && !"default".equals(depotConf.getStartConvert())){ | 
|---|
|  |  |  | sh2023Api2103.setDlcs(strs[1]); | 
|---|
|  |  |  | sh2023Api2103.setDlhs(strs[0]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 1-3-5 | 
|---|
|  |  |  | // 8-8-8 | 
|---|
|  |  |  | //筒仓规则 | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(depotConf.getCableCir())){ | 
|---|
|  |  |  | sh2023Api2103.setDlqs("0"); | 
|---|
|  |  |  | if (StringUtils.isNotEmpty(depotConf.getCableCir())) { | 
|---|
|  |  |  | sh2023Api2103.setDlqs(String.valueOf(strs.length)); | 
|---|
|  |  |  | sh2023Api2103.setDlhs(null); | 
|---|
|  |  |  | sh2023Api2103.setDlls(null); | 
|---|
|  |  |  | sh2023Api2103.setDlhs("0"); | 
|---|
|  |  |  | sh2023Api2103.setDlls("0"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //电缆圈排列详情 | 
|---|
|  |  |  | listItem = new ArrayList<>(); | 
|---|
|  |  |  | String[] cableCir = depotConf.getCableCir().split("-"); | 
|---|
|  |  |  | int num1 = 0;  //起始根 | 
|---|
|  |  |  | int num2 = 0;  //截止根 | 
|---|
|  |  |  | for(int i = 0; i < cableCir.length; i ++){ | 
|---|
|  |  |  | for (int i = 0; i < cableCir.length; i++) { | 
|---|
|  |  |  | sh2023Api2103.setDlcs(cableCir[i]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103Item = new SH2023Api2103Item(); | 
|---|
|  |  |  | sh2023Api2103Item.setQh(i + 1 + ""); | 
|---|
|  |  |  | if(i == 0){ | 
|---|
|  |  |  | if (i == 0) { | 
|---|
|  |  |  | num1 += 1; | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | num1 = num2 + 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | num2 += Integer.valueOf(strs[i]); | 
|---|
|  |  |  | sh2023Api2103Item.setQsdlbh(num1 + ""); | 
|---|
|  |  |  | sh2023Api2103Item.setJsdlbh(num2 + ""); | 
|---|
|  |  |  | sh2023Api2103Item.setCs(cableCir[i]); | 
|---|
|  |  |  | sh2023Api2103Item.setYbj((i + 1)*4 + ""); | 
|---|
|  |  |  | sh2023Api2103Item.setYbj((i + 1) * 4 + ""); | 
|---|
|  |  |  | sh2023Api2103Item.setRowId(i + ""); | 
|---|
|  |  |  | listItem.add(sh2023Api2103Item); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103.setScqd("1"); | 
|---|
|  |  |  | sh2023Api2103.setSczd(Integer.valueOf(strs[1])*Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  | sh2023Api2103.setSczd(Integer.valueOf(strs[1]) * Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103.setZcqd("1"); | 
|---|
|  |  |  | sh2023Api2103.setZczd(Integer.valueOf(strs[1])*Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  | sh2023Api2103.setZczd(Integer.valueOf(strs[1]) * Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103.setXcqd("1"); | 
|---|
|  |  |  | sh2023Api2103.setXczd(Integer.valueOf(strs[1])*Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  | sh2023Api2103.setXczd(Integer.valueOf(strs[1]) * Integer.valueOf(strs[2]) + ""); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103.setYxfwqsc("1"); | 
|---|
|  |  |  | sh2023Api2103.setYxfwjsc(strs[0]); | 
|---|
|  |  |  | sh2023Api2103.setYxfwjsc(sh2023Api2103.getDlcs()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sh2023Api2103.setBjw(bjw); | 
|---|
|  |  |  | sh2023Api2103.setZhgxsj(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | infoData.setRemarks("粮情设备配置信息"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置操作标志 | 
|---|
|  |  |  | apiInfoDataList = apiInfoDataRep.getDataByDataId(infoData.getDataId()); | 
|---|
|  |  |  | apiInfoDataList = apiInfoDataRep.getDataByInteAndData(SH2023Constant.SH_2023_API_CODE_2103, infoData.getDataId(),kqdm); | 
|---|
|  |  |  | if (null == apiInfoDataList || apiInfoDataList.isEmpty()) { | 
|---|
|  |  |  | infoData.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | sh2023Api2103.setCzbz(Constant.CZBZ_I); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | infoData.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|---|
|  |  |  | sh2023Api2103.setCzbz(apiInfoDataList.get(0).getCzbz()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | infoData.setData(JSON.toJSONString(sh2023Api2103)); | 
|---|