فهرست منبع

8.28 根据航通传来的数据判定其事务状态进行处理

Mechrevo 1 سال پیش
والد
کامیت
31afb629a5

+ 20 - 4
sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java

@@ -67,7 +67,7 @@ public class HtByteTask {
             String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
             //控制台输出
             dataDto.setData(body);
-            System.out.println("开始处理数据: " + dataDto);
+//            System.out.println("开始处理数据: " + dataDto);
             //数据处理完成状态
             boolean flag = false;
             // 根据类型匹配对象
@@ -80,14 +80,18 @@ public class HtByteTask {
                     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":
                     //商铺备案
@@ -97,15 +101,19 @@ public class HtByteTask {
                     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());
-                htByteMapper.updateById(item);
-                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);
@@ -114,14 +122,18 @@ public class HtByteTask {
                     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":
                     //边民合作社备案
@@ -131,14 +143,18 @@ public class HtByteTask {
                     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":
                     //车辆

+ 12 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_cooperative/TbCooperativeService.java

@@ -1,5 +1,6 @@
 package com.pj.tb_cooperative;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.dto.CooperativeDto;
@@ -72,7 +73,17 @@ public class TbCooperativeService extends ServiceImpl<TbCooperativeMapper,TbCoop
 		BeanUtils.copyProperties(cooperativeDto,tbCooperative);
 		tbCooperative.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
 		tbCooperative.setCreateTime(new Date());
-		return this.save(tbCooperative);
+		//查询是否有数据
+		List<TbCooperative> tbCooperativeList = tbCooperativeMapper.selectList(new LambdaQueryWrapper<TbCooperative>().eq(TbCooperative::getPlatSeqNo, cooperativeDto.getPlatSeqNo()));
+		if(tbCooperativeList.size() == 0){
+			//新增
+			boolean save = this.save(tbCooperative);
+			return save;
+		}
+		//修改
+		BeanUtils.copyProperties(tbCooperativeList.get(0),tbCooperative);
+		int i = tbCooperativeMapper.updateById(tbCooperative);
+		return i == 1;
 	}
 
 }

+ 14 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -351,14 +351,23 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
 		return "数据导出完成!共导出 " + count + " 条数据。";
 	}
 
-	/** 远程调用方法 注册身份为组长时调用*/
+	/** 远程调用方法 */
 	public boolean groupDto(GroupDto groupDto){
 		TbGroup tbGroup = new TbGroup();
 		BeanUtils.copyProperties(groupDto,tbGroup);
-		tbGroup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-		tbGroup.setCreateTime(new Date());
-		boolean save = this.save(tbGroup);
-		return save;
+		//根据编号进行事务处理
+		List<TbGroup> tbGroupList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(TbGroup::getPlatSeqNo, groupDto.getPlatSeqNo()));
+		if(tbGroupList.size() == 0){
+			//新增
+			tbGroup.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+			tbGroup.setCreateTime(new Date());
+			boolean save = this.save(tbGroup);
+			return save;
+		}
+		//修改
+		BeanUtils.copyProperties(tbGroupList.get(0),tbGroup);
+		int i = tbGroupMapper.updateById(tbGroup);
+		return i == 1;
 	}
 
 	/** 远程调用方法 获取边民组的基本信息*/

+ 7 - 5
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java

@@ -536,14 +536,16 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 		//设置基本信息
 		tbPeople.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
 		tbPeople.setCreateTime(new Date());
-		//todo: 判断其身份证? 无则新增,无有则修改
-		if(tbPeople.getIdCardNo() != null){
+		List<TbPeople> peopleList = tbPeopleMapper.selectList(new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getPlatSeqNo, peopleDto.getPlatSeqNo()));
+		if(peopleList.size() == 0){
+			//新增
 			boolean save = this.save(tbPeople);
 			return save;
-		}else{
-			int update = tbPeopleMapper.update(tbPeople, new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getBorderTel, tbPeople.getBorderTel()));
-			return update == 1;
 		}
+		//修改
+		BeanUtils.copyProperties(peopleList.get(0),tbPeople);
+		int i = tbPeopleMapper.updateById(tbPeople);
+		return i == 1;
 	}
 
 	/** 远程调用查 */

+ 13 - 4
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java

@@ -180,10 +180,19 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 	public boolean shopDto(ShopDto shopDto){
 		TbShop tbShop = new TbShop();
 		BeanUtils.copyProperties(shopDto,tbShop);
-		tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-		tbShop.setCreateTime(new Date());
-		int insert = tbShopMapper.insert(tbShop);
-		return insert == 1;
+		//根据编号进行事务处理
+		List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
+		if(tbShopList.size() == 0){
+			//无则新增
+			tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+			tbShop.setCreateTime(new Date());
+			int insert = tbShopMapper.insert(tbShop);
+			return insert == 1;
+		}
+		//修改
+		BeanUtils.copyProperties(tbShopList.get(0),tbShop);
+		int i = tbShopMapper.updateById(tbShop);
+		return i == 1;
 	}
 
 }