| | |
| | | import com.fzzy.api.service.ApiCommonService; |
| | | import com.fzzy.api.service.ApiRemoteService; |
| | | import com.fzzy.api.utils.*; |
| | | import com.fzzy.api.view.repository.Api1101Rep; |
| | | import com.fzzy.api.view.repository.Api1102Rep; |
| | | import com.fzzy.api.view.repository.Api1404Rep; |
| | | import com.fzzy.api.view.repository.ApiLogRep; |
| | | import com.fzzy.push.gd2022.dto.*; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1101; |
| | |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1208; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1307; |
| | | import com.fzzy.push.gd2022.dto.Gd2022Api1308; |
| | | import com.fzzy.push.sh2023.SH2023Constant; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang.StringUtils; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private ApiCommonService apiCommonService; |
| | | |
| | | @Autowired |
| | | private Api1404Rep api1404Rep; |
| | | @Autowired |
| | | private Api1101Rep api1101Rep; |
| | | @Autowired |
| | | private Api1102Rep api1102Rep; |
| | | @Autowired |
| | | private ApiLogRep apiLogRep; |
| | | |
| | | @Override |
| | | public String getProtocol() { |
| | | return PushProtocol.SB_GD_2022.getCode(); |
| | | } |
| | | |
| | | @Override |
| | | public ResponseDto pushData(ApiParam param, Object data) { |
| | | return pushData(param, null, data); |
| | | } |
| | | |
| | | @Override |
| | |
| | | ResponseDto resd = new ResponseDto(); |
| | | resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode()); |
| | | resd.setMsg(responseDto.getMsg()); |
| | | //updateGD2022AuthToken(responseDto,conf, token); |
| | | return resd; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ResponseDto pushData(ApiParam param, Object data) { |
| | | return pushData(param, null, data); |
| | | } |
| | | |
| | | // @Override |
| | | // public ResponseDto pushFile(ApiParam param, ApiConfs conf, Object data) { |
| | | // |
| | | // String inteId = param.getInteId(); |
| | | // String kqdm = param.getKqdm(); |
| | | // |
| | | // try { |
| | | // |
| | | // if (null == conf) { |
| | | // conf = apiCommonService.getConf(kqdm); |
| | | // } |
| | | // //获取TOKEN |
| | | // GD2022AuthToken token = getGD2022AuthToken(conf); |
| | | // |
| | | // ApiLog apiLog = new ApiLog(); |
| | | // apiLog.setId(ContextUtil.getUUID()); |
| | | // apiLog.setInteId(inteId); |
| | | // apiLog.setData(JSON.toJSONString(data)); |
| | | // apiLog.setKqdm(kqdm); |
| | | // apiLog.setUploadTime(new Date()); |
| | | // |
| | | // String wjdz = ""; |
| | | // if (Constant.API_CODE_1109.equals(inteId)) { |
| | | // //封装数据,获取文件地址 |
| | | // Gd2022Api1109 api1109 = new Gd2022Api1109(); |
| | | // BeanUtils.copyProperties(data, api1109); |
| | | // wjdz = api1109.getWjdz(); |
| | | // } else if (Constant.API_CODE_1307.equals(inteId)) { |
| | | // //封装数据,获取文件地址 |
| | | // Gd2022Api1307 api1307 = new Gd2022Api1307(); |
| | | // BeanUtils.copyProperties(data, api1307); |
| | | // wjdz = api1307.getWjdz(); |
| | | // } else if (Constant.API_CODE_1308.equals(inteId)) { |
| | | // //封装数据,获取文件地址 |
| | | // Gd2022Api1308 api1308 = new Gd2022Api1308(); |
| | | // BeanUtils.copyProperties(data, api1308); |
| | | // wjdz = api1308.getWjdz(); |
| | | // } |
| | | // if (StringUtils.isEmpty(wjdz)) { |
| | | // ResponseDto responseDto = new ResponseDto(99, "没有获取到文件地址", wjdz); |
| | | // apiLog.setStatus(99); |
| | | // apiLog.setResult("没有获取到文件地址"); |
| | | // apiLogRep.save(apiLog); |
| | | // return responseDto; |
| | | // } |
| | | // //先上传文件,获取文件id |
| | | // GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(conf.getApiUrl(), token, wjdz); |
| | | // ResponseDto resd = new ResponseDto(); |
| | | // resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode()); |
| | | // resd.setBizId((String) responseDto.getData()); |
| | | // resd.setMsg(responseDto.getMsg()); |
| | | // return resd; |
| | | // } catch (Exception e) { |
| | | // log.error(e.getMessage(), e); |
| | | // return new ResponseDto(99, e.getMessage()); |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 推送财务数据接口 |
| | | * |
| | | * @param param |
| | | * @param conf |
| | | * @param data |
| | |
| | | } |
| | | } |
| | | |
| | | private Object changeObject(Object object) { |
| | | // 使用反射获取属性列表 object为实体对象名 |
| | | Field[] fields = object.getClass().getDeclaredFields(); |
| | | for (Field field : fields) { |
| | | field.setAccessible(true); |
| | | try { |
| | | // 判断属性值是否为null |
| | | if (field.get(object) == null || field.get(object) == "") { |
| | | //根据类型设置默认值 |
| | | if (field.getType() == String.class) { |
| | | field.set(object, "0"); |
| | | } |
| | | if (field.getType() == Integer.class) { |
| | | field.set(object, 0); |
| | | } |
| | | if (field.getType() == Double.class) { |
| | | field.set(object, 0.0); |
| | | } |
| | | if (field.getType() == Date.class) { |
| | | field.set(object, new Date()); |
| | | } |
| | | } |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return object; |
| | | } |
| | | |
| | | private String getJsonData(String inteId, Object data, String url, GD2022AuthToken authToken) throws Exception { |
| | | if (Constant.API_CODE_1101.equals(inteId)) { |
| | | Gd2022Api1101 api1101 = new Gd2022Api1101(); |
| | | BeanUtils.copyProperties(data, api1101); |
| | | api1101.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1101); |
| | | } else if (Constant.API_CODE_1102.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1102.equals(inteId)) { |
| | | Gd2022Api1102 api1102 = new Gd2022Api1102(); |
| | | BeanUtils.copyProperties(data, api1102); |
| | | api1102.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1102); |
| | | } else if (Constant.API_CODE_1103.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1103.equals(inteId)) { |
| | | Gd2022Api1103 api1103 = new Gd2022Api1103(); |
| | | BeanUtils.copyProperties(data, api1103); |
| | | changeObject(api1103); |
| | | api1103.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1103); |
| | | } else if (Constant.API_CODE_1104.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1104.equals(inteId)) { |
| | | Gd2022Api1104 api1104 = new Gd2022Api1104(); |
| | | BeanUtils.copyProperties(data, api1104); |
| | | changeObject(api1104); |
| | | api1104.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1104); |
| | | } else if (Constant.API_CODE_1105.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1105.equals(inteId)) { |
| | | Gd2022Api1105 api1105 = new Gd2022Api1105(); |
| | | BeanUtils.copyProperties(data, api1105); |
| | | api1105.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1105); |
| | | }else if (Constant.API_CODE_1109.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1106.equals(inteId)) { |
| | | Api1106 api1106 = (Api1106) data; |
| | | api1106.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1106); |
| | | } |
| | | if (Constant.API_CODE_1107.equals(inteId)) { |
| | | Api1107 api1107 = (Api1107) data; |
| | | api1107.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1107); |
| | | } |
| | | if (Constant.API_CODE_1108.equals(inteId)) { |
| | | Api1108 api1108 = (Api1108) data; |
| | | api1108.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1108); |
| | | } |
| | | if (Constant.API_CODE_1109.equals(inteId)) { |
| | | //封装数据 |
| | | Gd2022Api1109 api1109 = new Gd2022Api1109(); |
| | | BeanUtils.copyProperties(data, api1109); |
| | |
| | | System.out.println((String) responseDto.getData()); |
| | | //设置上传文件id |
| | | api1109.setFileStorageId((String) responseDto.getData()); |
| | | api1109.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1109); |
| | | }else if (Constant.API_CODE_1111.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1110.equals(inteId)) { |
| | | Api1110 api1110 = (Api1110) data; |
| | | api1110.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1110); |
| | | } |
| | | if (Constant.API_CODE_1111.equals(inteId)) { |
| | | Gd2022Api1111 api1111 = new Gd2022Api1111(); |
| | | BeanUtils.copyProperties(data, api1111); |
| | | List<Api1102> api1102List = api1102Rep.findPushData(api1111.getKqdm()); |
| | | if(null != api1102List && api1102List.size() > 0){ |
| | | api1111.setKqmc(api1102List.get(0).getKqmc()); |
| | | } |
| | | List<Api1101> api1101List = api1101Rep.findDataByDwdm(api1111.getDwdm()); |
| | | if(null != api1101List && api1101List.size() > 0){ |
| | | api1111.setDwmc(api1101List.get(0).getDwmc()); |
| | | } |
| | | api1111.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1111); |
| | | } else if (Constant.API_CODE_1208.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1112.equals(inteId)) { |
| | | Api1112 api1112 = (Api1112) data; |
| | | api1112.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1112); |
| | | } |
| | | if (Constant.API_CODE_1113.equals(inteId)) { |
| | | Api1113 api1113 = (Api1113) data; |
| | | api1113.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1113); |
| | | } |
| | | if (Constant.API_CODE_1201.equals(inteId)) { |
| | | Api1201 apiData = (Api1201) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1202.equals(inteId)) { |
| | | Api1202 apiData = (Api1202) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1203.equals(inteId)) { |
| | | Api1203 apiData = (Api1203) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1204.equals(inteId)) { |
| | | Api1204 apiData = (Api1204) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1205.equals(inteId)) { |
| | | Api1205 apiData = (Api1205) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1206.equals(inteId)) { |
| | | Api1206 apiData = (Api1206) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1207.equals(inteId)) { |
| | | Api1207 apiData = (Api1207) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1208.equals(inteId)) { |
| | | Gd2022Api1208 api1208 = new Gd2022Api1208(); |
| | | BeanUtils.copyProperties(data, api1208); |
| | | return JSON.toJSONString(api1208); |
| | | } else if (Constant.API_CODE_1307.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1209.equals(inteId)) { |
| | | Api1209 apiData = (Api1209) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1210.equals(inteId)) { |
| | | Api1210 apiData = (Api1210) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1211.equals(inteId)) { |
| | | Api1211 apiData = (Api1211) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1212.equals(inteId)) { |
| | | Api1212 apiData = (Api1212) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1301.equals(inteId)) { |
| | | Api1301 apiData = (Api1301) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1302.equals(inteId)) { |
| | | Api1302 apiData = (Api1302) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1303.equals(inteId)) { |
| | | Api1303 apiData = (Api1303) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1304.equals(inteId)) { |
| | | Api1304 apiData = (Api1304) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1305.equals(inteId)) { |
| | | Api1305 apiData = (Api1305) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1306.equals(inteId)) { |
| | | Api1306 apiData = (Api1306) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1307.equals(inteId)) { |
| | | //封装数据 |
| | | Gd2022Api1307 api1307 = new Gd2022Api1307(); |
| | | BeanUtils.copyProperties(data, api1307); |
| | |
| | | GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(url, authToken, api1307.getWjdz()); |
| | | //设置上传文件id |
| | | api1307.setFileStorageId((String) responseDto.getData()); |
| | | api1307.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1307); |
| | | } else if (Constant.API_CODE_1308.equals(inteId)) { |
| | | } |
| | | if (Constant.API_CODE_1308.equals(inteId)) { |
| | | //封装数据 |
| | | Gd2022Api1308 api1308 = new Gd2022Api1308(); |
| | | BeanUtils.copyProperties(data, api1308); |
| | |
| | | GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(url, authToken, api1308.getWjdz()); |
| | | //设置上传文件id |
| | | api1308.setFileStorageId((String) responseDto.getData()); |
| | | api1308.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1308); |
| | | } else { |
| | | return JSON.toJSONString(data); |
| | | } |
| | | if (Constant.API_CODE_1309.equals(inteId)) { |
| | | Api1309 apiData = (Api1309) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1310.equals(inteId)) { |
| | | Api1310 apiData = (Api1310) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1401.equals(inteId)) { |
| | | Api1401 apiData = (Api1401) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1402.equals(inteId)) { |
| | | Api1402 apiData = (Api1402) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | if (Constant.API_CODE_1403.equals(inteId)) { |
| | | //轮换计划,单独查询轮换计划明细信息,统一封装后上传 |
| | | Gd2022Api1403 api1403 = new Gd2022Api1403(); |
| | | BeanUtils.copyProperties(data, api1403); |
| | | List<Api1404> list = api1404Rep.getDataByLhjhdh(api1403.getLhjhdh()); |
| | | Gd2022Api1404 gd2022Api1404; |
| | | List<Gd2022Api1404> dtls = new ArrayList<>(); |
| | | Double lrsl = 0.0, lcsl = 0.0; //用于统计轮入数量和轮出数量 |
| | | if(null != list && list.size() > 0){ |
| | | for (Api1404 api1404 : list) { |
| | | gd2022Api1404 = new Gd2022Api1404(); |
| | | BeanUtils.copyProperties(api1404, gd2022Api1404); |
| | | if(null!= gd2022Api1404.getLhlx() && "2".equals(gd2022Api1404.getLhlx())){ |
| | | lrsl += gd2022Api1404.getLhsl(); |
| | | } |
| | | if(null!= gd2022Api1404.getLhlx() && "1".equals(gd2022Api1404.getLhlx())){ |
| | | lcsl += gd2022Api1404.getLhsl(); |
| | | } |
| | | gd2022Api1404.setZhgxsj(new Date()); |
| | | dtls.add(gd2022Api1404); |
| | | } |
| | | } |
| | | api1403.setRotationInQty(lrsl); |
| | | api1403.setRotationOutQty(lcsl); |
| | | api1403.setDtls(dtls); |
| | | //先上传文件,获取文件id |
| | | GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(url, authToken, api1403.getWjdz()); |
| | | //设置上传文件id |
| | | api1403.setFileStorageId((String) responseDto.getData()); |
| | | api1403.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(api1403); |
| | | } |
| | | if (Constant.API_CODE_1404.equals(inteId)) { |
| | | //轮换计划明细,不单独上传,在轮换计划中统一上传 |
| | | return null; |
| | | } |
| | | if (Constant.API_CODE_1405.equals(inteId)) { |
| | | Api1405 apiData = (Api1405) data; |
| | | apiData.setZhgxsj(new Date()); |
| | | return JSON.toJSONString(apiData); |
| | | } |
| | | return JSON.toJSONString(data); |
| | | } |
| | | |
| | | |
| | |
| | | gdFinanceDto.setBbsj(DateFormatUtils.format(api1503.getBbsj(), "yyyyMMdd")); |
| | | gdFinanceDto.setBbm("03"); |
| | | gdFinanceDto.setCzbz(api1503.getCzbz()); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(api1503.getZhgxsj(), "yyyy-MM-dd HH:mm:ss")); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | paddingData(gdFinanceDto, list, 1, "项目//t", "本期金额//t", "本年累计//t"); |
| | | paddingData(gdFinanceDto, list, 2, "一、营业收入", api1503.getYyzsrbqye() + "", api1503.getYyzsrbnlj() + ""); |
| | |
| | | gdFinanceDto.setBbsj(DateFormatUtils.format(api1502.getBbsj(), "yyyyMMdd")); |
| | | gdFinanceDto.setBbm("02"); |
| | | gdFinanceDto.setCzbz(api1502.getCzbz()); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(api1502.getZhgxsj(), "yyyy-MM-dd HH:mm:ss")); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | paddingData(gdFinanceDto, list, 1, "项目//t", "本月数//t", "本年累计数//t"); |
| | | paddingData(gdFinanceDto, list, 2, "一、经营活动产生的现金流量:", api1502.getJyhdxjllbys() + "", api1502.getJyhdxjllbnljs() + ""); |
| | |
| | | gdFinanceDto.setBbsj(DateFormatUtils.format(api1501.getBbsj(), "yyyyMMdd")); |
| | | gdFinanceDto.setBbm("01"); |
| | | gdFinanceDto.setCzbz(api1501.getCzbz()); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(api1501.getZhgxsj(), "yyyy-MM-dd HH:mm:ss")); |
| | | gdFinanceDto.setZhgxsj(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | paddingData(gdFinanceDto, list, 1, "资产//t", "期末余额//t", "年初余额//t"); |
| | | paddingData(gdFinanceDto, list, 2, "流动资产:", api1501.getLdzchjqmye() + "", api1501.getLdzchjncye() + ""); |
| | |
| | | case "1112": |
| | | return ApiCodeConstant.API_CODE_RYXX; |
| | | case "1113": |
| | | return ""; |
| | | return ApiCodeConstant.API_CODE_QYXYXX; |
| | | case "1201": |
| | | return ApiCodeConstant.API_CODE_HTXX; |
| | | case "1202": |
| | |
| | | case "1401": |
| | | return ApiCodeConstant.API_CODE_CBGM; |
| | | case "1402": |
| | | return ApiCodeConstant.API_CODE_CBJHXX; |
| | | return ApiCodeConstant.API_CODE_CBJH; |
| | | case "1403": |
| | | return ApiCodeConstant.API_CODE_LHJHXX; |
| | | return ApiCodeConstant.API_CODE_LHJH; |
| | | case "1404": |
| | | return ApiCodeConstant.API_CODE_LHJHMXXX; |
| | | return null; |
| | | case "1405": |
| | | return ""; |
| | | case "1501": |