3043 lines
113 KiB
Java
3043 lines
113 KiB
Java
package com.rzyc.controller;
|
||
|
||
import com.alibaba.fastjson.JSON;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.common.utils.*;
|
||
import com.common.utils.encryption.PasswdFactory;
|
||
import com.common.utils.excel.ExcelUtils;
|
||
import com.common.utils.jwt.JwtUtil;
|
||
import com.common.utils.model.*;
|
||
import com.github.pagehelper.Page;
|
||
import com.github.pagehelper.PageHelper;
|
||
import com.rzyc.advice.LoginAuth;
|
||
import com.rzyc.bean.PageDto;
|
||
import com.rzyc.bean.UserDepart;
|
||
import com.rzyc.bean.check.CheckList;
|
||
import com.rzyc.bean.check.CheckPerform;
|
||
import com.rzyc.bean.ent.CompaniesDto;
|
||
import com.rzyc.bean.index.AreaDangerNum;
|
||
import com.rzyc.bean.index.IndexDangerNum;
|
||
import com.rzyc.bean.index.IndexOrgInfo;
|
||
import com.rzyc.bean.index.StayFactor;
|
||
import com.rzyc.bean.index.dto.IndexEntPageDto;
|
||
import com.rzyc.bean.user.*;
|
||
import com.rzyc.bean.user.dutyTree.DutyTrees;
|
||
import com.rzyc.bean.user.task.TaskDetailDto;
|
||
import com.rzyc.bean.user.task.TaskPageDto;
|
||
import com.rzyc.bean.user.dto.*;
|
||
import com.rzyc.config.MethodAnnotation;
|
||
import com.rzyc.enums.*;
|
||
import com.rzyc.model.*;
|
||
import com.rzyc.model.ent.SysEnterprise;
|
||
import com.rzyc.model.log.SysLogs;
|
||
import com.rzyc.model.oth.OtheWareHouse;
|
||
import com.rzyc.model.personal.SysResource;
|
||
import com.rzyc.model.user.*;
|
||
import io.swagger.annotations.*;
|
||
import org.apache.catalina.User;
|
||
import org.apache.commons.beanutils.BeanUtils;
|
||
import org.apache.commons.beanutils.ConvertUtils;
|
||
import org.apache.commons.beanutils.converters.DateConverter;
|
||
import org.springframework.security.access.prepost.PreAuthorize;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import javax.validation.Valid;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* PC个人中心
|
||
*/
|
||
@Api(tags = "PC个人中心")
|
||
@CrossOrigin("*")
|
||
@RequestMapping("pcPersonal")
|
||
@Controller
|
||
@Validated
|
||
public class PcPersonalController extends com.rzyc.controller.BaseController {
|
||
|
||
|
||
/**
|
||
* PC登录
|
||
* @param loginDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "PC政府用户登录", notes = "PC政府用户登录")
|
||
@PostMapping(value = "/pclogin")
|
||
/*@PreAuthorize("hasAnyAuthority('pclogin','pclogin:update')")
|
||
@MethodAnnotation(authorizations = {"pclogin","pclogin:update"},name = "PC政府用户登录")*/
|
||
@ResponseBody
|
||
public SingleResult<SysUser> pclogin(@Valid LoginDto loginDto)throws Exception{
|
||
SingleResult<SysUser> result = new SingleResult<>();
|
||
System.out.println("loginDto -> "+JSONArray.toJSONString(loginDto));
|
||
String sysusername = loginDto.getSysusername();
|
||
String syspassword = loginDto.getSyspassword();
|
||
|
||
//获取验证码
|
||
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
||
//验证码只能使用一次
|
||
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
||
|
||
if(loginDto.getGenerateCode().equals(generateCode)){
|
||
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
||
|
||
//登录的是政府用户
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户")){
|
||
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
||
System.out.println("========" + ps);
|
||
if(sysUser.getSyspassword().equals(ps)){
|
||
sysUser.setSyspassword("");
|
||
|
||
//获取职务
|
||
sysUser = getUserDuty(sysUser);
|
||
|
||
//通过角色判断是否为安办 或者 部门管理员
|
||
if(StringUtils.isNotBlank(sysUser.getUserroles())){
|
||
Integer userRole = this.getUserRole(sysUser.getUserroles());
|
||
sysUser.setUserRole(userRole);
|
||
}
|
||
|
||
//获取用户令牌
|
||
String userToken = JwtUtil.createToken(sysUser.getSysuserid());
|
||
sysUser.setUserToken(userToken);
|
||
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","成功","");
|
||
result.setData(sysUser);
|
||
|
||
}else{
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","失败","");
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.CODE_ERROT.getCode());
|
||
result.setMessage(Message.CODE_ERROT);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* @Description: PC管理员登录
|
||
* @Author ZQW
|
||
* @CreateTime 2022/10/12 14:08
|
||
*/
|
||
@ApiOperation(value = "PC管理员登录", notes = "PC管理员登录")
|
||
@PostMapping(value = "/pcManageLogin")
|
||
/*@PreAuthorize("hasAnyAuthority('pcManageLogin','pcManageLogin:update')")
|
||
@MethodAnnotation(authorizations = {"pcManageLogin","pcManageLogin:update"},name = "PC管理员登录")*/
|
||
@ResponseBody
|
||
public SingleResult<SysUser> pcManageLogin(@Valid LoginDto loginDto)throws Exception{
|
||
SingleResult<SysUser> result = new SingleResult<>();
|
||
System.out.println("loginDto -> "+JSONArray.toJSONString(loginDto));
|
||
String sysusername = loginDto.getSysusername();
|
||
String syspassword = loginDto.getSyspassword();
|
||
|
||
//获取验证码
|
||
String generateCode = request.getSession().getAttribute(constantsConfigure.getGenerateCodeKey())+"";
|
||
|
||
//验证码只能使用一次
|
||
request.getSession().removeAttribute(constantsConfigure.getGenerateCodeKey());
|
||
|
||
if(loginDto.getGenerateCode().equals(generateCode)){
|
||
SysUser sysUser = sysUserMapper.findBySysUserName(sysusername);
|
||
|
||
//登录的是管理员
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getUsertype()) && sysUser.getUsertype().equals("政府用户") & sysUser.getManageState() == IsManage.MANAGE.getState()){
|
||
String ps = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysusername, syspassword);
|
||
System.out.println("========" + ps);
|
||
if(sysUser.getSyspassword().equals(ps)){
|
||
sysUser.setSyspassword("");
|
||
|
||
//获取职务
|
||
sysUser = getUserDuty(sysUser);
|
||
|
||
//通过角色判断是否为安办 或者 部门管理员
|
||
if(StringUtils.isNotBlank(sysUser.getUserroles())){
|
||
Integer userRole = this.getUserRole(sysUser.getUserroles());
|
||
sysUser.setUserRole(userRole);
|
||
}
|
||
|
||
//获取用户令牌
|
||
String userToken = JwtUtil.createToken(sysUser.getSysuserid());
|
||
sysUser.setUserToken(userToken);
|
||
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","成功","");
|
||
result.setData(sysUser);
|
||
|
||
}else{
|
||
this.addLogAuth(sysUser.getSysuserid(),"登录","失败","");
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.CODE_ERROT.getCode());
|
||
result.setMessage(Message.CODE_ERROT);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 用户功能项
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "用户功能项", notes = "用户功能项")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "manageState",value = "是否为管理员 1.管理员 2.普通用户 不传默认普通用户")
|
||
})
|
||
@PostMapping(value = "/userResource/{userId}")
|
||
@ResponseBody
|
||
public MultiResult<SysResource> userResource(@Valid @PathVariable String userId,
|
||
Integer manageState)throws Exception{
|
||
MultiResult<SysResource> result = new MultiResult<>();
|
||
System.out.println("userId -> "+userId);
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
System.out.println(sysUser.getUserroles());
|
||
String roleId = sysUser.getUserroles();
|
||
if(ManageState.YES.getState().equals(manageState)){
|
||
SysRole sysRole = sysRoleMapper.adminRole(ManageState.YES.getState());
|
||
if(null != sysRole){
|
||
roleId = sysRole.getSysroleid();
|
||
}
|
||
}
|
||
List<SysResource> resources = resources = sysResourceMapper.findByRoleId(roleId);
|
||
if(resources.size() > 0){
|
||
//获取树形结构
|
||
JSONArray resourcesTree = handleResouceTree(resources);
|
||
List<SysResource> sysResources = JSONArray.parseArray(JSONArray.toJSONString(resourcesTree),SysResource.class);
|
||
result.setData(sysResources);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 功能项树形结构
|
||
* @param resources
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private JSONArray handleResouceTree(List<SysResource> resources)throws Exception{
|
||
List<Map<String,Object>> data = new ArrayList<>();
|
||
for(SysResource resource : resources){
|
||
Map<String,String> metaMap = JSONArray.parseObject(resource.getMeta(),HashMap.class);
|
||
if(StringUtils.isBlank(resource.getParentId())){
|
||
resource.setParentId("");
|
||
}
|
||
Map<String,Object> entUserMap = new HashMap<String,Object>();
|
||
entUserMap.put("resourceId",resource.getResourceId());
|
||
entUserMap.put("name",resource.getName());
|
||
entUserMap.put("path",resource.getPath());
|
||
entUserMap.put("component",resource.getComponent());
|
||
entUserMap.put("metas",metaMap);
|
||
entUserMap.put("parentId",resource.getParentId());
|
||
entUserMap.put("redirect",resource.getRedirect());
|
||
entUserMap.put("hidden",resource.getHidden());
|
||
entUserMap.put("check",resource.getCheck());
|
||
data.add(entUserMap);
|
||
}
|
||
JSONArray result = TypeConversion.listToTree(JSONArray.parseArray(JSON.toJSONString(data)),"resourceId","parentId","children");
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 用户信息
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "用户信息", notes = "用户信息")
|
||
@PostMapping(value = "/userInfo/{userId}")
|
||
@ResponseBody
|
||
public SingleResult<SysUser> userInfo(@Valid @PathVariable String userId)throws Exception{
|
||
SingleResult<SysUser> result = new SingleResult<>();
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
|
||
//获取职务
|
||
sysUser = getUserDuty(sysUser);
|
||
|
||
//用户权限
|
||
userAuth(sysUser);
|
||
|
||
//数量信息
|
||
IndexNum indexNum = indexNum(sysUser.getSystitle(),sysUser.getSysuserid());
|
||
sysUser.setIndexNum(indexNum);
|
||
|
||
result.setData(sysUser);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 代办事项 履职异常 消息通知 数量
|
||
*/
|
||
private IndexNum indexNum(String listPerformId, String sysUserId)throws Exception{
|
||
IndexNum indexNum = new IndexNum();
|
||
Integer stayNum = 0;
|
||
Integer warnNum = 0;
|
||
Integer messageNum = 0;
|
||
|
||
//代办任务数量
|
||
Integer year = Calendar.getInstance().get(Calendar.YEAR);
|
||
Integer month = Calendar.getInstance().get(Calendar.MONTH) + 1;
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
String startTime = year + "-" + month + "-" + day + " 23:59:59";
|
||
List<OATask> oaTasks = new ArrayList<>();
|
||
List<OATask> tasks = oaTaskMapper.findByListPerformId(listPerformId,year+"",startTime, TaskCompleteState.STAYCOMPLETE.getCompleteState());
|
||
if(tasks.size() > 0){
|
||
oaTasks = stayTask(tasks);
|
||
}
|
||
stayNum = oaTasks.size();
|
||
System.out.println("stayNum -> "+stayNum);
|
||
|
||
|
||
//智能预警数量
|
||
System.out.println("warnNum -> "+warnNum);
|
||
|
||
indexNum.setStayNum(stayNum);
|
||
indexNum.setWarnNum(warnNum);
|
||
indexNum.setMessageNum(messageNum);
|
||
return indexNum;
|
||
}
|
||
|
||
/**
|
||
* 待办事项
|
||
* @param stayMatterDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "待办事项", notes = "待办事项")
|
||
@PostMapping(value = "/stayMatter")
|
||
@ResponseBody
|
||
public MultiResult<OATask> stayMatter(@Valid StayMatterDto stayMatterDto)throws Exception{
|
||
MultiResult<OATask> result = new MultiResult<>();
|
||
System.out.println("stayMatterDto -> "+JSONArray.toJSONString(stayMatterDto));
|
||
SysUser sysUser = sysUserMapper.findById(stayMatterDto.getUserId());
|
||
if(null != sysUser){
|
||
Integer year = Calendar.getInstance().get(Calendar.YEAR);
|
||
Integer month = Calendar.getInstance().get(Calendar.MONTH) + 1;
|
||
Integer day = DateUtils.getMonthLastDay(year,month);
|
||
String startTime = year + "-" + month + "-" + day + " 23:59:59";
|
||
|
||
//任务完成状态
|
||
String completeState = "";
|
||
if(null != stayMatterDto.getCompleteState()){
|
||
completeState = taskCompleteStateMap.get(stayMatterDto.getCompleteState());
|
||
}else{
|
||
stayMatterDto.setCompleteState(TaskCompleteState.STAYCOMPLETE.getState());
|
||
completeState = TaskCompleteState.STAYCOMPLETE.getCompleteState();
|
||
}
|
||
|
||
//查询任务
|
||
List<OATask> tasks = oaTaskMapper.findByListPerformId(sysUser.getSystitle(),year+"",startTime,completeState);
|
||
if(tasks.size() > 0){
|
||
|
||
//如果选择未完成任务 处理一下
|
||
if(TaskCompleteState.STAYCOMPLETE.getState() == stayMatterDto.getCompleteState()){
|
||
// tasks = stayTask(tasks);
|
||
}
|
||
|
||
//处理结束时间
|
||
for (OATask oaTask : tasks){
|
||
handleEndDate(oaTask);
|
||
}
|
||
result.setData(tasks);
|
||
|
||
}else{
|
||
result.setData(tasks);
|
||
}
|
||
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 安全生产职责
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "安全生产职责", notes = "安全生产职责")
|
||
@PostMapping(value = "/dutyList/{userId}")
|
||
@ResponseBody
|
||
public MultiResult<ListSafeWithBLOBs> dutyList(@Valid @PathVariable String userId)throws Exception{
|
||
MultiResult<ListSafeWithBLOBs> result = new MultiResult<>();
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getSystitle())){
|
||
List<ListSafeWithBLOBs> listSafes = listSafeMapper.userListSafe(sysUser.getSystitle());
|
||
if(null != listSafes && listSafes.size() > 0){
|
||
result.setData(listSafes);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职清单
|
||
* @param factorListDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职清单", notes = "履职清单")
|
||
@PostMapping(value = "/factorList")
|
||
@ResponseBody
|
||
public MultiResult<ListFactor> factorList(@Valid FactorListDto factorListDto)throws Exception{
|
||
MultiResult<ListFactor> result = new MultiResult<>();
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(factorListDto.getUserId());
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getSystitle())){
|
||
String time = factorListDto.getYear();
|
||
if(StringUtils.isBlank(time)){
|
||
time = DateUtils.getNowDateTimeStr("yyyy");
|
||
}
|
||
List<ListFactor> listFactors = listFactorMapper.userListFactor(sysUser.getSystitle(),time);
|
||
if(null != listFactors && listFactors.size() > 0){
|
||
//处理履职清单
|
||
handleFactorAlert(listFactors);
|
||
result.setData(listFactors);
|
||
}else{
|
||
result.setData(listFactors);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职清单(一个)
|
||
* @param factorListDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职清单(一个)", notes = "履职清单(一个)")
|
||
@PostMapping(value = "/factorListById")
|
||
@ResponseBody
|
||
public SingleResult<ListFactor> factorListById(@Valid FactorListDto factorListDto)throws Exception{
|
||
SingleResult<ListFactor> result = new SingleResult<>();
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(factorListDto.getUserId());
|
||
if(null != sysUser && StringUtils.isNotBlank(sysUser.getSystitle())){
|
||
String time = factorListDto.getYear();
|
||
if(StringUtils.isBlank(time)){
|
||
time = DateUtils.getNowDateTimeStr("yyyy");
|
||
}
|
||
ListFactor listFactor = listFactorMapper.userListFactorById(sysUser.getSystitle(),time);
|
||
if(null != listFactor){
|
||
//处理履职清单
|
||
handleFactorAlert(listFactor);
|
||
result.setData(listFactor);
|
||
}else{
|
||
result.setData(listFactor);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* 履职进度
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "履职进度", notes = "履职进度")
|
||
@PostMapping(value = "/factorProgress")
|
||
@ResponseBody
|
||
public SingleResult<UserDepart> factorProgress(@Valid FactorProgressDto factorProgressDto)throws Exception{
|
||
SingleResult<UserDepart> result = new SingleResult<>();
|
||
SysUser sysUser = sysUserMapper.findById(factorProgressDto.getUserId());
|
||
if(null != sysUser){
|
||
|
||
//更新履职进度
|
||
// getFactor(sysUser.getSystitle());
|
||
|
||
|
||
UserDepart userDepart = listPerformMapper.userPerform(sysUser.getSysuserid());
|
||
if(null != userDepart){
|
||
|
||
//当前年份
|
||
String nowYear = DateUtils.getNowDateTimeStr("yyyy");
|
||
String year = factorProgressDto.getYear();
|
||
if(StringUtils.isBlank(year)){
|
||
year = DateUtils.getNowDateTimeStr("yyyy");
|
||
}
|
||
|
||
//如果是当前年的进度 直接查询
|
||
if(nowYear.equals(year)){
|
||
if(StringUtils.isNotBlank(userDepart.getCompletion())){
|
||
userDepart.setCompletion(TypeConversion.StringToDouble(userDepart.getCompletion()).intValue()+"");
|
||
}else{
|
||
userDepart.setCompletion("0.0");
|
||
}
|
||
}else{
|
||
|
||
List<String> performIds = new ArrayList<>();
|
||
performIds.add(sysUser.getSystitle());
|
||
|
||
//岗位进度
|
||
Map<String, PerformProgress> progressMap = getPerformProgress(performIds,year);
|
||
|
||
|
||
PerformProgress performProgress = progressMap.get(userDepart.getListPerformId());
|
||
if(null != performProgress){
|
||
//获取岗位进度
|
||
Integer completion = performProgress.getAllprogress();
|
||
if(null == completion){
|
||
completion = 0;
|
||
}
|
||
userDepart.setCompletion(completion+"");
|
||
|
||
//需完成总数
|
||
userDepart.setTotal(performProgress.getTotal());
|
||
//已完成总数
|
||
userDepart.setFinishTotal(performProgress.getFinishTotal());
|
||
}else{
|
||
|
||
userDepart.setCompletion(0+"");
|
||
//需完成总数
|
||
userDepart.setTotal(0);
|
||
//已完成总数
|
||
userDepart.setFinishTotal(0);
|
||
}
|
||
|
||
|
||
}
|
||
}else{
|
||
userDepart.setCompletion("0.0");
|
||
}
|
||
|
||
System.out.println("userDepart -> "+userDepart);
|
||
result.setData(userDepart);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 下属履职情况
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "下属履职情况", notes = "下属履职情况")
|
||
@PostMapping(value = "/subordinatePerform")
|
||
@ResponseBody
|
||
public SingleResult<Pager<UserDepart>> subordinatePerform (@Valid SubordinatePerformDto subordinatePerformDto)throws Exception{
|
||
SingleResult<Pager<UserDepart>> result = new SingleResult<>();
|
||
|
||
String condition = TypeConversion.getCondition(subordinatePerformDto.getCondition());
|
||
//处理年份
|
||
String year = subordinatePerformDto.getYear();
|
||
if(StringUtils.isBlank(year)){
|
||
year = DateUtils.getNowDateTimeStr("yyyy");
|
||
}
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(subordinatePerformDto.getUserId());
|
||
if(null != sysUser){
|
||
String listPerformId = sysUser.getSystitle();
|
||
listPerformId = TypeConversion.getCondition(listPerformId);
|
||
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(sysUser.getSystitle());
|
||
if(null != listPerform && StringUtils.isNotBlank(listPerform.getViewJurisdiction())){
|
||
|
||
String[] strs = listPerform.getViewJurisdiction().split(",");
|
||
//可查看的下级职务
|
||
List<String> performIds = new ArrayList<>();
|
||
for (String str : strs){
|
||
if(!str.equals(listPerformId)){
|
||
performIds.add(str);
|
||
}
|
||
}
|
||
|
||
//分页
|
||
PageHelper.startPage(subordinatePerformDto.getPage(), subordinatePerformDto.getPageSize());
|
||
Page<UserDepart> page = (Page<UserDepart>)listPerformMapper.subordinatePerforms(performIds,condition);
|
||
Pager<UserDepart> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
List<UserDepart> userDeparts = userDeparts = pager.getRows();
|
||
if(userDeparts.size() > 0){
|
||
handerPerform(userDeparts,year,performIds);
|
||
pager.setRows(userDeparts);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 待办事项详情
|
||
* @param taskId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "待办事项详情", notes = "待办事项详情")
|
||
@PostMapping(value = "matterDetail/{taskId}")
|
||
@ResponseBody
|
||
public SingleResult<OATask> matterDetail(@Valid @PathVariable String taskId)throws Exception{
|
||
SingleResult<OATask> result = new SingleResult<>();
|
||
System.out.println("taskId -> "+taskId);
|
||
OATask oaTask = oaTaskMapper.findById(taskId);
|
||
if(null != oaTask){
|
||
|
||
//结束时间
|
||
handleEndDate(oaTask);
|
||
result.setData(oaTask);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 清单履职记录
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "清单履职记录", notes = "清单履职记录")
|
||
@PostMapping(value = "performRecord/{listFactorId}")
|
||
@ResponseBody
|
||
public MultiResult<ListDetailWithBLOBs> performRecord(@Valid @PathVariable String listFactorId)throws Exception{
|
||
MultiResult<ListDetailWithBLOBs> result = new MultiResult<>();
|
||
List<ListDetailWithBLOBs> listDetails = listDetailMapper.factorDetail(listFactorId,"");
|
||
if(listDetails.size() > 0){
|
||
for(ListDetailWithBLOBs listDetailWithBLOBs :listDetails ){
|
||
listDetailWithBLOBs.setWorktitle(listDetailWithBLOBs.getWorkcnt());
|
||
}
|
||
result.setData(listDetails);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职记录详情
|
||
* @param listDetailId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职记录详情", notes = "履职记录详情")
|
||
@PostMapping(value = "listDetail/{listDetailId}")
|
||
@ResponseBody
|
||
public SingleResult<ListDetail> listDetail(@Valid @PathVariable String listDetailId)throws Exception{
|
||
SingleResult<ListDetail> result = new SingleResult<>();
|
||
ListDetail listDetail = listDetailMapper.findById(listDetailId);
|
||
if(null != listDetail){
|
||
|
||
//清单内容
|
||
ListFactor listFactor = listFactorMapper.selectByPrimaryKey(listDetail.getListfactorid());
|
||
if(null != listFactor){
|
||
listDetail.setFactorCnt(listFactor.getFactorcnt());
|
||
}
|
||
|
||
//履职清单
|
||
List<ListFactor> factors = listFactorMapper.detailFactors(listDetail.getListdetailid());
|
||
if(null != factors && factors.size() > 0){
|
||
listDetail.setFactors(factors);
|
||
}
|
||
|
||
//履职任务
|
||
List<OATask> tasks = oaTaskMapper.detailTasks(listDetail.getListdetailid());
|
||
if(null != tasks && tasks.size() > 0){
|
||
listDetail.setTasks(tasks);
|
||
}
|
||
|
||
result.setData(listDetail);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 岗位列表
|
||
* @param listperformid
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "岗位列表", notes = "岗位列表")
|
||
@ApiImplicitParam(name = "listperformid",value = "岗位id,传返回二级岗位 不传返回一级岗位")
|
||
@PostMapping(value = "performList")
|
||
@ResponseBody
|
||
public MultiResult<ListPerform> performList(String listperformid)throws Exception{
|
||
MultiResult<ListPerform> result = new MultiResult<>();
|
||
System.out.println("listperformid -> "+listperformid);
|
||
List<ListPerform> listPerforms = listPerformMapper.findBySupClassId(listperformid);
|
||
if(listPerforms.size() > 0){
|
||
result.setData(listPerforms);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 部门列表
|
||
* @param unitId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "部门列表", notes = "部门列表")
|
||
@ApiImplicitParam(name = "unitId",value = "部门id,传返回二级部门 不传返回一级部门")
|
||
@PostMapping(value = "unitList")
|
||
@ResponseBody
|
||
public MultiResult<SysUnit> unitList(String unitId)throws Exception{
|
||
MultiResult<SysUnit> result = new MultiResult<>();
|
||
List<SysUnit> units = sysUnitMapper.findByParentId(unitId);
|
||
if(units.size() > 0){
|
||
result.setData(units);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 政府用户分页
|
||
* @param userPageDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "政府用户分页", notes = "政府用户分页")
|
||
@PostMapping(value = "userPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysUser>> userPage(@Valid UserPageDto userPageDto)throws Exception{
|
||
SingleResult<Pager<SysUser>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(userPageDto.getCondition());
|
||
String userId = getUserId();
|
||
|
||
userPageDto.setPerformId(userPageDto.getUnitId());
|
||
|
||
//部门id
|
||
String unitId = getUnitId(userId);
|
||
|
||
String areaCode = getUserArea(userId);
|
||
|
||
//分页
|
||
PageHelper.startPage(userPageDto.getPage(), userPageDto.getPageSize());
|
||
Page<SysUser> page = (Page<SysUser>)sysUserMapper.govUserList(condition,unitId,userPageDto.getPerformId(),areaCode,userPageDto.getState());
|
||
|
||
/*
|
||
//判断是属地还是部门
|
||
if(unitEnumType.equals(unitType)){
|
||
page = (Page<SysUser>)sysUserMapper.govUserList(condition,userPageDto.getUnitId(),userPageDto.getPerformId(),areaCode,userPageDto.getState());
|
||
}else{
|
||
page = (Page<SysUser>)sysUserMapper.unitUserList(condition,unitId,userPageDto.getState());
|
||
}
|
||
*/
|
||
|
||
Pager<SysUser> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
handleUser(pager.getRows());
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 部门树形结构
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "部门树形结构", notes = "部门树形结构")
|
||
@PostMapping(value = "unitTree")
|
||
@ResponseBody
|
||
public MultiResult<SysUnit> unitTree()throws Exception{
|
||
MultiResult<SysUnit> result = new MultiResult<>();
|
||
|
||
String userId = getUserId();
|
||
String parentUnitId = getUnitId(userId);
|
||
|
||
List<SysUnit> units = sysUnitMapper.findUnit(parentUnitId);
|
||
if(units.size() > 0){
|
||
JSONArray unitJson = handleUnitTree(units);
|
||
List<SysUnit> sysUnits = JSONArray.parseArray(JSONArray.toJSONString(unitJson),SysUnit.class);
|
||
result.setData(sysUnits);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 部门树形结构
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "部门树形结构", notes = "部门树形结构")
|
||
@PostMapping(value = "unitTreeV1")
|
||
@ResponseBody
|
||
public MultiResult<SysUnit> unitTreeV1()throws Exception{
|
||
MultiResult<SysUnit> result = new MultiResult<>();
|
||
|
||
String userId = getUserId();
|
||
String parentUnitId = getSuperUnitId(userId);
|
||
|
||
List<SysUnit> units = sysUnitMapper.findUnit(parentUnitId);
|
||
if(units.size() > 0){
|
||
JSONArray unitJson = handleUnitTree(units);
|
||
List<SysUnit> sysUnits = JSONArray.parseArray(JSONArray.toJSONString(unitJson),SysUnit.class);
|
||
result.setData(sysUnits);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 部门树形结构
|
||
* @param sysUnits
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private JSONArray handleUnitTree(List<SysUnit> sysUnits)throws Exception{
|
||
List<Map<String,Object>> data = new ArrayList<>();
|
||
for(SysUnit unit : sysUnits){
|
||
if(StringUtils.isBlank(unit.getSuperiorunitid())){
|
||
unit.setSuperiorunitid("");
|
||
}
|
||
Map<String,Object> entUserMap = new HashMap<String,Object>();
|
||
entUserMap.put("sysunitid",unit.getSysunitid());
|
||
entUserMap.put("unitname",unit.getUnitname());
|
||
entUserMap.put("superiorunitid",unit.getSuperiorunitid());
|
||
data.add(entUserMap);
|
||
}
|
||
JSONArray result = TypeConversion.listToTree(JSONArray.parseArray(JSON.toJSONString(data)),"sysunitid","superiorunitid","children");
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取用户部门id
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/8 15:00
|
||
*/
|
||
private String getSuperPerformId(String userId)throws Exception{
|
||
String superPerformId = "";
|
||
if(StringUtils.isBlank(userId)){
|
||
userId = getUserId();
|
||
}
|
||
if(StringUtils.isNotBlank(userId)){
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
String performId = sysUser.getSystitle();
|
||
ListPerform perform = listPerformMapper.selectByPrimaryKey(performId);
|
||
if(null != perform){
|
||
superPerformId = perform.getSupclassid();
|
||
}
|
||
}
|
||
}
|
||
return superPerformId;
|
||
}
|
||
|
||
/**
|
||
* 岗位树形列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "岗位树形列表", notes = "岗位树形列表")
|
||
@PostMapping(value = "performTree")
|
||
@ResponseBody
|
||
public MultiResult<ListPerform> performTree()throws Exception{
|
||
MultiResult<ListPerform> result = new MultiResult<>();
|
||
String userId = getUserId();
|
||
|
||
if(StringUtils.isBlank(userId)){
|
||
userId = getUserId();
|
||
}
|
||
//获取部门id
|
||
String superPerformId = getSuperPerformId(userId);
|
||
|
||
List<ListPerform> listPerforms = listPerformMapper.findUnit(superPerformId);
|
||
if(listPerforms.size() > 0){
|
||
for(ListPerform listPerform : listPerforms){
|
||
if(StringUtils.isNotBlank(listPerform.getPerformName())){
|
||
listPerform.setPerformclassname(listPerform.getPerformclassname()+"("+listPerform.getPerformName()+")");
|
||
}
|
||
}
|
||
JSONArray performJson = handlePerformTree(listPerforms);
|
||
List<ListPerform> performs = JSONArray.parseArray(JSONArray.toJSONString(performJson),ListPerform.class);
|
||
result.setData(performs);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
@ApiOperation(value = "新增用户岗位树形列表", notes = "新增用户岗位树形列表")
|
||
@PostMapping(value = "performTreeUser")
|
||
@ResponseBody
|
||
public MultiResult<ListPerform> performTreeUser()throws Exception{
|
||
MultiResult<ListPerform> result = new MultiResult<>();
|
||
String userId = getUserId();
|
||
//获取部门id
|
||
String superPerformId = getSuperPerformId(userId);
|
||
List<ListPerform> listPerforms = listPerformMapper.findAll(superPerformId);
|
||
if(listPerforms.size() > 0){
|
||
for(ListPerform listPerform : listPerforms){
|
||
if(StringUtils.isNotBlank(listPerform.getPerformName())){
|
||
listPerform.setPerformclassname(listPerform.getPerformclassname()+"("+listPerform.getPerformName()+")");
|
||
}
|
||
}
|
||
JSONArray performJson = handlePerformTree(listPerforms);
|
||
List<ListPerform> performs = JSONArray.parseArray(JSONArray.toJSONString(performJson),ListPerform.class);
|
||
result.setData(performs);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 岗位树形结构
|
||
* @param listPerforms
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
private JSONArray handlePerformTree(List<ListPerform> listPerforms)throws Exception{
|
||
List<Map<String,Object>> data = new ArrayList<>();
|
||
for(ListPerform perform : listPerforms){
|
||
if(StringUtils.isBlank(perform.getSupclassid())){
|
||
perform.setSupclassid("");
|
||
}
|
||
Map<String,Object> entUserMap = new HashMap<String,Object>();
|
||
entUserMap.put("listperformid",perform.getListperformid());
|
||
entUserMap.put("performclassname",perform.getPerformclassname());
|
||
entUserMap.put("performName",perform.getPerformName());
|
||
entUserMap.put("supclassid",perform.getSupclassid());
|
||
data.add(entUserMap);
|
||
}
|
||
JSONArray result = TypeConversion.listToTree(JSONArray.parseArray(JSON.toJSONString(data)),"listperformid","supclassid","children");
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 新增、修改用户信息
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "新增、修改用户信息", notes = "新增、修改用户信息")
|
||
@PostMapping(value = "changeUser")
|
||
@ResponseBody
|
||
public SingleResult<String> changeUser(@Valid ChangeUserDto changeUserDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
SysUser sysUser = new SysUser();
|
||
BeanUtils.copyProperties(sysUser,changeUserDto);
|
||
System.out.println("sysUser -> "+JSONArray.toJSONString(sysUser));
|
||
System.out.println("userId -> " + sysUser.getSysuserid());
|
||
|
||
//操作人
|
||
SysUser operator = getUser(changeUserDto.getUserId());
|
||
sysUser.setModifiedby(operator.getChinaname());
|
||
sysUser.setCreatedby(operator.getChinaname());
|
||
sysUser.setModifiedon(new Date());
|
||
sysUser.setCreatedon(new Date());
|
||
sysUser.setUsertype(UserType.GOV.getType());
|
||
|
||
String areaCode = constantsConfigure.getSuperiorOrgCode();
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(changeUserDto.getSystitle());
|
||
if(null != listPerform && StringUtils.isNotBlank(listPerform.getAreaCode())){
|
||
areaCode = listPerform.getAreaCode();
|
||
}
|
||
|
||
|
||
|
||
//监管地区
|
||
sysUser.setSuperviseArea(changeUserDto.getSuperviseAreaId());
|
||
SysUser user = sysUserMapper.findById(sysUser.getSysuserid());
|
||
if(null != user){
|
||
//修改
|
||
if(!sysUser.getSyspassword().equals(user.getSyspassword())){
|
||
String passwd = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysUser.getSysusername(), sysUser.getSyspassword());
|
||
sysUser.setSyspassword(passwd);
|
||
}else{
|
||
String passwd = user.getSyspassword();
|
||
sysUser.setSyspassword(passwd);
|
||
}
|
||
|
||
//判断用户名是否存在
|
||
user = sysUserMapper.findOtherUesr(sysUser.getSysusername(),sysUser.getSysuserid());
|
||
if(null == user){
|
||
|
||
getUserAreaCode(areaCode,sysUser);
|
||
getUserPost(changeUserDto.getSystitle(),sysUser);
|
||
// getUserUnit(sysUser.getSysunitorentid(),sysUser);
|
||
sysUserMapper.changeUser(sysUser);
|
||
//处理监管地区
|
||
changeSuperviseArea(sysUser.getSysuserid(),changeUserDto.getSuperviseAreaId(),operator.getChinaname());
|
||
}else{
|
||
result.setCode(Code.ERROR.getCode());
|
||
result.setMessage(Message.HAS_USERNAME);
|
||
}
|
||
}else{
|
||
|
||
//判断用户名是否存在
|
||
user = sysUserMapper.findBySysUserName(sysUser.getSysusername());
|
||
if(null == user){
|
||
//密码
|
||
String passwd = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysUser.getSysusername(), sysUser.getSyspassword());
|
||
sysUser.setSyspassword(passwd);
|
||
getUserPost(changeUserDto.getSystitle(),sysUser);
|
||
getUserAreaCode(areaCode,sysUser);
|
||
// getUserUnit(sysUser.getSysunitorentid(),sysUser);
|
||
sysUserMapper.insert(sysUser);
|
||
//处理监管地区
|
||
changeSuperviseArea(sysUser.getSysuserid(),changeUserDto.getSuperviseAreaId(),operator.getChinaname());
|
||
}else{
|
||
result.setCode(Code.ERROR.getCode());
|
||
result.setMessage(Message.HAS_USERNAME);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 处理用户部门信息
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/9 14:07
|
||
*/
|
||
public void getUserUnit(String unitId,SysUser user)throws Exception{
|
||
if(StringUtils.isNotBlank(unitId)){
|
||
SysUnit sysUnit = sysUnitMapper.selectByPrimaryKey(unitId);
|
||
if(null != sysUnit){
|
||
user.setSysunitorentid(unitId);
|
||
user.setUnitPath(sysUnit.getParentPath());
|
||
user.setUnitPathName(sysUnit.getParentName());
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理企业地区信息
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/11/1 14:40
|
||
*/
|
||
public void getUserAreaCode(String areaCode,SysUser user)throws Exception{
|
||
if(StringUtils.isNotBlank(areaCode)){
|
||
SysOrg sysOrg = sysOrgMapper.selectById(areaCode);
|
||
if(null != sysOrg){
|
||
user.setAreaCode(areaCode);
|
||
user.setAreaPath(sysOrg.getParentPath());
|
||
user.setAreaName(sysOrg.getParentName());
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理企业岗位信息
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/11/1 14:40
|
||
*/
|
||
public void getUserPost(String performId,SysUser user)throws Exception{
|
||
if(StringUtils.isNotBlank(performId)){
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(performId);
|
||
if(null != listPerform){
|
||
user.setSystitle(performId);
|
||
user.setPostPath(listPerform.getParentPath());
|
||
user.setPostName(listPerform.getParentName());
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理监管地区
|
||
* @param userId
|
||
* @param superviseAreaId
|
||
* @throws Exception
|
||
*/
|
||
private void changeSuperviseArea(String userId,String superviseAreaId,String chinaname)throws Exception{
|
||
|
||
/*//删除用户监管地区
|
||
sysUserAreaMapper.delByUserId(userId);
|
||
if(StringUtils.isNotBlank(superviseAreaId)){
|
||
String[] strs = superviseAreaId.split(",");
|
||
for (String str : strs){
|
||
SysUserArea userArea = new SysUserArea();
|
||
userArea.setUserAreaId(RandomNumber.getUUid());
|
||
userArea.setUserId(userId);
|
||
userArea.setOrgcode(str);
|
||
userArea.setModified(chinaname);
|
||
userArea.setCreated(chinaname);
|
||
userArea.setModifyTime(new Date());
|
||
userArea.setCreateTime(new Date());
|
||
sysUserAreaMapper.insert(userArea);
|
||
}
|
||
}*/
|
||
}
|
||
|
||
/**
|
||
* 地区列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "地区列表", notes = "地区列表")
|
||
@PostMapping(value = "orgList")
|
||
@ResponseBody
|
||
public MultiResult<SysOrg> orgList()throws Exception{
|
||
MultiResult<SysOrg> result = new MultiResult<>();
|
||
List<SysOrg> sysOrgs = getSysOrg(constantsConfigure.getSuperiorOrgCode());
|
||
if(sysOrgs.size() > 0){
|
||
result.setData(sysOrgs);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 地区列表,查询包括新都区
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "地区列表包括一级", notes = "地区列表包括一级")
|
||
@PostMapping(value = "orgListHighLevel")
|
||
@ResponseBody
|
||
public MultiResult<SysOrg> orgListHighLevel()throws Exception{
|
||
MultiResult<SysOrg> result = new MultiResult<>();
|
||
List<SysOrg> sysOrgs = getSysOrgHighLevel();
|
||
if(sysOrgs.size() > 0){
|
||
result.setData(sysOrgs);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职记录
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职记录", notes = "履职记录")
|
||
@PostMapping(value = "performRecord")
|
||
@ResponseBody
|
||
public SingleResult<Pager<ListDetailWithBLOBs>> performRecord(@Valid PerformRecordDto performRecordDto)throws Exception{
|
||
SingleResult<Pager<ListDetailWithBLOBs>> result = new SingleResult<>();
|
||
SysUser sysUser = sysUserMapper.findById(performRecordDto.getUserId());
|
||
if(null != sysUser){
|
||
|
||
//未选择年份 则默认当前年份
|
||
String year = performRecordDto.getYear();
|
||
if(StringUtils.isBlank(year)){
|
||
year = DateUtils.getNowDateTimeStr("yyyy");
|
||
}
|
||
|
||
String performId = sysUser.getSystitle();
|
||
String condition = TypeConversion.getCondition(performRecordDto.getCondition());
|
||
|
||
PageHelper.startPage(performRecordDto.getPage(), performRecordDto.getPageSize());
|
||
Page<ListDetailWithBLOBs> page = (Page<ListDetailWithBLOBs>)listDetailMapper.performRecord(performId,condition,year);
|
||
Pager<ListDetailWithBLOBs> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职记录详情
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/16 15:50
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职记录详情", notes = "履职记录详情")
|
||
@GetMapping(value = "performRecordDetail/{listdetailid}")
|
||
@ApiImplicitParam(name = "listdetailid",value = "履职记录id",required = true)
|
||
@ResponseBody
|
||
public SingleResult<ListDetailWithBLOBs> performRecordDetail(@PathVariable String listdetailid)throws Exception{
|
||
SingleResult<ListDetailWithBLOBs> result = new SingleResult<>();
|
||
ListDetailWithBLOBs detail = listDetailMapper.findByDetailId(listdetailid);
|
||
if(null != detail){
|
||
|
||
//履职清单
|
||
List<ListFactor> factors = listFactorMapper.detailFactors(detail.getListdetailid());
|
||
if(null != factors && factors.size() > 0){
|
||
detail.setFactors(factors);
|
||
}
|
||
|
||
//履职任务
|
||
List<OATask> tasks = oaTaskMapper.detailTasks(detail.getListdetailid());
|
||
if(null != tasks && tasks.size() > 0){
|
||
detail.setTasks(tasks);
|
||
}
|
||
|
||
}
|
||
result.setData(detail);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职变更记录
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/2/9 14:57
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职变更记录", notes = "履职变更记录")
|
||
@GetMapping(value = "listChangePage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<Listchange>> listChangePage(@Valid ListChangePageDto listChangePageDto)throws Exception{
|
||
SingleResult<Pager<Listchange>> result = new SingleResult<>();
|
||
SysUser sysUser = getUser(listChangePageDto.getUserId());
|
||
String performId = sysUser.getSystitle();
|
||
String condition = TypeConversion.getCondition(listChangePageDto.getCondition());
|
||
PageHelper.startPage(listChangePageDto.getPage(), listChangePageDto.getPageSize());
|
||
Page<Listchange> page = (Page<Listchange>)listchangeMapper.listchangeList(performId,condition);
|
||
Pager<Listchange> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 新增履职记录
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "新增履职记录", notes = "新增履职记录")
|
||
@PostMapping(value = "addPerformRecord")
|
||
@ResponseBody
|
||
@Transactional
|
||
public SingleResult<String> addPerformRecord(@Valid @RequestBody AddPerformRecordDto addPerformRecordDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
ListDetailWithBLOBs listDetail = new ListDetailWithBLOBs();
|
||
BeanUtils.copyProperties(listDetail,addPerformRecordDto);
|
||
|
||
//处理时间
|
||
listDetail.setStarttime(DateUtils.parseString2Date(addPerformRecordDto.getStartTime(),"yyyy-MM-dd"));
|
||
listDetail.setEndtime(DateUtils.parseString2Date(addPerformRecordDto.getEndTime(),"yyyy-MM-dd"));
|
||
listDetail.setFinishtime(listDetail.getEndtime());
|
||
|
||
String userId = getUserId();
|
||
String chinaName = userId;
|
||
System.out.println("chinaName -> "+chinaName);
|
||
listDetail.setCreatedby(chinaName);
|
||
listDetail.setModifiedby(chinaName);
|
||
listDetail.setTaskId(addPerformRecordDto.getTaskId());
|
||
listDetail.setIsfinish(IsFinish.YES.getFinish());
|
||
listDetail.setDelState(DelState.NOT_DEL.getState());
|
||
|
||
//获取岗位id
|
||
SysUser sysUser = getUser(userId);
|
||
if(null != sysUser){
|
||
listDetail.setListperformid(sysUser.getSystitle());
|
||
}
|
||
|
||
listDetailMapper.insert(listDetail);
|
||
|
||
//清单id 多个逗号隔开
|
||
String listfactorid = addPerformRecordDto.getListfactorid();
|
||
|
||
//处理清单和任务信息
|
||
handleFactorAndTask(listfactorid,addPerformRecordDto,listDetail,chinaName);
|
||
|
||
|
||
System.out.println("listDetail -> "+JSONArray.toJSONString(listDetail));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 新增或者修改履职记录之后处理清单和任务信息
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/16 16:20
|
||
*/
|
||
private void handleFactorAndTask(String listfactorid,AddPerformRecordDto addPerformRecordDto,ListDetailWithBLOBs listDetail,String chinaName)throws Exception{
|
||
|
||
//新增履职修改记录 和 新增履职关联信息
|
||
addFacotrRelation(listfactorid,addPerformRecordDto.getWorkcnt(),listDetail.getListdetailid(),chinaName);
|
||
|
||
//多个清单id 修改履职清单完成进度
|
||
if(StringUtils.isNotBlank(listfactorid)){
|
||
String[] listfactorids = listfactorid.split(",");
|
||
for(String str : listfactorids){
|
||
//修改履职档案完成情况
|
||
factorProgres(str);
|
||
}
|
||
}
|
||
|
||
//如果是通过任务添加的履职信息 修改任务状态
|
||
String taskId = addPerformRecordDto.getTaskId();
|
||
if(StringUtils.isNotBlank(taskId)){
|
||
String[] strs = taskId.split(",");
|
||
List<String> taskIds = Arrays.asList(strs);
|
||
for (String str : taskIds){
|
||
OATask oaTask = oaTaskMapper.findById(str);
|
||
if(null != oaTask){
|
||
//修改任务状态
|
||
changeTaskState(oaTask,listfactorid);
|
||
}
|
||
|
||
//先删除清单关联信息
|
||
listRelationMapper.delByTargetId(listDetail.getListdetailid(),ListTargerType.TASK.getType());
|
||
//新增履职记录关联
|
||
addListRelation(listDetail.getListdetailid(),str,ListTargerType.TASK.getType());
|
||
}
|
||
}
|
||
System.out.println("listDetail -> "+JSONArray.toJSONString(listDetail));
|
||
}
|
||
|
||
/**
|
||
* 新增履职修改记录 和 新增履职关联信息
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/16 14:02
|
||
*/
|
||
private void addFacotrRelation(String listfactorid,String workcnt,String listdetailid,String chinaName)throws Exception{
|
||
//清单id
|
||
if(StringUtils.isNotBlank(listfactorid)){
|
||
String[] listfactorids = listfactorid.split(",");
|
||
|
||
//记录履职记录
|
||
ListFactor listFactor = listFactorMapper.selectByPrimaryKey(listfactorids[0]);
|
||
if(null != listFactor){
|
||
String content = "新增履职记录:"+workcnt;
|
||
addListChange(listFactor.getListperformid(),listFactor.getListfactorid(),content);
|
||
}
|
||
|
||
//先删除清单关联信息
|
||
listRelationMapper.delByTargetId(listdetailid,ListTargerType.LIST.getType());
|
||
|
||
//新增履职记录关联
|
||
for (String str : listfactorids){
|
||
addListRelation(listdetailid,str,ListTargerType.LIST.getType());
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 新增履职记录关联
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/16 14:11
|
||
*/
|
||
private void addListRelation(String listdetailid,String targetId,Integer targetType)throws Exception{
|
||
ListRelation relation = new ListRelation();
|
||
relation.setRelationId(RandomNumber.getUUid());
|
||
relation.setDetailId(listdetailid);
|
||
relation.setTargetId(targetId);
|
||
relation.setTargetType(targetType);
|
||
relation.setCreateBy(getUserId());
|
||
relation.setCreateTime(new Date());
|
||
relation.setModifyBy(getUserId());
|
||
relation.setModifyTime(new Date());
|
||
listRelationMapper.insert(relation);
|
||
}
|
||
|
||
/**
|
||
* 角色列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "角色列表", notes = "角色列表")
|
||
@PostMapping(value = "roleList")
|
||
@ResponseBody
|
||
public MultiResult<SysRole> roleList()throws Exception{
|
||
MultiResult<SysRole> result = new MultiResult<>();
|
||
List<SysRole> sysRoles = sysRoleMapper.findAll();
|
||
if(sysRoles.size() > 0){
|
||
result.setData(sysRoles);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改履职记录
|
||
* @param addPerformRecordDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改履职记录", notes = "修改履职记录")
|
||
@PostMapping(value = "changePerformRecord")
|
||
@ResponseBody
|
||
public SingleResult<String> changePerformRecord(@Valid @RequestBody AddPerformRecordDto addPerformRecordDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
ListDetailWithBLOBs listDetail = new ListDetailWithBLOBs();
|
||
org.springframework.beans.BeanUtils.copyProperties(addPerformRecordDto,listDetail);
|
||
|
||
//处理时间
|
||
listDetail.setStarttime(DateUtils.parseString2Date(addPerformRecordDto.getStartTime(),"yyyy-MM-dd"));
|
||
listDetail.setEndtime(DateUtils.parseString2Date(addPerformRecordDto.getEndTime(),"yyyy-MM-dd"));
|
||
listDetail.setFinishtime(listDetail.getEndtime());
|
||
listDetail.setTaskId(addPerformRecordDto.getTaskId());
|
||
|
||
String chinaName = getChinaName();
|
||
System.out.println("chinaName -> "+chinaName);
|
||
listDetail.setCreatedby(chinaName);
|
||
listDetail.setModifiedby(chinaName);
|
||
listDetail.setIsfinish(IsFinish.YES.getFinish());
|
||
listDetail.setDelState(DelState.NOT_DEL.getState());
|
||
|
||
listDetailMapper.changeListDetail(listDetail);
|
||
|
||
//清单id
|
||
String listfactorid = addPerformRecordDto.getListfactorid();
|
||
|
||
//处理清单和任务信息
|
||
handleFactorAndTask(listfactorid,addPerformRecordDto,listDetail,chinaName);
|
||
|
||
/*//修改履职档案完成情况
|
||
factorProgres(listfactorid);
|
||
|
||
//如果是通过任务添加的履职信息
|
||
String taskId = addPerformRecordDto.getTaskId();
|
||
if(StringUtils.isNotBlank(taskId)){
|
||
String[] strs = taskId.split(",");
|
||
List<String> taskIds = Arrays.asList(strs);
|
||
for (String str : taskIds){
|
||
OATask oaTask = oaTaskMapper.findById(str);
|
||
if(null != oaTask){
|
||
//修改任务状态
|
||
changeTaskState(oaTask,listfactorid);
|
||
}
|
||
}
|
||
}
|
||
|
||
System.out.println("listDetail -> "+JSONArray.toJSONString(listDetail));*/
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 删除履职记录
|
||
* @param listdetailid
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "删除履职记录", notes = "删除履职记录")
|
||
@ApiImplicitParam(name = "listdetailid",value = "履职记录id 多个逗号隔开")
|
||
@PostMapping(value = "delPerformRecord/{listdetailid}")
|
||
@ResponseBody
|
||
@Transactional
|
||
public SingleResult<String> delPerformRecord(@PathVariable String listdetailid)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
String[] strs = listdetailid.split(",");
|
||
List<String> listdetailids = Arrays.asList(strs);
|
||
for (String listIds : listdetailids){
|
||
ListDetailWithBLOBs listDetail = listDetailMapper.findById(listIds);
|
||
if(null != listDetail){
|
||
String chinaName = getChinaName();
|
||
listDetailMapper.changeSelState(listIds, DelState.DELETE.getState(),chinaName);
|
||
|
||
//修改任务状态为未完成
|
||
List<ListRelation> relations = listRelationMapper.findByDetailId(listDetail.getListdetailid(),ListTargerType.TASK.getType());
|
||
if(null != relations && relations.size() > 0){
|
||
for (ListRelation relation : relations){
|
||
|
||
OATask oaTask = oaTaskMapper.selectById(relation.getTargetId());
|
||
if(null != oaTask){
|
||
//修改任务状态
|
||
taskStateChange(oaTask,listDetail.getListfactorid());
|
||
}
|
||
}
|
||
}
|
||
|
||
//修改履职档案完成情况
|
||
factorProgres(listDetail.getListfactorid());
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 删除履职清单时 修改任务状态
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/8/22 16:20
|
||
*/
|
||
private void taskStateChange(OATask oaTask,String listfactorid)throws Exception{
|
||
Long total = oaTask.getFrequency();
|
||
if(null == total){
|
||
total = 0l;
|
||
}
|
||
|
||
total = total - 1;
|
||
|
||
if(total < 0){
|
||
total = 0l;
|
||
}
|
||
|
||
|
||
ListFactor listFactor = listFactorMapper.selectByPrimaryKey(oaTask.getOtcid());
|
||
if(null == listFactor.getFrequency()){
|
||
listFactor.setFrequency(1);
|
||
}
|
||
String isFinsh = "否";
|
||
if(total >= listFactor.getFrequency()){
|
||
isFinsh = "是";
|
||
}
|
||
oaTaskMapper.changeFrequency(oaTask.getOataskid(),total,isFinsh);
|
||
}
|
||
|
||
|
||
/**
|
||
* 未完成的履职任务
|
||
* @param factorId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "未完成的履职任务", notes = "未完成的履职任务")
|
||
@ApiImplicitParam(name = "factorId",value = "清单id 多个逗号隔开")
|
||
@PostMapping(value = "factorTask/{factorId}")
|
||
@ResponseBody
|
||
public MultiResult<OATask> factorTask(@PathVariable String factorId)throws Exception{
|
||
MultiResult<OATask> result = new MultiResult<>();
|
||
String[] strs = factorId.split(",");
|
||
List<String> factorIds = Arrays.asList(strs);
|
||
if(null != factorIds && factorIds.size() > 0){
|
||
List<OATask> tasks = oaTaskMapper.notFinishTasks(factorIds);
|
||
if(tasks.size() > 0 ){
|
||
result.setData(tasks);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 未完成的履职任务
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "未完成的履职任务", notes = "未完成的履职任务")
|
||
@GetMapping(value = "factorTaskByFactorId")
|
||
@ResponseBody
|
||
public MultiResult<OATask> factorTaskByFactorId()throws Exception{
|
||
MultiResult<OATask> result = new MultiResult<>();
|
||
List<OATask> tasks = oaTaskMapper.notFinishTaskByUserId(getUserId());
|
||
if(tasks.size() > 0 ){
|
||
result.setData(tasks);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 部门分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "部门分页", notes = "部门分页")
|
||
@PostMapping(value = "unitPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysUnit>> unitPage(@Valid UnitPageDto unitPageDto)throws Exception{
|
||
SingleResult<Pager<SysUnit>> result = new SingleResult<>();
|
||
|
||
String userId = getUserId();
|
||
String parentUnitId = getSuperUnitId(userId);
|
||
String condition = TypeConversion.getCondition(unitPageDto.getCondition());
|
||
PageHelper.startPage(unitPageDto.getPage(), unitPageDto.getPageSize());
|
||
Page<SysUnit> page = (Page<SysUnit>)sysUnitMapper.findByName(condition,unitPageDto.getUnitId(),parentUnitId);
|
||
Pager<SysUnit> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取用户部门id
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/8 15:00
|
||
*/
|
||
private String getSuperUnitId(String userId)throws Exception{
|
||
String parentUnitId = "";
|
||
if(StringUtils.isBlank(userId)){
|
||
userId = getUserId();
|
||
}
|
||
if(StringUtils.isNotBlank(userId)){
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
parentUnitId = sysUser.getSysunitorentid();
|
||
}
|
||
}
|
||
return parentUnitId;
|
||
}
|
||
|
||
/**
|
||
* 修改新增部门
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增部门", notes = "修改新增部门")
|
||
@PostMapping(value = "changeUnit")
|
||
@ResponseBody
|
||
public SingleResult<String> changeUnit(@Valid ChangeUnitDto changeUnitDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
SysUnit sysUnit = new SysUnit();
|
||
BeanUtils.copyProperties(sysUnit,changeUnitDto);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
sysUnit.setCreatedby(chinaName);
|
||
sysUnit.setModifiedby(chinaName);
|
||
sysUnit.setCreatedon(new Date());
|
||
sysUnit.setModifiedon(new Date());
|
||
|
||
//查重
|
||
SysUnit unit = sysUnitMapper.selectByPrimaryKey(sysUnit.getSysunitid());
|
||
if(null != unit){
|
||
getUnitPath(sysUnit.getSuperiorunitid(),sysUnit);
|
||
sysUnitMapper.changeUnit(sysUnit);
|
||
}else{
|
||
//新增
|
||
getUnitPath(sysUnit.getSuperiorunitid(),sysUnit);
|
||
sysUnitMapper.insert(sysUnit);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/8 13:52
|
||
*/
|
||
public void getUnitPath(String parentId,SysUnit sysUnit)throws Exception{
|
||
sysUnit.setParentPath(sysUnit.getSysunitid());
|
||
sysUnit.setParentName(sysUnit.getUnitname());
|
||
if(StringUtils.isNotBlank(parentId)){
|
||
SysUnit unit = sysUnitMapper.selectByPrimaryKey(parentId);
|
||
if(null != unit){
|
||
sysUnit.setParentPath(unit.getParentPath()+","+sysUnit.getSysunitid());
|
||
sysUnit.setParentName(unit.getParentName()+","+sysUnit.getUnitname());
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 角色分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "角色分页", notes = "角色分页")
|
||
@PostMapping(value = "rolePage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysRole>> rolePage(@Valid RolePageDto rolePageDto)throws Exception{
|
||
SingleResult<Pager<SysRole>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(rolePageDto.getCondition());
|
||
PageHelper.startPage(rolePageDto.getPage(), rolePageDto.getPageSize());
|
||
Page<SysRole> page = (Page<SysRole>)sysRoleMapper.rolePage(condition);
|
||
Pager<SysRole> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改新增角色
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增角色", notes = "修改新增角色")
|
||
@PostMapping(value = "changeRole")
|
||
@ResponseBody
|
||
public SingleResult<String> changeRole(@Valid ChangeRoleDto changeRoleDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
SysRole sysRole = new SysRole();
|
||
BeanUtils.copyProperties(sysRole,changeRoleDto);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
sysRole.setCreatedby(chinaName);
|
||
sysRole.setModifiedby(chinaName);
|
||
sysRole.setCreatedon(new Date());
|
||
sysRole.setModifiedon(new Date());
|
||
|
||
SysRole role = sysRoleMapper.selectByPrimaryKey(sysRole.getSysroleid());
|
||
if(null != role){
|
||
sysRoleMapper.changeRole(sysRole);
|
||
}else{
|
||
sysRoleMapper.insert(sysRole);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 角色功能
|
||
* @param roleId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "角色功能", notes = "角色功能")
|
||
@PostMapping(value = "roleResource/{roleId}")
|
||
@ResponseBody
|
||
public MultiResult<SysResource> roleResource(@PathVariable String roleId)throws Exception{
|
||
MultiResult<SysResource> result = new MultiResult<>();
|
||
List<SysResource> resources = sysResourceMapper.roleResource(roleId);
|
||
if(resources.size() > 0){
|
||
for (SysResource resource : resources){
|
||
if(StringUtils.isBlank(resource.getRoleResourceId())){
|
||
resource.setCheck(2);
|
||
}
|
||
}
|
||
//获取树形结构
|
||
JSONArray resourcesTree = handleResouceTree(resources);
|
||
List<SysResource> sysResources = JSONArray.parseArray(JSONArray.toJSONString(resourcesTree),SysResource.class);
|
||
result.setData(sysResources);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改角色功能
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改角色功能", notes = "修改角色功能")
|
||
@PostMapping(value = "changeRoleResource")
|
||
@ResponseBody
|
||
public SingleResult<String> changeRoleResource(@Valid @RequestBody RoleResourceDto roleResourceDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
SysRole sysRole = sysRoleMapper.selectByPrimaryKey(roleResourceDto.getRoleId());
|
||
if(null != sysRole){
|
||
//先删除角色资源
|
||
sysRoleResourceMapper.delRoleId(roleResourceDto.getRoleId());
|
||
|
||
String[] strs = roleResourceDto.getResourceIds().split(",");
|
||
List<String> resourceIds = Arrays.asList(strs);
|
||
String chinaName = getChinaName();
|
||
if(null != resourceIds && resourceIds.size() > 0){
|
||
|
||
List<SysRoleResource> roleResources = new ArrayList<>();
|
||
for (String resourceId : resourceIds){
|
||
SysRoleResource roleResource = new SysRoleResource();
|
||
roleResource.setRoleResourceId(RandomNumber.getUUid());
|
||
roleResource.setRoleId(roleResourceDto.getRoleId());
|
||
roleResource.setResourceId(resourceId);
|
||
roleResource.setModified(chinaName);
|
||
roleResource.setCreated(chinaName);
|
||
roleResource.setModifyTime(new Date());
|
||
roleResource.setCreateTime(new Date());
|
||
roleResources.add(roleResource);
|
||
}
|
||
sysRoleResourceMapper.insertList(roleResources);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 岗位列表分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "岗位列表分页", notes = "岗位列表分页")
|
||
@PostMapping(value = "performPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<ListPerform>> performPage(@Valid PerformPageDto performPageDto, HttpServletRequest servletRequest)throws Exception{
|
||
SingleResult<Pager<ListPerform>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(performPageDto.getCondition());
|
||
String userId = performPageDto.getUserId();
|
||
String performId = "";
|
||
|
||
Pager<ListPerform> pager = new Pager<>();
|
||
if(StringUtils.isNotBlank(userId)){
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
|
||
if(null != sysUser){
|
||
performId = sysUser.getSystitle();
|
||
}
|
||
PageHelper.startPage(performPageDto.getPage(), performPageDto.getPageSize());
|
||
Page<ListPerform> page = (Page<ListPerform>)listPerformMapper.performPage(performPageDto.getListperformid(),performId,condition,"");
|
||
getDatePage(pager,page);
|
||
}else{
|
||
userId = getUserId();
|
||
String superPerformId = getSuperPerformId(userId);
|
||
PageHelper.startPage(performPageDto.getPage(), performPageDto.getPageSize());
|
||
Page<ListPerform> page = (Page<ListPerform>)listPerformMapper.performPage(performPageDto.getListperformid(),performId,condition,superPerformId);
|
||
getDatePage(pager,page);
|
||
}
|
||
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改新增岗位
|
||
* @param changePerformDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增岗位", notes = "修改新增岗位")
|
||
@PostMapping(value = "changePerform")
|
||
@ResponseBody
|
||
public SingleResult<String> changePerform(@Valid @RequestBody ChangePerformDto changePerformDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
ListPerform listPerform = new ListPerform();
|
||
BeanUtils.copyProperties(listPerform,changePerformDto);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
listPerform.setCreatedby(chinaName);
|
||
listPerform.setModifiedby(chinaName);
|
||
listPerform.setCreatedon(new Date());
|
||
listPerform.setModifiedon(new Date());
|
||
|
||
//查询层级
|
||
Integer level = getPerformLevel(changePerformDto.getSupclassid());
|
||
listPerform.setSyslevel(level);
|
||
|
||
String areaCode = changePerformDto.getAreaCode();
|
||
if(StringUtils.isBlank(areaCode)){
|
||
areaCode = constantsConfigure.getSuperiorOrgCode();
|
||
}
|
||
SysOrg sysOrg = sysOrgMapper.selectById(areaCode);
|
||
if(null != sysOrg){
|
||
listPerform.setAreaCode(areaCode);
|
||
listPerform.setAreaPath(sysOrg.getParentPath());
|
||
listPerform.setAreaPathName(sysOrg.getParentName());
|
||
}
|
||
|
||
ListPerform perform = listPerformMapper.selectByPrimaryKey(listPerform.getListperformid());
|
||
if(null != perform){
|
||
getPerformPath(listPerform.getSupclassid(),listPerform);
|
||
|
||
Integer postNum = listPerformMapper.countPost(listPerform.getListperformid());
|
||
if(postNum > 0){
|
||
listPerform.setPositionType(PositionTypeEnum.UNIT.getType());
|
||
}
|
||
|
||
|
||
//修改
|
||
listPerformMapper.changeListPerform(listPerform);
|
||
}else{
|
||
|
||
listPerform.setCompletion("0");
|
||
String performClassCode = "001";
|
||
if(StringUtils.isNotBlank(listPerform.getSupclassid())){
|
||
perform = listPerformMapper.selectByPrimaryKey(listPerform.getSupclassid());
|
||
performClassCode = GetSysOrganCode(perform);//生成
|
||
}
|
||
listPerform.setPerformclasscode(performClassCode);
|
||
listPerform.setPositionType(PositionTypeEnum.POST.getType());
|
||
getPerformPath(listPerform.getSupclassid(),listPerform);
|
||
|
||
//新增
|
||
listPerformMapper.insert(listPerform);
|
||
|
||
//修改上级部门的部门类型
|
||
listPerformMapper.changePositionType(listPerform.getSupclassid(),PositionTypeEnum.UNIT.getType());
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 查询层级
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/9 15:44
|
||
*/
|
||
public Integer getPerformLevel(String parentId)throws Exception{
|
||
Integer level = 1;
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(parentId);
|
||
if(null != listPerform){
|
||
level = listPerform.getSyslevel() + 1;
|
||
}
|
||
return level;
|
||
}
|
||
|
||
/**
|
||
*
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2022/12/8 13:52
|
||
*/
|
||
public void getPerformPath(String parentId,ListPerform perform)throws Exception{
|
||
perform.setParentPath(perform.getListperformid());
|
||
perform.setParentName(perform.getPerformclassname());
|
||
if(StringUtils.isNotBlank(parentId)){
|
||
ListPerform listPerform = listPerformMapper.selectByPrimaryKey(parentId);
|
||
if(null != listPerform){
|
||
perform.setParentPath(listPerform.getParentPath()+","+perform.getListperformid());
|
||
perform.setParentName(listPerform.getParentName()+","+perform.getPerformclassname());
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 岗位安全生产职责清单
|
||
* @param listperformId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "岗位安全生产职责清单", notes = "岗位安全生产职责清单")
|
||
@PostMapping(value = "performSafe")
|
||
@ResponseBody
|
||
public MultiResult<ListSafeWithBLOBs> performSafe(String listperformId)throws Exception{
|
||
MultiResult<ListSafeWithBLOBs> result = new MultiResult<>();
|
||
List<ListSafeWithBLOBs> listSafes = listSafeMapper.userListSafe(listperformId);
|
||
if(listSafes.size() > 0){
|
||
Integer sortId = 1;
|
||
for (ListSafeWithBLOBs listSafe : listSafes){
|
||
if(null == listSafe.getSortid()){
|
||
listSafe.setSortid(sortId);
|
||
}
|
||
sortId++;
|
||
}
|
||
result.setData(listSafes);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 修改新增安全生产职责清单
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增安全生产职责清单", notes = "修改新增安全生产职责清单")
|
||
@PostMapping(value = "changeListSafe")
|
||
@ResponseBody
|
||
public SingleResult<String> changeListSafe(@Valid ChangeSafeDto changeSafeDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
ListSafeWithBLOBs listSafe = new ListSafeWithBLOBs();
|
||
BeanUtils.copyProperties(listSafe,changeSafeDto);
|
||
|
||
//操作人
|
||
String chinaName = getChinaName();
|
||
listSafe.setCreatedby(chinaName);
|
||
listSafe.setModifiedby(chinaName);
|
||
listSafe.setCreatedon(new Date());
|
||
listSafe.setModifiedon(new Date());
|
||
|
||
listSafe.setChkbilldate(new Date());
|
||
|
||
ListSafe safe = listSafeMapper.selectByPrimaryKey(listSafe.getListsafeid());
|
||
if(null != safe){
|
||
listSafeMapper.changeSafe(listSafe);
|
||
}else{
|
||
listSafeMapper.insert(listSafe);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 删除安全生产职责清单
|
||
* @param listSafeId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "删除安全生产职责清单", notes = "删除安全生产职责清单")
|
||
@ApiImplicitParam(name = "listSafeId",value = "安全生产职责清单id 多个逗号隔开",required = true)
|
||
@PostMapping(value = "delListSafe")
|
||
@ResponseBody
|
||
public SingleResult<String> delListSafe(String listSafeId)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
String[] strs = listSafeId.split(",");
|
||
List<String> listSafeIds = Arrays.asList(strs);
|
||
if(null != listSafeIds && listSafeIds.size() > 0){
|
||
listSafeMapper.delInId(listSafeIds);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 岗位履职清单分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "岗位履职清单分页", notes = "岗位履职清单分页")
|
||
@PostMapping(value = "factorPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<ListFactor>> factorPage(@Valid FactorPageDto factorPageDto)throws Exception{
|
||
SingleResult<Pager<ListFactor>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(factorPageDto.getCondition());
|
||
PageHelper.startPage(factorPageDto.getPage(), factorPageDto.getPageSize());
|
||
Page<ListFactor> page = (Page<ListFactor>)listFactorMapper.factorPage(factorPageDto.getListPerformId(),factorPageDto.getYear(),condition,factorPageDto.getType());
|
||
Pager<ListFactor> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
|
||
Integer start = (factorPageDto.getPage() - 1) * factorPageDto.getPageSize();
|
||
start += 1;
|
||
for (ListFactor listFactor : pager.getRows()){
|
||
listFactor.setListnum(start+"");
|
||
start++;
|
||
}
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改新增履职清单
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "修改新增履职清单", notes = "修改新增履职清单")
|
||
@PostMapping(value = "changeFactor")
|
||
@ResponseBody
|
||
@Transactional
|
||
public SingleResult<String> changeFactor(@Valid ChangeFactorDto changeFactorDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
ListFactor listFactor = new ListFactor();
|
||
|
||
ConvertUtils.register(new DateConverter(null), java.util.Date.class);
|
||
BeanUtils.copyProperties(listFactor,changeFactorDto);
|
||
|
||
String userId = getUserId();
|
||
//操作人
|
||
listFactor.setCreatedby(userId);
|
||
listFactor.setModifiedby(userId);
|
||
listFactor.setCreatedon(new Date());
|
||
listFactor.setModifiedon(new Date());
|
||
|
||
listFactor.setStartTime(DateUtils.parseString2Date(changeFactorDto.getStartTime(),"yyyy-MM-dd"));
|
||
listFactor.setEndTime(DateUtils.parseString2Date(changeFactorDto.getEndTime(),"yyyy-MM-dd"));
|
||
|
||
//清单提醒时间
|
||
listFactor.setYellowAlert(5+"");
|
||
listFactor.setRedAlert(2+"");
|
||
|
||
//清单类型
|
||
listFactor.setType(1);
|
||
|
||
if(StringUtils.isNotBlank(changeFactorDto.getSysyear())){
|
||
//不跨年的清单
|
||
listFactor.setSysyear(changeFactorDto.getSysyear());
|
||
}else{
|
||
//跨年的清单
|
||
String sysyear = "";
|
||
List<String> yearList = DateUtils.getYearBetweenDate(changeFactorDto.getStartTime(),changeFactorDto.getEndTime());
|
||
for (String str : yearList){
|
||
if(StringUtils.isNotBlank(sysyear)){
|
||
sysyear = sysyear +","+str;
|
||
}else{
|
||
sysyear = str;
|
||
}
|
||
}
|
||
listFactor.setSysyear(sysyear);
|
||
}
|
||
|
||
|
||
//数据初始
|
||
Integer sortId = listFactorMapper.findSortId(listFactor.getListperformid(),listFactor.getSysyear());
|
||
if(null == sortId){
|
||
sortId = 1;
|
||
}
|
||
sortId++;
|
||
listFactor.setIsfinish(IsFinish.NOT.getFinish());
|
||
listFactor.setFinishProgres(0+"");
|
||
listFactor.setListnum("1");
|
||
listFactor.setFactorIsFinish(IsFinish.NOT.getFinish());
|
||
listFactor.setSortid(sortId);
|
||
listFactor.setDelState(DelState.NOT_DEL.getState());
|
||
|
||
ListFactor factor = listFactorMapper.selectByPrimaryKey(listFactor.getListfactorid());
|
||
if(null != factor){
|
||
//先修改原清单为删除状态
|
||
listFactorMapper.delFactor(listFactor.getListfactorid());
|
||
|
||
|
||
|
||
//修改成功后 在重新新增一条履职清单
|
||
listFactor.setDelState(DelState.NOT_DEL.getState());
|
||
listFactor.setListfactorid(RandomNumber.getUUid());
|
||
listFactorMapper.insert(listFactor);
|
||
String content = "履职清单:<"+factor.getFactorcnt()+">修改为:<"+listFactor.getFactorcnt()+">";
|
||
addListChange(listFactor.getListperformid(),listFactor.getListfactorid(),content);
|
||
//修改
|
||
// listFactorMapper.changeFactor(listFactor);
|
||
}else{
|
||
|
||
listFactorMapper.insert(listFactor);
|
||
|
||
String content = "新增履职清单:"+listFactor.getFactorcnt();
|
||
addListChange(listFactor.getListperformid(),listFactor.getListfactorid(),content);
|
||
}
|
||
|
||
//添加任务
|
||
addFactorTask(listFactor,userId);
|
||
|
||
//修改总体履职进度
|
||
changeListPerForm(listFactor.getListperformid());
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 保存履职记录
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/2/9 14:21
|
||
*/
|
||
public void addListChange(String performId,String factorId,String content)throws Exception{
|
||
String userId = getUserId();
|
||
Listchange listchange = new Listchange();
|
||
listchange.setListchangeId(RandomNumber.getUUid());
|
||
listchange.setPerformId(performId);
|
||
listchange.setFactorId(factorId);
|
||
listchange.setChangeContent(content);
|
||
listchange.setUserId(userId);
|
||
listchange.setCreateBy(userId);
|
||
listchange.setModifyBy(userId);
|
||
listchange.setCreateTime(new Date());
|
||
listchange.setModifyTime(new Date());
|
||
listchangeMapper.insert(listchange);
|
||
}
|
||
|
||
/**
|
||
* 删除履职清单
|
||
* @param delFactorDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "删除履职清单", notes = "删除履职清单")
|
||
@PostMapping(value = "delFactor")
|
||
@ResponseBody
|
||
public SingleResult<String> delFactor(@Valid DelFactorDto delFactorDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
String[] strs = delFactorDto.getListFactorId().split(",");
|
||
List<String> listFactorIds = Arrays.asList(strs);
|
||
if(null != listFactorIds && listFactorIds.size() > 0){
|
||
for (String factorId : listFactorIds){
|
||
listFactorMapper.delFactor(factorId);
|
||
}
|
||
}
|
||
//修改总体履职进度
|
||
changeListPerForm(delFactorDto.getListperformid());
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 修改密码
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "修改密码", notes = "修改密码")
|
||
@PostMapping(value = "changePasswd")
|
||
@ResponseBody
|
||
public SingleResult<String> changePasswd(@Valid ChangePasswdDto changePasswdDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
SysUser sysUser = sysUserMapper.findById(changePasswdDto.getUserId());
|
||
if(null != sysUser){
|
||
if (changePasswdDto.getNowPasswd().matches(Constants.PASSWORD_REGULAR)){
|
||
String oldPasswd = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysUser.getSysusername(),changePasswdDto.getOldPasswd());
|
||
if(sysUser.getSyspassword().equals(oldPasswd)){
|
||
String nowPasswd = PasswdFactory.encryptPasswd(sysUser.getSysuserid(), sysUser.getSysusername(),changePasswdDto.getNowPasswd());
|
||
sysUserMapper.changePassword(changePasswdDto.getUserId(),nowPasswd);
|
||
}else{
|
||
result.setCode(Code.PASSWORD_ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD_ERROR);
|
||
}
|
||
}else{
|
||
result.setCode(Code.ERROR.getCode());
|
||
result.setMessage(Message.PASSWORD);
|
||
}
|
||
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职类别详细
|
||
*
|
||
* */
|
||
@LoginAuth
|
||
@ApiOperation(value = "履职类别详细", notes = "履职类别详细")
|
||
@ApiImplicitParam(name = "listPerformId",value = "清单id")
|
||
@PostMapping(value = "listPerformDetail")
|
||
@ResponseBody
|
||
public SingleResult<String> listPerformDetail(String listPerformId)throws Exception{
|
||
SingleResult singleResult = new SingleResult();
|
||
ListPerform listPerform = listPerformMapper.selectListPerformDetail(listPerformId);
|
||
if (listPerform != null){
|
||
singleResult.setMessage(Message.SUCCESS);
|
||
singleResult.setCode(Code.SUCCESS.getCode());
|
||
singleResult.setData(listPerform);
|
||
}else {
|
||
singleResult.setMessage(Message.ERROR);
|
||
singleResult.setCode(Code.ERROR.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
/**
|
||
* 接收任务管理
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "接收任务管理", notes = "接收任务管理")
|
||
@PostMapping(value = "taskPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<OATask>> taskPage(@Valid TaskPageDto taskPageDto)throws Exception{
|
||
SingleResult<Pager<OATask>> result = new SingleResult<>();
|
||
List<String> sysUserIds = getReceiveTaskUserId(taskPageDto.getUserId());
|
||
if(sysUserIds.size() > 0){
|
||
String condition = TypeConversion.getCondition(taskPageDto.getCondition());
|
||
PageHelper.startPage(taskPageDto.getPage(), taskPageDto.getPageSize());
|
||
Page<OATask> page = (Page<OATask>)oaTaskMapper.receiveTaskPages(sysUserIds,condition,taskPageDto.getTasktype());
|
||
if(page.getTotal() > 0){
|
||
Pager<OATask> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 任务类型列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "任务类型列表", notes = "任务类型列表")
|
||
@PostMapping(value = "taskType")
|
||
@ResponseBody
|
||
public MultiResult<OaTaskType> taskType()throws Exception{
|
||
MultiResult<OaTaskType> result = new MultiResult<>();
|
||
List<OaTaskType> taskTypes = oaTaskTypeMapper.findBySortId();
|
||
if(taskTypes.size() > 0){
|
||
result.setData(taskTypes);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 任务详情
|
||
* @param taskDetailDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
/*@LoginAuth
|
||
@ApiOperation(value = "任务详情", notes = "任务详情")
|
||
@PostMapping(value = "taskDetail")
|
||
@ResponseBody
|
||
public SingleResult<OATask> taskDetail(@Valid TaskDetailDto taskDetailDto)throws Exception{
|
||
SingleResult<OATask> result = new SingleResult<>();
|
||
OATask oaTask = oaTaskMapper.taskDetail(taskDetailDto.getTaskId(),taskDetailDto.getUserId());
|
||
if(null != oaTask){
|
||
//任务详情处理
|
||
getTaskDetail(oaTask,taskDetailDto.getUserId());
|
||
handleTaskDetail(oaTask);
|
||
result.setData(oaTask);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}*/
|
||
// /**
|
||
// * 任务详情
|
||
// * @param taskDetailDto
|
||
// * @return
|
||
// * @throws Exception
|
||
// */
|
||
// @LoginAuth
|
||
// @ApiOperation(value = "任务详情", notes = "任务详情")
|
||
// @PostMapping(value = "taskDetail")
|
||
// @ResponseBody
|
||
// public SingleResult<OATask> taskDetail(@Valid TaskDetailDto taskDetailDto)throws Exception{
|
||
// SingleResult<OATask> result = new SingleResult<>();
|
||
// OATask oaTask = oaTaskMapper.taskDetail(taskDetailDto.getTaskId(),taskDetailDto.getUserId());
|
||
// if(null != oaTask){
|
||
// //任务详情处理
|
||
// getTaskDetail(oaTask,taskDetailDto.getUserId());
|
||
// handleTaskDetail(oaTask);
|
||
// result.setData(oaTask);
|
||
// }else{
|
||
// result.setCode(Code.NO_DATA.getCode());
|
||
// result.setMessage(Message.NO_DATA);
|
||
// }
|
||
// return result;
|
||
// }
|
||
|
||
/**
|
||
* 认证日志分页
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "认证日志分页", notes = "认证日志分页")
|
||
@PostMapping("/authLog")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysLogAuth>> authLog(@Valid AuthLogDto authLogDto)throws Exception{
|
||
SingleResult<Pager<SysLogAuth>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(authLogDto.getCondition());
|
||
PageHelper.startPage(authLogDto.getPage(), authLogDto.getPageSize());
|
||
Page<SysLogAuth> page = (Page<SysLogAuth>)sysLogAuthMapper.findAll(condition);
|
||
if(page.getTotal() > 0){
|
||
Pager<SysLogAuth> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 操作日志
|
||
* @param authLogDto
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@LoginAuth
|
||
@ApiOperation(value = "操作日志", notes = "操作日志")
|
||
@PostMapping("/logsPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysLogs>> logsPage(@Valid AuthLogDto authLogDto)throws Exception{
|
||
SingleResult<Pager<SysLogs>> result = new SingleResult<>();
|
||
String condition = TypeConversion.getCondition(authLogDto.getCondition());
|
||
PageHelper.startPage(authLogDto.getPage(), authLogDto.getPageSize());
|
||
Page<SysLogs> page = (Page<SysLogs>)sysLogsMapper.findAll(condition);
|
||
if(page.getTotal() > 0){
|
||
Pager<SysLogs> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 街道用户树形
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "街道用户树形", notes = "街道用户树形")
|
||
@PostMapping("/streetUser/{userId}")
|
||
@ResponseBody
|
||
public MultiResult<StreetUser> streetUser(@PathVariable String userId)throws Exception{
|
||
MultiResult<StreetUser> result = new MultiResult<>();
|
||
String areaCode = getUserArea(userId);
|
||
if(StringUtils.isNotBlank(areaCode)){
|
||
List<SysUser> users = sysUserMapper.findByArea(areaCode);
|
||
List<StreetUser> streetUsers = new ArrayList<>();
|
||
|
||
if(users.size() > 0){
|
||
|
||
//格式化
|
||
Map<String,List<SysUser>> userMap = new LinkedHashMap<>();
|
||
for (SysUser sysUser : users){
|
||
List<SysUser> sysUsers = new ArrayList<>();
|
||
String deptName = sysUser.getSuperName();
|
||
String postName = sysUser.getPerformClassName();
|
||
postName = postName.replaceAll(deptName,"");
|
||
postName = deptName + postName;
|
||
String key = sysUser.getSystitle()+","+postName;
|
||
if(userMap.containsKey(key)){
|
||
sysUsers = userMap.get(key);
|
||
}
|
||
sysUsers.add(sysUser);
|
||
userMap.put(key,sysUsers);
|
||
}
|
||
|
||
|
||
for (Map.Entry<String,List<SysUser>> entry : userMap.entrySet()){
|
||
StreetUser streetUser = new StreetUser();
|
||
String[] strs = entry.getKey().split(",");
|
||
streetUser.setListperformid(strs[0]);
|
||
streetUser.setPerformclassname(strs[1]);
|
||
streetUser.setUsers(entry.getValue());
|
||
streetUsers.add(streetUser);
|
||
}
|
||
}
|
||
result.setData(streetUsers);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 街道用户列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "街道用户列表", notes = "街道用户列表")
|
||
@PostMapping("/streetUserList")
|
||
@ResponseBody
|
||
@LoginAuth
|
||
public MultiResult<SysUser> streetUserList(@Valid StreetUserListDto streetUserListDto)throws Exception{
|
||
MultiResult<SysUser> result = new MultiResult<>();
|
||
String areaCode = getUserArea(streetUserListDto.getUserId());
|
||
if(StringUtils.isNotBlank(areaCode)){
|
||
String condition = TypeConversion.getCondition(streetUserListDto.getCondition());
|
||
List<SysUser> users = sysUserMapper.areaUser(areaCode,condition,streetUserListDto.getUserId());
|
||
if(users.size() > 0){
|
||
for (SysUser sysUser : users){
|
||
if(StringUtils.isNotBlank(sysUser.getPerformClassName())){
|
||
String deptName = sysUser.getPerformClassName();
|
||
sysUser.setChinaname(deptName+"-"+sysUser.getChinaname());
|
||
}
|
||
}
|
||
result.setData(users);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* 修改责任树
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "修改责任树", notes = "修改责任树")
|
||
@PostMapping("/changeDutyTree")
|
||
@ResponseBody
|
||
@LoginAuth
|
||
@Transactional
|
||
public synchronized SingleResult<String> changeDutyTree(@Valid ChangeDutyTreeDto changeDutyTreeDto)throws Exception{
|
||
SingleResult<String> result = new SingleResult<>();
|
||
|
||
List<String> targetIds = new ArrayList<>();
|
||
|
||
//修改前企业id
|
||
if(2 == changeDutyTreeDto.getTargetType()){
|
||
List<DutyTree> trees = dutyTreeMapper.findByUserId(changeDutyTreeDto.getUserId());
|
||
if(null != trees && trees.size() > 0){
|
||
for (DutyTree dutyTree : trees){
|
||
targetIds.add(dutyTree.getTargetId());
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//删除原来的信息
|
||
dutyTreeMapper.delByUserId(changeDutyTreeDto.getUserId(),changeDutyTreeDto.getTargetType());
|
||
if(StringUtils.isNotBlank(changeDutyTreeDto.getTargetId())){
|
||
String[] strs = changeDutyTreeDto.getTargetId().split(",");
|
||
String chinaName = getChinaName();
|
||
List<DutyTree> dutyTrees = new ArrayList<>();
|
||
for (String str : strs){
|
||
//记录被选择的企业id
|
||
if(2 == changeDutyTreeDto.getTargetType()){
|
||
targetIds.add(str);
|
||
}
|
||
DutyTree dutyTree = new DutyTree();
|
||
dutyTree.setDutyTreeId(RandomNumber.getUUid());
|
||
dutyTree.setTargetId(str);
|
||
dutyTree.setUserId(changeDutyTreeDto.getUserId());
|
||
dutyTree.setTargetType(changeDutyTreeDto.getTargetType());
|
||
dutyTree.setCreated(chinaName);
|
||
dutyTree.setModified(chinaName);
|
||
dutyTree.setCreateTime(new Date());
|
||
dutyTree.setModifyTime(new Date());
|
||
dutyTrees.add(dutyTree);
|
||
}
|
||
//批量插入
|
||
dutyTreeMapper.insertList(dutyTrees);
|
||
}
|
||
|
||
//选择企业不为空
|
||
if(targetIds.size() > 0){
|
||
sysEnterpriseMapper.changeChoiceNum(targetIds);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 在执行一次
|
||
* @param changeDutyTreeDto
|
||
*/
|
||
private void dutyTreeChange(ChangeDutyTreeDto changeDutyTreeDto){
|
||
try {
|
||
//删除原来的信息
|
||
dutyTreeMapper.delByUserId(changeDutyTreeDto.getUserId(),changeDutyTreeDto.getTargetType());
|
||
if(StringUtils.isNotBlank(changeDutyTreeDto.getTargetId())){
|
||
String[] strs = changeDutyTreeDto.getTargetId().split(",");
|
||
String chinaName = getChinaName();
|
||
List<DutyTree> dutyTrees = new ArrayList<>();
|
||
for (String str : strs){
|
||
DutyTree dutyTree = new DutyTree();
|
||
dutyTree.setDutyTreeId(RandomNumber.getUUid());
|
||
dutyTree.setTargetId(str);
|
||
dutyTree.setUserId(changeDutyTreeDto.getUserId());
|
||
dutyTree.setTargetType(changeDutyTreeDto.getTargetType());
|
||
dutyTree.setCreated(chinaName);
|
||
dutyTree.setModified(chinaName);
|
||
dutyTree.setCreateTime(new Date());
|
||
dutyTree.setModifyTime(new Date());
|
||
dutyTrees.add(dutyTree);
|
||
}
|
||
//批量插入
|
||
dutyTreeMapper.insertList(dutyTrees);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 责任树用户列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "责任树用户列表", notes = "责任树用户列表")
|
||
@GetMapping("/dutyTreeUser/{userId}")
|
||
@ApiImplicitParam(name = "userId",value = "用户id",required = true)
|
||
@ResponseBody
|
||
@LoginAuth
|
||
public MultiResult<SysUser> dutyTreeUser(@PathVariable String userId)throws Exception{
|
||
MultiResult<SysUser> result = new MultiResult<>();
|
||
List<SysUser> users = userTree(userId);
|
||
if(users.size() > 0){
|
||
result.setData(users);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 责任树企业列表
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "责任树企业列表", notes = "责任树企业列表")
|
||
@GetMapping("/dutyTreeEnt/{userId}")
|
||
@ApiImplicitParam(name = "userId",value = "用户id",required = true)
|
||
@ResponseBody
|
||
@LoginAuth
|
||
public MultiResult<SysEnterprise> dutyTreeEnt(@PathVariable String userId)throws Exception{
|
||
MultiResult<SysEnterprise> result = new MultiResult<>();
|
||
List<SysEnterprise> enterprises = entTree(userId);
|
||
if(enterprises.size() > 0){
|
||
result.setData(enterprises);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 用户责任树
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "用户责任树", notes = "用户责任树")
|
||
@GetMapping("/userDutyTree/{userId}")
|
||
@ApiImplicitParam(name = "userId",value = "用户id",required = true)
|
||
@ResponseBody
|
||
public MultiResult<DutyTrees> userDutyTree(@PathVariable String userId)throws Exception{
|
||
MultiResult<DutyTrees> result = new MultiResult<>();
|
||
SysUser sysUser = sysUserMapper.findById(userId);
|
||
if(null != sysUser){
|
||
|
||
List<DutyTrees> dutyTrees = new ArrayList<>();
|
||
DutyTrees dutyTree = new DutyTrees();
|
||
dutyTree.setId(sysUser.getSysuserid());
|
||
dutyTree.setText(sysUser.getChinaname());
|
||
|
||
Integer userNum = dutyTreeMapper.countUser(userId);
|
||
Integer entNum = dutyTreeMapper.countEnt(userId);
|
||
|
||
dutyTree.setUserNum(userNum);
|
||
dutyTree.setEntNum(entNum);
|
||
|
||
|
||
|
||
List<DutyTrees> childrens = getChindTree(userId);
|
||
dutyTree.setAreas(childrens);
|
||
dutyTrees.add(dutyTree);
|
||
result.setData(dutyTrees);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取子级用户
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public List<DutyTrees> getChindTree(String userId)throws Exception{
|
||
List<DutyTrees> childrens = new LinkedList<>();
|
||
|
||
//子级用户
|
||
List<SysUser> users = userTree(userId);
|
||
if(null != users && users.size() > 0){
|
||
for (SysUser user : users){
|
||
DutyTrees userDuty = new DutyTrees();
|
||
userDuty.setId(user.getSysuserid());
|
||
|
||
Integer completeNum = 0;
|
||
Integer totalNum = 0;
|
||
CheckPerform checkPerform = getCheckPerform(user);
|
||
|
||
|
||
if(null != checkPerform && checkPerform.getCheckList().size() > 0){
|
||
for(CheckList checkList : checkPerform.getCheckList()){
|
||
completeNum += checkList.getCompleteNum();
|
||
totalNum += checkList.getTotalNum();
|
||
}
|
||
}
|
||
|
||
String text = user.getChinaname();
|
||
text = text + "("+completeNum+"/"+totalNum+")";
|
||
userDuty.setText(text);
|
||
Integer userNum = dutyTreeMapper.countUser(user.getSysuserid());
|
||
Integer entNum = dutyTreeMapper.countEnt(user.getSysuserid());
|
||
userDuty.setUserNum(userNum);
|
||
userDuty.setEntNum(entNum);
|
||
|
||
childrens.add(userDuty);
|
||
}
|
||
}
|
||
|
||
List<SysEnterprise> enterprises = entTree(userId);
|
||
if(null != enterprises && enterprises.size() > 0){
|
||
for(SysEnterprise enterprise : enterprises){
|
||
DutyTrees entDuty = new DutyTrees();
|
||
entDuty.setId(enterprise.getSysenterpriseid());
|
||
entDuty.setText(enterprise.getEntname());
|
||
entDuty.setType(2);
|
||
if(null != enterprise.getCheckNum() && enterprise.getCheckNum() > 0){
|
||
entDuty.setCheckState(1);
|
||
}
|
||
childrens.add(entDuty);
|
||
}
|
||
}
|
||
return childrens;
|
||
}
|
||
|
||
/**
|
||
* 包片的人
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public List<SysUser> userTree(String userId)throws Exception{
|
||
List<SysUser> users = sysUserMapper.dutyTreeUser(userId);
|
||
if(users.size() > 0){
|
||
for (SysUser sysUser : users){
|
||
if(StringUtils.isNotBlank(sysUser.getPerformClassName())){
|
||
|
||
String performClassName = sysUser.getPerformClassName();
|
||
|
||
/*//显示总长度
|
||
Integer total = 14;
|
||
|
||
Integer performLenght = sysUser.getPerformClassName().length();
|
||
Integer chinaNameLenght = sysUser.getChinaname().length();
|
||
|
||
//减去用户名剩下的长度
|
||
total = total - chinaNameLenght;
|
||
|
||
System.out.println("total ------------> "+total);
|
||
System.out.println("performLenght ------------> "+performLenght);
|
||
|
||
//如果岗位长度超过总长度 则截取后面部门
|
||
if(performLenght > total){
|
||
|
||
//需要截取的长度
|
||
Integer needTotal = performLenght - total;
|
||
|
||
|
||
|
||
System.out.println("needTotal -----------------> "+needTotal);
|
||
//
|
||
performClassName = performClassName.substring(needTotal,performLenght);
|
||
performClassName = "..." + performClassName;
|
||
}*/
|
||
|
||
|
||
sysUser.setChinaname(performClassName+"-"+sysUser.getChinaname());
|
||
}
|
||
}
|
||
}
|
||
return users;
|
||
}
|
||
|
||
/**
|
||
* 包片的企业
|
||
* @param userId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public List<SysEnterprise> entTree(String userId)throws Exception{
|
||
List<SysEnterprise> enterprises = sysEnterpriseMapper.dutyTreeEnt(userId);
|
||
return enterprises;
|
||
}
|
||
|
||
/**
|
||
* 用户责任树子级
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@ApiOperation(value = "用户责任树子级", notes = "用户责任树子级")
|
||
@GetMapping("/userDutyTreeChild/{id}")
|
||
@ApiImplicitParam(name = "id",value = "id",required = true)
|
||
@ResponseBody
|
||
public MultiResult<DutyTrees> userDutyTreeChild(@PathVariable String id)throws Exception{
|
||
MultiResult<DutyTrees> result = new MultiResult<>();
|
||
List<DutyTrees> childrens = getChindTree(id);
|
||
if(null != childrens && childrens.size() > 0){
|
||
result.setData(childrens);
|
||
}else{
|
||
result.setCode(Code.NO_DATA.getCode());
|
||
result.setMessage(Message.NO_DATA);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
@ApiOperation(value = "首页本年隐患数据", notes = "首页本年隐患数据")
|
||
@GetMapping("/indexDangerNum/{userId}")
|
||
@ApiImplicitParam(name = "userId",required = true,value = "用户id")
|
||
@ResponseBody
|
||
public SingleResult<IndexDangerNum> indexDangerNum(@PathVariable String userId)throws Exception{
|
||
SingleResult<IndexDangerNum> result = new SingleResult<>();
|
||
|
||
IndexDangerNum indexDangerNum = new IndexDangerNum();
|
||
|
||
String areaCode = getUserArea(userId);
|
||
|
||
String year = Calendar.getInstance().get(Calendar.YEAR)+"";
|
||
year = TypeConversion.getCondition(year+"");
|
||
|
||
Integer total = 0;
|
||
Integer rectifyedNum = bookEntHTMapper.countByUserArea("已整改",year,areaCode);
|
||
Integer rectifyingNum = bookEntHTMapper.countByUserArea("整改中",year,areaCode);
|
||
Integer notRectifyNum = bookEntHTMapper.countByUserArea("未整改",year,areaCode);
|
||
total = rectifyedNum + rectifyingNum + notRectifyNum;
|
||
|
||
indexDangerNum.setTotal(total);
|
||
indexDangerNum.setRectifyedNum(rectifyedNum);
|
||
indexDangerNum.setRectifyingNum(rectifyingNum);
|
||
indexDangerNum.setNotRectifyNum(notRectifyNum);
|
||
|
||
result.setData(indexDangerNum);
|
||
return result;
|
||
}
|
||
|
||
@ApiOperation(value = "首页隐患统计", notes = "首页隐患统计")
|
||
@GetMapping("/indexAreaDangerNum/{userId}/{type}")
|
||
@ApiImplicitParams({
|
||
@ApiImplicitParam(name = "userId",required = true,value = "用户id"),
|
||
@ApiImplicitParam(name = "type",required = true,value = "类型 1、月 2、年")
|
||
})
|
||
@ResponseBody
|
||
public MultiResult<AreaDangerNum> indexAreaDangerNum(@PathVariable String userId,@PathVariable Integer type)throws Exception{
|
||
MultiResult<AreaDangerNum> result = new MultiResult<>();
|
||
|
||
String areaCode = getUserArea(userId);
|
||
|
||
String year = Calendar.getInstance().get(Calendar.YEAR)+"";
|
||
if(1 == type){
|
||
Integer month = Calendar.getInstance().get(Calendar.MONTH)+1;
|
||
if(month < 10){
|
||
year = year + "-0" + month;
|
||
}else{
|
||
year = year + "-" + month;
|
||
}
|
||
}
|
||
|
||
year = TypeConversion.getCondition(year+"");
|
||
List<AreaDangerNum> dangerNums = bookEntHTMapper.userAreaDangerNum(areaCode,year);
|
||
result.setData(dangerNums);
|
||
return result;
|
||
}
|
||
|
||
@ApiOperation(value = "首页机构检查信息", notes = "首页机构检查信息")
|
||
@GetMapping("/indexOrgInfo/{userId}")
|
||
@ApiImplicitParam(name = "userId",required = true,value = "用户id")
|
||
@ResponseBody
|
||
public SingleResult<IndexOrgInfo> indexOrgInfo(@PathVariable String userId)throws Exception{
|
||
SingleResult<IndexOrgInfo> result = new SingleResult<>();
|
||
|
||
String areaCode = getUserArea(userId);
|
||
|
||
String year = Calendar.getInstance().get(Calendar.YEAR)+"";
|
||
year = TypeConversion.getCondition(year+"");
|
||
|
||
Integer totalEnt = orgEnterpriseMapper.countOrgEntNum(areaCode);
|
||
Integer checkEntNum = orgBatchMapper.countCheckEntNum(areaCode,year);
|
||
Integer notCheckEntNum = totalEnt - checkEntNum;
|
||
|
||
Integer commonlyNum = orgDangerMapper.countByLevel(areaCode,year,2);
|
||
Integer majorNum = orgDangerMapper.countByLevel(areaCode,year,1);
|
||
|
||
IndexOrgInfo indexOrgInfo = new IndexOrgInfo();
|
||
indexOrgInfo.setTotalEnt(totalEnt);
|
||
indexOrgInfo.setCheckEntNum(checkEntNum);
|
||
indexOrgInfo.setNotCheckEntNum(notCheckEntNum);
|
||
indexOrgInfo.setCommonlyNum(commonlyNum);
|
||
indexOrgInfo.setMajorNum(majorNum);
|
||
result.setData(indexOrgInfo);
|
||
|
||
return result;
|
||
}
|
||
|
||
|
||
/**
|
||
* PC企业列表
|
||
* @return
|
||
*/
|
||
@ApiOperation(value = "PC企业列表", notes = "PC企业列表")
|
||
@GetMapping("/indexEntPage")
|
||
@ResponseBody
|
||
public SingleResult<Pager<SysEnterprise>> indexEntPage(@Valid IndexEntPageDto indexEntPageDto)throws Exception {
|
||
SingleResult singleResult = new SingleResult();
|
||
Pager<SysEnterprise> pager = new Pager<>();
|
||
|
||
|
||
String areaCode = getUserArea(indexEntPageDto.getUserId());
|
||
String condition = TypeConversion.getCondition(indexEntPageDto.getCondition());
|
||
|
||
|
||
PageHelper.startPage(indexEntPageDto.getPage(), indexEntPageDto.getPageSize());
|
||
Page<SysEnterprise> object = (Page<SysEnterprise>)sysEnterpriseMapper.userEntList(condition,areaCode);
|
||
getDatePage(pager,object);
|
||
if (object != null){
|
||
for(SysEnterprise enterprise : pager.getRows()){
|
||
String orgName = enterprise.getStreetName();
|
||
if(StringUtils.isNotBlank(enterprise.getCommunityName())){
|
||
orgName = orgName + "-" + enterprise.getCommunityName();
|
||
}
|
||
enterprise.setOrgName(orgName);
|
||
|
||
//隐患整改数量
|
||
Integer notRectificationCount = enterprise.getDangerCount() - enterprise.getRectifiedCount() - enterprise.getRectificationCount();
|
||
enterprise.setNotRectificationCount(notRectificationCount);
|
||
}
|
||
singleResult.setData(pager);
|
||
}else {
|
||
singleResult.setMessage(Message.NO_DATA);
|
||
singleResult.setCode(Code.NO_DATA.getCode());
|
||
}
|
||
return singleResult;
|
||
}
|
||
|
||
@ApiOperation(value = "首页代办事项", notes = "首页代办事项")
|
||
@GetMapping("/indexStayFactor/{userId}")
|
||
@ApiImplicitParam(name = "userId",required = true,value = "用户id")
|
||
@ResponseBody
|
||
public SingleResult<StayFactor> indexStayFactor(@PathVariable String userId)throws Exception{
|
||
SingleResult<StayFactor> result = new SingleResult<>();
|
||
StayFactor stayFactor = new StayFactor();
|
||
|
||
//岗位id
|
||
String listPerformId = "";
|
||
SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
|
||
if(null != sysUser){
|
||
listPerformId = sysUser.getSystitle();
|
||
}
|
||
|
||
Integer completeNum = oaTaskMapper.countComplete(listPerformId);
|
||
Integer overtimeNum = oaTaskMapper.countOvertime(listPerformId);
|
||
Integer conductNum = oaTaskMapper.countConduct(listPerformId);
|
||
stayFactor.setCompleteNum(completeNum);
|
||
stayFactor.setOvertimeNum(overtimeNum);
|
||
stayFactor.setConductNum(conductNum);
|
||
|
||
result.setData(stayFactor);
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 履职完成进度分页
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/9/27 14:13
|
||
*/
|
||
@ApiOperation(value = "履职完成进度", notes = "履职完成进度")
|
||
@GetMapping("/userPerform")
|
||
@ResponseBody
|
||
public SingleResult<Pager<UserPerformInfo>> userPerform(@Valid UserPerformDto userPerformDto,@Valid PageDto pageDto)throws Exception{
|
||
SingleResult<Pager<UserPerformInfo>> result = new SingleResult<>();
|
||
|
||
String condition = TypeConversion.getCondition(userPerformDto.getCondition());
|
||
|
||
String performId = userPerformDto.getPerformId();
|
||
if(StringUtils.isBlank(performId)){
|
||
performId = getUnitId(userPerformDto.getUserId());
|
||
}
|
||
//分页
|
||
PageHelper.startPage(pageDto.getPage(), pageDto.getPageSize());
|
||
Page<UserPerformInfo> page = (Page<UserPerformInfo>)listPerformMapper.userPerformInfo(condition,performId);
|
||
Pager<UserPerformInfo> pager = new Pager<>();
|
||
getDatePage(pager,page);
|
||
result.setData(pager);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* userPerformExport
|
||
* @version v1.0
|
||
* @author dong
|
||
* @date 2023/9/27 15:30
|
||
*/
|
||
@ApiOperation(value = "导出用户履职情况", notes = "导出用户履职情况")
|
||
@GetMapping("userPerformExport")
|
||
@ResponseBody
|
||
public void userPerformExport(@Valid UserPerformDto userPerformDto, HttpServletResponse response)throws Exception{
|
||
SingleResult<Pager<UserPerformInfo>> result = new SingleResult<>();
|
||
|
||
String condition = TypeConversion.getCondition(userPerformDto.getCondition());
|
||
|
||
String performId = userPerformDto.getPerformId();
|
||
if(StringUtils.isBlank(performId)){
|
||
performId = getUnitId(userPerformDto.getUserId());
|
||
}
|
||
List<UserPerformInfo> userPerformInfos = listPerformMapper.userPerformInfo(condition,performId);
|
||
if(null != userPerformInfos && userPerformInfos.size() > 0){
|
||
String excelName = "用户履职记录"+ DateUtils.getNowDateTimeStr("yyyyMMdd") +".xlsx";
|
||
long t1 = System.currentTimeMillis();
|
||
ExcelUtils.writeExcel(response, excelName,userPerformInfos, UserPerformInfo.class);
|
||
long t2 = System.currentTimeMillis();
|
||
System.out.println(String.format("write over! cost:%sms", (t2 - t1)));
|
||
}
|
||
}
|
||
|
||
|
||
}
|