| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311 |
- 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 = "根据ID添加账号到小鱼通讯录")
- @RequestMapping(value = "/meeting/add/{id}", method = {RequestMethod.POST})
- public BaseResponse addToMeetingUser(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- BisInspAllRlationPers bisInspAllRlationPers = bisInspAllRlationPersService.get(id);
- /**
- * 添加小鱼账号信息
- */
- try {
- int code = bisInspMeetInvitationService.batchUser(bisInspAllRlationPers);
- if(0==code){
- return buildSuccessResponse();
- }else {
- return buildFailResponse();
- }
- } catch (Exception e) {
- logger.error("添加小鱼账号信息 Exception",e.getMessage());
- }
- 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);
- }
- }
|