|
@@ -1,15 +1,24 @@
|
|
package com.pj.task;
|
|
package com.pj.task;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.pj.api.client.async_server.AsyncServerInterface;
|
|
import com.pj.api.client.async_server.AsyncServerInterface;
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
import com.pj.api.dto.*;
|
|
import com.pj.api.dto.*;
|
|
|
|
+import com.pj.dto.DataDto;
|
|
import com.pj.enummj.DataType;
|
|
import com.pj.enummj.DataType;
|
|
|
|
+import com.pj.enummj.FinishStatus;
|
|
|
|
+import com.pj.ht_byte.HtByte;
|
|
import com.pj.ht_byte.HtByteMapper;
|
|
import com.pj.ht_byte.HtByteMapper;
|
|
|
|
+import com.pj.rabbitmq.RabbitMQ;
|
|
|
|
+import com.pj.utils.ht.AESUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Author Mechrevo
|
|
* @Author Mechrevo
|
|
@@ -50,125 +59,121 @@ public class HtByteTask {
|
|
@Scheduled(cron = "*/9 * * * * ?") // 测试阶段,每9秒扫描一次
|
|
@Scheduled(cron = "*/9 * * * * ?") // 测试阶段,每9秒扫描一次
|
|
private void htByteTask(){
|
|
private void htByteTask(){
|
|
/* 测试mq */
|
|
/* 测试mq */
|
|
-// List<HtByte> htBytes = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, 2));
|
|
|
|
- OrderDto orderDtoById = levelOneServerInterface.getOrderDtoById(8833342005355478419L);
|
|
|
|
- asyncServerInterface.sendLevelOneOrderDto(orderDtoById, DataType.DATA_TYPE_ONE.getCode());
|
|
|
|
|
|
+// OrderDto orderDtoById = levelOneServerInterface.getOrderDtoById(8833342005355478419L);
|
|
|
|
+// asyncServerInterface.sendLevelOneOrderDto(orderDtoById, DataType.DATA_TYPE_ONE.getCode());
|
|
/* 测试mq */
|
|
/* 测试mq */
|
|
-// //扫描表内是否有待处理任务
|
|
|
|
-// List<HtByte> byteList = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, FinishStatus.FINISH_STATUS_ZERO.getCode()));
|
|
|
|
-// //判断是否有任务,没有则返回
|
|
|
|
-// if(byteList.size() == 0)System.out.println("\n暂无待处理任务。\n");
|
|
|
|
-// //执行任务处理流程
|
|
|
|
-// byteList.forEach(item -> {
|
|
|
|
-// //对象转换
|
|
|
|
-// DataDto dataDto = JSONObject.parseObject(item.getBody(), DataDto.class);
|
|
|
|
-// //数据解析
|
|
|
|
-// String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
|
|
|
|
-// //控制台输出
|
|
|
|
-// dataDto.setData(body);
|
|
|
|
-//// System.out.println("开始处理数据: " + dataDto);
|
|
|
|
-// //数据处理完成状态
|
|
|
|
-// boolean flag = false;
|
|
|
|
-// // 根据类型匹配对象
|
|
|
|
-// switch (dataDto.getDataType()){
|
|
|
|
-// case "001":
|
|
|
|
-// //对象转换
|
|
|
|
-// PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
|
|
|
|
-// //根据其内的身份证,有则新增,无则修改???
|
|
|
|
-// flag = levelOneServerInterface.peopleDto(peopleDto);
|
|
|
|
-// if(flag){
|
|
|
|
-// //将完成状态设置成 2 , 表示处理失败
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// //保存
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n边民信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// //todo: 发送失败信息给管理员
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// break;
|
|
|
|
-// case "002":
|
|
|
|
-// //商铺备案
|
|
|
|
-// ShopDto shopDto = JSONObject.parseObject(body, ShopDto.class);
|
|
|
|
-// //保存
|
|
|
|
-// flag = levelOneServerInterface.shopDto(shopDto);
|
|
|
|
-// if(!flag){
|
|
|
|
-// //将完成状态设置成 2 , 表示处理失败
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// //保存
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// //todo: 发送失败信息给管理员
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// break;
|
|
|
|
-// case "003":
|
|
|
|
-// //边民互助组备案
|
|
|
|
-// GroupDto groupDto = JSONObject.parseObject(body, GroupDto.class);
|
|
|
|
-// //保存
|
|
|
|
-// flag = levelOneServerInterface.groupDto(groupDto);
|
|
|
|
-// if(!flag){
|
|
|
|
-// //将完成状态设置成 2 , 表示处理失败
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// //保存
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// //todo: 发送失败信息给管理员
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// break;
|
|
|
|
-// case "004":
|
|
|
|
-// //边民合作社备案
|
|
|
|
-// CooperativeDto cooperativeDto = JSONObject.parseObject(body, CooperativeDto.class);
|
|
|
|
-// //保存
|
|
|
|
-// flag = levelOneServerInterface.cooperativeDto(cooperativeDto);
|
|
|
|
-// if(!flag){
|
|
|
|
-// //将完成状态设置成 2 , 表示处理失败
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// //保存
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// //todo: 发送失败信息给管理员
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
-// item.setMessageId(dataDto.getMsgId());
|
|
|
|
-// htByteMapper.updateById(item);
|
|
|
|
-// System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
-// break;
|
|
|
|
-// case "005":
|
|
|
|
-// //车辆
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// case "006":
|
|
|
|
-// //进境申报单
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// case "007":
|
|
|
|
-// //进口申报单
|
|
|
|
-//
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
|
|
+ //扫描表内是否有待处理任务
|
|
|
|
+ List<HtByte> byteList = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, FinishStatus.FINISH_STATUS_ZERO.getCode()));
|
|
|
|
+ //判断是否有任务,没有则返回
|
|
|
|
+ if(byteList.size() == 0)System.out.println("\n --- 暂无待处理任务。\n");
|
|
|
|
+ //执行任务处理流程
|
|
|
|
+ byteList.forEach(item -> {
|
|
|
|
+ //对象转换
|
|
|
|
+ DataDto dataDto = JSONObject.parseObject(item.getBody(), DataDto.class);
|
|
|
|
+ //数据解析
|
|
|
|
+ String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
|
|
|
|
+ //数据处理完成状态
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ // 根据类型匹配对象
|
|
|
|
+ switch (dataDto.getDataType()){
|
|
|
|
+ case "001":
|
|
|
|
+ //对象转换
|
|
|
|
+ PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
|
|
|
|
+ //根据其内的身份证,有则新增,无则修改???
|
|
|
|
+ flag = levelOneServerInterface.peopleDto(peopleDto);
|
|
|
|
+ if(flag){
|
|
|
|
+ //将完成状态设置成 2 , 表示处理失败
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ //保存
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n边民信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ //todo: 发送失败信息给管理员
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ break;
|
|
|
|
+ case "002":
|
|
|
|
+ //商铺备案
|
|
|
|
+ ShopDto shopDto = JSONObject.parseObject(body, ShopDto.class);
|
|
|
|
+ //保存
|
|
|
|
+ flag = levelOneServerInterface.shopDto(shopDto);
|
|
|
|
+ if(!flag){
|
|
|
|
+ //将完成状态设置成 2 , 表示处理失败
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ //保存
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ //todo: 发送失败信息给管理员
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ break;
|
|
|
|
+ case "003":
|
|
|
|
+ //边民互助组备案
|
|
|
|
+ GroupDto groupDto = JSONObject.parseObject(body, GroupDto.class);
|
|
|
|
+ //保存
|
|
|
|
+ flag = levelOneServerInterface.groupDto(groupDto);
|
|
|
|
+ if(!flag){
|
|
|
|
+ //将完成状态设置成 2 , 表示处理失败
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ //保存
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ //todo: 发送失败信息给管理员
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ break;
|
|
|
|
+ case "004":
|
|
|
|
+ //边民合作社备案
|
|
|
|
+ CooperativeDto cooperativeDto = JSONObject.parseObject(body, CooperativeDto.class);
|
|
|
|
+ //保存
|
|
|
|
+ flag = levelOneServerInterface.cooperativeDto(cooperativeDto);
|
|
|
|
+ if(!flag){
|
|
|
|
+ //将完成状态设置成 2 , 表示处理失败
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ //保存
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ //todo: 发送失败信息给管理员
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
|
+ item.setMessageId(dataDto.getMsgId());
|
|
|
|
+ htByteMapper.updateById(item);
|
|
|
|
+ System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
|
+ break;
|
|
|
|
+ case "005":
|
|
|
|
+ //车辆
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case "006":
|
|
|
|
+ //进境申报单
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case "007":
|
|
|
|
+ //进口申报单
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|