|
|
@@ -1,7 +1,14 @@
|
|
|
package com.mokamrp.privates.service.pangu.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxWxfriend;
|
|
|
import com.mokamrp.privates.mapper.pangu.FosterwxWxfriendMapper;
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
+import com.mokamrp.privates.service.pangu.FosterwxStationService;
|
|
|
import com.mokamrp.privates.service.pangu.FosterwxWxfriendService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -10,6 +17,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import com.mokamrp.privates.entity.ResHandle;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -25,6 +36,9 @@ public class FosterwxWxfriendServiceImpl extends ServiceImpl<FosterwxWxfriendMap
|
|
|
|
|
|
@Autowired
|
|
|
public FosterwxWxfriendMapper fosterwxWxfriendMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxStationService fosterwxStationService;
|
|
|
/**
|
|
|
* 获取数据列表 支持分页
|
|
|
* @param handle
|
|
|
@@ -40,4 +54,29 @@ public class FosterwxWxfriendServiceImpl extends ServiceImpl<FosterwxWxfriendMap
|
|
|
res.setTotal(pageObj.getTotal());
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ 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("表格读取完成后,没有获取到任何数据");
|
|
|
+ }
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ for (int i = 0; i < row.size(); i++) {
|
|
|
+ FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
|
|
|
+ .eq("station_name", row.get(i).get("stationName")));
|
|
|
+ if (stationInfo == null) {
|
|
|
+ throw new Exception("站点编号不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ FosterwxWxfriend add = new FosterwxWxfriend();
|
|
|
+ add.setStationId(stationInfo.getId());
|
|
|
+ add.setWxName(row.get(i).get("wxName"));
|
|
|
+ add.setWxUsername(row.get(i).get("wxUsername"));
|
|
|
+ add.setCreateAt(LocalDateTime.now());
|
|
|
+ add.setUpdateAt(LocalDateTime.now());
|
|
|
+ this.save(add);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|