|
@@ -7,9 +7,12 @@ import com.pj.api.client.async_server.AsyncServerInterface;
|
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
|
import com.pj.api.dto.*;
|
|
|
+import com.pj.common.core.exception.ServiceException;
|
|
|
import com.pj.dto.DataDto;
|
|
|
import com.pj.enummj.DataType;
|
|
|
import com.pj.enummj.FinishStatus;
|
|
|
+import com.pj.ht_border_buy_goods_list.HtBorderBuyGoodsList;
|
|
|
+import com.pj.ht_border_buy_goods_list.HtBorderBuyGoodsListMapper;
|
|
|
import com.pj.ht_borders_list.HtBordersList;
|
|
|
import com.pj.ht_borders_list.HtBordersListMapper;
|
|
|
import com.pj.ht_byte.HtByte;
|
|
@@ -18,6 +21,8 @@ import com.pj.ht_import_declare_people.HtImportDeclarePeople;
|
|
|
import com.pj.ht_import_declare_people.HtImportDeclarePeopleMapper;
|
|
|
import com.pj.ht_pass_card_record.HtPassCardRecord;
|
|
|
import com.pj.ht_pass_card_record.HtPassCardRecordMapper;
|
|
|
+import com.pj.ht_sell_goods_list.HtSellGoodsList;
|
|
|
+import com.pj.ht_sell_goods_list.HtSellGoodsListMapper;
|
|
|
import com.pj.ht_trade_settlement.HtTradeSettlement;
|
|
|
import com.pj.ht_trade_settlement.HtTradeSettlementMapper;
|
|
|
import com.pj.rabbitmq.RabbitMQ;
|
|
@@ -26,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
@@ -38,6 +44,7 @@ import java.util.List;
|
|
|
**/
|
|
|
@Configuration
|
|
|
@EnableScheduling
|
|
|
+@Transactional(rollbackFor = Exception.class)
|
|
|
public class HtByteTask {
|
|
|
|
|
|
/**
|
|
@@ -51,16 +58,6 @@ public class HtByteTask {
|
|
|
@Autowired
|
|
|
private LevelOneServerInterface levelOneServerInterface;
|
|
|
/**
|
|
|
- * mq测试
|
|
|
- */
|
|
|
- @Autowired
|
|
|
- private AsyncServerInterface asyncServerInterface;
|
|
|
- /**
|
|
|
- * 货运
|
|
|
- */
|
|
|
- @Autowired
|
|
|
- private TransportInterface transportInterface;
|
|
|
- /**
|
|
|
* 交易结算信息
|
|
|
*/
|
|
|
@Autowired
|
|
@@ -81,10 +78,20 @@ public class HtByteTask {
|
|
|
@Autowired
|
|
|
private HtTradeSettlementMapper htTradeSettlementMapper;
|
|
|
/**
|
|
|
- * 边民购买记录
|
|
|
+ * 边民购买记录(主表:ht_trade_settlement)
|
|
|
*/
|
|
|
@Autowired
|
|
|
private HtBordersListMapper htBordersListMapper;
|
|
|
+ /**
|
|
|
+ * 边民购买商品信息表(主表:ht_trade_settlement)
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ private HtBorderBuyGoodsListMapper htBorderBuyGoodsListMapper;
|
|
|
+ /**
|
|
|
+ * 商铺卖货物信息表(主表:ht_trade_settlement)
|
|
|
+ */
|
|
|
+ @Autowired
|
|
|
+ private HtSellGoodsListMapper htSellGoodsListMapper;
|
|
|
|
|
|
/**
|
|
|
* 启动定时任务
|
|
@@ -126,149 +133,146 @@ public class HtByteTask {
|
|
|
PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
|
|
|
//根据其内的身份证,有则新增,无则修改???
|
|
|
flag = levelOneServerInterface.peopleDto(peopleDto);
|
|
|
+ methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
|
|
|
if(!flag){
|
|
|
- //将完成状态设置成 2 , 表示处理失败
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- //保存
|
|
|
- htByteMapper.updateById(item);
|
|
|
System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
- //todo: 发送失败信息给管理员
|
|
|
-
|
|
|
- break;
|
|
|
+ }else {
|
|
|
+ System.out.println("\n边民信息处理成功。 messageId = " + item.getMessageId() + "\n");
|
|
|
}
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- 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);
|
|
|
+ methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
|
|
|
if(!flag){
|
|
|
- //将完成状态设置成 2 , 表示处理失败
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- //保存
|
|
|
- htByteMapper.updateById(item);
|
|
|
System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
- //todo: 发送失败信息给管理员
|
|
|
-
|
|
|
- break;
|
|
|
+ }else {
|
|
|
+ System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
}
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- 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);
|
|
|
+ methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
|
|
|
if(!flag){
|
|
|
- //将完成状态设置成 2 , 表示处理失败
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- //保存
|
|
|
- htByteMapper.updateById(item);
|
|
|
System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
- //todo: 发送失败信息给管理员
|
|
|
-
|
|
|
- break;
|
|
|
+ }else {
|
|
|
+ System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
}
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- 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);
|
|
|
+ methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
|
|
|
if(!flag){
|
|
|
- //将完成状态设置成 2 , 表示处理失败
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- //保存
|
|
|
- htByteMapper.updateById(item);
|
|
|
System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
- //todo: 发送失败信息给管理员
|
|
|
-
|
|
|
- break;
|
|
|
+ }else {
|
|
|
+ System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
}
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- htByteMapper.updateById(item);
|
|
|
- System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
break;
|
|
|
case "005":
|
|
|
//商品基础信息
|
|
|
GoodsDto goodsDto = JSONObject.parseObject(body, GoodsDto.class);
|
|
|
//保存
|
|
|
flag = levelOneServerInterface.goodsDto(goodsDto);
|
|
|
+ methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
|
|
|
if(!flag){
|
|
|
- //将完成状态设置成 2 , 表示处理失败
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- //保存
|
|
|
- htByteMapper.updateById(item);
|
|
|
System.out.println("\n海关监管商品信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
- //todo: 发送失败信息给管理员
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
|
|
|
- item.setMessageId(dataDto.getMsgId());
|
|
|
- item.setDataType(dataDto.getDataType());
|
|
|
- htByteMapper.updateById(item);
|
|
|
+ }else {
|
|
|
System.out.println("\n海关监管商品信息处理完成。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ }
|
|
|
break;
|
|
|
case "006":
|
|
|
//交易结算信息
|
|
|
HtTradeSettlement importDeclarePeople = JSONObject.parseObject(body, HtTradeSettlement.class);
|
|
|
importDeclarePeople.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode()); // 默认待处理
|
|
|
+ importDeclarePeople.setCreateTime(new Date());
|
|
|
//保存
|
|
|
int insert = htTradeSettlementMapper.insert(importDeclarePeople);
|
|
|
if(insert == 1){
|
|
|
+ //购买边民列表
|
|
|
List<HtBordersList> bordersLists = JSON.parseArray(importDeclarePeople.getBordersList(), HtBordersList.class);
|
|
|
- //创建预申报单号
|
|
|
- String platSeqNo = null;
|
|
|
- //保存
|
|
|
+ //边民购买商品列表
|
|
|
+ List<HtBorderBuyGoodsList> buyGoodsList = JSON.parseArray(importDeclarePeople.getBorderBuyGoodsList(), HtBorderBuyGoodsList.class);
|
|
|
+ //商铺卖货物列表
|
|
|
+ List<HtSellGoodsList> htSellGoodsList = JSON.parseArray(importDeclarePeople.getSellGoodsList(), HtSellGoodsList.class);
|
|
|
+ //航通关联主键
|
|
|
+ String platSeqNo = importDeclarePeople.getPlatSeqNo();
|
|
|
+ //保存购买边民
|
|
|
if(bordersLists.size() > 0){
|
|
|
- for(HtBordersList t: bordersLists){
|
|
|
- platSeqNo = t.getPlatSeqNo();
|
|
|
+ bordersLists.forEach(t -> {
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
|
|
|
htBordersListMapper.insert(t);
|
|
|
- }
|
|
|
+ });
|
|
|
/**
|
|
|
* 接收订单推送消息,边民进行交易确认,支付申请,刷脸认证,系统发起进行交易
|
|
|
*/
|
|
|
List<HtBordersList> htBordersLists = htBordersListMapper.selectList(new LambdaQueryWrapper<HtBordersList>().eq(HtBordersList::getPlatSeqNo, platSeqNo));
|
|
|
methodHtByteTask.sendMessageToPeople(htBordersLists);
|
|
|
}
|
|
|
+ //保存边民购买商品
|
|
|
+ if(buyGoodsList.size() > 0){
|
|
|
+ buyGoodsList.forEach(t -> {
|
|
|
+ t.setCreateTime(new Date());
|
|
|
+ t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
|
|
|
+ htBorderBuyGoodsListMapper.insert(t);
|
|
|
+ });
|
|
|
+ // ???
|
|
|
+ }
|
|
|
+ //保存商铺卖货物
|
|
|
+ if(htSellGoodsList.size() > 0){
|
|
|
+ htSellGoodsList.forEach(t -> {
|
|
|
+ t.setCreateTime(new Date());
|
|
|
+ t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
|
|
|
+ htSellGoodsListMapper.insert(t);
|
|
|
+ });
|
|
|
+ // ???
|
|
|
+ }
|
|
|
+ //保存航通监听记录
|
|
|
+ methodHtByteTask.updateHtByteInfo(true,item,dataDto);
|
|
|
+ System.out.println("\n交易结算信息处理成功。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ break;
|
|
|
}
|
|
|
+ //保存航通监听记录
|
|
|
+ methodHtByteTask.updateHtByteInfo(false,item,dataDto);
|
|
|
+ System.out.println("\n交易结算信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
break;
|
|
|
case "007":
|
|
|
//放行记录(过卡记录)
|
|
|
HtPassCardRecord htPassCardRecord = JSONObject.parseObject(body, HtPassCardRecord.class);
|
|
|
htPassCardRecord.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode()); // 默认待处理
|
|
|
+ htPassCardRecord.setCreateTime(new Date());
|
|
|
//保存
|
|
|
- htPassCardRecordMapper.insert(htPassCardRecord);
|
|
|
+ int insert1 = htPassCardRecordMapper.insert(htPassCardRecord);
|
|
|
+ methodHtByteTask.updateHtByteInfo(true,item,dataDto);
|
|
|
+ if(insert1 == 1){
|
|
|
+ System.out.println("\n放行记录(过卡记录)信息处理成功。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ }else {
|
|
|
+ System.out.println("\n放行记录(过卡记录)信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "008":
|
|
|
+ //进口申报单边民确认
|
|
|
+ HtImportDeclarePeople htImportDeclarePeople = JSONObject.parseObject(body, HtImportDeclarePeople.class);
|
|
|
+ htImportDeclarePeople.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
|
|
|
+ htImportDeclarePeople.setCreateTime(new Date());
|
|
|
+ int insert2 = htImportDeclarePeopleMapper.insert(htImportDeclarePeople);
|
|
|
+ methodHtByteTask.updateHtByteInfo(insert2 == 1,item,dataDto);
|
|
|
+ if(insert2 == 1){
|
|
|
+ System.out.println("\n进口申报单边民确认信息处理成功。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ }else {
|
|
|
+ System.out.println("\n进口申报单边民确认信息处理失败。 messageId = " + item.getMessageId() + "\n");
|
|
|
+ }
|
|
|
break;
|
|
|
+ default:
|
|
|
+ throw new ServiceException("类型错误。");
|
|
|
}
|
|
|
});
|
|
|
|