|
@@ -1,13 +1,15 @@
|
|
|
package cn.cslg.pas.service;
|
|
|
|
|
|
-import cn.cslg.pas.common.core.base.EStatus;
|
|
|
import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
import cn.cslg.pas.common.model.vo.ClientVO;
|
|
|
+import cn.cslg.pas.common.model.vo.ProjectVO;
|
|
|
import cn.cslg.pas.common.utils.*;
|
|
|
import cn.cslg.pas.common.utils.SecurityUtils.LoginUtils;
|
|
|
import cn.cslg.pas.domain.Client;
|
|
|
import cn.cslg.pas.mapper.ClientMapper;
|
|
|
-import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -17,7 +19,10 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -32,15 +37,39 @@ import java.util.List;
|
|
|
public class ClientService extends ServiceImpl<ClientMapper, Client> {
|
|
|
private final LoginUtils loginUtils;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
+ private final ApiUtils apiUtils;
|
|
|
+
|
|
|
public IPage<Client> getPageList(ClientVO params) {
|
|
|
LambdaQueryWrapper<Client> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
if (StringUtils.isNotEmpty(params.getName())) {
|
|
|
queryWrapper.like(Client::getName, params.getName());
|
|
|
}
|
|
|
queryWrapper.orderByDesc(Client::getCreateTime);
|
|
|
- IPage<Client> pageList = this.page(new Page<>(params.getCurrent(), params.getSize()), queryWrapper);
|
|
|
|
|
|
- return pageList;
|
|
|
+ IPage<Client> lst = this.page(new Page<>(params.getCurrent(), params.getSize()), queryWrapper);
|
|
|
+ List<Client> list = this.page(new Page<>(params.getCurrent(), params.getSize()), queryWrapper).getRecords();
|
|
|
+ //获取专题库负责人对应信息
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ try {
|
|
|
+ map1.put("personnelId", list.stream().map(Client::getPersonnelId).collect(Collectors.toList()));
|
|
|
+ String jsonObject1 = apiUtils.invokeApi(new JSONObject(map1), "/permission/api/system/getPersonnelById", "post", "data");
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonObject1);
|
|
|
+ List<ProjectVO.Personnel> personnelList = jsonArray.toJavaList(ProjectVO.Personnel.class);
|
|
|
+ for (Client client : list) {
|
|
|
+ for (ProjectVO.Personnel personnel : personnelList) {
|
|
|
+ if (client.getPersonnelId() != null) {
|
|
|
+ if (client.getPersonnelId().equals(personnel.getId())) {
|
|
|
+ client.setPersonnelName(personnel.getPersonnelName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ lst.setRecords(list);
|
|
|
+
|
|
|
+ return lst;
|
|
|
}
|
|
|
|
|
|
public Client getClientByName(String name) {
|
|
@@ -85,7 +114,6 @@ public class ClientService extends ServiceImpl<ClientMapper, Client> {
|
|
|
client.setCreateBy(personnelVO.getId());
|
|
|
client.setCreateTime(DateUtils.getDateTime());
|
|
|
client.setStatus(1);
|
|
|
- client.setCreateName(personnelVO.getName());
|
|
|
client.insert();
|
|
|
return Response.success(client.getId());
|
|
|
}
|