| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291 |
- package cn.com.goldenwater.dcproj.controller.ducha;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.constValue.AdCodeLabel;
- import cn.com.goldenwater.dcproj.constValue.CommonLabel;
- import cn.com.goldenwater.dcproj.dao.BisInspOrgDao;
- import cn.com.goldenwater.dcproj.dto.AddRlationPersDto;
- import cn.com.goldenwater.dcproj.dto.GroupLeaderDto;
- import cn.com.goldenwater.dcproj.dto.InspTypeDto;
- import cn.com.goldenwater.dcproj.dto.LoginDto;
- import cn.com.goldenwater.dcproj.dto.LoginUser;
- import cn.com.goldenwater.dcproj.dto.PersListDto;
- import cn.com.goldenwater.dcproj.model.BisInspAll;
- import cn.com.goldenwater.dcproj.model.BisInspAllRlation;
- import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
- import cn.com.goldenwater.dcproj.model.BisInspOrg;
- import cn.com.goldenwater.dcproj.model.BisInspPersOrg;
- import cn.com.goldenwater.dcproj.model.GwComFile;
- import cn.com.goldenwater.dcproj.model.InspType;
- import cn.com.goldenwater.dcproj.model.OlBisInspOrg;
- import cn.com.goldenwater.dcproj.param.BisInspAllParam;
- import cn.com.goldenwater.dcproj.param.BisInspAllRlationParam;
- import cn.com.goldenwater.dcproj.param.BisInspAllRlationPersParam;
- import cn.com.goldenwater.dcproj.param.BisInspOrgParam;
- import cn.com.goldenwater.dcproj.param.BisInspPersOrgParam;
- import cn.com.goldenwater.dcproj.param.GroupLeaderParam;
- import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
- import cn.com.goldenwater.dcproj.param.UpdateCallNumberParam;
- import cn.com.goldenwater.dcproj.param.UserListByCurUserParam;
- import cn.com.goldenwater.dcproj.param.UserRoleParam;
- import cn.com.goldenwater.dcproj.service.BisInspAllRlationPersService;
- import cn.com.goldenwater.dcproj.service.BisInspAllRlationService;
- import cn.com.goldenwater.dcproj.service.BisInspAllService;
- import cn.com.goldenwater.dcproj.service.BisInspMeetInvitationService;
- import cn.com.goldenwater.dcproj.service.BisInspPersOrgService;
- import cn.com.goldenwater.dcproj.service.GwComFileService;
- import cn.com.goldenwater.dcproj.service.LoginService;
- import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
- import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupPersService;
- import cn.com.goldenwater.dcproj.service.impl.system.OrganizationTreeImpl;
- import cn.com.goldenwater.dcproj.target.Authority;
- import cn.com.goldenwater.dcproj.target.Log;
- import cn.com.goldenwater.dcproj.target.VerifyBean;
- import cn.com.goldenwater.dcproj.util.Base64Util;
- import cn.com.goldenwater.dcproj.utils.*;
- import cn.com.goldenwater.id.util.UuidUtil;
- import cn.com.goldenwater.target.CheckException;
- import com.github.pagehelper.PageInfo;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.collections.MapUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.data.redis.core.RedisTemplate;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.util.Assert;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.web.multipart.MultipartFile;
- import javax.annotation.PostConstruct;
- import javax.servlet.http.HttpServletRequest;
- import java.io.File;
- import java.io.IOException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.Optional;
- import java.util.concurrent.TimeUnit;
- /**
- * @author zhaohg
- * @date 2019-2-23
- */
- @Api(value = "新用户管理", tags = "006新用户管理")
- @RestController
- @RequestMapping("/bis/insp")
- public class BisInspAllRlationPersController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Value("${api.url}")
- private String apiUrl;
- @Value("${smsCode}")
- private String smsCode;
- @Value("${getFile.prefix}")
- public String prefix;
- @Value("${web.upload-path}")
- public String fileDir;
- @Autowired
- private BisInspAllRlationPersService bisInspAllRlationPersService;
- @Autowired
- private BisInspAllRlationService bisInspAllRlationService;
- @Autowired
- private OrganizationTreeImpl organizationTree;
- @Autowired
- private GwComFileService gwComFileService;
- @Autowired
- private RedisTemplate redisTemplate;
- @Autowired
- private BisInspMeetInvitationService bisInspMeetInvitationService;
- @Autowired
- private TacInspYearBatchGroupPersService groupPersService;
- @Autowired
- private OlBisInspOrgService olBisInspOrgService;
- @Autowired
- private OlBisInspOrgService inspOrgService;
- @Autowired
- private BisInspPersOrgService persOrgService;
- @Autowired
- private LoginService loginService;
- @PostConstruct
- public void Cache() {
- Object newSmscode = redisTemplate.opsForValue().get("smsCode");
- if (newSmscode == null) {
- redisTemplate.opsForValue().set("smsCode", smsCode);
- }
- }
- @RequestMapping(value = "/test/{month}", method = {RequestMethod.GET})
- public BaseResponse test(@PathVariable String month) {
- // countTaskService.washWxPic(request);
- gwComFileService.changeSmallImg("2020", month);
- return buildSuccessResponse("更新完成!!");
- }
- @GetMapping("/getCaptchaImage")
- public BaseResponse getCaptcha() throws Exception {
- String uuid = UuidUtil.uuid();
- ImgResult imgResult = VerifyCodeUtils.VerifyCode(4);
- this.redisTemplate.opsForValue().set(uuid, imgResult.getCode(), 10L, TimeUnit.MINUTES);
- Map<String, Object> map = new HashMap<>(2);
- map.put("imgCodeId", uuid);
- map.put("img", imgResult.getImg());
- logger.info("--------------------imgCode:" + imgResult.getCode() + "------------------------------");
- return buildSuccessResponse(map);
- }
- @Log
- @ApiOperation(value = "用户发送短信", notes = "用户发送短信")
- @RequestMapping(value = "/sendMessage", method = {RequestMethod.POST})
- public BaseResponse sendMessage(@RequestParam(required = true) String phone, @RequestParam(required = false) String imgCodeId, @RequestParam(required = false) String code, HttpServletRequest request)
- throws Exception {
- if (code.length() != 4) {
- return buildFailResponse("验证码有误!");
- }
- String uuidCode = "";
- Object object = this.redisTemplate.opsForValue().get(imgCodeId);
- if (object != null) {
- uuidCode = object.toString();
- }
- String inputCode = Base64Util.encodeStr(code.toLowerCase());
- if (!(uuidCode.equalsIgnoreCase(inputCode))) {
- return buildFailResponse(1500, "您输入的验证码不正确或已过期,请点击验证码图片刷新,重新输入!");
- }
- uuidCode = UuidUtil.uuid();
- redisTemplate.opsForValue().set(phone, uuidCode + "_" + imgCodeId, 10L, TimeUnit.MINUTES);
- redisTemplate.delete(imgCodeId);
- redisTemplate.opsForValue().set(imgCodeId, uuidCode);
- boolean flag = this.bisInspAllRlationPersService.sendMessage(phone);
- if (flag) {
- return buildSuccessResponse();
- }
- return buildFailResponse(1002, "您还不是本系统用户,请联系系统管理员");
- }
- /**
- * 新版本登录接口
- *
- * @param loginDto phone、code
- * @param request 请求
- * @return 判断能否登录,登录成果返回用户信息
- */
- @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
- @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
- public BaseResponse loginByCode(@RequestBody LoginDto loginDto, HttpServletRequest request) {
- return loginService.login(loginDto, request);
- }
- /**
- * 手机号密码登录接口
- *
- * @param loginDto phone、pwd
- * @param request 请求
- * @return 判断能否登录,登录成果返回用户信息
- */
- @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
- @RequestMapping(value = "/loginByPwd", method = {RequestMethod.POST})
- public BaseResponse loginByPwd(@RequestBody LoginDto loginDto, HttpServletRequest request) {
- return loginService.loginByPwd(loginDto, request);
- }
- /**
- * 更新密码为m5加密后的
- *
- * @param
- */
- @ApiOperation(value = "更新密码为m5加密后的", notes = "更新密码为m5加密后的")
- @RequestMapping(value = "/updatePwdMd5", method = {RequestMethod.POST})
- public BaseResponse updatePwdMd5() {
- return loginService.updatePwdMd5();
- }
- // /**
- // * 旧版本登录接口
- // *
- // * @param phone 手机号
- // * @param code 验证码
- // * @param request 请求
- // * @return 判断能否登录,登录成果返回用户信息
- // */
- // @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
- // @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
- // public BaseResponse loginByCode(@RequestParam String phone, @RequestParam String code, HttpServletRequest request) {
- // if (code.length() != 6) {
- // return buildFailResponse("验证码有误!");
- // }
- // // 根据phone-code获取用户信息
- // BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.loginByCode(phone, code);
- // boolean logincode = true;
- // if (bisInspAllRlationPers == null) {
- // GwStaticUser gwStaticUser = gwStaticUserDao.get(phone);
- // if (gwStaticUser != null) {
- // String newSmscode = smsCode;
- // // 判断是否与固定验证码相同,相同时获取用户信息
- // if (newSmscode.equals(code)) {
- // BisInspAllRlationPersParam inspAllRlationPersParam = new BisInspAllRlationPersParam();
- // inspAllRlationPersParam.setMobilenumb(phone);
- // bisInspAllRlationPers = bisInspAllRlationPersService.getBy(inspAllRlationPersParam);
- // logincode = false;
- // }
- // }
- // }
- //
- // //发送信息成功后记录数据
- // if (logincode) {
- // String yzm = (String) redisTemplate.opsForValue().get(phone);
- // if (StringUtils.isBlank(yzm)) {
- // return buildFailResponse("图片验证码已经过期,请重新验证!!");
- // }
- // String[] arrays = yzm.split("_");
- // //验证码为arrays[0]
- // String yzmReal = (String) redisTemplate.opsForValue().get(arrays[1]);
- // if (StringUtils.isBlank(yzm) || "null".equals(yzm)) {
- // return buildFailResponse("图片验证码已经过期,请重新输入!!");
- // }
- // if (!yzmReal.equals(arrays[0])) {
- // return buildFailResponse("图片验证码已经过期,请重新验输入!");
- // }
- // redisTemplate.delete(phone);
- // redisTemplate.delete(arrays[1]);
- // }
- // if (bisInspAllRlationPers == null) {
- // BisInspAllRlationPersParam allRlationPersParam = new BisInspAllRlationPersParam();
- // allRlationPersParam.setMobilenumb(phone);
- // bisInspAllRlationPers = bisInspAllRlationPersService.getBy(allRlationPersParam);
- // if (bisInspAllRlationPers == null) {
- // return buildFailResponse(1002, "该手机号尚未注册", "", "");
- // }
- // return buildFailResponse(1001, "验证码错误", "", "");
- // } else {
- // bisInspAllRlationPers.setPwd(null);
- // bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
- // BisInspAllRlationPers pers = new BisInspAllRlationPers();
- // pers.setGuid(bisInspAllRlationPers.getGuid());
- // pers.setLoginTm(new Date());
- // if (StringUtils.isBlank(bisInspAllRlationPers.getPersType())) {
- // bisInspAllRlationPers.setPersType("3");
- // pers.setPersType("3");
- // }
- // bisInspAllRlationPersService.update(pers);
- // String uuid = UuidUtil.uuid();
- // bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.ADD.getNumber());
- // String accessToken = JWTTokenUtil.sign(bisInspAllRlationPersService.getLoginUser(bisInspAllRlationPers), bisInspAllRlationPers.getGuid());
- //
- // redisTemplate.opsForValue().set(uuid, accessToken, JWTTokenUtil.maxAge, TimeUnit.MILLISECONDS);
- // redisTemplate.opsForValue().set(uuid + bisInspAllRlationPers.getGuid(), accessToken, JWTTokenUtil.refreshmaxAge, TimeUnit.MILLISECONDS);
- // bisInspAllRlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhone(bisInspAllRlationPers.getMobilenumb()));
- // return buildSuccessResponse(bisInspAllRlationPers, uuid);
- // }
- // }
- /**
- * 江苏数字看板、 需要手机号码模拟登陆。
- *
- * @param map 手机号码
- * @param request
- * @return
- */
- @ApiOperation(value = "", notes = "")
- @RequestMapping(value = "/getTokenByTel", method = {RequestMethod.POST})
- public BaseResponse<Object> loginByPhone(@RequestBody Map<String, String> map, HttpServletRequest request) {
- // 判断是否与固定验证码相同,相同时获取用户信息
- BisInspAllRlationPersParam inspAllRlationPersParam = new BisInspAllRlationPersParam();
- inspAllRlationPersParam.setMobilenumb(map.get("phone"));
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.getBy(inspAllRlationPersParam);
- if (bisInspAllRlationPers == null) {
- return buildFailResponse(1002, "该手机号尚未注册", "", "");
- }
- bisInspAllRlationPers.setPwd(null);
- bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
- BisInspAllRlationPers pers = new BisInspAllRlationPers();
- pers.setGuid(bisInspAllRlationPers.getGuid());
- pers.setLoginTm(new Date());
- if (StringUtils.isBlank(bisInspAllRlationPers.getPersType())) {
- bisInspAllRlationPers.setPersType("3");
- pers.setPersType("3");
- }
- bisInspAllRlationPersService.update(pers);
- String uuid = UuidUtil.uuid();
- //bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.ADD.getNumber());
- String accessToken = JWTTokenUtil.sign(bisInspAllRlationPersService.getLoginUser(bisInspAllRlationPers), bisInspAllRlationPers.getGuid());
- redisTemplate.opsForValue().set(uuid, accessToken, JWTTokenUtil.maxAge, TimeUnit.MILLISECONDS);
- redisTemplate.opsForValue().set(uuid + bisInspAllRlationPers.getGuid(), accessToken, JWTTokenUtil.refreshmaxAge, TimeUnit.MILLISECONDS);
- bisInspAllRlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhone(bisInspAllRlationPers.getMobilenumb()));
- // TODO 有时间做个加密处理
- return buildSuccessResponse(bisInspAllRlationPers, uuid);
- }
- @Autowired
- private BisInspOrgDao bisInspOrgDao;
- private BisInspAllRlationPers getBisInspAllRlations(BisInspAllRlationPers bisInspAllRlationPers) {
- // 1.设置默认显示机构和所能看到的所有机构
- BisInspOrg bisInspOrg = new BisInspOrg();
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getOrgId())) {
- // 设置所有能看到的机构
- BisInspOrgParam inspOrgParam = new BisInspOrgParam();
- inspOrgParam.setPersId(bisInspAllRlationPers.getGuid());
- List<BisInspOrg> inspOrgList = bisInspOrgDao.findPersOrgList(inspOrgParam);
- bisInspAllRlationPers.setAllOrg(inspOrgList);
- String orgId = bisInspAllRlationPers.getOrgId();
- // 获取所有orgId 判断用户所属机构是否在其中,没有 选择第一个机构 为默认机构
- if (inspOrgList != null && inspOrgList.size() > 0) {
- orgId = inspOrgList.get(0).getOrgId();
- for (BisInspOrg org : inspOrgList) {
- if (org.getOrgId().equals(bisInspAllRlationPers.getOrgId())) {
- orgId = bisInspAllRlationPers.getOrgId();
- break;
- }
- }
- }
- bisInspOrg = olBisInspOrgService.getDefaultOrg(orgId);
- bisInspAllRlationPers.setDefaultOrg(bisInspOrg);
- }
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getGuid())) {
- List<BisInspAll> allNode = organizationTree.getAllNode(bisInspAllRlationPers.getGuid(), "", bisInspAllRlationPers.getOrgId(), "", "", "", "", "");
- if (allNode.size() > 0) {
- StringBuffer s = new StringBuffer();
- s.append("1");
- String sk = "0";
- String ry = "000";
- String sh = "0";
- String ogc = "0";
- String dxs = "0";
- String sz = "0";
- String sd = "0";
- for (BisInspAll b : allNode) {
- if ("001".equals(b.getId().substring(0, 3))) {
- sk = "1";
- }
- if ("002".equals(b.getId().substring(0, 3))) {
- ry = "111";
- }
- if ("003".equals(b.getId().substring(0, 3))) {
- sh = "1";
- }
- if ("004".equals(b.getId().substring(0, 3))) {
- ogc = "1";
- }
- if ("005".equals(b.getId().substring(0, 3))) {
- dxs = "1";
- }
- if ("006".equals(b.getId().substring(0, 3))) {
- sz = "1";
- }
- if ("011".equals(b.getId().substring(0, 3))) {
- sd = "1";
- }
- }
- s.append(sk).append(ry).append(sh).append(ogc).append(dxs).append(sz).append(sd);
- bisInspAllRlationPers.setJurisdiction(s.toString());
- } else {
- bisInspAllRlationPers.setJurisdiction("100000000");
- }
- bisInspAllRlationPers.setAllNode(allNode);
- }
- return bisInspAllRlationPers;
- }
- @Authority(roles = "1")
- @ApiOperation(value = "添加人员")
- @RequestMapping(value = "/insert", method = {RequestMethod.POST})
- @Transactional(rollbackFor = Exception.class)
- public BaseResponse insert(@RequestParam(value = "file", required = false) MultipartFile file, BisInspAllRlationPers bisInspAllRlationPers) throws Exception {
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- if (inspAllRlationPers == null) {
- return buildFailResponse("当前用户不存在!!");
- }
- if (!"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- if (file != null) {
- Calendar dat = Calendar.getInstance();
- //写入文件
- String originalFilename = file.getOriginalFilename();
- GwComFile gwComFile = new GwComFile();
- String uuid = UuidUtil.uuid();
- gwComFile.setId(uuid);
- gwComFile.setFileName(originalFilename);
- gwComFile.setFileSize((double) file.getSize());
- gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
- String filePath = prefix + dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH) + File.separator + uuid + "." + gwComFile.getFileExt();
- gwComFile.setFilePath(filePath);
- if (!FileExtUtil.valFileExt(gwComFile.getFileExt())) {
- return buildFailResponse(9993, "文件类型允许!!");
- }
- //写入文件
- String filePath2 = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
- gwComFileService.writeFile(gwComFile, file, filePath2);
- bisInspAllRlationPers.setImgurl(filePath);
- }
- BisInspAllRlationPers p = bisInspAllRlationPersService.createUser(bisInspAllRlationPers);
- return buildSuccessResponse(p.getGuid());
- }
- private void addPreOrg(BisInspAllRlationPers bisInspAllRlationPers) {
- //先删除授权,再添加机构授权
- BisInspPersOrgParam persOrgParam = new BisInspPersOrgParam();
- persOrgParam.setPersId(bisInspAllRlationPers.getGuid());
- persOrgService.deleteBy(persOrgParam);
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getOrgId())) {
- OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(bisInspAllRlationPers.getOrgId());
- if (olBisInspOrg != null) {
- bisInspAllRlationPers.setOrgNm(olBisInspOrg.getOrgNm());
- bisInspAllRlationPers.setProvince(olBisInspOrg.getAdCode());
- }
- BisInspPersOrg inspPersOrg = new BisInspPersOrg();
- inspPersOrg.setOrgId(bisInspAllRlationPers.getOrgId());
- inspPersOrg.setPersId(bisInspAllRlationPers.getGuid());
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getPersType())) {
- inspPersOrg.setUserType(bisInspAllRlationPers.getPersType());
- } else {
- inspPersOrg.setUserType(AdCodeLabel.GROUP_LEADER);
- }
- BisInspPersOrgParam bisInspPersOrgParam = new BisInspPersOrgParam();
- bisInspPersOrgParam.setPersId(inspPersOrg.getPersId());
- bisInspPersOrgParam.setOrgId(inspPersOrg.getOrgId());
- if (null == persOrgService.getBy(bisInspPersOrgParam)) {
- persOrgService.insert(inspPersOrg);
- }
- }
- }
- @ApiOperation(value = "根据id获取人员(对象详情)")
- @RequestMapping(value = "/{id}", method = {RequestMethod.GET})
- public BaseResponse<BisInspAllRlationPers> info(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- String currentPersId = getCurrentPersId();
- BisInspAllRlationPers rlationPers = bisInspAllRlationPersService.getById(id);
- BisInspAllRlationPers currentPers = bisInspAllRlationPersService.getById(currentPersId);
- rlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhoneNotExc(rlationPers.getMobilenumb()));
- if (rlationPers != null) {
- rlationPers.setPwd(null);
- if (!"1".equals(currentPers.getPersType()) && !getCurrentPersId().equals(rlationPers.getGuid())) {
- rlationPers = null;
- }
- }
- return buildSuccessResponse(rlationPers);
- }
- @Authority(roles = "1")
- @ApiOperation(value = "根据ID删除人员")
- @RequestMapping(value = "/delete/{id}", method = {RequestMethod.POST})
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- if ("80df1213ad9f493e85a771d6f4b18a17".equals(id)) {
- return buildFailResponse("管理员账户不允许删除!");
- }
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(id);
- int ret = bisInspAllRlationPersService.delete(id);
- /**
- * 删除小鱼账号信息
- */
- try {
- bisInspMeetInvitationService.batchUsersDel(bisInspAllRlationPers);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return buildSuccessResponse();
- }
- @ApiOperation(value = "绑定人员机构关系")
- @RequestMapping(value = "/add/presorg", method = {RequestMethod.POST})
- public BaseResponse<List<BisInspPersOrg>> presorg(@RequestBody List<BisInspPersOrg> inspPersOrgList) {
- if (inspPersOrgList == null || inspPersOrgList.isEmpty()) {
- return buildFailResponse();
- }
- //先删除
- BisInspPersOrgParam persOrgParam = new BisInspPersOrgParam();
- BisInspPersOrg inspPersOrgOne = inspPersOrgList.get(0);
- persOrgParam.setPersId(inspPersOrgOne.getPersId());
- if (StringUtils.isNotBlank(inspPersOrgOne.getPersId())) {
- persOrgService.deleteBy(persOrgParam);
- }
- //添加
- for (BisInspPersOrg inspPersOrg : inspPersOrgList) {
- inspPersOrg.setUserType(AdCodeLabel.GROUP_LEADER);
- persOrgService.insert(inspPersOrg);
- }
- /* OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(inspPersOrgOne.getOrgId());
- if (olBisInspOrg != null) {
- //更新默认
- BisInspAllRlationPers inspAllRlationPers = new BisInspAllRlationPers();
- inspAllRlationPers.setOrgId(inspPersOrgOne.getOrgId());
- inspAllRlationPers.setOrgNm(olBisInspOrg.getOrgNm());
- inspAllRlationPers.setGuid(inspPersOrgOne.getPersId());
- bisInspAllRlationPersService.update(inspAllRlationPers);
- }*/
- return buildSuccessResponse(inspPersOrgList);
- }
- @Autowired
- private BisInspAllService bisInspAllService;
- @ApiOperation(value = "获取系统中的所有督查类型")
- @RequestMapping(value = "/listInspType", method = {RequestMethod.GET})
- public BaseResponse<List<InspType>> listInspType() {
- return buildSuccessResponse(bisInspAllService.listInspType());
- }
- @Authority(roles = "1")
- @ApiOperation(value = "获取系统中的已经绑定的所有督查类型")
- @RequestMapping(value = "/list/{orgId}/{persId}", method = {RequestMethod.GET})
- public BaseResponse<List<BisInspAllRlation>> listBindInspType(@PathVariable String orgId, @PathVariable String persId) {
- BisInspAllParam inspAllRParam = new BisInspAllParam();
- inspAllRParam.setOrgId(orgId);
- String province = inspOrgService.getProvince(orgId);
- inspAllRParam.setProvince(province);
- inspAllRParam.setPersId(persId);
- List<BisInspAllRlation> inspAllRlationList = bisInspAllService.findExistList(inspAllRParam);
- for (BisInspAllRlation allRlation : inspAllRlationList) {
- String id = allRlation.getId().substring(0, 3);
- allRlation.setId(id);
- allRlation.setPersid(persId);
- allRlation.setAdCode(province);
- }
- return buildSuccessResponse(inspAllRlationList);
- }
- @Authority(roles = "1")
- @ApiOperation(value = "删除系统中的已经绑定的所有督查类型,code位类型编码,如001小水库")
- @RequestMapping(value = "/del/{orgId}/{persId}/{code}", method = {RequestMethod.GET})
- public BaseResponse<String> delBindInspType(@PathVariable String orgId, @PathVariable String persId, @PathVariable String code) {
- String id = code + orgId;
- BisInspAllParam inspAllParam = new BisInspAllParam();
- inspAllParam.setPid(id);
- List<BisInspAll> inspAlls = bisInspAllService.findList(inspAllParam);
- if (inspAlls != null && !inspAlls.isEmpty()) {
- return buildFailResponse("删除失败,改督查类型已经存在关联数据!!");
- }
- bisInspAllService.delete(id);
- return buildSuccessResponse("删除成功");
- }
- @ApiOperation(value = "个人账户更新登录")
- @RequestMapping(value = "/updatePassword", method = {RequestMethod.POST})
- public BaseResponse updatePassword(@RequestBody BisInspAllRlationPers bisInspAllRlationPers) {
- String currentPersId = getCurrentPersId();
- BisInspAllRlationPers currentPers = bisInspAllRlationPersService.getById(currentPersId);
- if (currentPersId != bisInspAllRlationPers.getGuid()) {
- if (!currentPers.getPersType().equals("1")) {
- return buildFailResponse("无权限操作!");
- }
- }
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getGuid()) && StringUtils.isNotBlank(bisInspAllRlationPers.getPwd())) {
- bisInspAllRlationPers.setPwd(MD5.getMD5(aesUtil.desEncrypt(bisInspAllRlationPers.getPwd())));
- bisInspAllRlationPersService.updatePassword(bisInspAllRlationPers);
- }
- return buildSuccessResponse();
- }
- @Autowired
- private BisInspAllRlationService rlationService;
- @Authority(roles = "1")
- @ApiOperation(value = "管理员绑定人员管理员和督查类型")
- @RequestMapping(value = "/add/inspType", method = {RequestMethod.POST})
- @Transactional(rollbackFor = Exception.class)
- public BaseResponse<List<InspType>> addInspType(@RequestBody List<InspType> inspTypeList, String delPersId, String delOrgId) {
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- if (inspAllRlationPers == null) {
- return buildFailResponse("当前用户不存在!!");
- }
- if (!"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- // 1. 获取 OrgId、 persId、 province 删除所有 与用户-省关联的 数据
- BisInspAllRlationParam bisInspAllRlationParam = new BisInspAllRlationParam();
- OlBisInspOrg bisInspOrg = null;
- // 判断 inspTypeList 是否为空,空就只删除数据,不添加数据
- if (inspTypeList.size() == 0) {
- bisInspAllRlationParam.setOrgId(delOrgId);
- bisInspAllRlationParam.setPersid(delPersId);
- bisInspAllRlationParam.setProvince(inspOrgService.get(delOrgId).getRlcode());
- rlationService.deleteBy(bisInspAllRlationParam);
- return buildSuccessResponse();
- } else {
- InspType inspTypeOne = inspTypeList.get(0);
- bisInspAllRlationParam.setOrgId(inspTypeOne.getOrgId());
- bisInspAllRlationParam.setPersid(inspTypeOne.getPersId());
- bisInspOrg = inspOrgService.get(inspTypeOne.getOrgId());
- bisInspAllRlationParam.setProvince(bisInspOrg.getRlcode());
- rlationService.deleteBy(bisInspAllRlationParam);
- }
- // 2. 循环要添加的督查类别, 添加督查类别
- for (InspType inspType : inspTypeList) {
- BisInspAll rootBisInsp = bisInspAllService.get(inspType.getCode());
- // 如果没有这个督查类别就添加督查类别
- if (rootBisInsp == null) {
- rootBisInsp = new BisInspAll();
- rootBisInsp.setId(inspType.getCode());
- rootBisInsp.setPnm(inspType.getName());
- rootBisInsp.setPid(CommonLabel.INIT_DATA);
- bisInspAllService.insert(rootBisInsp);
- }
- String orgId = inspType.getOrgId();
- if (inspType.getOrgId().length() == 2) {
- orgId = "0" + orgId;
- }
- // 添加 督查 BisInspAll tree
- String id = inspType.getCode() + orgId;
- BisInspAll inspAll = bisInspAllService.get(id);
- if (inspAll == null) {
- inspAll = new BisInspAll();
- inspAll.setOrgId(inspType.getOrgId());
- inspAll.setId(id);
- inspAll.setPnm(bisInspOrg.getOrgNm() + inspType.getName());
- inspAll.setPid(inspType.getCode());
- inspAll.setProvince(bisInspOrg.getRlcode());
- if (AdCodeLabel.PARENT_ADCODE.equals(bisInspOrg.getRlcode())) {
- inspAll.setProvince("");
- }
- bisInspAllService.insert(inspAll);
- }
- // 重点添加督查 BisInspAllRlation
- BisInspAllRlationParam rlationParam = new BisInspAllRlationParam();
- rlationParam.setPersid(inspType.getPersId());
- rlationParam.setId(id);
- rlationParam.setProvince(bisInspOrg.getRlcode());
- BisInspAllRlation allRlation = rlationService.getBy(rlationParam);
- if (allRlation == null) {
- allRlation = new BisInspAllRlation();
- allRlation.setAdCode(bisInspOrg.getRlcode());
- if (AdCodeLabel.PARENT_ADCODE.equals(bisInspOrg.getRlcode())) {
- allRlation.setAdCode("");
- }
- allRlation.setPersid(inspType.getPersId());
- allRlation.setId(id);
- BisInspAllRlationPers allRlationPers = bisInspAllRlationPersService.get(inspType.getPersId());
- if (allRlationPers != null) {
- allRlation.setPertype(allRlationPers.getPersType());
- }
- allRlation.setOrgId(orgId);
- allRlation.setType(String.valueOf(Integer.parseInt(inspType.getCode())));
- rlationService.insert(allRlation);
- }
- }
- return buildSuccessResponse(inspTypeList);
- }
- @Authority(roles = "1")
- @ApiOperation(value = "管理员绑定人员管理员和督查类型")
- @RequestMapping(value = "/batchAdd/inspType", method = {RequestMethod.POST})
- @Transactional(rollbackFor = Exception.class)
- public BaseResponse batchAddInspType(@RequestBody InspTypeDto inspTypeDto) {
- if (CollectionUtils.isEmpty(inspTypeDto.getPersIdList()) && CollectionUtils.isEmpty(inspTypeDto.getPhoneList())) {
- return buildFailResponse();
- }
- if (CollectionUtils.isEmpty(inspTypeDto.getInspTypeList())) {
- return buildFailResponse();
- }
- List<InspType> inspTypeList = inspTypeDto.getInspTypeList();
- if (CollectionUtils.isNotEmpty(inspTypeDto.getPersIdList())) {
- inspTypeDto.getPersIdList().forEach(persId -> {
- BisInspAllRlationPers p = bisInspAllRlationPersService.get(persId);
- Optional.ofNullable(p).ifPresent(per -> {
- for (InspType inspType : inspTypeList) {
- inspType.setPersId(per.getGuid());
- inspType.setOrgId(per.getOrgId());
- }
- addInspType(inspTypeList, per.getGuid(), per.getOrgId());
- });
- });
- } else {
- inspTypeDto.getPhoneList().forEach(phone -> {
- BisInspAllRlationPers p = bisInspAllRlationPersService.getBy(Builder.of(BisInspAllRlationPersParam::new)
- .with(BisInspAllRlationPersParam::setMobilenumb, phone)
- .build());
- Optional.ofNullable(p).ifPresent(per -> {
- for (InspType inspType : inspTypeList) {
- inspType.setPersId(per.getGuid());
- inspType.setOrgId(per.getOrgId());
- }
- addInspType(inspTypeList, per.getGuid(), per.getOrgId());
- });
- });
- }
- return buildSuccessResponse();
- }
- @Authority(roles = "1")
- @ApiOperation(value = "更新人员信息")
- @RequestMapping(value = "/update", method = {RequestMethod.POST})
- public BaseResponse update(@RequestParam(value = "file", required = false) MultipartFile file,
- @ApiParam(name = "bisInspAllRlationPers", value = "BisInspAllRlationPers", required = true)
- BisInspAllRlationPers bisInspAllRlationPers) {
- Assert.notNull(bisInspAllRlationPers.getGuid(), "主键guid为必填参数");
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- if (inspAllRlationPers == null) {
- return buildFailResponse("当前用户不存在!!");
- }
- if (!getCurrentPersId().equals(bisInspAllRlationPers.getGuid()) && !"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- if (file != null) {
- Calendar dat = Calendar.getInstance();
- //写入文件
- String originalFilename = file.getOriginalFilename();
- GwComFile gwComFile = new GwComFile();
- gwComFile.setId(bisInspAllRlationPers.getGuid());
- gwComFile.setFileName(originalFilename);
- gwComFile.setFileSize((double) file.getSize());
- gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
- String filePath = prefix + dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH) + File.separator + bisInspAllRlationPers.getGuid() + "." + gwComFile.getFileExt();
- gwComFile.setFilePath(filePath);
- if ("JPEG".equals(gwComFile.getFileExt().toUpperCase()) || "JPG".equals(gwComFile.getFileExt().toUpperCase()) || "PNG".equals(gwComFile.getFileExt().toUpperCase())) {
- //写入文件
- String filePath2 = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
- gwComFileService.writeFile(gwComFile, file, filePath2);
- bisInspAllRlationPers.setImgurl(filePath);
- }
- }
- // addPreOrg(bisInspAllRlationPers);
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getPwd())) {
- bisInspAllRlationPers.setPwd(MD5.getMD5(aesUtil.desEncrypt(bisInspAllRlationPers.getPwd().replace(" ", "+"))));
- }
- bisInspAllRlationPersService.update(bisInspAllRlationPers);
- /* //添加人员到小鱼账号
- try {
- bisInspMeetInvitationService.batchUser(bisInspAllRlationPers);
- } catch (IOException e) {
- e.printStackTrace();
- }*/
- return buildSuccessResponse(bisInspAllRlationPers);
- }
- @Authority(roles = "1")
- @ApiOperation(value = "批量更新人员信息")
- @PostMapping("/batchUpdateType")
- public BaseResponse batchUpdateType(@RequestBody Map<String, Object> params) {
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- Optional.ofNullable(inspAllRlationPers).orElseThrow(() -> new CheckException("当前用户不存在!!"));
- if (!"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- List<String> persIdList = (List<String>) params.get("persIdList");
- String persType = MapUtils.getString(params, "persType");
- if (CollectionUtils.isEmpty(persIdList)) {
- return buildFailResponse("persIdList is blank");
- }
- if (StringUtils.isBlank(persType)) {
- return buildFailResponse("persType is blank");
- }
- BisInspAllRlationPers p = new BisInspAllRlationPers();
- p.setPersType(persType);
- persIdList.forEach(id -> {
- p.setGuid(id);
- bisInspAllRlationPersService.update(p);
- });
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据条件获取人员信息列表", notes = "参数字段说明:{\n\r" +
- " \"guid\":\"人员ID\",\n\r" +
- " \"orgId\":\"机构Id\",\n\r" +
- " \"orgNm\":\"机构名称\",\n\r" +
- " \"dpnm\":\"部门名称\",\n\r" +
- " \"dppost\":\"职称\",\n\r" +
- " \"school\":\"学校\",\n\r" +
- " \"persName\":\"姓名\",\n\r" +
- " };\n\r" +
- "返回结构说明: {\n\r" +
- " \"code\":\"请求状态码\",\n\r" +
- " \"data(数据信息对象) \": {\n\r" +
- " \"endRow\":\"尾行\",\n\r" +
- " \"firstPage\":\"首页\",\n\r" +
- " \"hasNextPage\":\"是否有下一页\",\n\r" +
- " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
- " \"isFirstPage\":\"是否是第一页\",\n\r" +
- " \"isLastPage\":\"是否是最后一页\",\n\r" +
- " \"lastPage\":\"最后页\",\n\r" +
- " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
- " \"list(结果集)\":[\n\r" +
- " {\n\r" +
- " \"guid\":\"人员ID\",\n\r" +
- " \"orgId\":\"机构ID\",\n\r" +
- " \"orgNm\":\"机构名称\",\n\r" +
- " \"admDuty\":\"职务\",\n\r" +
- " \"orgGrad\":\"职责\",\n\r" +
- " \"idnm\":\"工作证号\",\n\r" +
- " \"plst\":\"政治面貌\",\n\r" +
- " \"school\":\"学校\",\n\r" +
- " \"specialty\":\"专业\",\n\r" +
- " \"imgurl\":\"照片地址\",\n\r" +
- " \"persName\":\"人员姓名\",\n\r" +
- " \"pwd\":\"密码\",\n\r" +
- " \"telnumb\":\"电话号码\",\n\r" +
- " \"mobilenumb\":\"手机号码\",\n\r" +
- " \"email\":\"邮箱\",\n\r" +
- " \"bornDate\":\"出生日期\",\n\r" +
- " \"collTime\":\"录入日期\",\n\r" +
- " \"remark\":\"备注\",\n\r" +
- " \"faxnumb\":\"传真号码\",\n\r" +
- " }\n\r" +
- " ],\n\r" +
- " \"navigateFirstPage\":\"未知\",\n\r" +
- " \"navigateLastPage\":\"未知\",\n\r" +
- " \"navigatePages\":\"未知\",\n\r" +
- " \"list(结果集)\":[\n\r" +
- " ],\n\r" +
- " \"nextPage\":\"下一页\",\n\r" +
- " \"pageNum\":\"页码\",\n\r" +
- " \"pageSize\":\"每页多少条\",\n\r" +
- " \"pages\":\"总页数\",\n\r" +
- " \"prePage\":\"前一页\",\n\r" +
- " \"size\":\"未知\",\n\r" +
- " \"startRow\":\"未知\",\n\r" +
- " \"total\":\"总条数\",\n\r" +
- " },\n\r" +
- " \"message\":\"响应消息\",\n\r" +
- " \"path\":\"路径\",\n\r" +
- " \"success\":\"是否成功\",\n\r" +
- " \"throwable\":\"异常\",\n\r" +
- " }")
- @Authority(roles = "1")
- @RequestMapping(value = "/list", method = {RequestMethod.POST})
- public BaseResponse<PageInfo<PersListDto>> list(@RequestBody BisInspAllRlationPersParam p) {
- PageInfo<PersListDto> list = bisInspAllRlationPersService.findPersData(p);
- for (int i = 0; i < list.getList().size(); i++) {
- String tel = list.getList().get(i).getMobilenumb() == null ? "" : list.getList().get(i).getMobilenumb().toString();
- if (!"".equals(tel)) {
- list.getList().get(i).setMobilenumb(TelUtil.getTel(tel));
- }
- }
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "根据id获取人员(对象详情)")
- @RequestMapping(value = "/createWork", method = {RequestMethod.GET})
- public BaseResponse<String> createWork() {
- boolean bol = bisInspAllRlationPersService.createWork();
- return buildSuccessResponse("true");
- }
- @ApiOperation(value = "设置组长")
- @RequestMapping(value = "/setHeadMan", method = {RequestMethod.GET})
- public BaseResponse setHeadMan(@ApiParam(name = "BisInspAllRlation", value = "BisInspAllRlation", required = true) BisInspAllRlation bisInspAllRlation) {
- int i = bisInspAllRlationPersService.setHeadMan(bisInspAllRlation);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "修改密码", notes = "参数字段说明:{\n\r" +
- " \"userCode\":\"用户编码\",\n\r" +
- " \"oldPassword\":\"旧密码\",\n\r" +
- " \"newPassword\":\"新 密码\",\n\r" +
- " };\n\r" +
- "返回结构说明:{\n\r" +
- " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
- " \"code\":\"错误代码\",\n\r" +
- " \"message\":\"描述信息\",\n\r" +
- " \"throwable\":\"异常信息\",\n\r" +
- " \"data\":null")
- @RequestMapping(value = "changePassword", method = RequestMethod.POST)
- public BaseResponse changePassword(String userCode, String password, String newPassword) {
- Assert.notNull(userCode, "主键id为必填参数");
- Assert.notNull(password, "修改前密码不能为空");
- Assert.notNull(newPassword, "新密码不能为空");
- int ret = bisInspAllRlationPersService.changePassword(userCode, password, newPassword);
- if (0 == ret) {
- return buildFailResponse(0, "用户不存在");
- }
- if (2 == ret) {
- return buildFailResponse(2, "原密码错误,修改密码失败");
- }
- return buildSuccessResponse();
- }
- @ApiOperation(value = "修改用户(关联角色)")
- @RequestMapping(value = "updateUser", method = RequestMethod.POST)
- public BaseResponse<String> updateUser(@ApiParam(name = "bisInspAllRlationPers", value = "bisInspAllRlationPers", required = true) @RequestBody BisInspAllRlationPers bisInspAllRlationPers) {
- Assert.notNull(bisInspAllRlationPers, "用户对象不能为空");
- Assert.notNull(bisInspAllRlationPers.getGuid(), "用户ID不能为空");
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- if (inspAllRlationPers == null) {
- return buildFailResponse("当前用户不存在!!");
- }
- //只有管理员能够操作
- if (!"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- logger.info("修改用户权限1");
- ArrayList<UserRoleParam> userRoleParams = new ArrayList<>();
- if (null != bisInspAllRlationPers.getRoleIds() && bisInspAllRlationPers.getRoleIds().size() > 0) {
- for (String roleId : bisInspAllRlationPers.getRoleIds()) {
- UserRoleParam userRoleParam = new UserRoleParam();
- userRoleParam.setUserId(bisInspAllRlationPers.getGuid());
- userRoleParam.setRoleId(roleId);
- userRoleParams.add(userRoleParam);
- }
- }
- UserRoleParam param = new UserRoleParam();
- param.setUserId(bisInspAllRlationPers.getGuid());
- BisInspAllRlationPers per = new BisInspAllRlationPers();
- per.setGuid(bisInspAllRlationPers.getGuid());
- if (StringUtils.isNotBlank(bisInspAllRlationPers.getOwnerSystem())) {
- per.setOwnerSystem(bisInspAllRlationPers.getOwnerSystem());
- bisInspAllRlationPersService.update(per);
- }
- logger.info("修改用户权限2");
- bisInspAllRlationPersService.updateUser(userRoleParams, param);
- logger.info("修改用户权限3");
- /* //修改用户类型,为用户添加节点
- if (bisInspAllRlationPers.getPersType() != null) {
- bisInspAllRlationPersService.updateUserNode(bisInspAllRlationPers.getGuid(), bisInspAllRlationPers.getPersType(), getCurrentOrgId());
- }*/
- return buildSuccessResponse();
- }
- @Authority(roles = "1")
- @ApiOperation(value = "修改用户(关联角色)")
- @PostMapping("/batch/updateRole")
- public BaseResponse batchUpdateRole(@RequestBody Map<String, Object> params) {
- BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
- if (inspAllRlationPers == null) {
- return buildFailResponse("当前用户不存在!!");
- }
- //只有管理员能够操作
- if (!"1".equals(inspAllRlationPers.getPersType())) {
- return buildFailResponse(9993, "当前用户无权限执行该操作!!");
- }
- List<String> roleIds = (List<String>) params.get("roleIds");
- List<String> persIdList = (List<String>) params.get("persIdList");
- if (CollectionUtils.isEmpty(persIdList) || CollectionUtils.isEmpty(roleIds)) {
- return buildFailResponse("roleIds or persIdList is blank");
- }
- persIdList.stream().distinct().forEach(id -> updateRole(id, roleIds));
- return buildSuccessResponse();
- }
- /**
- * 更新用户角色
- *
- * @param guid 用户ID
- * @param roleIds 角色ID
- */
- private void updateRole(String guid, List<String> roleIds) {
- List<UserRoleParam> userRoleParams = new ArrayList<>();
- for (String roleId : roleIds) {
- UserRoleParam userRoleParam = new UserRoleParam(guid, roleId);
- userRoleParams.add(userRoleParam);
- }
- UserRoleParam param = new UserRoleParam();
- param.setUserId(guid);
- bisInspAllRlationPersService.updateUser(userRoleParams, param);
- }
- @ApiOperation(value = "获取在线用户个数", notes = "参数字段说明:{\n\r" +
- " \"startTime\":\"统计开始时间(非必填),默认统计最近两小时的在线人员\",\n\r" +
- " \"endTime\":\"统计结束时间(非必填)\",\n\r" +
- " };\n\r" +
- "返回结构说明:{\n\r" +
- " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
- " \"code\":\"错误代码\",\n\r" +
- " \"message\":\"描述信息\",\n\r" +
- " \"throwable\":\"异常信息\",\n\r" +
- " \"data\":\"在线人数\"")
- @RequestMapping(value = "/getCountOnlinePers", method = RequestMethod.GET)
- public BaseResponse getCountOnlinePers(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
- if (StringUtils.isBlank(endTime)) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar calendar = Calendar.getInstance();
- endTime = sdf.format(calendar.getTime());
- calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) - 2);
- startTime = sdf.format(calendar.getTime());
- }
- String province = olBisInspOrgService.getProvince(getCurrentOrgId());
- int ret = bisInspAllRlationPersService.selectCountOnlinePers(startTime, endTime, province);
- return buildSuccessResponse(ret);
- }
- @ApiOperation(value = "获取在线用户", notes = "参数字段说明:{\n\r" +
- " \"startTime\":\"统计开始时间(非必填),默认统计最近两小时的在线人员\",\n\r" +
- " \"endTime\":\"统计结束时间(非必填)\",\n\r" +
- " };\n\r" +
- "返回结构说明: {\n\r" +
- " \"code\":\"请求状态码\",\n\r" +
- " \"data(数据信息对象) \": {\n\r" +
- " \"endRow\":\"尾行\",\n\r" +
- " \"firstPage\":\"首页\",\n\r" +
- " \"hasNextPage\":\"是否有下一页\",\n\r" +
- " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
- " \"isFirstPage\":\"是否是第一页\",\n\r" +
- " \"isLastPage\":\"是否是最后一页\",\n\r" +
- " \"lastPage\":\"最后页\",\n\r" +
- " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
- " \"list(结果集)\":[\n\r" +
- " {\n\r" +
- " \"guid\":\"人员ID\",\n\r" +
- " \"orgId\":\"机构ID\",\n\r" +
- " \"orgNm\":\"机构名称\",\n\r" +
- " \"admDuty\":\"职务\",\n\r" +
- " \"orgGrad\":\"职责\",\n\r" +
- " \"idnm\":\"工作证号\",\n\r" +
- " \"plst\":\"政治面貌\",\n\r" +
- " \"school\":\"学校\",\n\r" +
- " \"specialty\":\"专业\",\n\r" +
- " \"imgurl\":\"照片地址\",\n\r" +
- " \"persName\":\"人员姓名\",\n\r" +
- " \"pwd\":\"密码\",\n\r" +
- " \"telnumb\":\"电话号码\",\n\r" +
- " \"mobilenumb\":\"手机号码\",\n\r" +
- " \"email\":\"邮箱\",\n\r" +
- " \"bornDate\":\"出生日期\",\n\r" +
- " \"collTime\":\"录入日期\",\n\r" +
- " \"remark\":\"备注\",\n\r" +
- " \"faxnumb\":\"传真号码\",\n\r" +
- " }\n\r" +
- " ],\n\r" +
- " \"navigateFirstPage\":\"未知\",\n\r" +
- " \"navigateLastPage\":\"未知\",\n\r" +
- " \"navigatePages\":\"未知\",\n\r" +
- " \"list(结果集)\":[\n\r" +
- " ],\n\r" +
- " \"nextPage\":\"下一页\",\n\r" +
- " \"pageNum\":\"页码\",\n\r" +
- " \"pageSize\":\"每页多少条\",\n\r" +
- " \"pages\":\"总页数\",\n\r" +
- " \"prePage\":\"前一页\",\n\r" +
- " \"size\":\"未知\",\n\r" +
- " \"startRow\":\"未知\",\n\r" +
- " \"total\":\"总条数\",\n\r" +
- " },\n\r" +
- " \"message\":\"响应消息\",\n\r" +
- " \"path\":\"路径\",\n\r" +
- " \"success\":\"是否成功\",\n\r" +
- " \"throwable\":\"异常\",\n\r" +
- " }")
- @RequestMapping(value = "/getOnlinePers", method = RequestMethod.GET)
- public BaseResponse getCountOnlinePers2(@RequestParam(required = false) String sttm, @RequestParam(required = false) String entm) {
- if (StringUtils.isBlank(entm)) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar calendar = Calendar.getInstance();
- entm = sdf.format(calendar.getTime());
- calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) - 2);
- sttm = sdf.format(calendar.getTime());
- }
- List<HashMap<String, Object>> ret = bisInspAllRlationPersService.selectOnlinePers(sttm, entm, getCurrentOrgId());
- return buildSuccessResponse(ret);
- }
- @ApiOperation(value = "更新人员小鱼账号")
- @RequestMapping(value = "/updateCallNumber", method = {RequestMethod.POST})
- public BaseResponse updateCallNumber(HttpServletRequest request, @RequestBody UpdateCallNumberParam param
- ) throws Exception {
- if (StringUtils.isBlank(param.getPersId())) {
- param.setPersId(request.getHeader("persId"));
- }
- if (StringUtils.isBlank(param.getPersId())) {
- throw new Exception("缺少persId");
- }
- if (StringUtils.isBlank(param.getCallNumber())) {
- throw new Exception("缺少callNumber");
- }
- BisInspAllRlationPers p = new BisInspAllRlationPers();
- p.setGuid(param.getPersId());
- p.setCallnumber(param.getCallNumber());
- int ret = bisInspAllRlationPersService.update(p);
- if (ret == -2147482646) {
- return buildSuccessResponse(p);
- } else {
- return buildFailResponse(500, "更新失败", request.getRequestURI(), "");
- }
- }
- @ApiOperation(value = "获取小组组长信息")
- @RequestMapping(value = "getLeaderByGroup", method = RequestMethod.POST)
- public BaseResponse<GroupLeaderDto> getLeaderByGroup(@RequestBody GroupLeaderParam groupLeaderParam) {
- BisInspOrg inspOrg = bisInspOrgDao.get(getCurrentOrgId());
- if (inspOrg != null && !inspOrg.getRlcode().startsWith(AdCodeLabel.START_PARENT_ADCODE)) {
- groupLeaderParam.setProvince(inspOrg.getRlcode());
- }
- return buildSuccessResponse(this.bisInspAllRlationPersService.getLeaderByGroup(groupLeaderParam));
- }
- // @Authority(roles = "1")
- @VerifyBean
- @ApiOperation(value = "获取用户列表(用户管理界面)")
- @RequestMapping(value = "listByCurUser", method = RequestMethod.POST)
- public BaseResponse<PageInfo<PersListDto>> listByCurUser(@RequestBody UserListByCurUserParam param) throws Exception {
- String addvcd = AdLevelUtil.getAddvcd(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
- BisInspOrg inspOrg = bisInspOrgDao.get(getCurrentOrgId());
- if (inspOrg != null && !inspOrg.getRlcode().startsWith(AdCodeLabel.START_PARENT_ADCODE)) {
- param.setProvince(AdLevelUtil.getAddvcd(inspOrg.getRlcode()));
- } else {
- param.setOrgId("");
- }
- PageInfo<PersListDto> list = bisInspAllRlationPersService.listByCurUser(param, addvcd);
- return buildSuccessResponse(list);
- }
- @Authority
- @ApiOperation(value = "获取督查组中人员类型--人员类型(1:组长;2:组员;3:联络员;4:专家;11:前期专家;12:监管专家;13:计划专家;14:财务专家;15:质量专家;16:安全专家;19:助理;20:特派员)")
- @RequestMapping(value = "/getPerType", method = RequestMethod.POST)
- public BaseResponse<List<BisInspAllRlation>> getPerType(@ApiParam(name = "inspGroupId", value = "组ID", required = true) @RequestParam String inspGroupId, @ApiParam(name = "persId", value = "人员ID", required = true) @RequestParam String persId) {
- BisInspAllRlationParam param = new BisInspAllRlationParam();
- param.setId(inspGroupId);
- param.setPersid(persId);
- List<BisInspAllRlation> list = bisInspAllRlationService.findList(param);
- if (list == null || list.size() == 0) {
- list = new ArrayList<>();
- BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
- bisInspAllRlation.setId(inspGroupId);
- bisInspAllRlation.setPersid(persId);
- bisInspAllRlation.setPertype("1");
- list.add(bisInspAllRlation);
- }
- return buildSuccessResponse(list);
- }
- @Authority
- @ApiOperation(value = "获取稽察组中人员类型--人员类型(1:组长;2:组员;3:联络员;4:专家;11:前期专家;12:监管专家;13:计划专家;14:财务专家;15:质量专家;16:安全专家;19:助理;20:特派员)")
- @RequestMapping(value = "/getPerTypeNew", method = RequestMethod.GET)
- public BaseResponse<List<BisInspAllRlation>> getPerTypeNew(@ApiParam(name = "inspGroupId", value = "组ID", required = true) @RequestParam String inspGroupId, @ApiParam(name = "persId", value = "人员ID", required = true) @RequestParam String persId) {
- BisInspAllRlationPers pers = bisInspAllRlationPersService.get(persId);
- List<BisInspAllRlation> list = new ArrayList<>();
- if ("1".equals(pers.getPersType())) {
- BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
- bisInspAllRlation.setId(inspGroupId);
- bisInspAllRlation.setPersid(persId);
- bisInspAllRlation.setPertype("1");
- list.add(bisInspAllRlation);
- }
- if (list.size() == 0) {
- TacInspYearBatchGroupPersParam param = new TacInspYearBatchGroupPersParam();
- param.setGroupId(inspGroupId);
- param.setPersId(persId);
- List<BisInspAllRlation> rlations = groupPersService.findPersList(param);
- list.addAll(rlations);
- }
- if (list.size() == 0) {
- BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
- bisInspAllRlation.setId(inspGroupId);
- bisInspAllRlation.setPersid(persId);
- bisInspAllRlation.setPertype("1");
- list.add(bisInspAllRlation);
- }
- return buildSuccessResponse(list);
- }
- @ApiOperation(value = "获取加密公钥,并且把对应私钥储存到Redis")
- @RequestMapping(value = "/getPubKey", method = RequestMethod.POST)
- public BaseResponse<String> getPubKey() {
- Map<Integer, String> keyMap = Encryption.genKeyPair();
- redisTemplate.opsForValue().set(keyMap.get(0), keyMap.get(1), 10, TimeUnit.MINUTES);
- return buildSuccessResponse(keyMap.get(0));
- }
- @ApiOperation(value = "退出系统")
- @RequestMapping(value = "/logOut", method = RequestMethod.GET)
- public BaseResponse logOut(HttpServletRequest request) {
- String uuid = request.getHeader(CommonLabel.ACCESS_TOKEN);
- String accessToken = (String) redisTemplate.opsForValue().get(uuid);
- if (StringUtils.isNotBlank(accessToken)) {
- String persId = request.getHeader(CommonLabel.PERSID);
- LoginUser inspAllRlationPers = JWTTokenUtil.unsign(accessToken, persId);
- if (inspAllRlationPers != null) {
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(inspAllRlationPers.getPersId());
- //bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.PLUS.getNumber());
- }
- }
- redisTemplate.delete(uuid);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "添加多用户")
- @RequestMapping(value = "/updateListUsers", method = RequestMethod.POST)
- public BaseResponse updateUsers(@ApiParam(name = "AddRlationPersDto", value = "AddRlationPersDto", required = true)
- @RequestBody AddRlationPersDto addRlationPersDto) {
- return buildSuccessResponse(bisInspAllRlationPersService.updateListUsers(addRlationPersDto));
- }
- @ApiOperation(value = "获取对象信息")
- @RequestMapping(value = "/getUserById", method = RequestMethod.POST)
- public BaseResponse<BisInspAllRlationPers> getUserById(HttpServletRequest request) {
- String persId = request.getHeader(CommonLabel.PERSID);
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId);
- return buildSuccessResponse(bisInspAllRlationPers);
- }
- @ApiOperation(value = "获取对象信息")
- @RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)
- public BaseResponse<BisInspAllRlationPers> getUserInfo(@RequestParam String persId) {
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId);
- bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
- return buildSuccessResponse(bisInspAllRlationPers);
- }
- }
|