| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.common.config.FtpConfig; |
| | | import org.springblade.common.utils.DesensitizedUtil; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.http.util.HttpUtil; |
| | |
| | | import org.springblade.core.tool.constant.RoleConstant; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.system.dto.UserDTO; |
| | | import org.springblade.modules.system.entity.Role; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.excel.UserExcel; |
| | |
| | | import org.springblade.modules.system.excel.UserImporters; |
| | | import org.springblade.modules.system.service.IRoleService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.vo.UserRegisterStatisVO; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.system.vo.UsersVo; |
| | | import org.springblade.modules.system.wrapper.UserWrapper; |
| | | import org.springblade.modules.taskqd.vo.TaskqdVO; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; |
| | | |
| | |
| | | //获取user |
| | | User user = JSON.parseObject(JSON.toJSONString(userMap.get("user")), User.class); |
| | | |
| | | //数据脱敏处理 |
| | | user.setAccount(user.getRealName().substring(0,1)+user.getCardid().substring(user.getCardid().length()-4)); |
| | | user.setCardid(DesensitizedUtil.desensitizedIdNumber(user.getCardid())); |
| | | user.setPhone(DesensitizedUtil.desensitizedPhoneNumber(user.getPhone())); |
| | | user.setName(DesensitizedUtil.desensitizedName(user.getName())); |
| | | user.setRealName(DesensitizedUtil.desensitizedName(user.getRealName())); |
| | | |
| | | |
| | | Integer userCount = userService.selectCount(user.getAccount()); |
| | | if (userCount > 0 && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | |
| | | @PostMapping("/securitySaves") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R securitySaves(@RequestBody User user) { |
| | | Integer userCount = userService.selectCount(user.getAccount()); |
| | | //判断用户是否存在 |
| | | if (userCount > 0) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | user.setRoleId("1372092102682521602"); |
| | | // Integer userCount = userService.selectCount(user.getAccount()); |
| | | // //判断用户是否存在 |
| | | // if (userCount > 0) { |
| | | // throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | // } |
| | | user.setRoleId("1495714343888039937"); |
| | | user.setDeptId("1424615972718895106"); |
| | | user.setStype("1"); |
| | | user.setId(null); |
| | | //用户新增 |
| | | boolean status = userService.save(user); |
| | | // System.out.println("user = " + user); |
| | | //返回 |
| | | return R.status(status); |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * 保安员修改(数据同步调用) |
| | | */ |
| | | @PostMapping("/updateBySecurtiy") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R updateBySecurtiy(@RequestBody User user) { |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | // user1.setCardid(user.getCardid()); |
| | | user1.setSecurityId(user.getSecurityId()); |
| | | User one = userService.getOne(Condition.getQueryWrapper(user1)); |
| | | boolean status = false; |
| | | if (null!=one){ |
| | | one.setRealName(user.getRealName()); |
| | | one.setAvatar(user.getAvatar()); |
| | | one.setPhone(user.getPhone()); |
| | | one.setExamination_type(user.getExamination_type()); |
| | | one.setStatus(user.getStatus()); |
| | | one.setUpdateTime(new Date()); |
| | | //修改 |
| | | status = userService.updateById(one); |
| | | } |
| | | //返回 |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 保安员信息修改(账号,身份证,密码 修改) |
| | | */ |
| | | @PostMapping("/updateUserByAccount") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R updateUserByAccount(@RequestBody UserDTO user) { |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | user1.setSecurityId(user.getSecurityId()); |
| | | // user1.setCardid(user.getOldCardid()); |
| | | User one = userService.getOne(Condition.getQueryWrapper(user1)); |
| | | boolean status = false; |
| | | if (null!=one){ |
| | | //修改 |
| | | if (null!= one.getAccount()) { |
| | | one.setAccount(user.getAccount()); |
| | | } |
| | | if (null!= one.getCardid()) { |
| | | one.setCardid(user.getCardid()); |
| | | } |
| | | if (null!= one.getPassword()) { |
| | | one.setPassword(user.getPassword()); |
| | | } |
| | | if (null!= one.getAvatar()) { |
| | | one.setAvatar(user.getAvatar()); |
| | | } |
| | | if (null!= one.getPhone()) { |
| | | one.setPhone(user.getPhone()); |
| | | } |
| | | if (null!= one.getRealName()) { |
| | | one.setRealName(user.getRealName()); |
| | | } |
| | | one.setUpdateTime(new Date()); |
| | | //用户修改 |
| | | status = userService.updateById(one); |
| | | } |
| | | //返回 |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 同步删除 |
| | | */ |
| | | @PostMapping("/removeSecurity") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R removeSecurity(@RequestBody User user) { |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | user1.setSecurityId(user.getSecurityId()); |
| | | // user1.setCardid(user.getCardid()); |
| | | User one = userService.getOne(Condition.getQueryWrapper(user1)); |
| | | boolean status = false; |
| | | if (null!=one){ |
| | | //修改 |
| | | one.setIsDeleted(1); |
| | | //用户修改 |
| | | status = userService.removeById(one.getId()); |
| | | } |
| | | //返回 |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | | * 人员统计 |
| | | */ |
| | | @GetMapping("/userCount") |
| | | public R cancelTask(String xid,String index) { |
| | | List<UserRegisterStatisVO> cout = userService.getUserTypeCountXq(xid); |
| | | List<UserVO> list = userService.getUserTypeList(xid,index); |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("cout",cout); |
| | | res.put("list",list); |
| | | return R.data(res); |
| | | } |
| | | |
| | | /** |
| | | * 首次登录发送祝贺信 |
| | | */ |
| | | @GetMapping("/firstLogin") |
| | | public R firstLogin(String id) { |
| | | return R.status(userService.firstLogin(id)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 清除无效编号 |
| | | */ |
| | | @GetMapping("/clearPaper") |
| | | public void clearPaper() { |
| | | //修改符合条件的用户信息 |
| | | String s0 ="update blade_user set securitynumber = '',hold = '2' where securitynumber like concat('%','赣洪2022','%') and right(securitynumber,5) >2000"; |
| | | FtpUtil.sqlFileClear(s0); |
| | | |
| | | //修改符合条件的编号信息 |
| | | String s1 ="delete from sys_security_paper where number like concat('%','赣洪2022','%') and right(number,5) >2000"; |
| | | FtpUtil.sqlFileClear(s1); |
| | | |
| | | //修改两个用户的编号 |
| | | String s2 ="update blade_user set securitynumber = '',hold = '2' where id=1498127507772190722"; |
| | | FtpUtil.sqlFileClear(s2); |
| | | |
| | | String s3 ="update blade_user set securitynumber = '',hold = '2' where id=1502082757986168834"; |
| | | FtpUtil.sqlFileClear(s3); |
| | | } |
| | | } |
| | | |