| | |
| | | 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 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.*; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private Api1103Rep api1103Rep; |
| | | @Autowired |
| | | private Api1105Rep api1105Rep; |
| | | @Autowired |
| | | private Api1202Rep api1202Rep; |
| | | @Autowired |
| | | private Api1104Rep api1104Rep; |
| | | @Autowired |
| | | private Api1208Rep api1208Rep; |
| | | @Autowired |
| | | private Api1404Rep api1404Rep; |
| | | |
| | | |
| | | @Override |
| | | public String getProtocol() { |
| | |
| | | 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); |
| | |
| | | list.add(shjdjwApi1310); |
| | | } else if (Constant.API_CODE_1403.equals(inteId)) { |
| | | //轮换计划数据封装 |
| | | ShjdjwApi1403 shjdjwApi1403 = new ShjdjwApi1403(); |
| | | Api1403 api1403 = (Api1403) data; |
| | | BeanUtils.copyProperties(api1403, shjdjwApi1403); |
| | | |
| | | shjdjwApi1403.setJhbm(api1403.getLhjhdh()); |
| | | shjdjwApi1403.setPch("0"); |
| | | ShjdjwApi1403 shjdjwApi1403 = copyApi1403((Api1403) data); |
| | | |
| | | list.add(shjdjwApi1403); |
| | | } else if (Constant.API_CODE_1404.equals(inteId)) { |
| | | //轮换计划完成情况数据封装 |
| | | ShjdjwApi1404 shjdjwApi1404 = copyApi1404((Api1404) data); |
| | | |
| | | list.add(shjdjwApi1404); |
| | | } else { |
| | | |
| | | list.add(data); |
| | |
| | | return JSON.toJSONString(dto); |
| | | } |
| | | |
| | | private ShjdjwApi1404 copyApi1404(Api1404 api1404) { |
| | | ShjdjwApi1404 shjdjwApi1404 = new ShjdjwApi1404(); |
| | | private ShjdjwApi1403 copyApi1403(Api1403 api1403) { |
| | | ShjdjwApi1403 shjdjwApi1403 = new ShjdjwApi1403(); |
| | | BeanUtils.copyProperties(api1403, shjdjwApi1403); |
| | | |
| | | BeanUtils.copyProperties(api1404, shjdjwApi1404); |
| | | |
| | | //查询单位信息 |
| | | List<Api1101> listApi1101 = api1101Rep.findPushData(api1404.getKqdm()); |
| | | if (null != listApi1101 && listApi1101.size() > 0) { |
| | | shjdjwApi1404.setDwmc(listApi1101.get(0).getDwmc()); |
| | | List<Double> lhsl = getLhsl(api1403); |
| | | if (null != lhsl && lhsl.size() > 0) { |
| | | shjdjwApi1403.setLrsl(lhsl.get(1)); |
| | | shjdjwApi1403.setLrsl(lhsl.get(0)); |
| | | } |
| | | |
| | | //TODO 计划年度 计划数量 已执行数量 执行比例 招标/竞价比例 |
| | | shjdjwApi1404.setJhnd("0"); |
| | | shjdjwApi1404.setJhsl("0"); |
| | | shjdjwApi1404.setYzxsl("0"); |
| | | shjdjwApi1404.setZxbl("0"); |
| | | shjdjwApi1404.setZbjjbl("0"); |
| | | shjdjwApi1403.setJhbm(api1403.getLhjhdh()); |
| | | shjdjwApi1403.setPch("0"); |
| | | return shjdjwApi1403; |
| | | } |
| | | |
| | | return shjdjwApi1404; |
| | | /** |
| | | * 获取轮入和轮出重量 |
| | | * |
| | | * @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.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()); |
| | |
| | | shjdjwApi1310.setPznm(api1310.getLspzdm()); |
| | | shjdjwApi1310.setSkdjbm(api1310.getLsdjdm()); |
| | | shjdjwApi1310.setJylbbm(api1310.getJylb()); |
| | | if(StringUtils.isNotEmpty(shjdjwApi1310.getJyxm())){ |
| | | if (StringUtils.isNotEmpty(shjdjwApi1310.getJyxm())) { |
| | | String[] split = shjdjwApi1310.getJyxm().split(","); |
| | | StringBuilder jyjl = new StringBuilder(); |
| | | for (String s : split) { |
| | |
| | | BeanUtils.copyProperties(api1209, shjdjwApi1209); |
| | | |
| | | shjdjwApi1209.setSydbh(api1209.getSydh()); |
| | | shjdjwApi1209.setHwbm(api1209.getHwdm()); |
| | | |
| | | shjdjwApi1209.setRksl(api1209.getRkjz()); |
| | | shjdjwApi1209.setCksl(api1209.getCkjz()); |
| | | shjdjwApi1209.setSysl(api1209.getJzsysl()); |
| | |
| | | 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()); |
| | |
| | | |
| | | shjdjwApi1205.setDksj(api1205.getDjsj()); |
| | | shjdjwApi1205.setLksj(api1205.getCmsj()); |
| | | shjdjwApi1205.setLhnd(DateFormatUtils.format(api1205.getCmsj(), "yyyy")); |
| | | shjdjwApi1205.setPch("0"); |
| | | return shjdjwApi1205; |
| | | } |
| | |
| | | case "1403": |
| | | //轮换计划接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1501; |
| | | case "1404": |
| | | //轮换计划完成情况接口编码 |
| | | return ShjdjwApiCodeConstant.API_CODE_LS1502; |
| | | default: |
| | | return inteId; |
| | | } |
| | |
| | | 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()); |