3aaca4220dabcc87866ed89ad2d2610c55ed81cb.svn-base 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. package cn.com.goldenwater.dcproj.controller.ducha;
  2. import cn.com.goldenwater.core.web.BaseController;
  3. import cn.com.goldenwater.core.web.BaseResponse;
  4. import cn.com.goldenwater.dcproj.constValue.AdCodeLabel;
  5. import cn.com.goldenwater.dcproj.constValue.CommonLabel;
  6. import cn.com.goldenwater.dcproj.dao.BisInspOrgDao;
  7. import cn.com.goldenwater.dcproj.dto.AddRlationPersDto;
  8. import cn.com.goldenwater.dcproj.dto.GroupLeaderDto;
  9. import cn.com.goldenwater.dcproj.dto.InspTypeDto;
  10. import cn.com.goldenwater.dcproj.dto.LoginDto;
  11. import cn.com.goldenwater.dcproj.dto.LoginUser;
  12. import cn.com.goldenwater.dcproj.dto.PersListDto;
  13. import cn.com.goldenwater.dcproj.model.BisInspAll;
  14. import cn.com.goldenwater.dcproj.model.BisInspAllRlation;
  15. import cn.com.goldenwater.dcproj.model.BisInspAllRlationPers;
  16. import cn.com.goldenwater.dcproj.model.BisInspOrg;
  17. import cn.com.goldenwater.dcproj.model.BisInspPersOrg;
  18. import cn.com.goldenwater.dcproj.model.GwComFile;
  19. import cn.com.goldenwater.dcproj.model.InspType;
  20. import cn.com.goldenwater.dcproj.model.OlBisInspOrg;
  21. import cn.com.goldenwater.dcproj.param.BisInspAllParam;
  22. import cn.com.goldenwater.dcproj.param.BisInspAllRlationParam;
  23. import cn.com.goldenwater.dcproj.param.BisInspAllRlationPersParam;
  24. import cn.com.goldenwater.dcproj.param.BisInspOrgParam;
  25. import cn.com.goldenwater.dcproj.param.BisInspPersOrgParam;
  26. import cn.com.goldenwater.dcproj.param.GroupLeaderParam;
  27. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
  28. import cn.com.goldenwater.dcproj.param.UpdateCallNumberParam;
  29. import cn.com.goldenwater.dcproj.param.UserListByCurUserParam;
  30. import cn.com.goldenwater.dcproj.param.UserRoleParam;
  31. import cn.com.goldenwater.dcproj.service.BisInspAllRlationPersService;
  32. import cn.com.goldenwater.dcproj.service.BisInspAllRlationService;
  33. import cn.com.goldenwater.dcproj.service.BisInspAllService;
  34. import cn.com.goldenwater.dcproj.service.BisInspMeetInvitationService;
  35. import cn.com.goldenwater.dcproj.service.BisInspPersOrgService;
  36. import cn.com.goldenwater.dcproj.service.GwComFileService;
  37. import cn.com.goldenwater.dcproj.service.LoginService;
  38. import cn.com.goldenwater.dcproj.service.OlBisInspOrgService;
  39. import cn.com.goldenwater.dcproj.service.TacInspYearBatchGroupPersService;
  40. import cn.com.goldenwater.dcproj.service.impl.system.OrganizationTreeImpl;
  41. import cn.com.goldenwater.dcproj.target.Authority;
  42. import cn.com.goldenwater.dcproj.target.Log;
  43. import cn.com.goldenwater.dcproj.target.VerifyBean;
  44. import cn.com.goldenwater.dcproj.util.Base64Util;
  45. import cn.com.goldenwater.dcproj.utils.*;
  46. import cn.com.goldenwater.id.util.UuidUtil;
  47. import cn.com.goldenwater.target.CheckException;
  48. import com.github.pagehelper.PageInfo;
  49. import io.swagger.annotations.Api;
  50. import io.swagger.annotations.ApiOperation;
  51. import io.swagger.annotations.ApiParam;
  52. import org.apache.commons.collections.CollectionUtils;
  53. import org.apache.commons.collections.MapUtils;
  54. import org.apache.commons.lang3.StringUtils;
  55. import org.slf4j.Logger;
  56. import org.slf4j.LoggerFactory;
  57. import org.springframework.beans.factory.annotation.Autowired;
  58. import org.springframework.beans.factory.annotation.Value;
  59. import org.springframework.data.redis.core.RedisTemplate;
  60. import org.springframework.transaction.annotation.Transactional;
  61. import org.springframework.util.Assert;
  62. import org.springframework.web.bind.annotation.GetMapping;
  63. import org.springframework.web.bind.annotation.PathVariable;
  64. import org.springframework.web.bind.annotation.PostMapping;
  65. import org.springframework.web.bind.annotation.RequestBody;
  66. import org.springframework.web.bind.annotation.RequestMapping;
  67. import org.springframework.web.bind.annotation.RequestMethod;
  68. import org.springframework.web.bind.annotation.RequestParam;
  69. import org.springframework.web.bind.annotation.RestController;
  70. import org.springframework.web.multipart.MultipartFile;
  71. import javax.annotation.PostConstruct;
  72. import javax.servlet.http.HttpServletRequest;
  73. import java.io.File;
  74. import java.io.IOException;
  75. import java.text.SimpleDateFormat;
  76. import java.util.ArrayList;
  77. import java.util.Calendar;
  78. import java.util.Date;
  79. import java.util.HashMap;
  80. import java.util.List;
  81. import java.util.Map;
  82. import java.util.Optional;
  83. import java.util.concurrent.TimeUnit;
  84. /**
  85. * @author zhaohg
  86. * @date 2019-2-23
  87. */
  88. @Api(value = "新用户管理", tags = "006新用户管理")
  89. @RestController
  90. @RequestMapping("/bis/insp")
  91. public class BisInspAllRlationPersController extends BaseController {
  92. private Logger logger = LoggerFactory.getLogger(getClass());
  93. @Value("${api.url}")
  94. private String apiUrl;
  95. @Value("${smsCode}")
  96. private String smsCode;
  97. @Value("${getFile.prefix}")
  98. public String prefix;
  99. @Value("${web.upload-path}")
  100. public String fileDir;
  101. @Autowired
  102. private BisInspAllRlationPersService bisInspAllRlationPersService;
  103. @Autowired
  104. private BisInspAllRlationService bisInspAllRlationService;
  105. @Autowired
  106. private OrganizationTreeImpl organizationTree;
  107. @Autowired
  108. private GwComFileService gwComFileService;
  109. @Autowired
  110. private RedisTemplate redisTemplate;
  111. @Autowired
  112. private BisInspMeetInvitationService bisInspMeetInvitationService;
  113. @Autowired
  114. private TacInspYearBatchGroupPersService groupPersService;
  115. @Autowired
  116. private OlBisInspOrgService olBisInspOrgService;
  117. @Autowired
  118. private OlBisInspOrgService inspOrgService;
  119. @Autowired
  120. private BisInspPersOrgService persOrgService;
  121. @Autowired
  122. private LoginService loginService;
  123. @PostConstruct
  124. public void Cache() {
  125. Object newSmscode = redisTemplate.opsForValue().get("smsCode");
  126. if (newSmscode == null) {
  127. redisTemplate.opsForValue().set("smsCode", smsCode);
  128. }
  129. }
  130. @RequestMapping(value = "/test/{month}", method = {RequestMethod.GET})
  131. public BaseResponse test(@PathVariable String month) {
  132. // countTaskService.washWxPic(request);
  133. gwComFileService.changeSmallImg("2020", month);
  134. return buildSuccessResponse("更新完成!!");
  135. }
  136. @GetMapping("/getCaptchaImage")
  137. public BaseResponse getCaptcha() throws Exception {
  138. String uuid = UuidUtil.uuid();
  139. ImgResult imgResult = VerifyCodeUtils.VerifyCode(4);
  140. this.redisTemplate.opsForValue().set(uuid, imgResult.getCode(), 10L, TimeUnit.MINUTES);
  141. Map<String, Object> map = new HashMap<>(2);
  142. map.put("imgCodeId", uuid);
  143. map.put("img", imgResult.getImg());
  144. logger.info("--------------------imgCode:" + imgResult.getCode() + "------------------------------");
  145. return buildSuccessResponse(map);
  146. }
  147. @Log
  148. @ApiOperation(value = "用户发送短信", notes = "用户发送短信")
  149. @RequestMapping(value = "/sendMessage", method = {RequestMethod.POST})
  150. public BaseResponse sendMessage(@RequestParam(required = true) String phone, @RequestParam(required = false) String imgCodeId, @RequestParam(required = false) String code, HttpServletRequest request)
  151. throws Exception {
  152. if (code.length() != 4) {
  153. return buildFailResponse("验证码有误!");
  154. }
  155. String uuidCode = "";
  156. Object object = this.redisTemplate.opsForValue().get(imgCodeId);
  157. if (object != null) {
  158. uuidCode = object.toString();
  159. }
  160. String inputCode = Base64Util.encodeStr(code.toLowerCase());
  161. if (!(uuidCode.equalsIgnoreCase(inputCode))) {
  162. return buildFailResponse(1500, "您输入的验证码不正确或已过期,请点击验证码图片刷新,重新输入!");
  163. }
  164. uuidCode = UuidUtil.uuid();
  165. redisTemplate.opsForValue().set(phone, uuidCode + "_" + imgCodeId, 10L, TimeUnit.MINUTES);
  166. redisTemplate.delete(imgCodeId);
  167. redisTemplate.opsForValue().set(imgCodeId, uuidCode);
  168. boolean flag = this.bisInspAllRlationPersService.sendMessage(phone);
  169. if (flag) {
  170. return buildSuccessResponse();
  171. }
  172. return buildFailResponse(1002, "您还不是本系统用户,请联系系统管理员");
  173. }
  174. /**
  175. * 新版本登录接口
  176. *
  177. * @param loginDto phone、code
  178. * @param request 请求
  179. * @return 判断能否登录,登录成果返回用户信息
  180. */
  181. @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
  182. @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
  183. public BaseResponse loginByCode(@RequestBody LoginDto loginDto, HttpServletRequest request) {
  184. return loginService.login(loginDto, request);
  185. }
  186. /**
  187. * 手机号密码登录接口
  188. *
  189. * @param loginDto phone、pwd
  190. * @param request 请求
  191. * @return 判断能否登录,登录成果返回用户信息
  192. */
  193. @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
  194. @RequestMapping(value = "/loginByPwd", method = {RequestMethod.POST})
  195. public BaseResponse loginByPwd(@RequestBody LoginDto loginDto, HttpServletRequest request) {
  196. return loginService.loginByPwd(loginDto, request);
  197. }
  198. /**
  199. * 更新密码为m5加密后的
  200. *
  201. * @param
  202. */
  203. @ApiOperation(value = "更新密码为m5加密后的", notes = "更新密码为m5加密后的")
  204. @RequestMapping(value = "/updatePwdMd5", method = {RequestMethod.POST})
  205. public BaseResponse updatePwdMd5() {
  206. return loginService.updatePwdMd5();
  207. }
  208. // /**
  209. // * 旧版本登录接口
  210. // *
  211. // * @param phone 手机号
  212. // * @param code 验证码
  213. // * @param request 请求
  214. // * @return 判断能否登录,登录成果返回用户信息
  215. // */
  216. // @ApiOperation(value = "用户验证码登录", notes = "与普通登录返回相同")
  217. // @RequestMapping(value = "/loginByCode", method = {RequestMethod.POST})
  218. // public BaseResponse loginByCode(@RequestParam String phone, @RequestParam String code, HttpServletRequest request) {
  219. // if (code.length() != 6) {
  220. // return buildFailResponse("验证码有误!");
  221. // }
  222. // // 根据phone-code获取用户信息
  223. // BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.loginByCode(phone, code);
  224. // boolean logincode = true;
  225. // if (bisInspAllRlationPers == null) {
  226. // GwStaticUser gwStaticUser = gwStaticUserDao.get(phone);
  227. // if (gwStaticUser != null) {
  228. // String newSmscode = smsCode;
  229. // // 判断是否与固定验证码相同,相同时获取用户信息
  230. // if (newSmscode.equals(code)) {
  231. // BisInspAllRlationPersParam inspAllRlationPersParam = new BisInspAllRlationPersParam();
  232. // inspAllRlationPersParam.setMobilenumb(phone);
  233. // bisInspAllRlationPers = bisInspAllRlationPersService.getBy(inspAllRlationPersParam);
  234. // logincode = false;
  235. // }
  236. // }
  237. // }
  238. //
  239. // //发送信息成功后记录数据
  240. // if (logincode) {
  241. // String yzm = (String) redisTemplate.opsForValue().get(phone);
  242. // if (StringUtils.isBlank(yzm)) {
  243. // return buildFailResponse("图片验证码已经过期,请重新验证!!");
  244. // }
  245. // String[] arrays = yzm.split("_");
  246. // //验证码为arrays[0]
  247. // String yzmReal = (String) redisTemplate.opsForValue().get(arrays[1]);
  248. // if (StringUtils.isBlank(yzm) || "null".equals(yzm)) {
  249. // return buildFailResponse("图片验证码已经过期,请重新输入!!");
  250. // }
  251. // if (!yzmReal.equals(arrays[0])) {
  252. // return buildFailResponse("图片验证码已经过期,请重新验输入!");
  253. // }
  254. // redisTemplate.delete(phone);
  255. // redisTemplate.delete(arrays[1]);
  256. // }
  257. // if (bisInspAllRlationPers == null) {
  258. // BisInspAllRlationPersParam allRlationPersParam = new BisInspAllRlationPersParam();
  259. // allRlationPersParam.setMobilenumb(phone);
  260. // bisInspAllRlationPers = bisInspAllRlationPersService.getBy(allRlationPersParam);
  261. // if (bisInspAllRlationPers == null) {
  262. // return buildFailResponse(1002, "该手机号尚未注册", "", "");
  263. // }
  264. // return buildFailResponse(1001, "验证码错误", "", "");
  265. // } else {
  266. // bisInspAllRlationPers.setPwd(null);
  267. // bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
  268. // BisInspAllRlationPers pers = new BisInspAllRlationPers();
  269. // pers.setGuid(bisInspAllRlationPers.getGuid());
  270. // pers.setLoginTm(new Date());
  271. // if (StringUtils.isBlank(bisInspAllRlationPers.getPersType())) {
  272. // bisInspAllRlationPers.setPersType("3");
  273. // pers.setPersType("3");
  274. // }
  275. // bisInspAllRlationPersService.update(pers);
  276. // String uuid = UuidUtil.uuid();
  277. // bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.ADD.getNumber());
  278. // String accessToken = JWTTokenUtil.sign(bisInspAllRlationPersService.getLoginUser(bisInspAllRlationPers), bisInspAllRlationPers.getGuid());
  279. //
  280. // redisTemplate.opsForValue().set(uuid, accessToken, JWTTokenUtil.maxAge, TimeUnit.MILLISECONDS);
  281. // redisTemplate.opsForValue().set(uuid + bisInspAllRlationPers.getGuid(), accessToken, JWTTokenUtil.refreshmaxAge, TimeUnit.MILLISECONDS);
  282. // bisInspAllRlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhone(bisInspAllRlationPers.getMobilenumb()));
  283. // return buildSuccessResponse(bisInspAllRlationPers, uuid);
  284. // }
  285. // }
  286. /**
  287. * 江苏数字看板、 需要手机号码模拟登陆。
  288. *
  289. * @param map 手机号码
  290. * @param request
  291. * @return
  292. */
  293. @ApiOperation(value = "", notes = "")
  294. @RequestMapping(value = "/getTokenByTel", method = {RequestMethod.POST})
  295. public BaseResponse<Object> loginByPhone(@RequestBody Map<String, String> map, HttpServletRequest request) {
  296. // 判断是否与固定验证码相同,相同时获取用户信息
  297. BisInspAllRlationPersParam inspAllRlationPersParam = new BisInspAllRlationPersParam();
  298. inspAllRlationPersParam.setMobilenumb(map.get("phone"));
  299. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.getBy(inspAllRlationPersParam);
  300. if (bisInspAllRlationPers == null) {
  301. return buildFailResponse(1002, "该手机号尚未注册", "", "");
  302. }
  303. bisInspAllRlationPers.setPwd(null);
  304. bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
  305. BisInspAllRlationPers pers = new BisInspAllRlationPers();
  306. pers.setGuid(bisInspAllRlationPers.getGuid());
  307. pers.setLoginTm(new Date());
  308. if (StringUtils.isBlank(bisInspAllRlationPers.getPersType())) {
  309. bisInspAllRlationPers.setPersType("3");
  310. pers.setPersType("3");
  311. }
  312. bisInspAllRlationPersService.update(pers);
  313. String uuid = UuidUtil.uuid();
  314. //bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.ADD.getNumber());
  315. String accessToken = JWTTokenUtil.sign(bisInspAllRlationPersService.getLoginUser(bisInspAllRlationPers), bisInspAllRlationPers.getGuid());
  316. redisTemplate.opsForValue().set(uuid, accessToken, JWTTokenUtil.maxAge, TimeUnit.MILLISECONDS);
  317. redisTemplate.opsForValue().set(uuid + bisInspAllRlationPers.getGuid(), accessToken, JWTTokenUtil.refreshmaxAge, TimeUnit.MILLISECONDS);
  318. bisInspAllRlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhone(bisInspAllRlationPers.getMobilenumb()));
  319. // TODO 有时间做个加密处理
  320. return buildSuccessResponse(bisInspAllRlationPers, uuid);
  321. }
  322. @Autowired
  323. private BisInspOrgDao bisInspOrgDao;
  324. private BisInspAllRlationPers getBisInspAllRlations(BisInspAllRlationPers bisInspAllRlationPers) {
  325. // 1.设置默认显示机构和所能看到的所有机构
  326. BisInspOrg bisInspOrg = new BisInspOrg();
  327. if (StringUtils.isNotBlank(bisInspAllRlationPers.getOrgId())) {
  328. // 设置所有能看到的机构
  329. BisInspOrgParam inspOrgParam = new BisInspOrgParam();
  330. inspOrgParam.setPersId(bisInspAllRlationPers.getGuid());
  331. List<BisInspOrg> inspOrgList = bisInspOrgDao.findPersOrgList(inspOrgParam);
  332. bisInspAllRlationPers.setAllOrg(inspOrgList);
  333. String orgId = bisInspAllRlationPers.getOrgId();
  334. // 获取所有orgId 判断用户所属机构是否在其中,没有 选择第一个机构 为默认机构
  335. if (inspOrgList != null && inspOrgList.size() > 0) {
  336. orgId = inspOrgList.get(0).getOrgId();
  337. for (BisInspOrg org : inspOrgList) {
  338. if (org.getOrgId().equals(bisInspAllRlationPers.getOrgId())) {
  339. orgId = bisInspAllRlationPers.getOrgId();
  340. break;
  341. }
  342. }
  343. }
  344. bisInspOrg = olBisInspOrgService.getDefaultOrg(orgId);
  345. bisInspAllRlationPers.setDefaultOrg(bisInspOrg);
  346. }
  347. if (StringUtils.isNotBlank(bisInspAllRlationPers.getGuid())) {
  348. List<BisInspAll> allNode = organizationTree.getAllNode(bisInspAllRlationPers.getGuid(), "", bisInspAllRlationPers.getOrgId(), "", "", "", "", "");
  349. if (allNode.size() > 0) {
  350. StringBuffer s = new StringBuffer();
  351. s.append("1");
  352. String sk = "0";
  353. String ry = "000";
  354. String sh = "0";
  355. String ogc = "0";
  356. String dxs = "0";
  357. String sz = "0";
  358. String sd = "0";
  359. for (BisInspAll b : allNode) {
  360. if ("001".equals(b.getId().substring(0, 3))) {
  361. sk = "1";
  362. }
  363. if ("002".equals(b.getId().substring(0, 3))) {
  364. ry = "111";
  365. }
  366. if ("003".equals(b.getId().substring(0, 3))) {
  367. sh = "1";
  368. }
  369. if ("004".equals(b.getId().substring(0, 3))) {
  370. ogc = "1";
  371. }
  372. if ("005".equals(b.getId().substring(0, 3))) {
  373. dxs = "1";
  374. }
  375. if ("006".equals(b.getId().substring(0, 3))) {
  376. sz = "1";
  377. }
  378. if ("011".equals(b.getId().substring(0, 3))) {
  379. sd = "1";
  380. }
  381. }
  382. s.append(sk).append(ry).append(sh).append(ogc).append(dxs).append(sz).append(sd);
  383. bisInspAllRlationPers.setJurisdiction(s.toString());
  384. } else {
  385. bisInspAllRlationPers.setJurisdiction("100000000");
  386. }
  387. bisInspAllRlationPers.setAllNode(allNode);
  388. }
  389. return bisInspAllRlationPers;
  390. }
  391. @Authority(roles = "1")
  392. @ApiOperation(value = "添加人员")
  393. @RequestMapping(value = "/insert", method = {RequestMethod.POST})
  394. @Transactional(rollbackFor = Exception.class)
  395. public BaseResponse insert(@RequestParam(value = "file", required = false) MultipartFile file, BisInspAllRlationPers bisInspAllRlationPers) throws Exception {
  396. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  397. if (inspAllRlationPers == null) {
  398. return buildFailResponse("当前用户不存在!!");
  399. }
  400. if (!"1".equals(inspAllRlationPers.getPersType())) {
  401. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  402. }
  403. if (file != null) {
  404. Calendar dat = Calendar.getInstance();
  405. //写入文件
  406. String originalFilename = file.getOriginalFilename();
  407. GwComFile gwComFile = new GwComFile();
  408. String uuid = UuidUtil.uuid();
  409. gwComFile.setId(uuid);
  410. gwComFile.setFileName(originalFilename);
  411. gwComFile.setFileSize((double) file.getSize());
  412. gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
  413. 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();
  414. gwComFile.setFilePath(filePath);
  415. if (!FileExtUtil.valFileExt(gwComFile.getFileExt())) {
  416. return buildFailResponse(9993, "文件类型允许!!");
  417. }
  418. //写入文件
  419. String filePath2 = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
  420. gwComFileService.writeFile(gwComFile, file, filePath2);
  421. bisInspAllRlationPers.setImgurl(filePath);
  422. }
  423. BisInspAllRlationPers p = bisInspAllRlationPersService.createUser(bisInspAllRlationPers);
  424. return buildSuccessResponse(p.getGuid());
  425. }
  426. private void addPreOrg(BisInspAllRlationPers bisInspAllRlationPers) {
  427. //先删除授权,再添加机构授权
  428. BisInspPersOrgParam persOrgParam = new BisInspPersOrgParam();
  429. persOrgParam.setPersId(bisInspAllRlationPers.getGuid());
  430. persOrgService.deleteBy(persOrgParam);
  431. if (StringUtils.isNotBlank(bisInspAllRlationPers.getOrgId())) {
  432. OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(bisInspAllRlationPers.getOrgId());
  433. if (olBisInspOrg != null) {
  434. bisInspAllRlationPers.setOrgNm(olBisInspOrg.getOrgNm());
  435. bisInspAllRlationPers.setProvince(olBisInspOrg.getAdCode());
  436. }
  437. BisInspPersOrg inspPersOrg = new BisInspPersOrg();
  438. inspPersOrg.setOrgId(bisInspAllRlationPers.getOrgId());
  439. inspPersOrg.setPersId(bisInspAllRlationPers.getGuid());
  440. if (StringUtils.isNotBlank(bisInspAllRlationPers.getPersType())) {
  441. inspPersOrg.setUserType(bisInspAllRlationPers.getPersType());
  442. } else {
  443. inspPersOrg.setUserType(AdCodeLabel.GROUP_LEADER);
  444. }
  445. BisInspPersOrgParam bisInspPersOrgParam = new BisInspPersOrgParam();
  446. bisInspPersOrgParam.setPersId(inspPersOrg.getPersId());
  447. bisInspPersOrgParam.setOrgId(inspPersOrg.getOrgId());
  448. if (null == persOrgService.getBy(bisInspPersOrgParam)) {
  449. persOrgService.insert(inspPersOrg);
  450. }
  451. }
  452. }
  453. @ApiOperation(value = "根据id获取人员(对象详情)")
  454. @RequestMapping(value = "/{id}", method = {RequestMethod.GET})
  455. public BaseResponse<BisInspAllRlationPers> info(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  456. String currentPersId = getCurrentPersId();
  457. BisInspAllRlationPers rlationPers = bisInspAllRlationPersService.getById(id);
  458. BisInspAllRlationPers currentPers = bisInspAllRlationPersService.getById(currentPersId);
  459. rlationPers.setMobilenumb(UserMsgSectrityUtils.blurPhoneNotExc(rlationPers.getMobilenumb()));
  460. if (rlationPers != null) {
  461. rlationPers.setPwd(null);
  462. if (!"1".equals(currentPers.getPersType()) && !getCurrentPersId().equals(rlationPers.getGuid())) {
  463. rlationPers = null;
  464. }
  465. }
  466. return buildSuccessResponse(rlationPers);
  467. }
  468. @Authority(roles = "1")
  469. @ApiOperation(value = "根据ID删除人员")
  470. @RequestMapping(value = "/delete/{id}", method = {RequestMethod.POST})
  471. public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
  472. if ("80df1213ad9f493e85a771d6f4b18a17".equals(id)) {
  473. return buildFailResponse("管理员账户不允许删除!");
  474. }
  475. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(id);
  476. int ret = bisInspAllRlationPersService.delete(id);
  477. /**
  478. * 删除小鱼账号信息
  479. */
  480. try {
  481. bisInspMeetInvitationService.batchUsersDel(bisInspAllRlationPers);
  482. } catch (IOException e) {
  483. e.printStackTrace();
  484. }
  485. return buildSuccessResponse();
  486. }
  487. @ApiOperation(value = "绑定人员机构关系")
  488. @RequestMapping(value = "/add/presorg", method = {RequestMethod.POST})
  489. public BaseResponse<List<BisInspPersOrg>> presorg(@RequestBody List<BisInspPersOrg> inspPersOrgList) {
  490. if (inspPersOrgList == null || inspPersOrgList.isEmpty()) {
  491. return buildFailResponse();
  492. }
  493. //先删除
  494. BisInspPersOrgParam persOrgParam = new BisInspPersOrgParam();
  495. BisInspPersOrg inspPersOrgOne = inspPersOrgList.get(0);
  496. persOrgParam.setPersId(inspPersOrgOne.getPersId());
  497. if (StringUtils.isNotBlank(inspPersOrgOne.getPersId())) {
  498. persOrgService.deleteBy(persOrgParam);
  499. }
  500. //添加
  501. for (BisInspPersOrg inspPersOrg : inspPersOrgList) {
  502. inspPersOrg.setUserType(AdCodeLabel.GROUP_LEADER);
  503. persOrgService.insert(inspPersOrg);
  504. }
  505. /* OlBisInspOrg olBisInspOrg = olBisInspOrgService.get(inspPersOrgOne.getOrgId());
  506. if (olBisInspOrg != null) {
  507. //更新默认
  508. BisInspAllRlationPers inspAllRlationPers = new BisInspAllRlationPers();
  509. inspAllRlationPers.setOrgId(inspPersOrgOne.getOrgId());
  510. inspAllRlationPers.setOrgNm(olBisInspOrg.getOrgNm());
  511. inspAllRlationPers.setGuid(inspPersOrgOne.getPersId());
  512. bisInspAllRlationPersService.update(inspAllRlationPers);
  513. }*/
  514. return buildSuccessResponse(inspPersOrgList);
  515. }
  516. @Autowired
  517. private BisInspAllService bisInspAllService;
  518. @ApiOperation(value = "获取系统中的所有督查类型")
  519. @RequestMapping(value = "/listInspType", method = {RequestMethod.GET})
  520. public BaseResponse<List<InspType>> listInspType() {
  521. return buildSuccessResponse(bisInspAllService.listInspType());
  522. }
  523. @Authority(roles = "1")
  524. @ApiOperation(value = "获取系统中的已经绑定的所有督查类型")
  525. @RequestMapping(value = "/list/{orgId}/{persId}", method = {RequestMethod.GET})
  526. public BaseResponse<List<BisInspAllRlation>> listBindInspType(@PathVariable String orgId, @PathVariable String persId) {
  527. BisInspAllParam inspAllRParam = new BisInspAllParam();
  528. inspAllRParam.setOrgId(orgId);
  529. String province = inspOrgService.getProvince(orgId);
  530. inspAllRParam.setProvince(province);
  531. inspAllRParam.setPersId(persId);
  532. List<BisInspAllRlation> inspAllRlationList = bisInspAllService.findExistList(inspAllRParam);
  533. for (BisInspAllRlation allRlation : inspAllRlationList) {
  534. String id = allRlation.getId().substring(0, 3);
  535. allRlation.setId(id);
  536. allRlation.setPersid(persId);
  537. allRlation.setAdCode(province);
  538. }
  539. return buildSuccessResponse(inspAllRlationList);
  540. }
  541. @Authority(roles = "1")
  542. @ApiOperation(value = "删除系统中的已经绑定的所有督查类型,code位类型编码,如001小水库")
  543. @RequestMapping(value = "/del/{orgId}/{persId}/{code}", method = {RequestMethod.GET})
  544. public BaseResponse<String> delBindInspType(@PathVariable String orgId, @PathVariable String persId, @PathVariable String code) {
  545. String id = code + orgId;
  546. BisInspAllParam inspAllParam = new BisInspAllParam();
  547. inspAllParam.setPid(id);
  548. List<BisInspAll> inspAlls = bisInspAllService.findList(inspAllParam);
  549. if (inspAlls != null && !inspAlls.isEmpty()) {
  550. return buildFailResponse("删除失败,改督查类型已经存在关联数据!!");
  551. }
  552. bisInspAllService.delete(id);
  553. return buildSuccessResponse("删除成功");
  554. }
  555. @ApiOperation(value = "个人账户更新登录")
  556. @RequestMapping(value = "/updatePassword", method = {RequestMethod.POST})
  557. public BaseResponse updatePassword(@RequestBody BisInspAllRlationPers bisInspAllRlationPers) {
  558. String currentPersId = getCurrentPersId();
  559. BisInspAllRlationPers currentPers = bisInspAllRlationPersService.getById(currentPersId);
  560. if (currentPersId != bisInspAllRlationPers.getGuid()) {
  561. if (!currentPers.getPersType().equals("1")) {
  562. return buildFailResponse("无权限操作!");
  563. }
  564. }
  565. if (StringUtils.isNotBlank(bisInspAllRlationPers.getGuid()) && StringUtils.isNotBlank(bisInspAllRlationPers.getPwd())) {
  566. bisInspAllRlationPers.setPwd(MD5.getMD5(aesUtil.desEncrypt(bisInspAllRlationPers.getPwd())));
  567. bisInspAllRlationPersService.updatePassword(bisInspAllRlationPers);
  568. }
  569. return buildSuccessResponse();
  570. }
  571. @Autowired
  572. private BisInspAllRlationService rlationService;
  573. @Authority(roles = "1")
  574. @ApiOperation(value = "管理员绑定人员管理员和督查类型")
  575. @RequestMapping(value = "/add/inspType", method = {RequestMethod.POST})
  576. @Transactional(rollbackFor = Exception.class)
  577. public BaseResponse<List<InspType>> addInspType(@RequestBody List<InspType> inspTypeList, String delPersId, String delOrgId) {
  578. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  579. if (inspAllRlationPers == null) {
  580. return buildFailResponse("当前用户不存在!!");
  581. }
  582. if (!"1".equals(inspAllRlationPers.getPersType())) {
  583. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  584. }
  585. // 1. 获取 OrgId、 persId、 province 删除所有 与用户-省关联的 数据
  586. BisInspAllRlationParam bisInspAllRlationParam = new BisInspAllRlationParam();
  587. OlBisInspOrg bisInspOrg = null;
  588. // 判断 inspTypeList 是否为空,空就只删除数据,不添加数据
  589. if (inspTypeList.size() == 0) {
  590. bisInspAllRlationParam.setOrgId(delOrgId);
  591. bisInspAllRlationParam.setPersid(delPersId);
  592. bisInspAllRlationParam.setProvince(inspOrgService.get(delOrgId).getRlcode());
  593. rlationService.deleteBy(bisInspAllRlationParam);
  594. return buildSuccessResponse();
  595. } else {
  596. InspType inspTypeOne = inspTypeList.get(0);
  597. bisInspAllRlationParam.setOrgId(inspTypeOne.getOrgId());
  598. bisInspAllRlationParam.setPersid(inspTypeOne.getPersId());
  599. bisInspOrg = inspOrgService.get(inspTypeOne.getOrgId());
  600. bisInspAllRlationParam.setProvince(bisInspOrg.getRlcode());
  601. rlationService.deleteBy(bisInspAllRlationParam);
  602. }
  603. // 2. 循环要添加的督查类别, 添加督查类别
  604. for (InspType inspType : inspTypeList) {
  605. BisInspAll rootBisInsp = bisInspAllService.get(inspType.getCode());
  606. // 如果没有这个督查类别就添加督查类别
  607. if (rootBisInsp == null) {
  608. rootBisInsp = new BisInspAll();
  609. rootBisInsp.setId(inspType.getCode());
  610. rootBisInsp.setPnm(inspType.getName());
  611. rootBisInsp.setPid(CommonLabel.INIT_DATA);
  612. bisInspAllService.insert(rootBisInsp);
  613. }
  614. String orgId = inspType.getOrgId();
  615. if (inspType.getOrgId().length() == 2) {
  616. orgId = "0" + orgId;
  617. }
  618. // 添加 督查 BisInspAll tree
  619. String id = inspType.getCode() + orgId;
  620. BisInspAll inspAll = bisInspAllService.get(id);
  621. if (inspAll == null) {
  622. inspAll = new BisInspAll();
  623. inspAll.setOrgId(inspType.getOrgId());
  624. inspAll.setId(id);
  625. inspAll.setPnm(bisInspOrg.getOrgNm() + inspType.getName());
  626. inspAll.setPid(inspType.getCode());
  627. inspAll.setProvince(bisInspOrg.getRlcode());
  628. if (AdCodeLabel.PARENT_ADCODE.equals(bisInspOrg.getRlcode())) {
  629. inspAll.setProvince("");
  630. }
  631. bisInspAllService.insert(inspAll);
  632. }
  633. // 重点添加督查 BisInspAllRlation
  634. BisInspAllRlationParam rlationParam = new BisInspAllRlationParam();
  635. rlationParam.setPersid(inspType.getPersId());
  636. rlationParam.setId(id);
  637. rlationParam.setProvince(bisInspOrg.getRlcode());
  638. BisInspAllRlation allRlation = rlationService.getBy(rlationParam);
  639. if (allRlation == null) {
  640. allRlation = new BisInspAllRlation();
  641. allRlation.setAdCode(bisInspOrg.getRlcode());
  642. if (AdCodeLabel.PARENT_ADCODE.equals(bisInspOrg.getRlcode())) {
  643. allRlation.setAdCode("");
  644. }
  645. allRlation.setPersid(inspType.getPersId());
  646. allRlation.setId(id);
  647. BisInspAllRlationPers allRlationPers = bisInspAllRlationPersService.get(inspType.getPersId());
  648. if (allRlationPers != null) {
  649. allRlation.setPertype(allRlationPers.getPersType());
  650. }
  651. allRlation.setOrgId(orgId);
  652. allRlation.setType(String.valueOf(Integer.parseInt(inspType.getCode())));
  653. rlationService.insert(allRlation);
  654. }
  655. }
  656. return buildSuccessResponse(inspTypeList);
  657. }
  658. @Authority(roles = "1")
  659. @ApiOperation(value = "管理员绑定人员管理员和督查类型")
  660. @RequestMapping(value = "/batchAdd/inspType", method = {RequestMethod.POST})
  661. @Transactional(rollbackFor = Exception.class)
  662. public BaseResponse batchAddInspType(@RequestBody InspTypeDto inspTypeDto) {
  663. if (CollectionUtils.isEmpty(inspTypeDto.getPersIdList()) && CollectionUtils.isEmpty(inspTypeDto.getPhoneList())) {
  664. return buildFailResponse();
  665. }
  666. if (CollectionUtils.isEmpty(inspTypeDto.getInspTypeList())) {
  667. return buildFailResponse();
  668. }
  669. List<InspType> inspTypeList = inspTypeDto.getInspTypeList();
  670. if (CollectionUtils.isNotEmpty(inspTypeDto.getPersIdList())) {
  671. inspTypeDto.getPersIdList().forEach(persId -> {
  672. BisInspAllRlationPers p = bisInspAllRlationPersService.get(persId);
  673. Optional.ofNullable(p).ifPresent(per -> {
  674. for (InspType inspType : inspTypeList) {
  675. inspType.setPersId(per.getGuid());
  676. inspType.setOrgId(per.getOrgId());
  677. }
  678. addInspType(inspTypeList, per.getGuid(), per.getOrgId());
  679. });
  680. });
  681. } else {
  682. inspTypeDto.getPhoneList().forEach(phone -> {
  683. BisInspAllRlationPers p = bisInspAllRlationPersService.getBy(Builder.of(BisInspAllRlationPersParam::new)
  684. .with(BisInspAllRlationPersParam::setMobilenumb, phone)
  685. .build());
  686. Optional.ofNullable(p).ifPresent(per -> {
  687. for (InspType inspType : inspTypeList) {
  688. inspType.setPersId(per.getGuid());
  689. inspType.setOrgId(per.getOrgId());
  690. }
  691. addInspType(inspTypeList, per.getGuid(), per.getOrgId());
  692. });
  693. });
  694. }
  695. return buildSuccessResponse();
  696. }
  697. @Authority(roles = "1")
  698. @ApiOperation(value = "更新人员信息")
  699. @RequestMapping(value = "/update", method = {RequestMethod.POST})
  700. public BaseResponse update(@RequestParam(value = "file", required = false) MultipartFile file,
  701. @ApiParam(name = "bisInspAllRlationPers", value = "BisInspAllRlationPers", required = true)
  702. BisInspAllRlationPers bisInspAllRlationPers) {
  703. Assert.notNull(bisInspAllRlationPers.getGuid(), "主键guid为必填参数");
  704. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  705. if (inspAllRlationPers == null) {
  706. return buildFailResponse("当前用户不存在!!");
  707. }
  708. if (!getCurrentPersId().equals(bisInspAllRlationPers.getGuid()) && !"1".equals(inspAllRlationPers.getPersType())) {
  709. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  710. }
  711. if (file != null) {
  712. Calendar dat = Calendar.getInstance();
  713. //写入文件
  714. String originalFilename = file.getOriginalFilename();
  715. GwComFile gwComFile = new GwComFile();
  716. gwComFile.setId(bisInspAllRlationPers.getGuid());
  717. gwComFile.setFileName(originalFilename);
  718. gwComFile.setFileSize((double) file.getSize());
  719. gwComFile.setFileExt(originalFilename.substring(1 + originalFilename.lastIndexOf(".")));
  720. 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();
  721. gwComFile.setFilePath(filePath);
  722. if ("JPEG".equals(gwComFile.getFileExt().toUpperCase()) || "JPG".equals(gwComFile.getFileExt().toUpperCase()) || "PNG".equals(gwComFile.getFileExt().toUpperCase())) {
  723. //写入文件
  724. String filePath2 = dat.get(Calendar.YEAR) + File.separator + (dat.get(Calendar.MONTH) + 1) + File.separator + dat.get(Calendar.DAY_OF_MONTH);
  725. gwComFileService.writeFile(gwComFile, file, filePath2);
  726. bisInspAllRlationPers.setImgurl(filePath);
  727. }
  728. }
  729. // addPreOrg(bisInspAllRlationPers);
  730. if (StringUtils.isNotBlank(bisInspAllRlationPers.getPwd())) {
  731. bisInspAllRlationPers.setPwd(MD5.getMD5(aesUtil.desEncrypt(bisInspAllRlationPers.getPwd().replace(" ", "+"))));
  732. }
  733. bisInspAllRlationPersService.update(bisInspAllRlationPers);
  734. /* //添加人员到小鱼账号
  735. try {
  736. bisInspMeetInvitationService.batchUser(bisInspAllRlationPers);
  737. } catch (IOException e) {
  738. e.printStackTrace();
  739. }*/
  740. return buildSuccessResponse(bisInspAllRlationPers);
  741. }
  742. @Authority(roles = "1")
  743. @ApiOperation(value = "批量更新人员信息")
  744. @PostMapping("/batchUpdateType")
  745. public BaseResponse batchUpdateType(@RequestBody Map<String, Object> params) {
  746. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  747. Optional.ofNullable(inspAllRlationPers).orElseThrow(() -> new CheckException("当前用户不存在!!"));
  748. if (!"1".equals(inspAllRlationPers.getPersType())) {
  749. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  750. }
  751. List<String> persIdList = (List<String>) params.get("persIdList");
  752. String persType = MapUtils.getString(params, "persType");
  753. if (CollectionUtils.isEmpty(persIdList)) {
  754. return buildFailResponse("persIdList is blank");
  755. }
  756. if (StringUtils.isBlank(persType)) {
  757. return buildFailResponse("persType is blank");
  758. }
  759. BisInspAllRlationPers p = new BisInspAllRlationPers();
  760. p.setPersType(persType);
  761. persIdList.forEach(id -> {
  762. p.setGuid(id);
  763. bisInspAllRlationPersService.update(p);
  764. });
  765. return buildSuccessResponse();
  766. }
  767. @ApiOperation(value = "根据条件获取人员信息列表", notes = "参数字段说明:{\n\r" +
  768. " \"guid\":\"人员ID\",\n\r" +
  769. " \"orgId\":\"机构Id\",\n\r" +
  770. " \"orgNm\":\"机构名称\",\n\r" +
  771. " \"dpnm\":\"部门名称\",\n\r" +
  772. " \"dppost\":\"职称\",\n\r" +
  773. " \"school\":\"学校\",\n\r" +
  774. " \"persName\":\"姓名\",\n\r" +
  775. " };\n\r" +
  776. "返回结构说明: {\n\r" +
  777. " \"code\":\"请求状态码\",\n\r" +
  778. " \"data(数据信息对象) \": {\n\r" +
  779. " \"endRow\":\"尾行\",\n\r" +
  780. " \"firstPage\":\"首页\",\n\r" +
  781. " \"hasNextPage\":\"是否有下一页\",\n\r" +
  782. " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
  783. " \"isFirstPage\":\"是否是第一页\",\n\r" +
  784. " \"isLastPage\":\"是否是最后一页\",\n\r" +
  785. " \"lastPage\":\"最后页\",\n\r" +
  786. " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
  787. " \"list(结果集)\":[\n\r" +
  788. " {\n\r" +
  789. " \"guid\":\"人员ID\",\n\r" +
  790. " \"orgId\":\"机构ID\",\n\r" +
  791. " \"orgNm\":\"机构名称\",\n\r" +
  792. " \"admDuty\":\"职务\",\n\r" +
  793. " \"orgGrad\":\"职责\",\n\r" +
  794. " \"idnm\":\"工作证号\",\n\r" +
  795. " \"plst\":\"政治面貌\",\n\r" +
  796. " \"school\":\"学校\",\n\r" +
  797. " \"specialty\":\"专业\",\n\r" +
  798. " \"imgurl\":\"照片地址\",\n\r" +
  799. " \"persName\":\"人员姓名\",\n\r" +
  800. " \"pwd\":\"密码\",\n\r" +
  801. " \"telnumb\":\"电话号码\",\n\r" +
  802. " \"mobilenumb\":\"手机号码\",\n\r" +
  803. " \"email\":\"邮箱\",\n\r" +
  804. " \"bornDate\":\"出生日期\",\n\r" +
  805. " \"collTime\":\"录入日期\",\n\r" +
  806. " \"remark\":\"备注\",\n\r" +
  807. " \"faxnumb\":\"传真号码\",\n\r" +
  808. " }\n\r" +
  809. " ],\n\r" +
  810. " \"navigateFirstPage\":\"未知\",\n\r" +
  811. " \"navigateLastPage\":\"未知\",\n\r" +
  812. " \"navigatePages\":\"未知\",\n\r" +
  813. " \"list(结果集)\":[\n\r" +
  814. " ],\n\r" +
  815. " \"nextPage\":\"下一页\",\n\r" +
  816. " \"pageNum\":\"页码\",\n\r" +
  817. " \"pageSize\":\"每页多少条\",\n\r" +
  818. " \"pages\":\"总页数\",\n\r" +
  819. " \"prePage\":\"前一页\",\n\r" +
  820. " \"size\":\"未知\",\n\r" +
  821. " \"startRow\":\"未知\",\n\r" +
  822. " \"total\":\"总条数\",\n\r" +
  823. " },\n\r" +
  824. " \"message\":\"响应消息\",\n\r" +
  825. " \"path\":\"路径\",\n\r" +
  826. " \"success\":\"是否成功\",\n\r" +
  827. " \"throwable\":\"异常\",\n\r" +
  828. " }")
  829. @Authority(roles = "1")
  830. @RequestMapping(value = "/list", method = {RequestMethod.POST})
  831. public BaseResponse<PageInfo<PersListDto>> list(@RequestBody BisInspAllRlationPersParam p) {
  832. PageInfo<PersListDto> list = bisInspAllRlationPersService.findPersData(p);
  833. for (int i = 0; i < list.getList().size(); i++) {
  834. String tel = list.getList().get(i).getMobilenumb() == null ? "" : list.getList().get(i).getMobilenumb().toString();
  835. if (!"".equals(tel)) {
  836. list.getList().get(i).setMobilenumb(TelUtil.getTel(tel));
  837. }
  838. }
  839. return buildSuccessResponse(list);
  840. }
  841. @ApiOperation(value = "根据id获取人员(对象详情)")
  842. @RequestMapping(value = "/createWork", method = {RequestMethod.GET})
  843. public BaseResponse<String> createWork() {
  844. boolean bol = bisInspAllRlationPersService.createWork();
  845. return buildSuccessResponse("true");
  846. }
  847. @ApiOperation(value = "设置组长")
  848. @RequestMapping(value = "/setHeadMan", method = {RequestMethod.GET})
  849. public BaseResponse setHeadMan(@ApiParam(name = "BisInspAllRlation", value = "BisInspAllRlation", required = true) BisInspAllRlation bisInspAllRlation) {
  850. int i = bisInspAllRlationPersService.setHeadMan(bisInspAllRlation);
  851. return buildSuccessResponse();
  852. }
  853. @ApiOperation(value = "修改密码", notes = "参数字段说明:{\n\r" +
  854. " \"userCode\":\"用户编码\",\n\r" +
  855. " \"oldPassword\":\"旧密码\",\n\r" +
  856. " \"newPassword\":\"新 密码\",\n\r" +
  857. " };\n\r" +
  858. "返回结构说明:{\n\r" +
  859. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  860. " \"code\":\"错误代码\",\n\r" +
  861. " \"message\":\"描述信息\",\n\r" +
  862. " \"throwable\":\"异常信息\",\n\r" +
  863. " \"data\":null")
  864. @RequestMapping(value = "changePassword", method = RequestMethod.POST)
  865. public BaseResponse changePassword(String userCode, String password, String newPassword) {
  866. Assert.notNull(userCode, "主键id为必填参数");
  867. Assert.notNull(password, "修改前密码不能为空");
  868. Assert.notNull(newPassword, "新密码不能为空");
  869. int ret = bisInspAllRlationPersService.changePassword(userCode, password, newPassword);
  870. if (0 == ret) {
  871. return buildFailResponse(0, "用户不存在");
  872. }
  873. if (2 == ret) {
  874. return buildFailResponse(2, "原密码错误,修改密码失败");
  875. }
  876. return buildSuccessResponse();
  877. }
  878. @ApiOperation(value = "修改用户(关联角色)")
  879. @RequestMapping(value = "updateUser", method = RequestMethod.POST)
  880. public BaseResponse<String> updateUser(@ApiParam(name = "bisInspAllRlationPers", value = "bisInspAllRlationPers", required = true) @RequestBody BisInspAllRlationPers bisInspAllRlationPers) {
  881. Assert.notNull(bisInspAllRlationPers, "用户对象不能为空");
  882. Assert.notNull(bisInspAllRlationPers.getGuid(), "用户ID不能为空");
  883. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  884. if (inspAllRlationPers == null) {
  885. return buildFailResponse("当前用户不存在!!");
  886. }
  887. //只有管理员能够操作
  888. if (!"1".equals(inspAllRlationPers.getPersType())) {
  889. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  890. }
  891. logger.info("修改用户权限1");
  892. ArrayList<UserRoleParam> userRoleParams = new ArrayList<>();
  893. if (null != bisInspAllRlationPers.getRoleIds() && bisInspAllRlationPers.getRoleIds().size() > 0) {
  894. for (String roleId : bisInspAllRlationPers.getRoleIds()) {
  895. UserRoleParam userRoleParam = new UserRoleParam();
  896. userRoleParam.setUserId(bisInspAllRlationPers.getGuid());
  897. userRoleParam.setRoleId(roleId);
  898. userRoleParams.add(userRoleParam);
  899. }
  900. }
  901. UserRoleParam param = new UserRoleParam();
  902. param.setUserId(bisInspAllRlationPers.getGuid());
  903. BisInspAllRlationPers per = new BisInspAllRlationPers();
  904. per.setGuid(bisInspAllRlationPers.getGuid());
  905. if (StringUtils.isNotBlank(bisInspAllRlationPers.getOwnerSystem())) {
  906. per.setOwnerSystem(bisInspAllRlationPers.getOwnerSystem());
  907. bisInspAllRlationPersService.update(per);
  908. }
  909. logger.info("修改用户权限2");
  910. bisInspAllRlationPersService.updateUser(userRoleParams, param);
  911. logger.info("修改用户权限3");
  912. /* //修改用户类型,为用户添加节点
  913. if (bisInspAllRlationPers.getPersType() != null) {
  914. bisInspAllRlationPersService.updateUserNode(bisInspAllRlationPers.getGuid(), bisInspAllRlationPers.getPersType(), getCurrentOrgId());
  915. }*/
  916. return buildSuccessResponse();
  917. }
  918. @Authority(roles = "1")
  919. @ApiOperation(value = "修改用户(关联角色)")
  920. @PostMapping("/batch/updateRole")
  921. public BaseResponse batchUpdateRole(@RequestBody Map<String, Object> params) {
  922. BisInspAllRlationPers inspAllRlationPers = bisInspAllRlationPersService.get(getCurrentPersId());
  923. if (inspAllRlationPers == null) {
  924. return buildFailResponse("当前用户不存在!!");
  925. }
  926. //只有管理员能够操作
  927. if (!"1".equals(inspAllRlationPers.getPersType())) {
  928. return buildFailResponse(9993, "当前用户无权限执行该操作!!");
  929. }
  930. List<String> roleIds = (List<String>) params.get("roleIds");
  931. List<String> persIdList = (List<String>) params.get("persIdList");
  932. if (CollectionUtils.isEmpty(persIdList) || CollectionUtils.isEmpty(roleIds)) {
  933. return buildFailResponse("roleIds or persIdList is blank");
  934. }
  935. persIdList.stream().distinct().forEach(id -> updateRole(id, roleIds));
  936. return buildSuccessResponse();
  937. }
  938. /**
  939. * 更新用户角色
  940. *
  941. * @param guid 用户ID
  942. * @param roleIds 角色ID
  943. */
  944. private void updateRole(String guid, List<String> roleIds) {
  945. List<UserRoleParam> userRoleParams = new ArrayList<>();
  946. for (String roleId : roleIds) {
  947. UserRoleParam userRoleParam = new UserRoleParam(guid, roleId);
  948. userRoleParams.add(userRoleParam);
  949. }
  950. UserRoleParam param = new UserRoleParam();
  951. param.setUserId(guid);
  952. bisInspAllRlationPersService.updateUser(userRoleParams, param);
  953. }
  954. @ApiOperation(value = "获取在线用户个数", notes = "参数字段说明:{\n\r" +
  955. " \"startTime\":\"统计开始时间(非必填),默认统计最近两小时的在线人员\",\n\r" +
  956. " \"endTime\":\"统计结束时间(非必填)\",\n\r" +
  957. " };\n\r" +
  958. "返回结构说明:{\n\r" +
  959. " \"success\":\"是否成功(true为成功,false为失败)\",\n\r" +
  960. " \"code\":\"错误代码\",\n\r" +
  961. " \"message\":\"描述信息\",\n\r" +
  962. " \"throwable\":\"异常信息\",\n\r" +
  963. " \"data\":\"在线人数\"")
  964. @RequestMapping(value = "/getCountOnlinePers", method = RequestMethod.GET)
  965. public BaseResponse getCountOnlinePers(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime) {
  966. if (StringUtils.isBlank(endTime)) {
  967. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  968. Calendar calendar = Calendar.getInstance();
  969. endTime = sdf.format(calendar.getTime());
  970. calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) - 2);
  971. startTime = sdf.format(calendar.getTime());
  972. }
  973. String province = olBisInspOrgService.getProvince(getCurrentOrgId());
  974. int ret = bisInspAllRlationPersService.selectCountOnlinePers(startTime, endTime, province);
  975. return buildSuccessResponse(ret);
  976. }
  977. @ApiOperation(value = "获取在线用户", notes = "参数字段说明:{\n\r" +
  978. " \"startTime\":\"统计开始时间(非必填),默认统计最近两小时的在线人员\",\n\r" +
  979. " \"endTime\":\"统计结束时间(非必填)\",\n\r" +
  980. " };\n\r" +
  981. "返回结构说明: {\n\r" +
  982. " \"code\":\"请求状态码\",\n\r" +
  983. " \"data(数据信息对象) \": {\n\r" +
  984. " \"endRow\":\"尾行\",\n\r" +
  985. " \"firstPage\":\"首页\",\n\r" +
  986. " \"hasNextPage\":\"是否有下一页\",\n\r" +
  987. " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
  988. " \"isFirstPage\":\"是否是第一页\",\n\r" +
  989. " \"isLastPage\":\"是否是最后一页\",\n\r" +
  990. " \"lastPage\":\"最后页\",\n\r" +
  991. " \"hasPreviousPage\":\"是否有前一页\",\n\r" +
  992. " \"list(结果集)\":[\n\r" +
  993. " {\n\r" +
  994. " \"guid\":\"人员ID\",\n\r" +
  995. " \"orgId\":\"机构ID\",\n\r" +
  996. " \"orgNm\":\"机构名称\",\n\r" +
  997. " \"admDuty\":\"职务\",\n\r" +
  998. " \"orgGrad\":\"职责\",\n\r" +
  999. " \"idnm\":\"工作证号\",\n\r" +
  1000. " \"plst\":\"政治面貌\",\n\r" +
  1001. " \"school\":\"学校\",\n\r" +
  1002. " \"specialty\":\"专业\",\n\r" +
  1003. " \"imgurl\":\"照片地址\",\n\r" +
  1004. " \"persName\":\"人员姓名\",\n\r" +
  1005. " \"pwd\":\"密码\",\n\r" +
  1006. " \"telnumb\":\"电话号码\",\n\r" +
  1007. " \"mobilenumb\":\"手机号码\",\n\r" +
  1008. " \"email\":\"邮箱\",\n\r" +
  1009. " \"bornDate\":\"出生日期\",\n\r" +
  1010. " \"collTime\":\"录入日期\",\n\r" +
  1011. " \"remark\":\"备注\",\n\r" +
  1012. " \"faxnumb\":\"传真号码\",\n\r" +
  1013. " }\n\r" +
  1014. " ],\n\r" +
  1015. " \"navigateFirstPage\":\"未知\",\n\r" +
  1016. " \"navigateLastPage\":\"未知\",\n\r" +
  1017. " \"navigatePages\":\"未知\",\n\r" +
  1018. " \"list(结果集)\":[\n\r" +
  1019. " ],\n\r" +
  1020. " \"nextPage\":\"下一页\",\n\r" +
  1021. " \"pageNum\":\"页码\",\n\r" +
  1022. " \"pageSize\":\"每页多少条\",\n\r" +
  1023. " \"pages\":\"总页数\",\n\r" +
  1024. " \"prePage\":\"前一页\",\n\r" +
  1025. " \"size\":\"未知\",\n\r" +
  1026. " \"startRow\":\"未知\",\n\r" +
  1027. " \"total\":\"总条数\",\n\r" +
  1028. " },\n\r" +
  1029. " \"message\":\"响应消息\",\n\r" +
  1030. " \"path\":\"路径\",\n\r" +
  1031. " \"success\":\"是否成功\",\n\r" +
  1032. " \"throwable\":\"异常\",\n\r" +
  1033. " }")
  1034. @RequestMapping(value = "/getOnlinePers", method = RequestMethod.GET)
  1035. public BaseResponse getCountOnlinePers2(@RequestParam(required = false) String sttm, @RequestParam(required = false) String entm) {
  1036. if (StringUtils.isBlank(entm)) {
  1037. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1038. Calendar calendar = Calendar.getInstance();
  1039. entm = sdf.format(calendar.getTime());
  1040. calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) - 2);
  1041. sttm = sdf.format(calendar.getTime());
  1042. }
  1043. List<HashMap<String, Object>> ret = bisInspAllRlationPersService.selectOnlinePers(sttm, entm, getCurrentOrgId());
  1044. return buildSuccessResponse(ret);
  1045. }
  1046. @ApiOperation(value = "更新人员小鱼账号")
  1047. @RequestMapping(value = "/updateCallNumber", method = {RequestMethod.POST})
  1048. public BaseResponse updateCallNumber(HttpServletRequest request, @RequestBody UpdateCallNumberParam param
  1049. ) throws Exception {
  1050. if (StringUtils.isBlank(param.getPersId())) {
  1051. param.setPersId(request.getHeader("persId"));
  1052. }
  1053. if (StringUtils.isBlank(param.getPersId())) {
  1054. throw new Exception("缺少persId");
  1055. }
  1056. if (StringUtils.isBlank(param.getCallNumber())) {
  1057. throw new Exception("缺少callNumber");
  1058. }
  1059. BisInspAllRlationPers p = new BisInspAllRlationPers();
  1060. p.setGuid(param.getPersId());
  1061. p.setCallnumber(param.getCallNumber());
  1062. int ret = bisInspAllRlationPersService.update(p);
  1063. if (ret == -2147482646) {
  1064. return buildSuccessResponse(p);
  1065. } else {
  1066. return buildFailResponse(500, "更新失败", request.getRequestURI(), "");
  1067. }
  1068. }
  1069. @ApiOperation(value = "获取小组组长信息")
  1070. @RequestMapping(value = "getLeaderByGroup", method = RequestMethod.POST)
  1071. public BaseResponse<GroupLeaderDto> getLeaderByGroup(@RequestBody GroupLeaderParam groupLeaderParam) {
  1072. BisInspOrg inspOrg = bisInspOrgDao.get(getCurrentOrgId());
  1073. if (inspOrg != null && !inspOrg.getRlcode().startsWith(AdCodeLabel.START_PARENT_ADCODE)) {
  1074. groupLeaderParam.setProvince(inspOrg.getRlcode());
  1075. }
  1076. return buildSuccessResponse(this.bisInspAllRlationPersService.getLeaderByGroup(groupLeaderParam));
  1077. }
  1078. // @Authority(roles = "1")
  1079. @VerifyBean
  1080. @ApiOperation(value = "获取用户列表(用户管理界面)")
  1081. @RequestMapping(value = "listByCurUser", method = RequestMethod.POST)
  1082. public BaseResponse<PageInfo<PersListDto>> listByCurUser(@RequestBody UserListByCurUserParam param) throws Exception {
  1083. String addvcd = AdLevelUtil.getAddvcd(olBisInspOrgService.getRlProvince(getCurrentOrgId()));
  1084. BisInspOrg inspOrg = bisInspOrgDao.get(getCurrentOrgId());
  1085. if (inspOrg != null && !inspOrg.getRlcode().startsWith(AdCodeLabel.START_PARENT_ADCODE)) {
  1086. param.setProvince(AdLevelUtil.getAddvcd(inspOrg.getRlcode()));
  1087. } else {
  1088. param.setOrgId("");
  1089. }
  1090. PageInfo<PersListDto> list = bisInspAllRlationPersService.listByCurUser(param, addvcd);
  1091. return buildSuccessResponse(list);
  1092. }
  1093. @Authority
  1094. @ApiOperation(value = "获取督查组中人员类型--人员类型(1:组长;2:组员;3:联络员;4:专家;11:前期专家;12:监管专家;13:计划专家;14:财务专家;15:质量专家;16:安全专家;19:助理;20:特派员)")
  1095. @RequestMapping(value = "/getPerType", method = RequestMethod.POST)
  1096. 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) {
  1097. BisInspAllRlationParam param = new BisInspAllRlationParam();
  1098. param.setId(inspGroupId);
  1099. param.setPersid(persId);
  1100. List<BisInspAllRlation> list = bisInspAllRlationService.findList(param);
  1101. if (list == null || list.size() == 0) {
  1102. list = new ArrayList<>();
  1103. BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
  1104. bisInspAllRlation.setId(inspGroupId);
  1105. bisInspAllRlation.setPersid(persId);
  1106. bisInspAllRlation.setPertype("1");
  1107. list.add(bisInspAllRlation);
  1108. }
  1109. return buildSuccessResponse(list);
  1110. }
  1111. @Authority
  1112. @ApiOperation(value = "获取稽察组中人员类型--人员类型(1:组长;2:组员;3:联络员;4:专家;11:前期专家;12:监管专家;13:计划专家;14:财务专家;15:质量专家;16:安全专家;19:助理;20:特派员)")
  1113. @RequestMapping(value = "/getPerTypeNew", method = RequestMethod.GET)
  1114. 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) {
  1115. BisInspAllRlationPers pers = bisInspAllRlationPersService.get(persId);
  1116. List<BisInspAllRlation> list = new ArrayList<>();
  1117. if ("1".equals(pers.getPersType())) {
  1118. BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
  1119. bisInspAllRlation.setId(inspGroupId);
  1120. bisInspAllRlation.setPersid(persId);
  1121. bisInspAllRlation.setPertype("1");
  1122. list.add(bisInspAllRlation);
  1123. }
  1124. if (list.size() == 0) {
  1125. TacInspYearBatchGroupPersParam param = new TacInspYearBatchGroupPersParam();
  1126. param.setGroupId(inspGroupId);
  1127. param.setPersId(persId);
  1128. List<BisInspAllRlation> rlations = groupPersService.findPersList(param);
  1129. list.addAll(rlations);
  1130. }
  1131. if (list.size() == 0) {
  1132. BisInspAllRlation bisInspAllRlation = new BisInspAllRlation();
  1133. bisInspAllRlation.setId(inspGroupId);
  1134. bisInspAllRlation.setPersid(persId);
  1135. bisInspAllRlation.setPertype("1");
  1136. list.add(bisInspAllRlation);
  1137. }
  1138. return buildSuccessResponse(list);
  1139. }
  1140. @ApiOperation(value = "获取加密公钥,并且把对应私钥储存到Redis")
  1141. @RequestMapping(value = "/getPubKey", method = RequestMethod.POST)
  1142. public BaseResponse<String> getPubKey() {
  1143. Map<Integer, String> keyMap = Encryption.genKeyPair();
  1144. redisTemplate.opsForValue().set(keyMap.get(0), keyMap.get(1), 10, TimeUnit.MINUTES);
  1145. return buildSuccessResponse(keyMap.get(0));
  1146. }
  1147. @ApiOperation(value = "退出系统")
  1148. @RequestMapping(value = "/logOut", method = RequestMethod.GET)
  1149. public BaseResponse logOut(HttpServletRequest request) {
  1150. String uuid = request.getHeader(CommonLabel.ACCESS_TOKEN);
  1151. String accessToken = (String) redisTemplate.opsForValue().get(uuid);
  1152. if (StringUtils.isNotBlank(accessToken)) {
  1153. String persId = request.getHeader(CommonLabel.PERSID);
  1154. LoginUser inspAllRlationPers = JWTTokenUtil.unsign(accessToken, persId);
  1155. if (inspAllRlationPers != null) {
  1156. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(inspAllRlationPers.getPersId());
  1157. //bisInspAllRlationPersService.sendChannel(uuid, bisInspAllRlationPers, request, PlusEnum.PLUS.getNumber());
  1158. }
  1159. }
  1160. redisTemplate.delete(uuid);
  1161. return buildSuccessResponse();
  1162. }
  1163. @ApiOperation(value = "添加多用户")
  1164. @RequestMapping(value = "/updateListUsers", method = RequestMethod.POST)
  1165. public BaseResponse updateUsers(@ApiParam(name = "AddRlationPersDto", value = "AddRlationPersDto", required = true)
  1166. @RequestBody AddRlationPersDto addRlationPersDto) {
  1167. return buildSuccessResponse(bisInspAllRlationPersService.updateListUsers(addRlationPersDto));
  1168. }
  1169. @ApiOperation(value = "获取对象信息")
  1170. @RequestMapping(value = "/getUserById", method = RequestMethod.POST)
  1171. public BaseResponse<BisInspAllRlationPers> getUserById(HttpServletRequest request) {
  1172. String persId = request.getHeader(CommonLabel.PERSID);
  1173. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId);
  1174. return buildSuccessResponse(bisInspAllRlationPers);
  1175. }
  1176. @ApiOperation(value = "获取对象信息")
  1177. @RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)
  1178. public BaseResponse<BisInspAllRlationPers> getUserInfo(@RequestParam String persId) {
  1179. BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(persId);
  1180. bisInspAllRlationPers = getBisInspAllRlations(bisInspAllRlationPers);
  1181. return buildSuccessResponse(bisInspAllRlationPers);
  1182. }
  1183. }