|
|
@@ -14,6 +14,7 @@ import com.mokamrp.privates.help.AjaxResult;
|
|
|
import com.mokamrp.privates.help.Analysis;
|
|
|
import com.mokamrp.privates.interceptor.AuthUser;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobile;
|
|
|
+import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobilePool;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxMobileWxfriend;
|
|
|
import com.mokamrp.privates.mapper.pangu.pojo.FosterwxStation;
|
|
|
import com.mokamrp.privates.mapper.pojo.User;
|
|
|
@@ -26,11 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -57,6 +54,9 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
|
|
|
@Autowired
|
|
|
private FosterwxTaskScheduleService fosterwxTaskScheduleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FosterwxMobilePoolService fosterwxMobilePoolService;
|
|
|
+
|
|
|
/*
|
|
|
* @fast
|
|
|
* 默认生成的控制器所继承的父类中有index/add/edit/del四个基础方法,均为post json请求
|
|
|
@@ -303,7 +303,120 @@ public class FosterwxMobileController extends BaseController<FosterwxMobile> {
|
|
|
} catch (Exception e) {
|
|
|
return AjaxResult.error(e.getMessage());
|
|
|
}
|
|
|
- Boolean res = fosterwxMobileService.importData(row,authUser);
|
|
|
+ Boolean res = fosterwxMobileService.importData(row, authUser);
|
|
|
+ return AjaxResult.success(HttpMsg.importSuccess);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置账号个微二维码
|
|
|
+ * @param editHandle
|
|
|
+ * @param bindingResult
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/setCodeUrl")
|
|
|
+ public Object setCodeUrl(
|
|
|
+ @Valid @RequestBody EditHandle<FosterwxMobile> editHandle, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return AjaxResult.error(HttpStatus.ERROR, bindingResult.getFieldError().getDefaultMessage());
|
|
|
+ }
|
|
|
+ //.登录验证
|
|
|
+ this.onUpdate(editHandle);
|
|
|
+ fosterwxMobileService.update(editHandle.getRaw(),
|
|
|
+ new QueryWrapper<FosterwxMobile>()
|
|
|
+ .eq("mobile_unio_code", editHandle.getRaw().getMobileUnioCode()));
|
|
|
+ return AjaxResult.success(Constants.SUCCESS, true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入个微池
|
|
|
+ * @param fosterwxMobileList
|
|
|
+ * @param authUser
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/loadPool")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Object loadPool(
|
|
|
+ @Valid @RequestBody List<FosterwxMobile> fosterwxMobileList, @AuthUser User authUser) {
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ fosterwxMobileList.forEach(fosterwxMobile -> {
|
|
|
+ LambdaQueryWrapper<FosterwxMobilePool> fosterwxMobilePoolLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fosterwxMobilePoolLambdaQueryWrapper.eq(FosterwxMobilePool::getPoolIndex, fosterwxMobile.getMobileUnioCode());
|
|
|
+
|
|
|
+ if (fosterwxMobilePoolService.getOne(fosterwxMobilePoolLambdaQueryWrapper) != null) {
|
|
|
+ sb.append(fosterwxMobile.getMobileUnioCode() + "已经导入个微池中了,不能重复导入!<br>");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (sb.length() > 0) {
|
|
|
+ return AjaxResult.error(sb.toString());
|
|
|
+ }
|
|
|
+ fosterwxMobileList.forEach(fosterwxMobile -> {
|
|
|
+ FosterwxMobilePool fosterwxMobilePool = new FosterwxMobilePool();
|
|
|
+ fosterwxMobilePool.setPoolIndex(fosterwxMobile.getMobileUnioCode());
|
|
|
+ fosterwxMobilePool.setStationId(fosterwxMobile.getStationId());
|
|
|
+ FosterwxStation fosterwxStation = fosterwxStationService.getById(fosterwxMobile.getStationId());
|
|
|
+ fosterwxMobilePool.setStationName(fosterwxStation.getStationName());
|
|
|
+ fosterwxMobilePool.setMobileCode(fosterwxMobile.getMobileCode());
|
|
|
+ fosterwxMobilePool.setMobileNo(fosterwxMobile.getMobileNo());
|
|
|
+ fosterwxMobilePool.setCodeUrl(fosterwxMobile.getCodeUrl());
|
|
|
+ fosterwxMobilePool.setStatus(1);
|
|
|
+ fosterwxMobilePool.setMaxFans("");
|
|
|
+ fosterwxMobilePool.setBusMobileNo(fosterwxMobile.getMobileNo());
|
|
|
+ fosterwxMobilePool.setFlowPosition("");
|
|
|
+ fosterwxMobilePool.setCreateUid(authUser.getId());
|
|
|
+ fosterwxMobilePool.setUpdateUid(authUser.getId());
|
|
|
+ fosterwxMobilePool.setCreateAt(LocalDateTime.now());
|
|
|
+ fosterwxMobilePool.setUpdateAt(LocalDateTime.now());
|
|
|
+
|
|
|
+ fosterwxMobilePoolService.save(fosterwxMobilePool);
|
|
|
+ });
|
|
|
+
|
|
|
+ return AjaxResult.success("导入成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导入
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/importCode")
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Object uploadFile(@RequestBody MultipartFile file) {
|
|
|
+ Map<Integer, String> field = new HashMap<>(2);
|
|
|
+ field.put(0, "mobileUnioCode");
|
|
|
+ field.put(1, "codeUrl");
|
|
|
+ List<Map<String, String>> row;
|
|
|
+ try {
|
|
|
+ row = Analysis.analysis(file, field);
|
|
|
+ } catch (Exception e) {
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ row.forEach(map -> {
|
|
|
+ LambdaQueryWrapper<FosterwxMobile> fosterwxMobileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fosterwxMobileLambdaQueryWrapper.eq(FosterwxMobile::getMobileCode, map.get("mobileUnioCode"));
|
|
|
+ // 手机唯一编码不存在
|
|
|
+ if (fosterwxMobileService.count(fosterwxMobileLambdaQueryWrapper) == 0)
|
|
|
+ sb.append("手机唯一编码:" + map.get("mobileUnioCode") + "不存在<br>");
|
|
|
+ });
|
|
|
+
|
|
|
+ if (sb.length() > 0) return AjaxResult.error(sb.toString());
|
|
|
+
|
|
|
+ row.forEach(map -> {
|
|
|
+ LambdaQueryWrapper<FosterwxMobile> fosterwxMobileLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fosterwxMobileLambdaQueryWrapper.eq(FosterwxMobile::getMobileCode, map.get("mobileUnioCode"));
|
|
|
+
|
|
|
+ FosterwxMobile updateVO = new FosterwxMobile();
|
|
|
+ updateVO.setCodeUrl(map.get("codeUrl"));
|
|
|
+ updateVO.setUpdateAt(LocalDateTime.now());
|
|
|
+
|
|
|
+ fosterwxMobileService.update(updateVO, fosterwxMobileLambdaQueryWrapper);
|
|
|
+ });
|
|
|
+
|
|
|
return AjaxResult.success(HttpMsg.importSuccess);
|
|
|
}
|
|
|
}
|