| | |
| | | package com.fzzy.push.shjdjw2023; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.bstek.dorado.util.DateUtils; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.data.PushProtocol; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.service.ApiTriggerService; |
| | | import com.fzzy.api.utils.AESUtils; |
| | | import com.fzzy.api.utils.ContextUtil; |
| | | import com.fzzy.api.utils.RedisUtil; |
| | | import com.fzzy.api.view.repository.*; |
| | | import com.fzzy.push.sh2023.dto.ShAreaBjw; |
| | | import com.fzzy.push.shjdjw2023.dto.*; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.commons.lang.time.DateFormatUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.DecimalFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 上海嘉定纪委监管平台-上传数据服务类 |
| | | * |
| | | * @author czt |
| | | * @date 2023/5/9 14:09 |
| | | * @date 2023/12/26 |
| | | */ |
| | | @Slf4j |
| | | @Data |
| | |
| | | @Autowired |
| | | private Api1103Rep api1103Rep; |
| | | @Autowired |
| | | private Api1104Rep api1104Rep; |
| | | @Autowired |
| | | private Api1105Rep api1105Rep; |
| | | @Autowired |
| | | private Api1202Rep api1202Rep; |
| | | @Autowired |
| | | private Api1104Rep api1104Rep; |
| | | private Api1205Rep api1205Rep; |
| | | @Autowired |
| | | private Api1208Rep api1208Rep; |
| | | @Autowired |
| | | private Api1210Rep api1210Rep; |
| | | @Autowired |
| | | private Api1403Rep api1403Rep; |
| | | @Autowired |
| | | private Api1404Rep api1404Rep; |
| | | |
| | | |
| | | @Override |
| | | public String getProtocol() { |
| | |
| | | @Override |
| | | public ResponseDto pushData(ApiParam param, Object data) { |
| | | return pushData(param, null, data); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseDto pullData(ApiParam param, ApiConfs conf) { |
| | | //该协议无此实现 |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | //添加日志 |
| | | ApiLog apiLog = new ApiLog(); |
| | | apiLog.setId(ContextUtil.getUUID()); |
| | | apiLog.setInteId(param.getInteId()); |
| | | apiLog.setInteId(inteId); |
| | | |
| | | //获取接口编码 |
| | | String interfaceId = getDataId(inteId); |
| | | |
| | | //获取json数据 |
| | | String jsonData = getJsonData(inteId, data, interfaceId); |
| | | |
| | | if (StringUtils.isEmpty(interfaceId)) { |
| | | if (StringUtils.isEmpty(inteId)) { |
| | | ResponseDto responseDto = new ResponseDto(99, "没有获取到接口", bizId); |
| | | apiLog.setStatus(99); |
| | | apiLog.setResult("没有获取到接口"); |
| | | apiLogRep.save(apiLog); |
| | | return responseDto; |
| | | } |
| | | apiLog.setData(jsonData); |
| | | |
| | | //查询库区信息行政区划码 |
| | | List<Api1102> api1102List = api1102Rep.findPushData(kqdm); |
| | | //获取json数据 |
| | | List<Object> list = getJsonData(inteId, data, api1102List.get(0).getXzqhdm()); |
| | | ShjdjwReqDto reqData = new ShjdjwReqDto(); |
| | | //接口ID |
| | | reqData.setId(getInteId(inteId)); |
| | | //上传数据,加密 |
| | | reqData.setData(list); |
| | | |
| | | apiLog.setData(JSON.toJSONString(reqData)); |
| | | apiLog.setKqdm(kqdm); |
| | | apiLog.setUploadTime(new Date()); |
| | | |
| | | if (conf == null) { |
| | | ResponseDto responseDto = new ResponseDto(99, "没有获取到上传配置", bizId); |
| | | apiLog.setStatus(99); |
| | |
| | | return responseDto; |
| | | } |
| | | |
| | | ShjdjwRespDto responseDto = Shjdjw2023HttpClientUtil.postPushData(conf.getApiUrl(), jsonData, conf); |
| | | String jsonStr = JSON.toJSONString(reqData); |
| | | log.info("上报数据信息=" + jsonStr); |
| | | jsonStr = AESUtils.encryptByEcb(jsonStr, conf.getPublicKey()); |
| | | |
| | | ShjdjwRespDto responseDto = Shjdjw2023HttpClientUtil.postPushData(conf.getApiUrl(), jsonStr, conf); |
| | | |
| | | responseDto.setBizId(bizId); |
| | | apiLog.setStatus(responseDto.getCode() == 1 ? 0 : responseDto.getCode()); |
| | | apiLog.setResult(responseDto.getDescription()); |
| | |
| | | ResponseDto resd = new ResponseDto(); |
| | | resd.setSuccess(responseDto.getCode() == 1 ? 0 : responseDto.getCode()); |
| | | resd.setMsg(responseDto.getDescription()); |
| | | |
| | | if (Constant.API_CODE_1403.equals(inteId)) { |
| | | //轮换计划完成情况数据封装 |
| | | Shjdjw1502 shjdjw1502 = copy1502((Api1403) data); |
| | | ShjdjwReqDto<Object> dto = new ShjdjwReqDto<>(); |
| | | dto.setId(getDataId(ShjdjwApiCodeConstant.API_CODE_LS1502)); |
| | | List<Object> list = new ArrayList<>(); |
| | | list.add(shjdjw1502); |
| | | dto.setData(list); |
| | | String json = JSON.toJSONString(dto); |
| | | |
| | | //轮换计划完成情况数据上传 |
| | | apiLog.setData(json); |
| | | apiLog.setKqdm(kqdm); |
| | | apiLog.setUploadTime(new Date()); |
| | | ShjdjwRespDto shjdjwresponseDto = Shjdjw2023HttpClientUtil.postPushData(conf.getApiUrl(), json, conf); |
| | | responseDto.setBizId(bizId); |
| | | apiLog.setStatus(shjdjwresponseDto.getCode() == 1 ? 0 : shjdjwresponseDto.getCode()); |
| | | apiLog.setResult(shjdjwresponseDto.getDescription()); |
| | | apiLogRep.save(apiLog); |
| | | ResponseDto response = new ResponseDto(); |
| | | response.setSuccess(shjdjwresponseDto.getCode() == 1 ? 0 : shjdjwresponseDto.getCode()); |
| | | response.setMsg(shjdjwresponseDto.getDescription()); |
| | | } |
| | | return resd; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return new ResponseDto(99, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取接口id |
| | | * |
| | | * @param inteId |
| | | * @return |
| | | */ |
| | | private String getInteId(String inteId) { |
| | | switch (inteId) { |
| | | case "1101": |
| | | return ShjdjwApiCodeConstant.API_CODE_1101_ID; |
| | | case "1102": |
| | | return ShjdjwApiCodeConstant.API_CODE_1102_ID; |
| | | case "1103": |
| | | return ShjdjwApiCodeConstant.API_CODE_1103_ID; |
| | | case "1104": |
| | | return ShjdjwApiCodeConstant.API_CODE_1104_ID; |
| | | case "1105": |
| | | return ShjdjwApiCodeConstant.API_CODE_1105_ID; |
| | | case "1202": |
| | | return ShjdjwApiCodeConstant.API_CODE_1202_ID; |
| | | case "1203": |
| | | return ShjdjwApiCodeConstant.API_CODE_1203_ID; |
| | | case "1205": |
| | | return ShjdjwApiCodeConstant.API_CODE_1205_ID; |
| | | case "1209": |
| | | return ShjdjwApiCodeConstant.API_CODE_1209_ID; |
| | | case "1310": |
| | | return ShjdjwApiCodeConstant.API_CODE_1310_ID; |
| | | case "1403": |
| | | return ShjdjwApiCodeConstant.API_CODE_1403_ID; |
| | | case "1404": |
| | | return ShjdjwApiCodeConstant.API_CODE_1404_ID; |
| | | default: |
| | | return inteId; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转为JSON |
| | | * |
| | | * @param inteId |
| | | * @param data |
| | | * @param code |
| | | * @return |
| | | */ |
| | | private List<Object> getJsonData(String inteId, Object data, String code) { |
| | | |
| | | List<Object> list = new ArrayList<>(); |
| | | Object object = getJsonApiData(inteId, data, code); |
| | | list.add(object); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private String getJsonData(String inteId, Object data, String interfaceId) { |
| | | ShjdjwReqDto<Object> dto = new ShjdjwReqDto<>(); |
| | | dto.setId(getDataId(interfaceId)); |
| | | List<Object> list = new ArrayList<>(); |
| | | //转换封装 |
| | | if (Constant.API_CODE_1102.equals(inteId)) { |
| | | //单位接口数据封装 |
| | | ShjdjwApi1101 shjdjwApi1101 = new ShjdjwApi1101(); |
| | | BeanUtils.copyProperties(data, shjdjwApi1101); |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(shjdjwApi1101.getKqdm()); |
| | | Api1101 api1101 = null; |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | api1101 = listApi1101.get(0); |
| | | } |
| | | if (null != api1101) { |
| | | shjdjwApi1101.setDwmc(api1101.getDwmc()); |
| | | shjdjwApi1101.setKqs(api1101.getKqs()); |
| | | } |
| | | |
| | | private Object getJsonApiData(String inteId, Object data, String code) { |
| | | //具体根据接口进行封装 |
| | | if (ShjdjwApiCodeConstant.API_CODE_1101.equals(inteId)) { |
| | | Shjdjw2023Api1101 api1101 = new Shjdjw2023Api1101(); |
| | | BeanUtils.copyProperties(data, api1101); |
| | | |
| | | return api1101; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1102.equals(inteId)) { |
| | | Shjdjw2023Api1102 api1102 = new Shjdjw2023Api1102(); |
| | | BeanUtils.copyProperties(data, api1102); |
| | | |
| | | return api1102; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1103.equals(inteId)) { |
| | | Shjdjw2023Api1103 api1103 = new Shjdjw2023Api1103(); |
| | | BeanUtils.copyProperties(data, api1103); |
| | | |
| | | return api1103; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1104.equals(inteId)) { |
| | | Shjdjw2023Api1104 api1104 = new Shjdjw2023Api1104(); |
| | | Api1104 apiData = (Api1104) data; |
| | | |
| | | //查询仓房信息 |
| | | List<Api1103> listApi1103 = api1103Rep.findPushData(shjdjwApi1101.getKqdm()); |
| | | if (null != listApi1103 && listApi1103.size() > 0) { |
| | | for (int i = 0; i < listApi1103.size(); i++) { |
| | | if (i == 0) { |
| | | shjdjwApi1101.setCfmc(listApi1103.get(i).getCfmc()); |
| | | } else { |
| | | shjdjwApi1101.setCfmc(shjdjwApi1101.getCfmc() + "#" + listApi1103.get(i).getCfmc()); |
| | | List<Api1103> api1103List = api1103Rep.findPushDataByCfdm(apiData.getCfbh()); |
| | | List<Api1104> api1104List = api1104Rep.findDataByCfbh(apiData.getCfbh()); |
| | | int num = 2; |
| | | if (null != api1104List && api1104List.size() > 0) { |
| | | num = api1104List.size(); |
| | | } |
| | | if (null != api1103List && api1103List.size() > 0) { |
| | | Api1103 api1103 = api1103List.get(0); |
| | | BeanUtils.copyProperties(api1103, api1104); |
| | | api1104.setCwc(api1103.getCwc() / num); |
| | | api1104.setCnc(api1103.getCnc() / num); |
| | | api1104.setSjcr(api1103.getSjcr() / num); |
| | | } |
| | | BeanUtils.copyProperties(apiData, api1104); |
| | | api1104.setAjdm(apiData.getAjdh()); |
| | | api1104.setCfdm(apiData.getCfbh()); |
| | | |
| | | //设置粮食性质代码(查看廒间对应的最新库存进行赋值) |
| | | List<Api1208> api1208List = api1208Rep.findDataByHwdm(api1104.getAjdm() + "01"); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | api1104.setLsxzdm(api1208List.get(0).getLsxzdm()); |
| | | } |
| | | |
| | | return api1104; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1105.equals(inteId)) { |
| | | Shjdjw2023Api1105 api1105 = new Shjdjw2023Api1105(); |
| | | BeanUtils.copyProperties(data, api1105); |
| | | |
| | | return api1105; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1202.equals(inteId)) { |
| | | Shjdjw2023Api1202 api1202 = new Shjdjw2023Api1202(); |
| | | Api1202 apiData = (Api1202) data; |
| | | BeanUtils.copyProperties(apiData, api1202); |
| | | api1202.setBjw(ShAreaBjw.getBjw(code)); |
| | | api1202.setJzrq(apiData.getCmsj()); |
| | | if (StringUtils.isEmpty(api1202.getCddm())) { |
| | | api1202.setCddm(api1202.getHwdm().substring(2, 8)); |
| | | } |
| | | if (StringUtils.isEmpty(api1202.getRkjsdh())) { |
| | | api1202.setRkjsdh("0"); |
| | | } |
| | | //设置粮食轮换年度,根据计划明细号查询计划明细,再根据计划明细查询轮换计划 |
| | | List<Api1404> api1404List = api1404Rep.getDataByJhmxdh(apiData.getJhmxh()); |
| | | if (null != api1404List && api1404List.size() > 0) { |
| | | if(StringUtils.isEmpty(api1202.getShnd())){ |
| | | api1202.setShnd(api1404List.get(0).getShnd()); |
| | | } |
| | | List<Api1403> api1403List = api1403Rep.getDataByLhjhdh(api1404List.get(0).getLhjhdh()); |
| | | if (null != api1403List && api1403List.size() > 0) { |
| | | if (StringUtils.isNotEmpty(api1403List.get(0).getJhnd())) { |
| | | api1202.setLhnd(api1403List.get(0).getJhnd()); |
| | | } |
| | | } |
| | | } |
| | | //单位信息封装 |
| | | list.add(shjdjwApi1101); |
| | | } else if (Constant.API_CODE_1202.equals(inteId)) { |
| | | //粮食入库数据封装 |
| | | ShjdjwApi1202 shjdjwApi1202 = new ShjdjwApi1202(); |
| | | Api1202 api1202 = (Api1202) data; |
| | | copyApi1202(api1202, shjdjwApi1202); |
| | | list.add(shjdjwApi1202); |
| | | } else if (Constant.API_CODE_1203.equals(inteId)) { |
| | | //粮食入库检验数据封装 |
| | | ShjdjwApi1203 shjdjwApi1203 = copyApi1203((Api1203) data); |
| | | //查询粮食性质转变单号(根据入库时间和货位代码查询粮食性质转变单) |
| | | List<Api1210> api1210List = api1210Rep.findDataByHwdmAndTime(api1202.getHwdm(), api1202.getCmsj()); |
| | | if (null != api1210List && api1210List.size() > 0) { |
| | | api1202.setLsxzzbdh(api1210List.get(0).getLsxzzbdh()); |
| | | } |
| | | //设置批次号 |
| | | List<Api1208> api1208List = api1208Rep.findDataByHwdm(api1202.getHwdm()); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | api1202.setPch(apiData.getHwdm() + api1208List.get(0).getShnd()); |
| | | } |
| | | //粮食性质 |
| | | api1202.setLsxzdm("200"); |
| | | |
| | | list.add(shjdjwApi1203); |
| | | } else if (Constant.API_CODE_1205.equals(inteId)) { |
| | | //粮食出库数据封装 |
| | | ShjdjwApi1205 shjdjwApi1205 = copyApi1205((Api1205) data); |
| | | |
| | | list.add(shjdjwApi1205); |
| | | } else if (Constant.API_CODE_1208.equals(inteId)) { |
| | | //粮食库存数据封装 |
| | | ShjdjwApi1208 shjdjwApi1208 = copyApi1208((Api1208) data); |
| | | |
| | | list.add(shjdjwApi1208); |
| | | } else if (Constant.API_CODE_1209.equals(inteId)) { |
| | | //损益单数据封装 |
| | | ShjdjwApi1209 shjdjwApi1209 = copyApi1209((Api1209) data); |
| | | |
| | | list.add(shjdjwApi1209); |
| | | } else if (Constant.API_CODE_1310.equals(inteId)) { |
| | | //质检数据封装 |
| | | ShjdjwApi1310 shjdjwApi1310 = copyApi1310((Api1310) data); |
| | | |
| | | list.add(shjdjwApi1310); |
| | | } else if (Constant.API_CODE_1403.equals(inteId)) { |
| | | //轮换计划数据封装 |
| | | ShjdjwApi1403 shjdjwApi1403 = copyApi1403((Api1403) data); |
| | | |
| | | list.add(shjdjwApi1403); |
| | | } else { |
| | | |
| | | list.add(data); |
| | | return api1202; |
| | | } |
| | | dto.setData(list); |
| | | return JSON.toJSONString(dto); |
| | | if (ShjdjwApiCodeConstant.API_CODE_1203.equals(inteId)) { |
| | | Shjdjw2023Api1203 api1203 = new Shjdjw2023Api1203(); |
| | | Api1203 apiData = (Api1203) data; |
| | | BeanUtils.copyProperties(apiData, api1203); |
| | | api1203.setBjw(ShAreaBjw.getBjw(code)); |
| | | if (StringUtils.isEmpty(api1203.getJyxm())) { |
| | | api1203.setJyxm("0"); |
| | | } |
| | | if (StringUtils.isEmpty(api1203.getJyz())) { |
| | | api1203.setJyz("0"); |
| | | } |
| | | if (StringUtils.isEmpty(api1203.getZkj())) { |
| | | api1203.setZkj("0"); |
| | | } |
| | | if (StringUtils.isEmpty(api1203.getZkl())) { |
| | | api1203.setZkl("0"); |
| | | } |
| | | //设置批次号 |
| | | List<Api1208> api1208List = api1208Rep.findDataByHwdm(api1203.getHwdm()); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | api1203.setPch(apiData.getHwdm() + api1208List.get(0).getShnd()); |
| | | } |
| | | //设置质检编码(默认等同于入库质检单号),若为船运,则设置为系统内船运的单号 |
| | | api1203.setZjbh(api1203.getRkjydh()); |
| | | List<Api1202> api1202List = api1202Rep.getDataById(api1203.getRkywdh()); |
| | | if (null != api1202List && api1202List.size() > 0) { |
| | | if (api1202List.get(0).getYsgj().equals("3")) { |
| | | api1203.setZjbh(api1202List.get(0).getBizId().substring(2)); |
| | | } |
| | | } |
| | | return api1203; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1205.equals(inteId)) { |
| | | |
| | | Shjdjw2023Api1205 api1205 = new Shjdjw2023Api1205(); |
| | | Api1205 apiData = (Api1205) data; |
| | | BeanUtils.copyProperties(apiData, api1205); |
| | | api1205.setBjw(ShAreaBjw.getBjw(code)); |
| | | |
| | | api1205.setJzrq(apiData.getCmsj()); |
| | | if (StringUtils.isEmpty(api1205.getCddm())) { |
| | | api1205.setCddm(api1205.getHwdm().substring(2, 8)); |
| | | } |
| | | if (StringUtils.isEmpty(api1205.getCkjsdh())) { |
| | | api1205.setCkjsdh("0"); |
| | | } |
| | | |
| | | //设置粮食轮换年度 |
| | | List<Api1404> api1404List = api1404Rep.getDataByJhmxdh(apiData.getJhmxh()); |
| | | if (null != api1404List && api1404List.size() > 0) { |
| | | if(StringUtils.isEmpty(api1205.getShnd())){ |
| | | api1205.setShnd(api1404List.get(0).getShnd()); |
| | | } |
| | | List<Api1403> api1403List = api1403Rep.getDataByLhjhdh(api1404List.get(0).getLhjhdh()); |
| | | if (null != api1403List && api1403List.size() > 0) { |
| | | if (StringUtils.isNotEmpty(api1403List.get(0).getJhnd())) { |
| | | api1205.setLhnd(api1403List.get(0).getJhnd()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //设置批次号 |
| | | List<Api1208> api1208List = api1208Rep.findDataByHwdm(api1205.getHwdm()); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | api1205.setPch(apiData.getHwdm() + api1208List.get(0).getShnd()); |
| | | } |
| | | |
| | | //粮食性质 |
| | | api1205.setLsxzdm("200"); |
| | | |
| | | return api1205; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1209.equals(inteId)) { |
| | | |
| | | Shjdjw2023Api1209 api1209 = new Shjdjw2023Api1209(); |
| | | Api1209 apiData = (Api1209) data; |
| | | |
| | | BeanUtils.copyProperties(apiData, api1209); |
| | | api1209.setDjlx("2"); |
| | | api1209.setSzjl(apiData.getQzszkl()); |
| | | api1209.setZrshde(apiData.getQzzrshde()); |
| | | api1209.setBjw(ShAreaBjw.getBjw(code)); |
| | | api1209.setJzrq(apiData.getYwrq()); |
| | | List<Api1208> api1208List = api1208Rep.findDataByHwdm(api1209.getHwdm()); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | api1209.setPch(api1209.getHwdm() + api1208List.get(0).getShnd()); |
| | | } |
| | | |
| | | //粮食性质,暂时默认区级储备 |
| | | api1209.setLsxzdm("122"); |
| | | |
| | | return api1209; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1310.equals(inteId)) { |
| | | Shjdjw2023Api1310 api1310 = new Shjdjw2023Api1310(); |
| | | Api1310 apiData = (Api1310) data; |
| | | BeanUtils.copyProperties(apiData, api1310); |
| | | api1310.setBjw(ShAreaBjw.getBjw(code)); |
| | | api1310.setJyrq(apiData.getJysj()); |
| | | |
| | | if (StringUtils.isEmpty(api1310.getJyxm())) { |
| | | api1310.setJyxm("0"); |
| | | } |
| | | if (StringUtils.isEmpty(api1310.getJyxmz())) { |
| | | api1310.setJyxmz("0"); |
| | | } |
| | | String lsxzdm = "122"; |
| | | String pch = ""; |
| | | List<Api1208> api1208List = api1208Rep.getDataByHwdm(api1310.getHwdm()); |
| | | if (null != api1208List && api1208List.size() > 0) { |
| | | if (StringUtils.isNotEmpty(api1208List.get(0).getLsxzdm())) { |
| | | lsxzdm = api1208List.get(0).getLsxzdm(); |
| | | pch = apiData.getHwdm() + api1208List.get(0).getShnd(); |
| | | } |
| | | } |
| | | //设置批次号 |
| | | api1310.setPch(pch); |
| | | api1310.setLsxzdm(lsxzdm); |
| | | if (api1310.getYpsl() == 0.0) { |
| | | api1310.setYpsl(5.0); |
| | | } |
| | | if (StringUtils.isEmpty(api1310.getQyrxm())) { |
| | | api1310.setQyrxm("扦样人"); |
| | | } |
| | | if (StringUtils.isEmpty(api1310.getJdrxm())) { |
| | | api1310.setJdrxm("监督人"); |
| | | } |
| | | if (StringUtils.isEmpty(api1310.getShrxm())) { |
| | | api1310.setShrxm("审核人"); |
| | | } |
| | | //设置空属性为默认值 |
| | | return api1310; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1403.equals(inteId)) { |
| | | Shjdjw2023Api1403 api1403 = new Shjdjw2023Api1403(); |
| | | Api1403 apiData = (Api1403) data; |
| | | BeanUtils.copyProperties(apiData, api1403); |
| | | List<Api1101> api1101List = api1101Rep.findDataByDwdm(apiData.getLhjhdh().substring(0, 18)); |
| | | |
| | | api1403.setJhzxdw(api1101List.get(0).getDwdm()); |
| | | api1403.setJhzxdwmc(api1101List.get(0).getDwmc()); |
| | | api1403.setBjw(ShAreaBjw.getBjw(code)); |
| | | |
| | | //查询轮换计划的轮入数量和轮出数量 |
| | | List<Api1404> list = api1404Rep.getDataByLhjhdh(api1403.getLhjhdh()); |
| | | Double lrsl = 0.0, lcsl = 0.0; //用于统计轮入数量和轮出数量 |
| | | if (null != list && list.size() > 0) { |
| | | for (Api1404 api1404 : list) { |
| | | if (null != api1404.getLhlx() && "2".equals(api1404.getLhlx())) { |
| | | lrsl += api1404.getLhsl(); |
| | | } |
| | | if (null != api1404.getLhlx() && "1".equals(api1404.getLhlx())) { |
| | | lcsl += api1404.getLhsl(); |
| | | } |
| | | } |
| | | } |
| | | api1403.setLrsl(lrsl + ""); |
| | | api1403.setLcsl(lcsl + ""); |
| | | |
| | | //设置空属性为默认值 |
| | | return api1403; |
| | | } |
| | | if (ShjdjwApiCodeConstant.API_CODE_1404.equals(inteId)) { |
| | | Shjdjw2023Api1404 api1404 = new Shjdjw2023Api1404(); |
| | | BeanUtils.copyProperties(data, api1404); |
| | | api1404.setMxzt("1"); |
| | | api1404.setBjw(ShAreaBjw.getBjw(code)); |
| | | |
| | | //设置空属性为默认值 |
| | | return api1404; |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | private ShjdjwApi1403 copyApi1403(Api1403 api1403) { |
| | | ShjdjwApi1403 shjdjwApi1403 = new ShjdjwApi1403(); |
| | | BeanUtils.copyProperties(api1403, shjdjwApi1403); |
| | | |
| | | List<Double> lhsl = getLhsl(api1403); |
| | | if (null != lhsl && lhsl.size() > 0) { |
| | | shjdjwApi1403.setLrsl(lhsl.get(1)); |
| | | shjdjwApi1403.setLrsl(lhsl.get(0)); |
| | | } |
| | | |
| | | shjdjwApi1403.setJhbm(api1403.getLhjhdh()); |
| | | shjdjwApi1403.setPch("0"); |
| | | return shjdjwApi1403; |
| | | } |
| | | |
| | | /** |
| | | * 获取轮入和轮出重量 |
| | | * |
| | | * @param api1403 |
| | | * @return |
| | | */ |
| | | private List<Double> getLhsl(Api1403 api1403) { |
| | | List<Api1404> api1404List = api1404Rep.getDataByLhjhdh(api1403.getLhjhdh()); |
| | | List<Double> lhsl = new ArrayList<>(); |
| | | if (null != api1404List && api1404List.size() > 0) { |
| | | // double sum = api1404List.stream().mapToDouble(Api1404::getLhsl).summaryStatistics().getSum(); |
| | | double lcSum = api1404List.stream() |
| | | .filter(x -> x.getLhlx().equals("1")) |
| | | .mapToDouble(Api1404::getLhsl) |
| | | .summaryStatistics().getSum(); |
| | | double lrSum = api1404List.stream() |
| | | .filter(x -> x.getLhlx().equals("2")) |
| | | .mapToDouble(Api1404::getLhsl) |
| | | .summaryStatistics().getSum(); |
| | | lhsl.add(lcSum); |
| | | lhsl.add(lrSum); |
| | | } |
| | | return lhsl; |
| | | } |
| | | |
| | | private Shjdjw1502 copy1502(Api1403 api1403) { |
| | | Shjdjw1502 shjdjw1502 = new Shjdjw1502(); |
| | | shjdjw1502.setDwmc(api1403.getLhjhdh()); |
| | | shjdjw1502.setJhnd(api1403.getJhnd()); |
| | | |
| | | // 计划数量 |
| | | List<Double> lhsl = getLhsl(api1403); |
| | | Double sum = 0.0; |
| | | if (null != lhsl && lhsl.size() > 0) { |
| | | sum = lhsl.stream().reduce(0d, Double::sum); |
| | | } |
| | | // 已执行数量 |
| | | List<Api1202> api1202List = api1202Rep.getDataByTime(api1403.getKszxrq(), api1403.getJzzxrq()); |
| | | |
| | | Double yzxsl = api1202List.stream() |
| | | .mapToDouble(Api1202::getJz) |
| | | .summaryStatistics().getSum(); |
| | | shjdjw1502.setJhsl(new DecimalFormat("0.00").format(sum)); |
| | | shjdjw1502.setYzxsl(new DecimalFormat("0.00").format(yzxsl)); |
| | | //执行比例 |
| | | shjdjw1502.setZxbl(String.valueOf((yzxsl / sum * 100))); |
| | | |
| | | // 招标/竞价比例 |
| | | shjdjw1502.setZbjjbl("100"); |
| | | shjdjw1502.setCzbz(api1403.getCzbz()); |
| | | |
| | | return shjdjw1502; |
| | | } |
| | | |
| | | private ShjdjwApi1203 copyApi1203(Api1203 api1203) { |
| | | ShjdjwApi1203 shjdjwApi1203 = new ShjdjwApi1203(); |
| | | |
| | | BeanUtils.copyProperties(api1203, shjdjwApi1203); |
| | | |
| | | shjdjwApi1203.setQydbh(api1203.getRkjydh()); |
| | | shjdjwApi1203.setHwbm(api1203.getHwdm()); |
| | | List<Api1105> list = api1105Rep.findPushDataByHwdm(api1203.getHwdm()); |
| | | if(null != list && list.size() > 0){ |
| | | shjdjwApi1203.setHwbm(list.get(0).getHwmc()); |
| | | } |
| | | shjdjwApi1203.setYpbm(api1203.getRkywdh()); |
| | | shjdjwApi1203.setJyjg(api1203.getJyz()); |
| | | shjdjwApi1203.setJyjl(api1203.getJyjg()); |
| | | shjdjwApi1203.setPzbm(api1203.getLspzdm()); |
| | | shjdjwApi1203.setBjw("jiading"); |
| | | shjdjwApi1203.setPch("0"); |
| | | return shjdjwApi1203; |
| | | } |
| | | |
| | | private ShjdjwApi1310 copyApi1310(Api1310 api1310) { |
| | | ShjdjwApi1310 shjdjwApi1310 = new ShjdjwApi1310(); |
| | | |
| | | BeanUtils.copyProperties(api1310, shjdjwApi1310); |
| | | |
| | | shjdjwApi1310.setZjbgdbh(api1310.getZjbgdh()); |
| | | shjdjwApi1310.setPznm(api1310.getLspzdm()); |
| | | shjdjwApi1310.setSkdjbm(api1310.getLsdjdm()); |
| | | shjdjwApi1310.setJylbbm(api1310.getJylb()); |
| | | // if (StringUtils.isNotEmpty(shjdjwApi1310.getJyxm())) { |
| | | // String[] split = shjdjwApi1310.getJyxm().split(","); |
| | | // StringBuilder jyjl = new StringBuilder(); |
| | | // for (String s : split) { |
| | | // jyjl.append(",合格"); |
| | | // } |
| | | // shjdjwApi1310.setJyjl(jyjl.toString().substring(1)); |
| | | // } |
| | | //调整为传递检验值 |
| | | shjdjwApi1310.setJyjl(api1310.getJyxmz()); |
| | | shjdjwApi1310.setZlzbjgpd(api1310.getZbjgpd()); |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(api1310.getKqdm()); |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | shjdjwApi1310.setDwmc(listApi1101.get(0).getDwmc()); |
| | | } |
| | | |
| | | //查询仓房信息 |
| | | List<Api1103> listApi1103 = api1103Rep.findPushDataByCfdm(api1310.getHwdm().substring(0, 25)); |
| | | if (null != listApi1103 && listApi1103.size() > 0) { |
| | | shjdjwApi1310.setCfmc(listApi1103.get(0).getCfmc()); |
| | | } |
| | | |
| | | //查询廒间信息 |
| | | List<Api1104> listApi1104 = api1104Rep.findDataByAjdh(api1310.getHwdm().substring(0, 28)); |
| | | if (null != listApi1104 && listApi1104.size() > 0) { |
| | | shjdjwApi1310.setAjmc(listApi1104.get(0).getAjmc()); |
| | | } |
| | | |
| | | //查询库区信息 |
| | | List<Api1102> listApi1102 = api1102Rep.findPushData(api1310.getKqdm()); |
| | | if (null != listApi1102 && listApi1102.size() > 0) { |
| | | shjdjwApi1310.setKdmc(listApi1102.get(0).getKqmc()); |
| | | } |
| | | //查询粮食库存 |
| | | List<Api1208> listApi1208 = api1208Rep.getDataByHwdm(api1310.getHwdm()); |
| | | if (null != listApi1208 && listApi1208.size() > 0) { |
| | | shjdjwApi1310.setKdmc(listApi1208.get(0).getLsxzdm()); |
| | | } |
| | | shjdjwApi1310.setPch("0"); |
| | | return shjdjwApi1310; |
| | | } |
| | | |
| | | private ShjdjwApi1209 copyApi1209(Api1209 api1209) { |
| | | ShjdjwApi1209 shjdjwApi1209 = new ShjdjwApi1209(); |
| | | |
| | | BeanUtils.copyProperties(api1209, shjdjwApi1209); |
| | | |
| | | shjdjwApi1209.setSydbh(api1209.getSydh()); |
| | | |
| | | shjdjwApi1209.setRksl(api1209.getRkjz()); |
| | | shjdjwApi1209.setCksl(api1209.getCkjz()); |
| | | shjdjwApi1209.setSysl(api1209.getJzsysl()); |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(api1209.getKqdm()); |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | shjdjwApi1209.setDwmc(listApi1101.get(0).getDwmc()); |
| | | } |
| | | //查询库区信息 |
| | | List<Api1102> listApi1102 = api1102Rep.findPushData(api1209.getKqdm()); |
| | | if (null != listApi1102 && listApi1102.size() > 0) { |
| | | shjdjwApi1209.setKdmc(listApi1102.get(0).getKqmc()); |
| | | } |
| | | //货位信息 |
| | | shjdjwApi1209.setHwbm(api1209.getHwdm()); |
| | | List<Api1105> list = api1105Rep.findPushDataByHwdm(api1209.getHwdm()); |
| | | if(null != list && list.size() > 0){ |
| | | shjdjwApi1209.setHwbm(list.get(0).getHwmc()); |
| | | } |
| | | |
| | | shjdjwApi1209.setNx(api1209.getYwrq()); |
| | | //辅损益数量 |
| | | shjdjwApi1209.setFsysl(0.0); |
| | | //损益类型 |
| | | shjdjwApi1209.setSylx(api1209.getJzsysl() > 0 ? "0" : "1"); |
| | | return shjdjwApi1209; |
| | | } |
| | | |
| | | private ShjdjwApi1208 copyApi1208(Api1208 api1208) { |
| | | ShjdjwApi1208 shjdjwApi1208 = new ShjdjwApi1208(); |
| | | |
| | | BeanUtils.copyProperties(api1208, shjdjwApi1208); |
| | | |
| | | shjdjwApi1208.setLspzbm(api1208.getLspzdm()); |
| | | shjdjwApi1208.setLsxzbm(api1208.getLsxzdm()); |
| | | shjdjwApi1208.setDjbm(api1208.getLsdjdm()); |
| | | shjdjwApi1208.setLqgsdwbm(api1208.getLqgsdwdm()); |
| | | |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(api1208.getKqdm()); |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | shjdjwApi1208.setDwmc(listApi1101.get(0).getDwmc()); |
| | | } |
| | | |
| | | //查询仓房信息 |
| | | List<Api1103> listApi1103 = api1103Rep.findPushDataByCfdm(api1208.getHwdm().substring(0, 25)); |
| | | if (null != listApi1103 && listApi1103.size() > 0) { |
| | | shjdjwApi1208.setCfmc(listApi1103.get(0).getCfmc()); |
| | | } |
| | | |
| | | //查询廒间信息 |
| | | List<Api1104> listApi1104 = api1104Rep.findDataByAjdh(api1208.getHwdm().substring(0, 28)); |
| | | if (null != listApi1104 && listApi1104.size() > 0) { |
| | | shjdjwApi1208.setAjmc(listApi1104.get(0).getAjmc()); |
| | | } |
| | | |
| | | shjdjwApi1208.setKcjcsj(api1208.getZhgxsj()); |
| | | |
| | | shjdjwApi1208.setPch("0"); |
| | | return shjdjwApi1208; |
| | | } |
| | | |
| | | private ShjdjwApi1205 copyApi1205(Api1205 api1205) { |
| | | ShjdjwApi1205 shjdjwApi1205 = new ShjdjwApi1205(); |
| | | |
| | | BeanUtils.copyProperties(api1205, shjdjwApi1205); |
| | | |
| | | shjdjwApi1205.setYwdh(api1205.getCkywdh()); |
| | | shjdjwApi1205.setHtbm(api1205.getHth()); |
| | | shjdjwApi1205.setPzbm(api1205.getLspzdm()); |
| | | shjdjwApi1205.setDjbm(api1205.getLsdjdm()); |
| | | shjdjwApi1205.setLqxzbm(api1205.getLsxzdm()); |
| | | shjdjwApi1205.setCzbz(api1205.getCzbz()); |
| | | shjdjwApi1205.setLrfs("0"); |
| | | shjdjwApi1205.setPzbm(api1205.getLspzdm()); |
| | | |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(api1205.getKqdm()); |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | shjdjwApi1205.setDwmc(listApi1101.get(0).getDwmc()); |
| | | } |
| | | |
| | | //查询货位信息 |
| | | List<Api1105> listApi1105 = api1105Rep.findPushDataByHwdm(api1205.getHwdm()); |
| | | if (null != listApi1105 && listApi1105.size() > 0) { |
| | | shjdjwApi1205.setCfmc(listApi1105.get(0).getHwmc()); |
| | | } |
| | | |
| | | shjdjwApi1205.setDjlx("0"); |
| | | |
| | | //查询字典数据 |
| | | ApiTrigger apiTrigger = apiTriggerService.findNameByCode(api1205.getLspzdm(), Constant.TRIGGER_P_LSPZ); |
| | | shjdjwApi1205.setWlmc(null == apiTrigger ? api1205.getLspzdm() : apiTrigger.getName()); |
| | | shjdjwApi1205.setDz(StringUtils.isNotEmpty(api1205.getXldd()) ? api1205.getXldd() : "库内"); |
| | | |
| | | shjdjwApi1205.setDksj(api1205.getDjsj()); |
| | | shjdjwApi1205.setLksj(api1205.getCmsj()); |
| | | shjdjwApi1205.setLhnd(DateFormatUtils.format(api1205.getCmsj(), "yyyy")); |
| | | shjdjwApi1205.setPch("0"); |
| | | return shjdjwApi1205; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取接口编码 |
| | | * |
| | | * @param inteId |
| | | * @return |
| | | */ |
| | | private String getDataId(String inteId) { |
| | | switch (inteId) { |
| | | case "1102": |
| | | //单位接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1101; |
| | | case "1202": |
| | | //粮食入库接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1302; |
| | | case "1203": |
| | | //粮食入库检验接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1303; |
| | | case "1205": |
| | | //粮食出库接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1306; |
| | | case "1208": |
| | | //粮食库存接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1310; |
| | | case "1209": |
| | | //损益单接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1311; |
| | | case "1310": |
| | | //质检接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1201; |
| | | case "1403": |
| | | //轮换计划接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1501; |
| | | default: |
| | | return inteId; |
| | | } |
| | | |
| | | } |
| | | |
| | | //装换封装 |
| | | private void copyApi1202(Api1202 api1202, ShjdjwApi1202 shjdjwApi1202) { |
| | | BeanUtils.copyProperties(api1202, shjdjwApi1202); |
| | | String ywdh = api1202.getRkywdh(); |
| | | shjdjwApi1202.setYwdh(ywdh); |
| | | shjdjwApi1202.setHwbm(api1202.getHwdm()); |
| | | List<Api1105> list = api1105Rep.findPushDataByHwdm(api1202.getHwdm()); |
| | | if(null != list && list.size() > 0){ |
| | | shjdjwApi1202.setHwbm(list.get(0).getHwmc()); |
| | | } |
| | | shjdjwApi1202.setPzbm(api1202.getLspzdm()); |
| | | shjdjwApi1202.setLqxzbm(api1202.getLsxzdm()); |
| | | shjdjwApi1202.setZjkl(api1202.getZjklxj()); |
| | | //轮换计划单号 |
| | | shjdjwApi1202.setJhbh(api1202.getJhmxh()); |
| | | //顺序号 |
| | | shjdjwApi1202.setSxh(ywdh.substring(ywdh.length() - 4)); |
| | | shjdjwApi1202.setDjzt("2"); |
| | | //业务单号 |
| | | shjdjwApi1202.setJydbh(api1202.getRkywdh()); |
| | | //轮换年度 |
| | | shjdjwApi1202.setLhnd(api1202.getShnd()); |
| | | //到库时间、离库时间 |
| | | shjdjwApi1202.setDksj(api1202.getDjsj()); |
| | | shjdjwApi1202.setLksj(api1202.getCmsj()); |
| | | //批次号 |
| | | shjdjwApi1202.setPch("0"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ResponseDto pullData(ApiParam param, ApiConfs conf) { |
| | | //该协议无此实现 |
| | | return null; |
| | | } |
| | | } |