2022-09-20 17:46:56 +08:00
|
|
|
package com.rzyc.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.common.utils.StringUtils;
|
2022-09-26 09:22:06 +08:00
|
|
|
import com.common.utils.encryption.PasswdFactory;
|
|
|
|
|
import com.common.utils.jwt.JwtUtil;
|
2022-09-20 17:46:56 +08:00
|
|
|
import com.common.utils.model.Code;
|
|
|
|
|
import com.common.utils.model.Message;
|
|
|
|
|
import com.common.utils.model.SingleResult;
|
2022-09-26 09:22:06 +08:00
|
|
|
import com.rzyc.bean.user.dto.LoginDto;
|
2022-09-20 17:46:56 +08:00
|
|
|
import com.rzyc.model.ent.SysEnterprise;
|
|
|
|
|
import com.rzyc.model.user.SysUnit;
|
2022-09-26 09:22:06 +08:00
|
|
|
import com.rzyc.model.user.SysUser;
|
2022-09-20 17:46:56 +08:00
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
2022-09-26 09:22:06 +08:00
|
|
|
import javax.validation.Valid;
|
2022-09-20 17:46:56 +08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author dong
|
|
|
|
|
* @date 2022-09-20 14:55
|
|
|
|
|
* @Version V1.0
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags = "企业系统")
|
|
|
|
|
@CrossOrigin("*")
|
|
|
|
|
@RequestMapping("pcCompany")
|
|
|
|
|
@Controller
|
|
|
|
|
@Validated
|
|
|
|
|
public class PcCompanyController extends BaseController{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* PC企业详细
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "PC企业详细", notes = "PC企业详细")
|
|
|
|
|
@ApiImplicitParams({
|
|
|
|
|
@ApiImplicitParam(name = "SysEnterpriseId", value = "公司id", required = true, dataType = "string")
|
|
|
|
|
})
|
|
|
|
|
@PostMapping("/companyDetail")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public SingleResult<String> companyDetail(String SysEnterpriseId)throws Exception {
|
|
|
|
|
SingleResult singleResult = new SingleResult();
|
|
|
|
|
List<SysEnterprise> sysEnterprises = sysEnterpriseMapper.companyDetail(SysEnterpriseId);
|
|
|
|
|
List<String>safeClass = new ArrayList<>();
|
|
|
|
|
if (StringUtils.isNotBlank(sysEnterprises.get(0).getBasesafeclassid())){
|
|
|
|
|
safeClass = super.exchange(sysEnterprises.get(0).getBasesafeclassid(),1);
|
|
|
|
|
}
|
|
|
|
|
List<String>incClass = new ArrayList<>();
|
|
|
|
|
if(StringUtils.isNotBlank(sysEnterprises.get(0).getBaseinclassid())){
|
|
|
|
|
incClass = super.exchange(sysEnterprises.get(0).getBaseinclassid(),2);
|
|
|
|
|
}
|
|
|
|
|
List<String>workClass = new ArrayList<>();
|
|
|
|
|
if(StringUtils.isNotBlank(sysEnterprises.get(0).getWorkClassId())){
|
|
|
|
|
incClass = super.exchange(sysEnterprises.get(0).getWorkClassId(),3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sysEnterprises.get(0).setInClassName(JSONArray.toJSONString(incClass));
|
|
|
|
|
sysEnterprises.get(0).setSafeClassName(JSONArray.toJSONString(safeClass));
|
|
|
|
|
sysEnterprises.get(0).setWorkClassName(JSONArray.toJSONString(incClass));
|
|
|
|
|
|
|
|
|
|
String orgName = sysEnterprises.get(0).getOrgName();
|
|
|
|
|
if(StringUtils.isNotBlank(sysEnterprises.get(0).getStreetName())){
|
|
|
|
|
orgName = orgName + "-" + sysEnterprises.get(0).getStreetName();
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(sysEnterprises.get(0).getCommunityName())){
|
|
|
|
|
orgName = orgName + "-" + sysEnterprises.get(0).getCommunityName();
|
|
|
|
|
}
|
|
|
|
|
sysEnterprises.get(0).setOrgName(orgName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SysUnit> units = sysUnitMapper.findUnit();
|
|
|
|
|
String sysUnitId = sysEnterprises.get(0).getSysUnitId();
|
|
|
|
|
String managerDept = sysEnterprises.get(0).getManagerDept();
|
|
|
|
|
String [] arr=sysUnitId.split(",");
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
|
|
for (String i:arr) {
|
|
|
|
|
for (SysUnit un:units) {
|
|
|
|
|
if (un.getSysunitid().equals(managerDept)){
|
|
|
|
|
sysEnterprises.get(0).setManagerDeptName(un.getUnitname());
|
|
|
|
|
}
|
|
|
|
|
if (un.getSysunitid().equals(i)){
|
|
|
|
|
stringBuilder.append(un.getUnitname()+",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(stringBuilder.toString())){
|
|
|
|
|
sysEnterprises.get(0).setSysUnitName(stringBuilder.toString().substring(0,stringBuilder.toString().length()-1));
|
|
|
|
|
}
|
|
|
|
|
if (sysEnterprises != null){
|
|
|
|
|
singleResult.setMessage(Message.SUCCESS);
|
|
|
|
|
singleResult.setData(sysEnterprises);
|
|
|
|
|
singleResult.setCode(Code.SUCCESS.getCode());
|
|
|
|
|
}else {
|
|
|
|
|
singleResult.setMessage(Message.ERROR);
|
|
|
|
|
singleResult.setCode(Code.ERROR.getCode());
|
|
|
|
|
}
|
|
|
|
|
return singleResult;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-26 09:22:06 +08:00
|
|
|
/**
|
|
|
|
|
* PC登录
|
|
|
|
|
* @param loginDto
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "PC登录", notes = "PC登录")
|
|
|
|
|
@PostMapping(value = "/pclogin")
|
|
|
|
|
@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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 17:46:56 +08:00
|
|
|
}
|