| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.alibaba.fastjson.JSON; |
| | | import lombok.AllArgsConstructor; |
| | | import net.sf.json.JSONObject; |
| | | import org.apache.commons.codec.Charsets; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.common.config.FtpConfig; |
| | |
| | | import org.springblade.common.excel.CustomCellWriteHeightConfig; |
| | | import org.springblade.common.excel.CustomCellWriteWeightConfig; |
| | | import org.springblade.common.excel.RowWriteHandler; |
| | | import org.springblade.common.utils.HttpClientUtils; |
| | | import org.springblade.common.utils.HttpReqUtil; |
| | | import org.springblade.common.utils.ImageUtils; |
| | | import org.springblade.common.utils.arg; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.accreditation.entity.AccreditationRecords; |
| | | import org.springblade.modules.accreditation.service.AccreditationRecordsService; |
| | | import org.springblade.modules.dispatcher.entity.Dispatcher; |
| | | import org.springblade.modules.dispatcher.service.IDispatcherService; |
| | | import org.springblade.modules.exam.excel.ExportExamScoreExcel; |
| | |
| | | import org.springblade.modules.experience.service.IExperienceService; |
| | | import org.springblade.modules.jurisdiction.entity.Jurisdiction; |
| | | import org.springblade.modules.jurisdiction.service.JurisdictionService; |
| | | import org.springblade.modules.securitypaper.entity.SecurityPaper; |
| | | import org.springblade.modules.securitypaper.service.SecurityPaperService; |
| | | import org.springblade.modules.signinrecords.entity.SignInRecords; |
| | | import org.springblade.modules.signinrecords.service.SignInRecordsService; |
| | | import org.springblade.modules.system.dto.UserDTO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Role; |
| | | import org.springblade.modules.system.entity.User; |
| | |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRoleService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springblade.modules.system.vo.DeptVO; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.system.wrapper.UserWrapper; |
| | | import org.springblade.modules.training.entity.TrainingRegistration; |
| | | import org.springblade.modules.training.service.TrainingRegistrationService; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.springblade.common.config.FtpConfig.*; |
| | | import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; |
| | |
| | | |
| | | |
| | | private final TrainingRegistrationService trainingRegistrationService; |
| | | |
| | | private final AccreditationRecordsService accreditationRecordsService; |
| | | |
| | | |
| | | private final SecurityPaperService securityPaperService; |
| | | |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | } |
| | | } |
| | | |
| | | //判断是否持证 |
| | | // if (user.getHold().equals("1") && null!=user.getSecuritynumber() && !user.getSecuritynumber().equals("")){ |
| | | // //持证,校验保安证编号是否合法 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(user.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean status = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // status = true; |
| | | // } |
| | | // } |
| | | // if (!status){ |
| | | // throw new ServiceException("保安证编号不匹配,请核实!"); |
| | | // } |
| | | // }else { |
| | | // throw new ServiceException("保安证编号不匹配,请核实!"); |
| | | // } |
| | | // } |
| | | |
| | | //如果是离职 |
| | | if (null!=user.getStatus()){ |
| | | if (user.getStatus().equals(2)){ |
| | |
| | | FtpUtil.sqlFileUpload(s); |
| | | } |
| | | |
| | | userService.updateById(user); |
| | | boolean status = userService.updateById(user); |
| | | //qfqk 数据推送 |
| | | if (status){ |
| | | myAsyncService.updateUserByQfqk(user); |
| | | } |
| | | |
| | | //内网更新 |
| | | String s1 = |
| | | "update blade_user set status = " + "'" + user.getStatus() + "'" |
| | |
| | | } |
| | | } |
| | | |
| | | int state = 0; |
| | | //如果是异常标记 |
| | | if (null!=user.getExaminationType() && !user.getExaminationType().equals("")){ |
| | | if (user.getExaminationType().equals("1")) { |
| | | //吊销保安证 |
| | | user.setHold("3"); |
| | | state = 1; |
| | | } |
| | | } |
| | | |
| | | user.setPassword(user1.getPassword()); |
| | | user.setUpdateTime(new Date()); |
| | | userService.updateById(user); |
| | | |
| | | //如果身份证号修改 |
| | | if (!user.getCardid().equals(user1.getCardid())){ |
| | | //账号,密码也修改 |
| | | user.setAccount(user.getCardid()); |
| | | //获取默认密码配置 |
| | | user.setPassword(user.getCardid().substring(user.getCardid().length() - 6)); |
| | | //加密 |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | state = 2; |
| | | } |
| | | |
| | | //修改 |
| | | boolean status = userService.updateById(user); |
| | | |
| | | if (status) { |
| | | if (state == 2) { |
| | | UserDTO userDTO = new UserDTO(); |
| | | userDTO.setAccount(user.getAccount()); |
| | | userDTO.setCardid(user.getCardid()); |
| | | userDTO.setOldCardid(user1.getCardid()); |
| | | userDTO.setPassword(user.getPassword()); |
| | | userDTO.setRealName(user.getRealName()); |
| | | userDTO.setPhone(user.getPhone()); |
| | | userDTO.setSex(user.getSex()); |
| | | userDTO.setAvatar(user.getAvatar()); |
| | | //推送qfqk |
| | | myAsyncService.updateUserByAccount(userDTO); |
| | | } else { |
| | | myAsyncService.updateUserByQfqk(user); |
| | | } |
| | | } |
| | | |
| | | |
| | | String rtime; |
| | | if (user.getRtime() == null) { |
| | | String s1 = |
| | |
| | | } else { |
| | | paperTime = new SimpleDateFormat("yyyy-MM-dd").format(user.getPaperTime()); |
| | | } |
| | | //更新制证记录制证状态 |
| | | AccreditationRecords accreditationRecords = new AccreditationRecords(); |
| | | accreditationRecords.setUserId(user.getId()); |
| | | //审核通过的 |
| | | accreditationRecords.setAuditStatus(2); |
| | | //未制证的记录 |
| | | accreditationRecords.setStatus(1); |
| | | //查询 |
| | | List<AccreditationRecords> list = accreditationRecordsService.list(Condition.getQueryWrapper(accreditationRecords)); |
| | | if (list.size()>0) { |
| | | //排序 |
| | | List<AccreditationRecords> collect = list.stream().sorted(Comparator.comparing(AccreditationRecords::getId).reversed()).collect(Collectors.toList()); |
| | | //取出第一个 |
| | | AccreditationRecords accreditationRecords1 = collect.get(0); |
| | | //修改为已制证状态 |
| | | accreditationRecords1.setStatus(2); |
| | | //记录打印时间 |
| | | accreditationRecords1.setPaperTime(new Date()); |
| | | //更新 |
| | | accreditationRecordsService.updateById(accreditationRecords1); |
| | | //同步 |
| | | String s1 = |
| | | "update blade_user set paper_time = " + "'" + paperTime + "'" |
| | | + ",user_type = " + "'" + user.getUserType() + "'" |
| | | + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" |
| | | + " " + "where id = " + "'" + user.getId() + "';" + |
| | | "update sys_accreditation_records set status = " + "'" + accreditationRecords1.getStatus() + "'" + |
| | | " " + "where id = " + "'" + accreditationRecords1.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | //返回 |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | String s1 = |
| | | "update blade_user set paper_time = " + "'" + paperTime + "'" |
| | | + ",user_type = " + "'" + user.getUserType() + "'" |
| | |
| | | CacheUtil.clear(USER_CACHE); |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | list.forEach(id -> { |
| | | User user = userService.getById(id); |
| | | User user1 = new User(); |
| | | user1.setId(user.getId()); |
| | | user1.setCardid(user.getCardid()); |
| | | user1.setIsDeleted(1); |
| | | //qfqk 同步 |
| | | myAsyncService.deleteUserByQfqk(user1); |
| | | //内网同步 |
| | | String s1 = "update blade_user set is_deleted = 1 where id = " + "'" + id + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | |
| | | securityExcel.setCardid("360XXX19XXXXXX****"); |
| | | securityExcel.setNation("汉"); |
| | | securityExcel.setRegistered("江西省南昌市******"); |
| | | securityExcel.setHold("是"); |
| | | // securityExcel.setHold("是"); |
| | | securityExcel.setSecuritynumber("赣洪202100001"); |
| | | list.add(securityExcel); |
| | | |
| | |
| | | securityExcel1.setCardid("360XXX19XXXXXX****"); |
| | | securityExcel1.setNation("汉"); |
| | | securityExcel1.setRegistered("江西省南昌市******"); |
| | | securityExcel1.setHold("否"); |
| | | // securityExcel1.setHold("否"); |
| | | securityExcel1.setSecuritynumber(""); |
| | | list.add(securityExcel1); |
| | | String fileName = null; |
| | |
| | | securityExcel.setCardid("360XXX19XXXXXX****"); |
| | | securityExcel.setNation("汉"); |
| | | securityExcel.setRegistered("江西省南昌市******"); |
| | | securityExcel.setHold("是"); |
| | | // securityExcel.setHold("是"); |
| | | securityExcel.setSecuritynumber("赣洪202100001"); |
| | | list.add(securityExcel); |
| | | |
| | |
| | | securityExcel1.setCardid("360XXX19XXXXXX****"); |
| | | securityExcel1.setNation("汉"); |
| | | securityExcel1.setRegistered("江西省南昌市******"); |
| | | securityExcel1.setHold("否"); |
| | | // securityExcel1.setHold("否"); |
| | | securityExcel1.setSecuritynumber(""); |
| | | list.add(securityExcel1); |
| | | String fileName = null; |
| | |
| | | user.setExaminationType("0"); |
| | | user.setAccount(user.getCardid()); |
| | | |
| | | // Integer userCount = userService.selectCount(user.getAccount()); |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | |
| | | } |
| | | } |
| | | |
| | | //判断是否持证 |
| | | // if (user.getHold().equals("1")){ |
| | | // //持证,校验保安证编号是否合法 |
| | | // SecurityPaper securityPaper = new SecurityPaper(); |
| | | // securityPaper.setIdCardNo(user.getCardid()); |
| | | // List<SecurityPaper> securityPaperList = securityPaperService.list(Condition.getQueryWrapper(securityPaper)); |
| | | // if (securityPaperList.size()>0){ |
| | | // boolean status = false; |
| | | // //遍历 |
| | | // for (SecurityPaper paper : securityPaperList) { |
| | | // if (paper.getNumber().equals(user.getSecuritynumber())){ |
| | | // status = true; |
| | | // } |
| | | // } |
| | | // if (!status){ |
| | | // throw new ServiceException("保安证编号不匹配,请核实!"); |
| | | // } |
| | | // }else { |
| | | // throw new ServiceException("保安证编号不匹配,请核实!"); |
| | | // } |
| | | // } |
| | | |
| | | String url = ""; |
| | | if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) { |
| | | if (user.getFingerprint().length()>100) { |
| | |
| | | url = split[1]; |
| | | } |
| | | } |
| | | // } |
| | | //未持证 |
| | | // if (user.getHold().equals("2")){ |
| | | // //分配未持证保安角色 |
| | | // Role role = new Role(); |
| | | // role.setRoleAlias("未持证保安"); |
| | | // Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | // user.setRoleId(oneRole.getId().toString()); |
| | | // } |
| | | // } |
| | | |
| | | //密码加密 |
| | | if (Func.isNotEmpty(user.getCardid())) { |
| | | // user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | |
| | | user.setAvatar(FtpConfig.ip + user.getAvatar().substring(26)); |
| | | } |
| | | |
| | | //数据推送 |
| | | //1.群访群控数据推送(异步) |
| | | if (status) { |
| | | myAsyncService.qfqkUserSave(user); |
| | | } |
| | | |
| | | |
| | | //2.内网数据推送 |
| | | String s = "insert into blade_user(" + |
| | | "id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," + |
| | | "role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," + |
| | |
| | | // ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保安员账号校验 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @GetMapping("/checkAccount") |
| | | public void checkAccount(User user) { |
| | | //根据身份证号查询用户 |
| | | User user1 = new User(); |
| | | user1.setAccount(user.getCardid()); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | User user2 = userService.getOne(Condition.getQueryWrapper(user1)); |
| | | if (null!=user2){ |
| | | //判断是单位否一致 |
| | | if (null!=user.getDeptId() && !user.getDeptId().equals("")) { |
| | | if (!user2.getDeptId().equals(user.getDeptId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已在其他单位录入!", user.getCardid())); |
| | | } else { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getCardid())); |
| | | } |
| | | }else { |
| | | //没有传 deptId 的情况 |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getCardid())); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 年龄分布查询 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @PostMapping("/getAgeStatistics") |
| | | public R getAgeStatistics(UserVO user){ |
| | | return R.data(userService.getAgeStatistics(user)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询登录密码还是 123456 的单位信息 |
| | | * @return |
| | | */ |
| | | @GetMapping("/getNotUpdatePwdInfo") |
| | | public R getNotUpdatePwdInfo(){ |
| | | return R.data(userService.getNotUpdatePwdInfo()); |
| | | } |
| | | } |