新增修改保安员信息接口,保安员导入修改,保安员新增修改,当机度身份证时,可以先将其他单位人员离职,然后再新增
8 files modified
1 files added
| | |
| | | @ExcelProperty("准考证号*") |
| | | private String candidateNo; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("理论得分*") |
| | | private Integer theoryGrade; |
| | | // @ColumnWidth(15) |
| | | // @ExcelProperty("理论得分*") |
| | | // private Integer theoryGrade; |
| | | |
| | | @ColumnWidth(15) |
| | | @ExcelProperty("实操得分*") |
| | |
| | | apply1.setIsExam(2); |
| | | applyService.updateById(apply1); |
| | | |
| | | |
| | | //数据同步 |
| | | String s = |
| | | "update sys_apply set is_exam = " + apply1.getIsExam() + " " +"where id = " + "'" + apply1.getId() + "';" + |
| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | 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.entity.Experience; |
| | | import org.springblade.modules.experience.service.IExperienceService; |
| | |
| | | private final IExperienceService experienceService; |
| | | |
| | | private final JurisdictionService jurisdictionService; |
| | | |
| | | private final IDispatcherService dispatcherService; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | } |
| | | } |
| | | |
| | | //如果是离职 |
| | | if (null!=user.getStatus()){ |
| | | if (user.getStatus()==2){ |
| | | //修改派遣状态 |
| | | user.setDispatch("1"); |
| | | //同时将派遣记录中的派遣状态修改 |
| | | //查询派遣记录(还在派遣中的) |
| | | Dispatcher dispatcher = new Dispatcher(); |
| | | dispatcher.setUserIds(user.getId().toString()); |
| | | dispatcher.setStatus(0); |
| | | List<Dispatcher> dispatcherList = dispatcherService.list(Condition.getQueryWrapper(dispatcher)); |
| | | if (dispatcherList.size()>0){ |
| | | dispatcherList.forEach(dispatcher1 -> { |
| | | dispatcher1.setStatus(1); |
| | | dispatcher1.setUpdateTime(new Date()); |
| | | String s1 = |
| | | "update sys_dispatcher set status = " + "'" + dispatcher1.getStatus() + "'" |
| | | + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dispatcher1.getUpdateTime()) + "'" |
| | | + " " + "where id = " + "'" + dispatcher1.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | |
| | | user.setPassword(user1.getPassword()); |
| | | userService.updateById(user); |
| | | String rtime; |
| | |
| | | + ",address = " + "'" + user.getAddress() + "'" |
| | | + ",registered = " + "'" + user.getRegistered() + "'" |
| | | + ",rtime = " + "'" + rtime + "'" |
| | | + ",dispatch = " + "'" + user.getDispatch() + "'" |
| | | + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" |
| | | + ",hold = " + "'" + user.getHold() + "'" |
| | | + ",jurisdiction = " + "'" + user.getJurisdiction() + "'" |
| | | + ",reason_for_leav = " + "'" + user.getReasonForLeav() + "'" |
| | | + ",guncode = " + "'" + user.getGuncode() + "'" |
| | | + " " + "where id = " + "'" + user.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | return R.success("修改成功"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @PostMapping("/updateUserInfo") |
| | | public R updateUserInfo(@Valid @RequestBody User user) throws Exception { |
| | | String url = null; |
| | | 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]; |
| | | } |
| | | } |
| | | |
| | | userService.updateById(user); |
| | | |
| | | //内网同步 |
| | | String s1 = |
| | | "update blade_user set account = " + "'" + user.getCardid() + "'" |
| | | + ",real_name = " + "'" + user.getRealName() + "'" |
| | | + ",avatar = " + "'" + user.getAvatar() + "'" |
| | | + ",sex = " + "'" + user.getSex() + "'" |
| | | + ",cardid = " + "'" + user.getCardid() + "'" |
| | | + ",nation = " + "'" + user.getNation() + "'" |
| | | + ",fingerprint = " + "'" + url + "'" |
| | | + ",my_picture = " + "'" + user.getMyPicture() + "'" |
| | | + ",address = " + "'" + user.getAddress() + "'" |
| | | + ",registered = " + "'" + user.getRegistered() + "'" |
| | | + ",securitynumber = " + "'" + user.getSecuritynumber() + "'" |
| | | + ",hold = " + "'" + user.getHold() + "'" |
| | | + " " + "where id = " + "'" + user.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | return R.success("修改成功"); |
| | |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importSecurity(MultipartFile file, Integer isCovered,String deptId) { |
| | | SecurityImporter securityImporter = new SecurityImporter(userService, false,deptId); |
| | | ExcelUtil.save(file, securityImporter, SecurityExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 导入保安员(test) |
| | | */ |
| | | @PostMapping("import-security-test") |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importSecurityTest(MultipartFile file, Integer isCovered,String deptId) { |
| | | SecurityImporterTest securityImporter = new SecurityImporterTest(userService, false,deptId); |
| | | ExcelUtil.save(file, securityImporter, SecurityExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | |
| | | user.setExaminationType("0"); |
| | | user.setAccount(user.getCardid()); |
| | | |
| | | Integer userCount = userService.selectCount(user.getAccount()); |
| | | if (userCount > 0 && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | // Integer userCount = userService.selectCount(user.getAccount()); |
| | | User user1 = new User(); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | user1.setAccount(user.getCardid()); |
| | | List<User> list = userService.list(Condition.getQueryWrapper(user1)); |
| | | |
| | | if (list.size() > 0 && Func.isEmpty(user.getId())) { |
| | | if (null!=user.getCell() && !user.getCell().equals("")) { |
| | | if (user.getCell().equals("2")){ |
| | | list.forEach(user2 -> { |
| | | user2.setStatus(2); |
| | | //先将原有人员离职 cell 1:手动录入 2:自动录入 |
| | | userService.updateById(user2); |
| | | //内网同步 |
| | | String s1 = "update blade_user set status = " + user2.getStatus() + |
| | | " where id = " + "'" + user2.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }); |
| | | } |
| | | }else { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | } |
| | | |
| | | String url = null; |
| | |
| | | "id,tenant_id,account,password,name,real_name,avatar,email,phone,sex," + |
| | | "role_id,dept_id,cardid,nativePlace,nation,fingerprint,education," + |
| | | "politicaloutlook,healstats,height,address,registered,rtime," + |
| | | "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode) " + |
| | | "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch,guncode,cell) " + |
| | | "values(" + "'" + user.getId() + "'" + |
| | | "," + "'" + user.getTenantId() + "'" + |
| | | "," + "'" + user.getAccount() + "'" + |
| | |
| | | "," + "'" + user.getExaminationType() + "'" + |
| | | "," + "'" + user.getStatus() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getGuncode() + "'" + ")"; |
| | | "," + "'" + user.getDispatch() + "'" + |
| | | "," + "'" + user.getGuncode() + "'" + |
| | | "," + "'" + user.getCell() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s); |
| | | |
| | | //获取从业记录 |
| | |
| | | return R.data(user1); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保安员导出 |
| | | * @param response |
| | | * @param user 查询条件 |
| | | */ |
| | | @GetMapping("export-security-info") |
| | | public void exportSecurityInfo(HttpServletResponse response,UserVO user) throws IOException { |
| | | List<SecurityExcel> list = userService.exportSecurityInfo(user); |
| | | String fileName = null; |
| | | try { |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name()); |
| | | fileName = URLEncoder.encode("保安员数据导出"+DateUtil.time(), Charsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | //修改单元格格式为文本格式 |
| | | EasyExcel.write(response.getOutputStream(), SecurityExcel.class).sheet("保安员数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list); |
| | | } catch (Throwable var6) { |
| | | throw var6; |
| | | } |
| | | // ExcelUtil.export(response, "保安员导入数据模板", "保安员数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.springblade.modules.system.excel; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springblade.core.excel.support.ExcelImporter; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户数据导入类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class SecurityImporterTest implements ExcelImporter<SecurityExcel> { |
| | | |
| | | private final IUserService service; |
| | | private final Boolean isCovered; |
| | | private final String deptId; |
| | | |
| | | @Override |
| | | public void save(List<SecurityExcel> data) { |
| | | service.importSecurityTest(data, isCovered,deptId); |
| | | } |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.MapKey; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springblade.modules.dispatcher.vo.DispatcherVO; |
| | | import org.springblade.modules.system.excel.SecurityExcel; |
| | | import org.springblade.modules.system.excel.UserExcel; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.node.TreeNode; |
| | |
| | | List<Map<String, Object>> getSecurityInfo(@Param("jurisdiction")String jurisdiction); |
| | | |
| | | /** |
| | | * 导出保安员证信息 |
| | | * 导出保安员信息 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<UserVO> exportSecurityPaperList(@Param("user") UserVO user); |
| | | List<SecurityExcel> exportSecurityInfo(@Param("user") UserVO user); |
| | | } |
| | |
| | | bu.id = str.user_id |
| | | where |
| | | bu.is_deleted = 0 |
| | | and bd.parent_id!=1425365577303621633 |
| | | and bd.id != 1425365577303621633 |
| | | and bd.id != 1432625856013971457 |
| | | <if test="user.examinationType!=null and user.examinationType != ''"> |
| | | <if test="user.examinationType == 0"> |
| | | and (bu.examination_type = #{user.examinationType} or bu.examination_type is null or bu.examination_type ='') |
| | | </if> |
| | | <if test="user.examinationType == 1"> |
| | | and bu.examination_type = #{user.examinationType} |
| | | </if> |
| | | </if> |
| | | <if test="user.account!=null and user.account != ''"> |
| | | and bu.account like concat('%', #{user.account},'%') |
| | | </if> |
| | |
| | | <if test="user.roleAlias!=null and user.roleAlias != ''"> |
| | | and br.role_alias = '保安' |
| | | </if> |
| | | <if test="user.status!=null and user.status != ''"> |
| | | <if test="user.status!=null and user.status != '' and user.status != 6"> |
| | | and bu.status = #{user.status} |
| | | </if> |
| | | <if test="user.trainingUnitId!=null and user.trainingUnitId != ''"> |
| | |
| | | </if> |
| | | <if test="user.cardid!=null and user.cardid != ''"> |
| | | and bu.cardid like concat('%', #{user.cardid},'%') |
| | | </if> |
| | | <if test="user.examinationType!=null and user.examinationType != ''"> |
| | | and bu.examination_type = #{user.examinationType} |
| | | </if> |
| | | ORDER BY bu.id desc |
| | | </select> |
| | |
| | | |
| | | ( |
| | | select |
| | | distinct |
| | | bu.id, |
| | | bu.real_name as name, |
| | | #{user.deptId} parentId |
| | | from |
| | | blade_user bu |
| | | left join |
| | | blade_dept bd |
| | | on |
| | | bu.dept_id = bd.id |
| | | left join |
| | | blade_role br |
| | | on |
| | | br.id = bu.role_id |
| | | where |
| | | bu.is_deleted = 0 |
| | | and bu.status = 1 |
| | | and (bu.examination_type != 1 or bu.examination_type is null) |
| | | and (hold = 2 or hold = 3) |
| | | and bd.id = #{user.deptId} |
| | | and br.role_alias = '保安' |
| | | a.id, |
| | | a.name, |
| | | a.parentId |
| | | from ( |
| | | select |
| | | distinct |
| | | bu.id, |
| | | ifnull(DATE_FORMAT(NOW(), '%Y') - SUBSTRING(bu.cardid,7,4),0) age, |
| | | bu.is_apply isApply, |
| | | bu.is_train isTrain, |
| | | bu.real_name as name, |
| | | #{user.deptId} parentId |
| | | from |
| | | blade_user bu |
| | | left join |
| | | blade_dept bd |
| | | on |
| | | bu.dept_id = bd.id |
| | | left join |
| | | blade_role br |
| | | on |
| | | br.id = bu.role_id |
| | | where |
| | | bu.is_deleted = 0 |
| | | and bu.status = 1 |
| | | and (bu.examination_type != 1 or bu.examination_type is null) |
| | | and (hold = 2 or hold = 3) |
| | | and bd.id = #{user.deptId} |
| | | and br.role_alias = '保安' |
| | | ) a |
| | | where 1 = 1 |
| | | <if test="user.examType==1"> |
| | | and bu.is_apply != 1 |
| | | and a.isApply != 1 |
| | | and a.age>=18 |
| | | and a.age<=60 |
| | | </if> |
| | | <if test="user.examType==2"> |
| | | and bu.is_train != 1 |
| | | and a.isTrain != 1 |
| | | and a.age>=18 |
| | | and a.age<=60 |
| | | </if> |
| | | ) |
| | | </select> |
| | |
| | | </select> |
| | | |
| | | |
| | | <!--导出保安员信息--> |
| | | <select id="exportSecurityInfo" resultType="org.springblade.modules.system.excel.SecurityExcel"> |
| | | select |
| | | bd.dept_name deptId, |
| | | bu.real_name realName, |
| | | bu.phone, |
| | | if(IF(mod(SUBSTR(bu.cardid,17,1),2),1,2)=1,"男","女") sex, |
| | | bu.cardid, |
| | | bu.nation, |
| | | bu.registered, |
| | | if(bu.hold=1,"是","否") hold, |
| | | bu.securitynumber |
| | | from |
| | | blade_user bu |
| | | left join |
| | | blade_dept bd |
| | | on |
| | | bu.dept_id = bd.id |
| | | left join |
| | | sys_information si |
| | | on |
| | | si.departmentid = bd.id |
| | | left join |
| | | sys_jurisdiction sj |
| | | on |
| | | sj.id = si.jurisdiction |
| | | left join |
| | | blade_role br |
| | | on |
| | | br.id = bu.role_id |
| | | left join |
| | | sys_training_registration str |
| | | on |
| | | bu.id = str.user_id |
| | | where |
| | | bu.is_deleted = 0 |
| | | <if test="user.examinationType!=null and user.examinationType != ''"> |
| | | <if test="user.examinationType == 0"> |
| | | and (bu.examination_type = #{user.examinationType} or bu.examination_type is null or bu.examination_type ='') |
| | | </if> |
| | | <if test="user.examinationType == 1"> |
| | | and bu.examination_type = #{user.examinationType} |
| | | </if> |
| | | </if> |
| | | <if test="user.account!=null and user.account != ''"> |
| | | and bu.account like concat('%', #{user.account},'%') |
| | | </if> |
| | | <if test="user.hold!=null and user.hold != ''"> |
| | | and bu.hold = #{user.hold} |
| | | </if> |
| | | <if test="user.deptId!=null and user.deptId != ''"> |
| | | and (bd.id = #{user.deptId} or bd.parent_id = #{user.deptId}) |
| | | </if> |
| | | <if test="user.roleId!=null and user.roleId != ''"> |
| | | and bu.role_id = #{user.roleId} |
| | | </if> |
| | | <if test="user.roleAlias!=null and user.roleAlias != ''"> |
| | | and br.role_alias = '保安' |
| | | </if> |
| | | <if test="user.status!=null and user.status != '' and user.status != 6"> |
| | | and bu.status = #{user.status} |
| | | </if> |
| | | <if test="user.trainingUnitId!=null and user.trainingUnitId != ''"> |
| | | and str.training_unit_id = #{user.trainingUnitId} |
| | | </if> |
| | | <if test="user.deptName!=null and user.deptName != ''"> |
| | | and bd.dept_name like concat('%', #{user.deptName},'%') |
| | | </if> |
| | | <if test="user.jurisdiction!=null and user.jurisdiction != '' and user.jurisdiction!='1372091709474910209'"> |
| | | and (sj.id = #{user.jurisdiction} or sj.parent_id = #{user.jurisdiction}) |
| | | </if> |
| | | <if test="user.realName!=null and user.realName != ''"> |
| | | and bu.real_name like concat('%', #{user.realName},'%') |
| | | </if> |
| | | <if test="user.dispatch!=null and user.dispatch != ''"> |
| | | and bu.dispatch = #{user.dispatch} |
| | | </if> |
| | | <if test="user.userType!=null and user.userType != ''"> |
| | | and bu.user_type = #{user.userType} |
| | | </if> |
| | | <if test="user.securitynumber!=null and user.securitynumber != ''"> |
| | | and bu.securitynumber like concat('%', #{user.securitynumber},'%') |
| | | </if> |
| | | <if test="user.cardid!=null and user.cardid != ''"> |
| | | and bu.cardid like concat('%', #{user.cardid},'%') |
| | | </if> |
| | | ORDER BY bu.id desc |
| | | </select> |
| | | |
| | | |
| | | |
| | | </mapper> |
| | |
| | | * @return |
| | | */ |
| | | Integer selectCountAccount(String account); |
| | | |
| | | /** |
| | | * 保安员信息导出 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | List<SecurityExcel> exportSecurityInfo(UserVO user); |
| | | |
| | | /** |
| | | * 导入保安员test |
| | | * @param data |
| | | * @param isCovered |
| | | * @param deptId |
| | | */ |
| | | void importSecurityTest(List<SecurityExcel> data, Boolean isCovered, String deptId); |
| | | } |
| | |
| | | } |
| | | } |
| | | //判断年龄,超过60岁的不入 |
| | | if (AgeUtil.idCardToAge(user.getCardid())<60) { |
| | | // if (AgeUtil.idCardToAge(user.getCardid())<60) { |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getDispatch() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s); |
| | | }else { |
| | | agetStatus.set(false); |
| | | ageErrorList.add(user.getCardid()); |
| | | } |
| | | // }else { |
| | | // agetStatus.set(false); |
| | | // ageErrorList.add(user.getCardid()); |
| | | // } |
| | | }else { |
| | | //匹配组织机构是否一致,如果不一致 |
| | | if(!user2.getDeptId().equals(user.getDeptId())){ |
| | | Dept dept = deptService.getById(user2.getDeptId()); |
| | | status.set(false); |
| | | //加入集合 |
| | | errorList.add(user.getCardid()); |
| | | //forEach 只能使用 return 跳出本次循环 |
| | | return; |
| | | Dept dept = deptService.getById(user.getDeptId()); |
| | | System.out.println("dept = " + dept); |
| | | //如果是南昌总公司分公司导入的 |
| | | if (dept.getParentId().equals(1432626178757275649L)){ |
| | | user2.setDeptId(dept.getId().toString()); |
| | | //判断是否持证 |
| | | if (null != userExcel.getHold() && userExcel.getHold() != "") { |
| | | if (userExcel.getHold().equals("是") && userExcel.getSecuritynumber()!=null && !userExcel.getSecuritynumber().equals("")) { |
| | | user2.setHold("1"); |
| | | //更新保安证编号 |
| | | user2.setSecuritynumber(user.getSecuritynumber()); |
| | | } |
| | | if (userExcel.getHold().equals("否")) { |
| | | user2.setHold("2"); |
| | | } |
| | | } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | | + ",dept_id = " + "'" + user2.getDeptId() + "'" |
| | | + ",registered = " + "'" + user2.getRegistered() + "'" |
| | | + " " + "where id = " + "'" + user2.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | status.set(false); |
| | | //加入集合 |
| | | errorList.add(user.getCardid()); |
| | | //forEach 只能使用 return 跳出本次循环 |
| | | return; |
| | | } |
| | | }else { |
| | | //如果是一致,则更新用户数据 |
| | | //判断是否持证 |
| | |
| | | } |
| | | }); |
| | | //如果所有数据导入有一个异常 |
| | | if (!status.get() || !agetStatus.get()){ |
| | | if (!status.get() && agetStatus.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | if (!agetStatus.get() && status.get()) { |
| | | String errorAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!年龄不符!"); |
| | | } |
| | | if (!status.get() && !agetStatus.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | String errorAgeAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"+ |
| | | "用户:[" + errorAgeAccount + "]导入失败!年龄不符!"); |
| | | } |
| | | // if (!status.get() || !agetStatus.get()){ |
| | | // if (!status.get() && agetStatus.get()) { |
| | | // String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | // throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | // } |
| | | // if (!agetStatus.get() && status.get()) { |
| | | // String errorAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | // throw new ServiceException("用户:[" + errorAccount + "]导入失败!年龄不符!"); |
| | | // } |
| | | // if (!status.get() && !agetStatus.get()) { |
| | | // String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | // String errorAgeAccount = StringUtils.join(ageErrorList, "\\\n"); |
| | | // throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"+ |
| | | // "用户:[" + errorAgeAccount + "]导入失败!年龄不符!"); |
| | | // } |
| | | // } |
| | | if (!status.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | } |
| | | |
| | |
| | | public Integer selectCountAccount(String account) { |
| | | return baseMapper.selectCountAccount(account); |
| | | } |
| | | |
| | | /** |
| | | * 保安员信息导出 |
| | | * @param user |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SecurityExcel> exportSecurityInfo(UserVO user) { |
| | | return baseMapper.exportSecurityInfo(user); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导入保安员 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | // @Transactional(rollbackFor = Exception.class) |
| | | public void importSecurityTest(List<SecurityExcel> data, Boolean isCovered, String deptId) { |
| | | //将不能导入的保安员账号存起来 |
| | | List<String> errorList = new ArrayList<>(); |
| | | //年龄不符的保安员信息存入集合 |
| | | List<String> ageErrorList = new ArrayList<>(); |
| | | //将需要更新的保安员信息存入集合 |
| | | List<User> updateList = new ArrayList<>(); |
| | | //导入状态,默认为true ,如果有一个出现问题则为 false |
| | | AtomicBoolean status = new AtomicBoolean(true); |
| | | data.forEach(userExcel -> { |
| | | User user = Objects.requireNonNull(BeanUtil.copy(userExcel, User.class)); |
| | | //设置部门id |
| | | String deptIds = userDeptService.selectIn(user.getDeptId()); |
| | | if (null!=deptIds && !deptIds.equals("")) { |
| | | // if (null != deptId && !deptId.equals("")) { |
| | | // if (!deptId.equals(deptIds)) { |
| | | // throw new ServiceException("导入失败!不能导入不是本公司的保安员数据!"); |
| | | // } |
| | | // } |
| | | user.setDeptId(deptIds); |
| | | }else { |
| | | //如果deptIds 为空,则说明还没有改公司 |
| | | throw new ServiceException("导入失败!公司名:["+user.getDeptId()+"]不存在!"); |
| | | } |
| | | //判断当前用户是否已在本单位,如果是的更新数据 |
| | | User user1 = new User(); |
| | | user1.setAccount(user.getCardid()); |
| | | user1.setIsDeleted(0); |
| | | user1.setStatus(1); |
| | | User user2 = this.getOne(Condition.getQueryWrapper(user1)); |
| | | if (null==user2){ |
| | | //用户不存在,去新增 |
| | | // 设置租户ID |
| | | user.setTenantId("000000"); |
| | | //默认在职 |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | //判断是否持证 |
| | | if (null != userExcel.getHold() && userExcel.getHold() != "") { |
| | | if (userExcel.getHold().equals("是")) { |
| | | user.setHold("1"); |
| | | } |
| | | if (userExcel.getHold().equals("否")) { |
| | | user.setHold("2"); |
| | | } |
| | | } |
| | | //判断年龄,超过60岁的不入 |
| | | // if (AgeUtil.idCardToAge(user.getCardid())<60) { |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安"); |
| | | Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | user.setRoleId(oneRole.getId().toString()); |
| | | |
| | | //性别 |
| | | if (null != userExcel.getSex()) { |
| | | if (userExcel.getSex().equals("男")) { |
| | | user.setSex(1); |
| | | } |
| | | if (userExcel.getSex().equals("女")) { |
| | | user.setSex(2); |
| | | } |
| | | } |
| | | |
| | | //设置账号 |
| | | user.setAccount(user.getCardid()); |
| | | //获取默认密码配置 |
| | | user.setPassword(user.getCardid().substring(user.getCardid().length() - 6)); |
| | | //加密 |
| | | if (Func.isNotEmpty(user.getPassword())) { |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | } |
| | | Integer userCount = baseMapper.selectCountAccount(user.getAccount()); |
| | | if (userCount > 0 && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | //新增 |
| | | this.save(user); |
| | | //内网同步 |
| | | 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," + |
| | | "politicaloutlook,healstats,height,address,registered," + |
| | | "securitynumber,hold,jurisdiction,examination_type,status,is_deleted,dispatch) " + |
| | | "values(" + "'" + user.getId() + "'" + |
| | | "," + "'" + user.getTenantId() + "'" + |
| | | "," + "'" + user.getAccount() + "'" + |
| | | "," + "'" + user.getPassword() + "'" + |
| | | "," + "'" + user.getName() + "'" + |
| | | "," + "'" + user.getRealName() + "'" + |
| | | "," + "'" + user.getAvatar() + "'" + |
| | | "," + "'" + user.getEmail() + "'" + |
| | | "," + "'" + user.getPhone() + "'" + |
| | | "," + "'" + user.getSex() + "'" + |
| | | "," + "'" + user.getRoleId() + "'" + |
| | | "," + "'" + user.getDeptId() + "'" + |
| | | "," + "'" + user.getCardid() + "'" + |
| | | "," + "'" + user.getNativeplace() + "'" + |
| | | "," + "'" + user.getNation() + "'" + |
| | | "," + "'" + user.getFingerprint() + "'" + |
| | | "," + "'" + user.getEducation() + "'" + |
| | | "," + "'" + user.getPoliticaloutlook() + "'" + |
| | | "," + "'" + user.getHealstats() + "'" + |
| | | "," + "'" + user.getHeight() + "'" + |
| | | "," + "'" + user.getAddress() + "'" + |
| | | "," + "'" + user.getRegistered() + "'" + |
| | | "," + "'" + user.getSecuritynumber() + "'" + |
| | | "," + "'" + user.getHold() + "'" + |
| | | "," + "'" + user.getJurisdiction() + "'" + |
| | | "," + "'" + user.getExaminationType() + "'" + |
| | | "," + "'" + user.getStatus() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + |
| | | "," + "'" + user.getDispatch() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s); |
| | | // }else { |
| | | // agetStatus.set(false); |
| | | // ageErrorList.add(user.getCardid()); |
| | | // } |
| | | }else { |
| | | //匹配组织机构是否一致,如果不一致 |
| | | if(!user2.getDeptId().equals(user.getDeptId())){ |
| | | Dept dept = deptService.getById(user2.getDeptId()); |
| | | if (dept.getParentId().equals("1432626178757275649")){ |
| | | //判断是否持证 |
| | | if (null != userExcel.getHold() && userExcel.getHold() != "") { |
| | | if (userExcel.getHold().equals("是") && userExcel.getSecuritynumber()!=null && !userExcel.getSecuritynumber().equals("")) { |
| | | user2.setHold("1"); |
| | | //更新保安证编号 |
| | | user2.setSecuritynumber(user.getSecuritynumber()); |
| | | } |
| | | if (userExcel.getHold().equals("否")) { |
| | | user2.setHold("2"); |
| | | } |
| | | } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | | + ",dept_id = " + "'" + user2.getDeptId() + "'" |
| | | + ",registered = " + "'" + user2.getRegistered() + "'" |
| | | + " " + "where id = " + "'" + user2.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | }else { |
| | | status.set(false); |
| | | //加入集合 |
| | | errorList.add(user.getCardid()); |
| | | //forEach 只能使用 return 跳出本次循环 |
| | | return; |
| | | } |
| | | }else { |
| | | //如果是一致,则更新用户数据 |
| | | //判断是否持证 |
| | | if (null != userExcel.getHold() && userExcel.getHold() != "") { |
| | | if (userExcel.getHold().equals("是") && userExcel.getSecuritynumber()!=null && !userExcel.getSecuritynumber().equals("")) { |
| | | user2.setHold("1"); |
| | | //更新保安证编号 |
| | | user2.setSecuritynumber(user.getSecuritynumber()); |
| | | } |
| | | if (userExcel.getHold().equals("否")) { |
| | | user2.setHold("2"); |
| | | } |
| | | } |
| | | if (null!=userExcel.getRegistered()){ |
| | | user2.setRegistered(userExcel.getRegistered()); |
| | | }else { |
| | | user2.setRegistered(""); |
| | | } |
| | | //更新用户数据 |
| | | this.updateById(user2); |
| | | String s1 = |
| | | "update blade_user set hold = " + "'" + user2.getHold() + "'" |
| | | + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" |
| | | + ",registered = " + "'" + user2.getRegistered() + "'" |
| | | + " " + "where id = " + "'" + user2.getId() + "'"; |
| | | FtpUtil.sqlFileUpload(s1); |
| | | } |
| | | } |
| | | }); |
| | | //如果所有数据导入有一个异常 |
| | | if (!status.get()) { |
| | | String errorAccount = StringUtils.join(errorList, "\\\n"); |
| | | throw new ServiceException("用户:[" + errorAccount + "]导入失败!已在其他单位存在!"); |
| | | } |
| | | } |
| | | } |
| | |
| | | <if test="trainingRegistration.realName!=null and trainingRegistration.realName!=''"> |
| | | and bu.real_name like concat('%', #{trainingRegistration.realName},'%') |
| | | </if> |
| | | <if test="trainingRegistration.idCardNo!=null and trainingRegistration.idCardNo!=''"> |
| | | and bu.cardid like concat('%', #{trainingRegistration.idCardNo},'%') |
| | | </if> |
| | | <if test="trainingRegistration.cancel!=null"> |
| | | and sr.cancel = #{trainingRegistration.cancel} |
| | | </if> |
| | |
| | | <if test="trainingRegistration.realName!=null and trainingRegistration.realName!=''"> |
| | | and bu.real_name like concat('%', #{trainingRegistration.realName},'%') |
| | | </if> |
| | | <if test="trainingRegistration.idCardNo!=null and trainingRegistration.idCardNo!=''"> |
| | | and bu.cardid like concat('%', #{trainingRegistration.idCardNo},'%') |
| | | </if> |
| | | <if test="trainingRegistration.cancel!=null"> |
| | | and sr.cancel = #{trainingRegistration.cancel} |
| | | </if> |