|
|
@@ -1,13 +1,16 @@
|
|
|
package com.mokamrp.privates.service.pangu.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBox;
|
|
|
+import com.mokamrp.privates.entity.VoltaHandle;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.*;
|
|
|
import com.mokamrp.privates.mapper.pangu.FosterwxCashOasBoxMapper;
|
|
|
-import com.mokamrp.privates.mapper.pangu.pojo.FosterwxCashOasBoxMobileGroup;
|
|
|
-import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxMobileGroupService;
|
|
|
-import com.mokamrp.privates.service.pangu.FosterwxCashOasBoxService;
|
|
|
+import com.mokamrp.privates.mapper.pojo.Corp;
|
|
|
+import com.mokamrp.privates.mapper.pojo.User;
|
|
|
+import com.mokamrp.privates.service.pangu.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.mokamrp.privates.utils.StringUtils;
|
|
|
+import org.apache.tomcat.jni.Local;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.mokamrp.privates.entity.PostBasePageHandle;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -17,6 +20,8 @@ import com.mokamrp.privates.entity.ResHandle;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -35,8 +40,17 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
|
|
|
public FosterwxCashOasBoxMapper fosterwxCashOasBoxMapper;
|
|
|
|
|
|
@Autowired
|
|
|
+ public FosterwxCashMobileService fosterwxCashMobileService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FosterwxCashMobileGroupService fosterwxCashMobileGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
public FosterwxCashOasBoxMobileGroupService fosterwxCashOasBoxMobileGroupService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ public FosterwxStationService fosterwxStationService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取数据列表 支持分页
|
|
|
*
|
|
|
@@ -119,4 +133,60 @@ public class FosterwxCashOasBoxServiceImpl extends ServiceImpl<FosterwxCashOasBo
|
|
|
int i = random.nextInt(max) % (max - min + 1) + min;
|
|
|
return list.get(i);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入数据
|
|
|
+ *
|
|
|
+ * @param row
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @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++) {
|
|
|
+ LocalDateTime nowDate = LocalDateTime.now();
|
|
|
+ Map<String, String> cell = row.get(i);
|
|
|
+ FosterwxCashOasBox fosterwxCashOasBox = new FosterwxCashOasBox();
|
|
|
+ FosterwxStation stationInfo = fosterwxStationService.getOne(new QueryWrapper<FosterwxStation>()
|
|
|
+ .eq("station_name", row.get(i).get("stationName")));
|
|
|
+ if (stationInfo == null) {
|
|
|
+ throw new Exception("站点编号不存在");
|
|
|
+ }
|
|
|
+ FosterwxCashMobileGroup fosterwxCashMobileGroup = fosterwxCashMobileGroupService.getOne(new QueryWrapper<FosterwxCashMobileGroup>().eq("id",Integer.parseInt(row.get(i).get("mobileGroupId"))));
|
|
|
+ if (fosterwxCashMobileGroup == null){
|
|
|
+ throw new Exception("第"+i+"行:账号分组ID不存在");
|
|
|
+ }
|
|
|
+ fosterwxCashOasBox.setStationId(stationInfo.getId());
|
|
|
+ fosterwxCashOasBox.setGroupId(Integer.parseInt(row.get(i).get("groupId")));
|
|
|
+ fosterwxCashOasBox.setType(Integer.parseInt(row.get(i).get("type")));
|
|
|
+ fosterwxCashOasBox.setBoxType(Integer.parseInt(row.get(i).get("boxType")));
|
|
|
+ fosterwxCashOasBox.setBoxLocation(Integer.parseInt(row.get(i).get("boxLocation")));
|
|
|
+ fosterwxCashOasBox.setGhId(row.get(i).get("ghId"));
|
|
|
+ fosterwxCashOasBox.setName(row.get(i).get("name"));
|
|
|
+ fosterwxCashOasBox.setScope(row.get(i).get("scope"));
|
|
|
+ fosterwxCashOasBox.setRemark(row.get(i).get("remark"));
|
|
|
+ fosterwxCashOasBox.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterwxCashOasBox.setUploadUid(authUser.getId());
|
|
|
+ fosterwxCashOasBox.setUpdateAt(LocalDateTime.now());
|
|
|
+ this.save(fosterwxCashOasBox);
|
|
|
+
|
|
|
+ FosterwxCashOasBoxMobileGroup fosterwxCashOasBoxMobileGroup = fosterwxCashOasBoxMobileGroupService.getOne(new QueryWrapper<FosterwxCashOasBoxMobileGroup>()
|
|
|
+ .eq("oas_box_id",fosterwxCashOasBox.getId())
|
|
|
+ .eq("cash_mobile_group_id",Integer.parseInt(row.get(i).get("mobileGroupId"))));
|
|
|
+ if (fosterwxCashOasBoxMobileGroup != null){
|
|
|
+ throw new Exception("第"+i+"行:账号分组ID与当前公众号ID绑定关系已经存在");
|
|
|
+ }
|
|
|
+ FosterwxCashOasBoxMobileGroup addBoxOasBindMobileGroup = new FosterwxCashOasBoxMobileGroup();
|
|
|
+ addBoxOasBindMobileGroup.setOasBoxId(fosterwxCashOasBox.getId());
|
|
|
+ addBoxOasBindMobileGroup.setCashMobileGroupId(Integer.parseInt(row.get(i).get("mobileGroupId")));
|
|
|
+ addBoxOasBindMobileGroup.setUpdateAt(LocalDateTime.now());
|
|
|
+ addBoxOasBindMobileGroup.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterwxCashOasBoxMobileGroupService.save(addBoxOasBindMobileGroup);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|