| | |
| | | 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.common.utils.*; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改保安员信息 |
| | | */ |
| | | @PostMapping("/updateSecurityInfo") |
| | | public R updateSecurityInfo(@RequestBody User user) throws Exception { |
| | | User user1 = userService.getById(user.getId()); |
| | | user.setId(user1.getId()); |
| | | user.setUpdateTime(new Date()); |
| | | user.setPassword(user1.getPassword()); |
| | | //创建更新的字符串 |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("update blade-user set update_time = "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime())); |
| | | |
| | | //姓名 |
| | | if (null != user.getRealName() && !user.getRealName().equals("")) { |
| | | builder.append(",set real_name = "+user.getRealName()); |
| | | } |
| | | |
| | | int state = 1; |
| | | //身份证号码 |
| | | if (null != user.getCardid() && !user.getCardid().equals("")) { |
| | | //身份证号校验 |
| | | //去除所有空格 |
| | | String cardid = user.getCardid().replaceAll(" ", ""); |
| | | //校验 |
| | | boolean b = IdCardNoUtil.checkIdCardNo(cardid); |
| | | if(b){ |
| | | user.setCardid(cardid); |
| | | //账号,密码也修改 |
| | | user.setAccount(user1.getRealName().substring(0,1)+cardid.substring(cardid.length()-4)); |
| | | //获取默认密码配置 |
| | | user.setPassword(user.getCardid().substring(user.getCardid().length() - 6)); |
| | | //加密 |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | state = 2; |
| | | builder.append(",set account = "+user.getAccount()+",set cardid = "+user.getCardid()+",set password = "+user.getPassword()); |
| | | }else { |
| | | throw new ServiceException("导入失败!身份证号码[ "+user.getCardid()+" ]不正确,请核对!"); |
| | | } |
| | | } |
| | | //手机号 |
| | | if (null != user.getPhone() && !user.getPhone().equals("")) { |
| | | builder.append(",set phone = "+user.getPhone()); |
| | | } |
| | | //指纹url 处理 |
| | | String url = ""; |
| | | if (null != user.getFingerprint() && !user.getFingerprint().equals("")) { |
| | | if (user.getFingerprint().length() > 100) { |
| | | //指纹图片上传并返回url |
| | | String s = uploadBase64String(user); |
| | | String[] split = s.split(","); |
| | | user.setFingerprint(split[0]); |
| | | //内网指纹图片url |
| | | url = split[1]; |
| | | builder.append(",set fingerprint = "+url); |
| | | } |
| | | } |
| | | //头像 |
| | | if (null != user.getAvatar() && !user.getAvatar().equals("")) { |
| | | String avatar = FtpConfig.ip +"/"+ user.getAvatar().substring(26); |
| | | System.out.println("头像上传 url = " + avatar); |
| | | builder.append(",set fingerprint = "+avatar); |
| | | } |
| | | |
| | | //名族 |
| | | if (null != user.getNation() && !user.getNation().equals("")) { |
| | | builder.append(",set nation = "+user.getNation()); |
| | | } |
| | | //学历 |
| | | if (null != user.getEducation() && !user.getEducation().equals("")) { |
| | | builder.append(",set education = "+user.getEducation()); |
| | | } |
| | | //政治面貌 |
| | | if (null != user.getPoliticaloutlook() && !user.getPoliticaloutlook().equals("")) { |
| | | builder.append(",set politicaloutlook = "+user.getPoliticaloutlook()); |
| | | } |
| | | //健康状态 |
| | | if (null != user.getHealstats() && !user.getHealstats().equals("")) { |
| | | builder.append(",set healstats = "+user.getHealstats()); |
| | | } |
| | | //身高 |
| | | if (null != user.getHeight() && !user.getHeight().equals("")) { |
| | | builder.append(",set height = "+user.getHeight()); |
| | | } |
| | | //联系地址 |
| | | if (null != user.getAddress() && !user.getAddress().equals("")) { |
| | | builder.append(",set address = "+user.getAddress()); |
| | | } |
| | | //身份证地址 |
| | | if (null != user.getRegistered() && !user.getRegistered().equals("")) { |
| | | builder.append(",set registered = "+user.getRegistered()); |
| | | } |
| | | |
| | | //修改 |
| | | 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); |
| | | } |
| | | } |
| | | //拼接最终的sql |
| | | String sql = builder.append(" where id = " + user.getId()).toString(); |
| | | myAsyncService.FTP(sql); |
| | | //返回 |
| | | return R.data(200,null,"修改成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 账号修改 |
| | | * @param user |
| | | * @return |