feat: 分类树标准法规回写接口定时任务
This commit is contained in:
@@ -29,6 +29,11 @@
|
|||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/lib/bim-codec-1.0.0.jar</systemPath>
|
<systemPath>${project.basedir}/lib/bim-codec-1.0.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- WebClient -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
+6
@@ -1,6 +1,7 @@
|
|||||||
package com.jero.modules.docking.srms.job;
|
package com.jero.modules.docking.srms.job;
|
||||||
|
|
||||||
import com.jero.modules.docking.srms.service.SrmsApiService;
|
import com.jero.modules.docking.srms.service.SrmsApiService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
@@ -12,6 +13,7 @@ import javax.annotation.Resource;
|
|||||||
* @author LQT
|
* @author LQT
|
||||||
* @date 2024/2/21 16:01
|
* @date 2024/2/21 16:01
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class SyncPartStandardJob implements Job {
|
public class SyncPartStandardJob implements Job {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -19,6 +21,10 @@ public class SyncPartStandardJob implements Job {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||||
|
log.info("每日分类树标准法规回写开始");
|
||||||
|
// 同步数据
|
||||||
srmsApiService.syncPartStandard();
|
srmsApiService.syncPartStandard();
|
||||||
|
// 发送请求
|
||||||
|
srmsApiService.sendPartStandard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ public interface SrmsApiService {
|
|||||||
* @param
|
* @param
|
||||||
* @return com.jero.common.api.vo.Result<java.lang.String>
|
* @return com.jero.common.api.vo.Result<java.lang.String>
|
||||||
*/
|
*/
|
||||||
void sendPartStandard();
|
void sendPartStandard() throws InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* E采通获取标准信息
|
* E采通获取标准信息
|
||||||
|
|||||||
+41
-27
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
@@ -131,7 +132,7 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
|||||||
@Value("${srms.etton_sys_user}")
|
@Value("${srms.etton_sys_user}")
|
||||||
private String ettonSysUser;
|
private String ettonSysUser;
|
||||||
@Value("${srms.part_standard_url}")
|
@Value("${srms.part_standard_url}")
|
||||||
private String partStandardUrl;
|
private String partStandardRewriteUrl;
|
||||||
|
|
||||||
@Value("${bindPart.pdm_Ip}")
|
@Value("${bindPart.pdm_Ip}")
|
||||||
private String pdmIp;
|
private String pdmIp;
|
||||||
@@ -700,24 +701,37 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPartStandard() {
|
public void sendPartStandard() throws InterruptedException {
|
||||||
try {
|
List<LawsPartStandard> listLawsPartStandard = lawsPartStandardService.list();
|
||||||
List<LawsPartStandard> listLawsPartStandard = lawsPartStandardService.list();
|
int size = listLawsPartStandard.size();
|
||||||
|
log.info("零部件分类回写总数居条数为:{}", size);
|
||||||
|
if (size == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 每10000条记录为一个子列表
|
||||||
|
int chunkSize = 10000;
|
||||||
|
List<List<LawsPartStandard>> listOfChunks = new ArrayList<>();
|
||||||
|
|
||||||
|
// 使用for循环和subList方法分割列表
|
||||||
|
for (int i = 0; i < size; i += chunkSize) {
|
||||||
|
int end = Math.min(size, i + chunkSize); // 确保不会超出列表的末尾
|
||||||
|
List<LawsPartStandard> chunk = listLawsPartStandard.subList(i, end);
|
||||||
|
listOfChunks.add(chunk);
|
||||||
|
}
|
||||||
|
String batchId = IdWorker.getIdStr();
|
||||||
|
for (int i = 0; i < listOfChunks.size(); i++) {
|
||||||
|
List<LawsPartStandard> list = listOfChunks.get(i);
|
||||||
|
// 判断数据量是否大于指定大小
|
||||||
JSONObject all = new JSONObject();
|
JSONObject all = new JSONObject();
|
||||||
JSONObject messageHeader = new JSONObject();
|
all.put(MESSAGE_HANDLER, getMessageHandler("CNHTC_PO1000400", null));
|
||||||
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
JSONObject requests = new JSONObject();
|
||||||
// todo Interface_ID,UUID
|
// 批次信息
|
||||||
messageHeader.put("Interface_ID", "");
|
requests.put("BatchId", batchId);
|
||||||
messageHeader.put("UUID", "");
|
requests.put("BatchNo", String.valueOf(i + 1));
|
||||||
messageHeader.put("MessageId", "");
|
// rows
|
||||||
messageHeader.put("Sender", "SRMS");
|
|
||||||
messageHeader.put("Receiver", "PDM");
|
|
||||||
messageHeader.put("SendDate", date.substring(0, 8));
|
|
||||||
messageHeader.put("SendTime", date.substring(8));
|
|
||||||
all.put("MessageHeader", messageHeader);
|
|
||||||
List<JSONObject> listObj = new ArrayList<>();
|
List<JSONObject> listObj = new ArrayList<>();
|
||||||
if (!CollectionUtils.isEmpty(listLawsPartStandard)) {
|
if (!CollectionUtils.isEmpty(listLawsPartStandard)) {
|
||||||
for (LawsPartStandard lawsPartStandard : listLawsPartStandard) {
|
for (LawsPartStandard lawsPartStandard : list) {
|
||||||
JSONObject rows = new JSONObject();
|
JSONObject rows = new JSONObject();
|
||||||
rows.put(PART_CATEGORY_NUM, lawsPartStandard.getPartCategoryNum());
|
rows.put(PART_CATEGORY_NUM, lawsPartStandard.getPartCategoryNum());
|
||||||
rows.put("StandardPdmType", lawsPartStandard.getStandardPdmType());
|
rows.put("StandardPdmType", lawsPartStandard.getStandardPdmType());
|
||||||
@@ -728,19 +742,19 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
|||||||
listObj.add(rows);
|
listObj.add(rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
JSONObject requests = new JSONObject();
|
|
||||||
requests.put("Rows", listObj);
|
requests.put("Rows", listObj);
|
||||||
all.put(REQUESTS, requests);
|
all.put(REQUESTS, requests);
|
||||||
// todo url
|
// 创建 HttpEntity 包含请求体和头信息
|
||||||
JSONObject reData = restTemplate.postForObject(partStandardUrl, all, JSONObject.class);
|
HttpHeaders headers = this.getBasicAuthHeaders();
|
||||||
log.info(JSON.toJSONString(reData));
|
HttpEntity<String> entity = new HttpEntity<>(all.toString(), headers);
|
||||||
if (!Objects.isNull(reData) && reData.containsKey("Success") && Objects.equals("true", reData.getString("Success"))) {
|
// 打印完整的请求报文信息
|
||||||
log.info("分类树标准法规回写接口成功");
|
log.info("零部件分类回写相关信息");
|
||||||
} else {
|
log.info("IP: " + pdmIp + partStandardRewriteUrl);
|
||||||
log.error("分类树标准法规回写接口失败");
|
log.info("Headers: " + headers);
|
||||||
}
|
JSONObject reData = restTemplate.postForObject(pdmIp + partStandardRewriteUrl, entity, JSONObject.class);
|
||||||
} catch (Exception e) {
|
Thread.sleep(3000);
|
||||||
log.error("分类树标准法规回写接口失败", e);
|
log.info("零部件分类回写请求返回");
|
||||||
|
log.info("返回报文: " + JSON.toJSONString(reData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ srms:
|
|||||||
# E彩通默认账户
|
# E彩通默认账户
|
||||||
etton_sys_user: etton
|
etton_sys_user: etton
|
||||||
# 分类树标准法规回写接口 url
|
# 分类树标准法规回写接口 url
|
||||||
part_standard_url:
|
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
|
||||||
|
|
||||||
# 标准性质 x替换为\d作为正则匹配
|
# 标准性质 x替换为\d作为正则匹配
|
||||||
standardProperty:
|
standardProperty:
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ srms:
|
|||||||
# E彩通默认账户
|
# E彩通默认账户
|
||||||
etton_sys_user: etton
|
etton_sys_user: etton
|
||||||
# 分类树标准法规回写接口 url
|
# 分类树标准法规回写接口 url
|
||||||
part_standard_url:
|
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
|
||||||
|
|
||||||
# 标准性质 x替换为\d作为正则匹配
|
# 标准性质 x替换为\d作为正则匹配
|
||||||
standardProperty:
|
standardProperty:
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ srms:
|
|||||||
# E彩通默认账户
|
# E彩通默认账户
|
||||||
etton_sys_user: etton
|
etton_sys_user: etton
|
||||||
# 分类树标准法规回写接口 url
|
# 分类树标准法规回写接口 url
|
||||||
part_standard_url:
|
part_standard_url: RESTAdapter/PSRMS/PO1000400/RegulatoryBackwriting
|
||||||
|
|
||||||
# 标准性质 x替换为\d作为正则匹配
|
# 标准性质 x替换为\d作为正则匹配
|
||||||
standardProperty:
|
standardProperty:
|
||||||
|
|||||||
Reference in New Issue
Block a user