package com.glxp.api.service.basic; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.glxp.api.annotation.Log; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.constant.BasicProcessStatus; import com.glxp.api.constant.BusinessType; import com.glxp.api.entity.basic.BasicCorpEntity; import com.glxp.api.entity.basic.BasicCorpsExportLogEntity; import com.glxp.api.entity.basic.BasicProductsExportLogEntity; import com.glxp.api.entity.sync.SyncDataSetEntity; import com.glxp.api.httpClient.utils.HttpOkClient; import com.glxp.api.req.basic.BasicCorpsExportRequest; import com.glxp.api.req.basic.BasicUnitMaintainFilterRequest; import com.glxp.api.res.basic.BasicCorpExportLogResponse; import com.glxp.api.res.basic.UdiRelevanceExportJsonResponse; import com.glxp.api.service.sync.SyncDataSetService; import com.glxp.api.util.ExcelUtil; import org.springframework.beans.BeanUtils; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; @Service public class BasicGenExcelService { @Resource SyncDataSetService syncDataSetService; @Resource HttpOkClient httpOkClient; public String getIpUrl() { SyncDataSetEntity syncDataSetEntity = syncDataSetService.findSet(); return syncDataSetEntity.getSyncIp(); } @Resource BasicCorpExportLogService basicCorpExportLogService; @Resource BasicProductsExportLogService basicProductsExportLogService; @Async @Log(title = "单据管理", businessType = BusinessType.UPDATE) public void uploadCorpSmpJson(String genKey, BasicCorpExportLogResponse exportData) { BasicCorpsExportLogEntity corpExportLogEntity = basicCorpExportLogService.selectByGenKey(genKey); String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/basic/corp/upload", exportData); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); if (baseResponse.getCode() == 20000) { corpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); } else { corpExportLogEntity.setRemark(baseResponse.getMessage()); corpExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); } basicCorpExportLogService.updateCorpExportLog(corpExportLogEntity); } @Async @Log(title = "单据管理", businessType = BusinessType.UPDATE) public void uploadProductsSmpJson(String genKey, UdiRelevanceExportJsonResponse exportData) { BasicProductsExportLogEntity basicProductsExportLogEntity = basicProductsExportLogService.selectByGenKey(genKey); String response = httpOkClient.uCloudPost(getIpUrl() + "/spssync/basic/udiinfo/upload", exportData); BaseResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { }); if (baseResponse.getCode() == 20000) { basicProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_SUCCESS); } else { basicProductsExportLogEntity.setRemark(baseResponse.getMessage()); basicProductsExportLogEntity.setStatus(BasicProcessStatus.UDIINFO_IMPORT_FAIL); } basicProductsExportLogService.updateUdiInfoExportLog(basicProductsExportLogEntity); } }