| | |
| | | import com.bstek.dorado.annotation.DataProvider; |
| | | import com.bstek.dorado.annotation.DataResolver; |
| | | import com.bstek.dorado.annotation.Expose; |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.api.Constant; |
| | | import com.fzzy.api.data.ApiParam; |
| | | import com.fzzy.api.dto.ResponseDto; |
| | | import com.fzzy.api.entity.Api1202; |
| | | import com.fzzy.api.entity.ApiConfs; |
| | | import com.fzzy.api.entity.ApiInfoData; |
| | | import com.fzzy.api.service.ApiCommonService; |
| | |
| | | import com.fzzy.data.ConfigData; |
| | | import com.fzzy.otherview.whhpjl.WhjlConstant; |
| | | import com.fzzy.otherview.whhpjl.dto.*; |
| | | 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.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.data.repository.query.Param; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import javax.persistence.criteria.CriteriaQuery; |
| | | import javax.persistence.criteria.Predicate; |
| | | import javax.persistence.criteria.Root; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | * |
| | | * @author czt |
| | | */ |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class WhjlShareApi2013PR2 { |
| | | @Autowired |
| | |
| | | @DataProvider |
| | | public List<WhjlShareApi2013> listData() { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_2013); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<WhjlShareApi2013> list = new ArrayList<>(); |
| | | WhjlShareApi2013 whjlShareApiData; |
| | | for (ApiInfoData infoData : result) { |
| | | whjlShareApiData = JSONObject.parseObject(infoData.getData(), WhjlShareApi2013.class); |
| | | whjlShareApiData.setKqdm(infoData.getKqdm()); |
| | | whjlShareApiData.setCzbz(infoData.getCzbz()); |
| | | whjlShareApiData.setUpdateTime(infoData.getUpdateTime()); |
| | | list.add(whjlShareApiData); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<WhjlShareApi2013> listDataByTime(Date start, Date end) { |
| | | List<ApiInfoData> result = apiInfoDataRep.getDataByInteId(WhjlConstant.API_CODE_2013, start, end); |
| | | if (null == result || result.isEmpty()) { |
| | | return null; |
| | | } |
| | |
| | | apiInfoDataRep.deleteById(data.getQlyOrgReportId()); |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 更新数据 |
| | | * whjlShareApi2013PR2#pullData |
| | | * |
| | | * @param items |
| | | * @param |
| | | * @return |
| | | */ |
| | | @Expose |
| | | public String pullData(List<WhjlShareApi2013> items) { |
| | | public String pullData(ApiParam param1) { |
| | | |
| | | |
| | | //获取配置信息 |
| | |
| | | } |
| | | //封装参数 |
| | | param = new ApiParam(apiConf, WhjlConstant.API_CATEGORY_20, WhjlConstant.API_CODE_2013); |
| | | |
| | | //设置起始时间 |
| | | param.setStart(param1.getStart()); |
| | | param.setEnd(param1.getEnd()); |
| | | |
| | | responseDto = apiService.pullData(param, apiConf); |
| | | |
| | | if(null == responseDto){ |
| | | if (null == responseDto) { |
| | | return "更新失败!"; |
| | | } |
| | | if (responseDto.getSuccess() == 0) { |
| | | list = JSONObject.parseArray(responseDto.getData(), WhjlShareApi2013.class); |
| | | if(null != list && list.size() > 0){ |
| | | if (null != list && list.size() > 0) { |
| | | for (WhjlShareApi2013 shareData : list) { |
| | | //保存文件 |
| | | //路径 |
| | |
| | | |
| | | //文件id |
| | | |
| | | if(StringUtils.isNotEmpty(shareData.getReportFile())){ |
| | | String fileId = ContextUtil.getTimeId(1000); |
| | | String fileName = "附件"+ ".pdf"; |
| | | Base64Util.saveBase64ToFile(shareData.getReportFile(),basePath + fileId + ".pdf"); |
| | | if (StringUtils.isNotEmpty(shareData.getReportFile())) { |
| | | String fileId = shareData.getDeletctionNumber() + ".pdf"; |
| | | Base64Util.base64StringToPDF(shareData.getReportFile(), basePath, fileId); |
| | | |
| | | shareData.setFileId(fileId); |
| | | shareData.setFileName(fileName); |
| | | shareData.setFileName(fileId); |
| | | shareData.setFileTime(new Date()); |
| | | |
| | | // shareData.setReportFile(null); |
| | |
| | | * whjlShareApi2013PR#sysDataToDept |
| | | */ |
| | | @Expose |
| | | public void sysDataToDept(){ |
| | | public void sysDataToDept(ApiParam param1) { |
| | | //获取所有数据 |
| | | List<WhjlShareApi2013> list = listData(); |
| | | if(null == list || list.isEmpty()){ |
| | | List<WhjlShareApi2013> list = listDataByTime(param1.getStart(), param1.getEnd()); |
| | | if (null == list || list.isEmpty()) { |
| | | return; |
| | | } |
| | | Fz40WhjlMQuality fz40WhjlMQuality = null; |
| | | for (WhjlShareApi2013 whjlShareApi2013 : list) { |
| | | fz40WhjlMQuality = new Fz40WhjlMQuality(); |
| | | fz40WhjlMQuality.setProvReserve(Constant.YN_Y); |
| | | fz40WhjlMQuality.setId(whjlShareApi2013.getQlyOrgReportId()); |
| | | String basePath = configData.getImgPath() + "COMMON/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | try { |
| | | |
| | | if(StringUtils.isNotEmpty(whjlShareApi2013.getReportFile())){ |
| | | fz40WhjlMQuality = new Fz40WhjlMQuality(); |
| | | fz40WhjlMQuality.setProvReserve(Constant.YN_Y); |
| | | fz40WhjlMQuality.setId(whjlShareApi2013.getQlyOrgReportId()); |
| | | String basePath = configData.getImgPath() + "COMMON/" + DateFormatUtils.format(new Date(), "yyyyMM") + "/"; |
| | | |
| | | String fileId = ContextUtil.getTimeId(1000) + ".pdf"; |
| | | String fileName = "附件"+ ".pdf"; |
| | | Base64Util.base64StringToPDF(whjlShareApi2013.getReportFile(),basePath , fileId ); |
| | | |
| | | |
| | | whjlShareApi2013.setFileId(fileId); |
| | | whjlShareApi2013.setFileName(fileName); |
| | | whjlShareApi2013.setFileTime(new Date()); |
| | | whjlShareApi2013.setReportFile(null); |
| | | } |
| | | BeanUtils.copyProperties(whjlShareApi2013, fz40WhjlMQuality); |
| | | fz40WhjlMQuality.setCompanyId(configData.getCompanyId()); |
| | | fz40WhjlMQuality.setDeptId(DEPT_ID); |
| | | fz40ToWhjlSync2013Rep.save(fz40WhjlMQuality); |
| | | if(whjlShareApi2013.getOrgReportNoodlesList() != null){ |
| | | List<ShareApi2013Xmf> orgReportNoodlesList = whjlShareApi2013.getOrgReportNoodlesList(); |
| | | for (ShareApi2013Xmf shareApi2013Xmf : orgReportNoodlesList) { |
| | | Fz40WhjlCheckItemXmf fz40WhjlCheckItemXmf = new Fz40WhjlCheckItemXmf(); |
| | | BeanUtils.copyProperties(shareApi2013Xmf,fz40WhjlCheckItemXmf); |
| | | if(StringUtils.isEmpty(fz40WhjlCheckItemXmf.getQlyOrgReportNoodlesId())) continue; |
| | | fz40ToWhjlSync2013XmfRep.save(fz40WhjlCheckItemXmf); |
| | | // if (StringUtils.isNotEmpty(whjlShareApi2013.getReportFile())) { |
| | | // |
| | | // String fileId = ContextUtil.getTimeId(1000) + ".pdf"; |
| | | // String fileName = "附件" + ".pdf"; |
| | | // Base64Util.base64StringToPDF(whjlShareApi2013.getReportFile(), basePath, fileId); |
| | | // |
| | | // |
| | | // whjlShareApi2013.setFileId(fileId); |
| | | // whjlShareApi2013.setFileName(fileName); |
| | | // whjlShareApi2013.setFileTime(new Date()); |
| | | // whjlShareApi2013.setReportFile(null); |
| | | // log.info("存入附件信息={}", fileName); |
| | | // } |
| | | BeanUtils.copyProperties(whjlShareApi2013, fz40WhjlMQuality); |
| | | fz40WhjlMQuality.setReportFile(null); |
| | | fz40WhjlMQuality.setCompanyId(configData.getCompanyId()); |
| | | fz40WhjlMQuality.setDeptId(DEPT_ID); |
| | | fz40ToWhjlSync2013Rep.save(fz40WhjlMQuality); |
| | | if (whjlShareApi2013.getOrgReportNoodlesList() != null) { |
| | | List<ShareApi2013Xmf> orgReportNoodlesList = whjlShareApi2013.getOrgReportNoodlesList(); |
| | | for (ShareApi2013Xmf shareApi2013Xmf : orgReportNoodlesList) { |
| | | Fz40WhjlCheckItemXmf fz40WhjlCheckItemXmf = new Fz40WhjlCheckItemXmf(); |
| | | BeanUtils.copyProperties(shareApi2013Xmf, fz40WhjlCheckItemXmf); |
| | | if (StringUtils.isEmpty(fz40WhjlCheckItemXmf.getQlyOrgReportNoodlesId())) continue; |
| | | fz40ToWhjlSync2013XmfRep.save(fz40WhjlCheckItemXmf); |
| | | } |
| | | } |
| | | } |
| | | if(whjlShareApi2013.getOrgReportSoybeanList() != null){ |
| | | List<ShareApi2013Dd> orgReportSoybeanList = whjlShareApi2013.getOrgReportSoybeanList(); |
| | | for (ShareApi2013Dd shareApi2013Dd : orgReportSoybeanList) { |
| | | Fz40WhjlCheckItemDd fz40WhjlCheckItemDd = new Fz40WhjlCheckItemDd(); |
| | | BeanUtils.copyProperties(shareApi2013Dd,fz40WhjlCheckItemDd); |
| | | if(StringUtils.isEmpty(fz40WhjlCheckItemDd.getQlyOrgReportSoybeanId())) continue; |
| | | if (whjlShareApi2013.getOrgReportSoybeanList() != null) { |
| | | List<ShareApi2013Dd> orgReportSoybeanList = whjlShareApi2013.getOrgReportSoybeanList(); |
| | | for (ShareApi2013Dd shareApi2013Dd : orgReportSoybeanList) { |
| | | Fz40WhjlCheckItemDd fz40WhjlCheckItemDd = new Fz40WhjlCheckItemDd(); |
| | | BeanUtils.copyProperties(shareApi2013Dd, fz40WhjlCheckItemDd); |
| | | if (StringUtils.isEmpty(fz40WhjlCheckItemDd.getQlyOrgReportSoybeanId())) continue; |
| | | |
| | | fz40ToWhjlSync2013DdRep.save(fz40WhjlCheckItemDd); |
| | | fz40ToWhjlSync2013DdRep.save(fz40WhjlCheckItemDd); |
| | | } |
| | | } |
| | | } |
| | | if(whjlShareApi2013.getOrgReportRiceList() != null){ |
| | | List<ShareApi2013Dm> orgReportRiceList = whjlShareApi2013.getOrgReportRiceList(); |
| | | for (ShareApi2013Dm shareApi2013Dm : orgReportRiceList) { |
| | | Fz40WhjlCheckItemDm fz40WhjlCheckItemDm = new Fz40WhjlCheckItemDm(); |
| | | BeanUtils.copyProperties(shareApi2013Dm,fz40WhjlCheckItemDm); |
| | | if(StringUtils.isEmpty(fz40WhjlCheckItemDm.getQlyOrgReportRiceId())) continue; |
| | | if (whjlShareApi2013.getOrgReportRiceList() != null) { |
| | | List<ShareApi2013Dm> orgReportRiceList = whjlShareApi2013.getOrgReportRiceList(); |
| | | for (ShareApi2013Dm shareApi2013Dm : orgReportRiceList) { |
| | | Fz40WhjlCheckItemDm fz40WhjlCheckItemDm = new Fz40WhjlCheckItemDm(); |
| | | BeanUtils.copyProperties(shareApi2013Dm, fz40WhjlCheckItemDm); |
| | | if (StringUtils.isEmpty(fz40WhjlCheckItemDm.getQlyOrgReportRiceId())) continue; |
| | | |
| | | fz40ToWhjlSync2013DmRep.save(fz40WhjlCheckItemDm); |
| | | fz40ToWhjlSync2013DmRep.save(fz40WhjlCheckItemDm); |
| | | } |
| | | } |
| | | } |
| | | if(whjlShareApi2013.getOrgReportOilList() != null){ |
| | | List<ShareApi2013Syy> orgReportOilList = whjlShareApi2013.getOrgReportOilList(); |
| | | for (ShareApi2013Syy shareApi2013Syy : orgReportOilList) { |
| | | Fz40WhjlCheckItemSyy fz40WhjlCheckItemSyy = new Fz40WhjlCheckItemSyy(); |
| | | BeanUtils.copyProperties(shareApi2013Syy,fz40WhjlCheckItemSyy); |
| | | if(StringUtils.isEmpty(fz40WhjlCheckItemSyy.getQlyOrgReportOilId())) continue; |
| | | if (whjlShareApi2013.getOrgReportOilList() != null) { |
| | | List<ShareApi2013Syy> orgReportOilList = whjlShareApi2013.getOrgReportOilList(); |
| | | for (ShareApi2013Syy shareApi2013Syy : orgReportOilList) { |
| | | Fz40WhjlCheckItemSyy fz40WhjlCheckItemSyy = new Fz40WhjlCheckItemSyy(); |
| | | BeanUtils.copyProperties(shareApi2013Syy, fz40WhjlCheckItemSyy); |
| | | if (StringUtils.isEmpty(fz40WhjlCheckItemSyy.getQlyOrgReportOilId())) continue; |
| | | |
| | | fz40ToWhjlSync2013SyyRep.save(fz40WhjlCheckItemSyy); |
| | | fz40ToWhjlSync2013SyyRep.save(fz40WhjlCheckItemSyy); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("同步数据失败!", e); |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |