2022-09-30 09:41:48 +08:00
|
|
|
|
package com.rzyc.service;
|
|
|
|
|
|
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import cn.jiguang.common.TimeUnit;
|
2022-09-30 09:41:48 +08:00
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import com.common.utils.DateUtils;
|
2022-09-30 09:41:48 +08:00
|
|
|
|
import com.common.utils.StringUtils;
|
|
|
|
|
|
import com.common.utils.TypeConversion;
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import com.common.utils.model.Code;
|
|
|
|
|
|
import com.common.utils.model.Message;
|
2022-09-30 09:41:48 +08:00
|
|
|
|
import com.common.utils.model.SingleResult;
|
|
|
|
|
|
import com.rzyc.bean.emergency.PlanList;
|
|
|
|
|
|
import com.rzyc.controller.BaseController;
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import com.rzyc.mapper.EntPostTaskMapper;
|
|
|
|
|
|
import com.rzyc.model.EntPostDuty;
|
2022-10-08 17:33:31 +08:00
|
|
|
|
import com.rzyc.model.EntPostList;
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import com.rzyc.model.EntPostTask;
|
|
|
|
|
|
import com.rzyc.model.EntUserCredential;
|
|
|
|
|
|
import com.rzyc.model.dto.EntUserCredentialUpdateDto;
|
2022-09-30 09:41:48 +08:00
|
|
|
|
import com.rzyc.model.ent.EntPost;
|
|
|
|
|
|
import com.rzyc.model.ent.EntUser;
|
|
|
|
|
|
import com.rzyc.model.ent.SysEnterprise;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
2022-10-09 17:33:16 +08:00
|
|
|
|
import java.util.*;
|
2022-09-30 09:41:48 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 企业端pc业务 Service
|
|
|
|
|
|
* @author Xuwanxin
|
|
|
|
|
|
* @date 2022/9/29
|
|
|
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class PcBusinessService extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
public SingleResult<List<EntUser>>entUserTree(String enterpriseId,String postId){
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
SysEnterprise sysEnterprise = sysEnterpriseMapper.selectByPrimaryKey(enterpriseId);
|
|
|
|
|
|
List<EntPost> list = entPostMapper.selectEntUserTree(enterpriseId,postId);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* sql里进行了order by,如果传入postId就是查询非全部的数结构,需要加入一个公司,所以把第一个最大权限设置为company,这样公司才会在树的最上面
|
|
|
|
|
|
* 相反不穿postId就是查询全部,默认会有company打头就不用再修改list的0对象
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (null != postId){
|
|
|
|
|
|
list.get(0).setParentId("company");
|
|
|
|
|
|
}
|
|
|
|
|
|
//加入公司为第一个树结构
|
|
|
|
|
|
EntPost entPost = new EntPost();
|
|
|
|
|
|
entPost.setName(sysEnterprise.getEntname());
|
|
|
|
|
|
entPost.setPostId("company");
|
|
|
|
|
|
list.add(entPost);
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray jsonArray = handleEntUserTree(list);
|
|
|
|
|
|
List<EntPost>posts = JSONArray.parseArray(JSONArray.toJSONString(jsonArray),EntPost.class);
|
|
|
|
|
|
singleResult.setData(posts);
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理企业用户数结构list
|
|
|
|
|
|
*/
|
|
|
|
|
|
private JSONArray handleEntUserTree(List<EntPost> list){
|
|
|
|
|
|
List<Map<String,Object>> data = new ArrayList<>();
|
|
|
|
|
|
for(EntPost entPost : list){
|
|
|
|
|
|
if(StringUtils.isBlank(entPost.getParentId())){
|
|
|
|
|
|
entPost.setParentId("");
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String,Object> entPostMap = new HashMap<String,Object>();
|
|
|
|
|
|
entPostMap.put("postId",entPost.getPostId());
|
|
|
|
|
|
entPostMap.put("name",entPost.getName());
|
|
|
|
|
|
entPostMap.put("parentId",entPost.getParentId());
|
|
|
|
|
|
entPostMap.put("subordinates",entPost.getSubordinates());
|
|
|
|
|
|
data.add(entPostMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
com.alibaba.fastjson.JSONArray result = TypeConversion.listToTree(com.alibaba.fastjson.JSONArray.parseArray(JSON.toJSONString(data)),"postId","parentId","children");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-08 17:33:31 +08:00
|
|
|
|
public SingleResult entUserPostList(String enterpriseId,String entUserId,String postId){
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
List<EntPostList>list = entPostListMapper.selectEntPostList(enterpriseId,entUserId,postId);
|
|
|
|
|
|
singleResult.setData(list);
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-09 17:33:16 +08:00
|
|
|
|
public SingleResult entUserPostTask(String enterpriseId, String entUserId,String postId,String listId,String content,Integer taskState){
|
2022-10-08 17:33:31 +08:00
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
//EntPostTask
|
2022-10-09 17:33:16 +08:00
|
|
|
|
List<EntPostTask>list = entPostTaskMapper.selectEntUserPostTask(enterpriseId,entUserId,postId,listId,content,taskState);
|
|
|
|
|
|
singleResult.setData(list);
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SingleResult entUserPostDuty(String enterpriseId, String postId){
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
//EntPostDuty
|
|
|
|
|
|
List<EntPostDuty>list = entPostDutyMapper.selectEntUserPostDuty(enterpriseId,postId);
|
|
|
|
|
|
singleResult.setData(list);
|
2022-10-08 17:33:31 +08:00
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-09 17:33:16 +08:00
|
|
|
|
public SingleResult entUserCredential(String enterpriseId, String entUserId){
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
List<EntUserCredential>list = entUserCredentialMapper.selectEntUserCredential(enterpriseId,entUserId);
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SingleResult entUserCredentialUpdate(EntUserCredentialUpdateDto entUserCredentialUpdateDto) throws Exception {
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
Integer result = 0;
|
|
|
|
|
|
if (StringUtils.isNotBlank(entUserCredentialUpdateDto.getCredentialId())) {
|
|
|
|
|
|
entUserCredentialUpdateDto.setModifyBy(getUserId());
|
|
|
|
|
|
entUserCredentialUpdateDto.setModifyTime(new Date());
|
|
|
|
|
|
result = entUserCredentialMapper.updateEntUserCredential(entUserCredentialUpdateDto);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
entUserCredentialUpdateDto.setCreateBy(getUserId());
|
|
|
|
|
|
entUserCredentialUpdateDto.setCreateTime(new Date());
|
|
|
|
|
|
result = entUserCredentialMapper.insertEntUserCredential(entUserCredentialUpdateDto);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (result==1){
|
|
|
|
|
|
singleResult.setCode(Code.SUCCESS.getCode());
|
|
|
|
|
|
singleResult.setMessage(Message.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SingleResult entUserCredentialDelete(String credentialId){
|
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
|
int result = entUserCredentialMapper.entUserCredentialDelete(credentialId);
|
|
|
|
|
|
if (result==1){
|
|
|
|
|
|
singleResult.setCode(Code.SUCCESS.getCode());
|
|
|
|
|
|
singleResult.setMessage(Message.SUCCESS);
|
|
|
|
|
|
}
|
|
|
|
|
|
return singleResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-30 09:41:48 +08:00
|
|
|
|
|
|
|
|
|
|
}
|