|
|
@@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.mokamrp.privates.constant.HttpMsg;
|
|
|
import com.mokamrp.privates.entity.ResHandle;
|
|
|
import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
import com.mokamrp.privates.entity.pangu.GetForsterwxMobileHandle;
|
|
|
+import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.mapper.pangu.FosterwxMobileMapper;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
|
|
|
@@ -29,6 +31,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -103,7 +106,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public VoltaHandle<Boolean> importData(List<Map<String, String>> row, User authUser) throws Exception {
|
|
|
+ public VoltaHandle<Boolean> importData(List<Map<String, String>> row, User authUser) throws Exception {
|
|
|
VoltaHandle<Boolean> res = new VoltaHandle<>();
|
|
|
if (row.size() <= 0) {
|
|
|
throw new Exception("表格读取完成后,没有获取到任何数据");
|
|
|
@@ -160,8 +163,15 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
|
|
|
|
|
|
fosterwxMobile.setMobileUnioCode(stationInfo.getStationName() + fosterwxMobile.getMobileCode());
|
|
|
this.save(fosterwxMobile);
|
|
|
+ //.查询当前站点下所有账号的微信好友
|
|
|
+ List<FosterwxMobile> mobileList = fosterwxMobileService.list(new QueryWrapper<FosterwxMobile>().eq("station_id",fosterwxMobile.getStationId()));
|
|
|
+ List<Integer> mobileIds = mobileList.stream().map(FosterwxMobile::getId).collect(Collectors.toList());
|
|
|
+ List<FosterwxMobileWxfriend> friends = fosterwxMobileWxfriendService.list(new QueryWrapper<FosterwxMobileWxfriend>()
|
|
|
+ .in("mobile_id",mobileIds)
|
|
|
+ );
|
|
|
//.批量录入微信好友
|
|
|
List<FosterwxMobileWxfriend> addFriend = new ArrayList<>();
|
|
|
+ Map<String,Boolean> friendsNames = new HashMap<>();
|
|
|
for (Integer s = 1; s <= 3; s++) {
|
|
|
String sStr = s.toString();
|
|
|
String wxFriendName = row.get(i).get("wxFriendName" + sStr);
|
|
|
@@ -169,6 +179,14 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
|
|
|
if (wxFriendName == null || wxFriendName.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if(friendsNames.get(wxFriendName) == null){
|
|
|
+ throw new Exception("第" + (i + 1) + "行," +wxFriendName+ "微信好友名称录入重复");
|
|
|
+ }
|
|
|
+ friendsNames.put(wxFriendName,true);
|
|
|
+ Boolean findRes = this.checkWxFriendCnt(friends,wxFriendName);
|
|
|
+ if (!findRes){
|
|
|
+ throw new Exception("第" + (i + 1) + "行," +wxFriendName+ "微信好友名称在当前站点内已经使用超过三次,无法再次录入");
|
|
|
+ }
|
|
|
FosterwxMobileWxfriend fosterwxMobileWxfriend = new FosterwxMobileWxfriend();
|
|
|
fosterwxMobileWxfriend.setMobileId(fosterwxMobile.getId());
|
|
|
fosterwxMobileWxfriend.setCreateAt(nowDate);
|
|
|
@@ -180,6 +198,7 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
|
|
|
}
|
|
|
addFriend.add(fosterwxMobileWxfriend);
|
|
|
}
|
|
|
+
|
|
|
if (addFriend.size() > 0) {
|
|
|
fosterwxMobileWxfriendService.remove(new QueryWrapper<FosterwxMobileWxfriend>().eq("mobile_id", fosterwxMobile.getId()));
|
|
|
fosterwxMobileWxfriendService.saveBatch(addFriend);
|
|
|
@@ -191,9 +210,23 @@ public class FosterwxMobileServiceImpl extends ServiceImpl<FosterwxMobileMapper,
|
|
|
setWxAppid(corp.getWxCorpid());
|
|
|
}}, new LambdaQueryWrapper<FosterwxMobilePool>().eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode()));
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
// this.saveBatch(add);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ private Boolean checkWxFriendCnt(List<FosterwxMobileWxfriend> row,String wxName){
|
|
|
+ Integer findCnt = 0;
|
|
|
+ for (FosterwxMobileWxfriend fosterwxMobileWxfriend : row){
|
|
|
+ if (fosterwxMobileWxfriend.getWxName().equals(wxName)){
|
|
|
+ findCnt++;
|
|
|
+ }
|
|
|
+ if (findCnt >= 3){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|