|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.ruixuan.common.core.domain.ResultResponse;
|
|
import com.ruixuan.common.core.domain.ResultResponse;
|
|
|
|
+import com.ruixuan.common.core.domain.entity.SysUser;
|
|
import com.ruixuan.common.utils.Check;
|
|
import com.ruixuan.common.utils.Check;
|
|
import com.ruixuan.data.utils.LiveDataExcelUtils;
|
|
import com.ruixuan.data.utils.LiveDataExcelUtils;
|
|
import com.ruixuan.live.entity.KuaishouLiveProject;
|
|
import com.ruixuan.live.entity.KuaishouLiveProject;
|
|
@@ -17,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
@@ -120,19 +123,62 @@ public class KuaishouLiveUserAccountServiceImpl implements IKuaishouLiveUserAcco
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResultResponse insertByExcel(MultipartFile file) {
|
|
public ResultResponse insertByExcel(MultipartFile file) {
|
|
- String fileName = file.getOriginalFilename();
|
|
|
|
|
|
+ List<KuaishouLiveUserAccount> accountList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
List<JSONObject> list = LiveDataExcelUtils.analysisFile(file, fileName);
|
|
List<JSONObject> list = LiveDataExcelUtils.analysisFile(file, fileName);
|
|
for (JSONObject object : list) {
|
|
for (JSONObject object : list) {
|
|
- KuaishouLiveUserAccount k = new KuaishouLiveUserAccount(object);
|
|
|
|
|
|
+ KuaishouLiveUserAccount account = new KuaishouLiveUserAccount(object);
|
|
|
|
+ account.setOperatorLeaderId(getUserIdByName(account.getOperatorLeader()));
|
|
|
|
+ account.setSaleLeaderId(getUserIdByName(account.getSaleLeader()));
|
|
|
|
+ account.setProjectId(getAndInsertProject(account.getKsId(), account.getProjectName()));
|
|
|
|
+ insertAccountPart(account);
|
|
|
|
+ accountList.add(account);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ return ResultResponse.error("导入异常");
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNotNull(accountList)) {
|
|
|
|
+ kuaishouLiveUserAccountMapper.replaceBatch(accountList);
|
|
}
|
|
}
|
|
|
|
+ return ResultResponse.success();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ private void insertAccountPart(KuaishouLiveUserAccount account) {
|
|
|
|
+ String collaborators = account.getCollaboratorList();
|
|
|
|
+ if (Check.isNotNull(collaborators)) {
|
|
|
|
+ List<String> users = Arrays.asList(collaborators.split(";"));
|
|
|
|
+ List<JSONObject> list = new ArrayList<>();
|
|
|
|
+ for (String user : users) {
|
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
|
+ obj.put("ksId", account.getKsId());
|
|
|
|
+ obj.put("ksName", account.getKsName());
|
|
|
|
+ obj.put("accountId", account.getAccountId());
|
|
|
|
+ obj.put("accountName", account.getAccountName());
|
|
|
|
+ obj.put("createrId", account.getCreaterId());
|
|
|
|
+ String idAndName = user.replace("(", "(").replace(")", ")").trim();
|
|
|
|
+ String[] split = idAndName.split("(");
|
|
|
|
+ obj.put("userId", getUserIdByName(split[0]));
|
|
|
|
+ obj.put("nickName", split[0]);
|
|
|
|
+ list.add(obj);
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNotNull(collaborators)) {
|
|
|
|
+ accountPartMapper.replaceBatch(list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 通过人员名字查询人员ID
|
|
|
|
+ private String getUserIdByName(String name) {
|
|
|
|
+ if (Check.isNull(name)) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ SysUser user = sysUserService.selectUserByUserName(name);
|
|
|
|
+ if (Check.isNotNull(user)) {
|
|
|
|
+ return user.getUserId().toString();
|
|
|
|
+ }
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|