src/main/java/org/springblade/common/utils/Base64Util.java
New file @@ -0,0 +1,84 @@ package org.springblade.common.utils; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.imageio.stream.FileImageInputStream; import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class Base64Util{ /** * 字符串转图片 * @param base64Str * @return */ public static byte[] decode(String base64Str){ byte[] b = null; BASE64Decoder decoder = new BASE64Decoder(); try { b = decoder.decodeBuffer(replaceEnter(base64Str)); } catch (IOException e) { e.printStackTrace(); } return b; } /** * 图片转字符串 * @param image * @return */ public static String encode(byte[] image){ BASE64Encoder decoder = new BASE64Encoder(); return replaceEnter(decoder.encode(image)); } public static String encode(String uri){ BASE64Encoder encoder = new BASE64Encoder(); return replaceEnter(encoder.encode(uri.getBytes())); } /** * * @path 图片路径 * @return */ public static byte[] imageTobyte(String path){ byte[] data = null; FileImageInputStream input = null; try { input = new FileImageInputStream(new File(path)); ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int numBytesRead = 0; while((numBytesRead = input.read(buf)) != -1){ output.write(buf, 0, numBytesRead); } data = output.toByteArray(); output.close(); input.close(); } catch (Exception e) { e.printStackTrace(); } return data; } public static String replaceEnter(String str){ String reg ="[\n-\r]"; Pattern p = Pattern.compile(reg); Matcher m = p.matcher(str); return m.replaceAll(""); } } src/main/java/org/springblade/common/utils/ImageUtils.java
New file @@ -0,0 +1,181 @@ package org.springblade.common.utils; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.HeadlessException; import java.awt.Image; import java.awt.Toolkit; import java.awt.Transparency; import java.net.HttpURLConnection; import java.net.URL; public class ImageUtils { public static String getBase64ByImgUrl(String url){ String suffix = url.substring(url.lastIndexOf(".") + 1); try { URL urls = new URL(url); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Image image = Toolkit.getDefaultToolkit().getImage(urls); BufferedImage biOut = toBufferedImage(image); ImageIO.write(biOut, suffix, baos); String base64Str = Base64Util.encode(baos.toByteArray()); return base64Str; } catch (Exception e) { return ""; } } public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage) image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); try { int transparency = Transparency.OPAQUE; GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); } catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; } /** * 通过图片的url获取图片的base64字符串 * @param imgUrl 图片url * @return 返回图片base64的字符串 */ public static String imageUrlToBase64(String imgUrl) { URL url = null; InputStream is = null; ByteArrayOutputStream outStream = null; HttpURLConnection httpUrl = null; try{ url = new URL(imgUrl); httpUrl = (HttpURLConnection) url.openConnection(); httpUrl.connect(); httpUrl.getInputStream(); is = httpUrl.getInputStream(); outStream = new ByteArrayOutputStream(); //创建一个Buffer字符串 byte[] buffer = new byte[1024]; //每次读取的字符串长度,如果为-1,代表全部读取完毕 int len = 0; //使用一个输入流从buffer里把数据读取出来 while( (len=is.read(buffer)) != -1 ){ //用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度 outStream.write(buffer, 0, len); } // 对字节数组Base64编码 return Base64Util.encode(outStream.toByteArray()); }catch (Exception e) { e.printStackTrace(); } finally{ if(is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } if(outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } if(httpUrl != null) { httpUrl.disconnect(); } } return imgUrl; } } src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -125,8 +125,8 @@ @GetMapping("/lazy-tree") @ApiOperationSupport(order = 5) @ApiOperation(value = "懒加载树形结构", notes = "树形结构") public R<List<DeptVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser) { List<DeptVO> tree = deptService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId); public R<List<DeptVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser,String userId) { List<DeptVO> tree = deptService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId,userId); return R.data(tree); } src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.minio.*; import io.minio.errors.*; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -36,6 +38,7 @@ import org.springblade.common.excel.CustomCellWriteHeightConfig; import org.springblade.common.excel.CustomCellWriteWeightConfig; import org.springblade.common.excel.RowWriteHandler; import org.springblade.common.utils.ImageUtils; import org.springblade.common.utils.arg; import org.springblade.core.cache.utils.CacheUtil; import org.springblade.core.excel.util.ExcelUtil; @@ -72,14 +75,21 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; import sun.misc.BASE64Decoder; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.*; import static org.springblade.common.config.FtpConfig.*; import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE; @@ -194,6 +204,7 @@ } user.setTenantId("000000"); user.setStatus(1); user.setIsDeleted(0); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); //判断是否为民警 code @@ -262,9 +273,21 @@ @PostMapping("/update") @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入User") public R update(@Valid @RequestBody User user) { public R update(@Valid @RequestBody User user) throws Exception { CacheUtil.clear(USER_CACHE); User user1 = userService.getById(user.getId()); 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]; } } user.setPassword(user1.getPassword()); userService.updateById(user); String rtime; @@ -272,14 +295,6 @@ rtime = null; } else { rtime = new SimpleDateFormat("yyyy-MM-dd").format(user.getRtime()); } String paperTime; //发证日期处理 if (user.getPaperTime() == null) { paperTime = null; } else { paperTime = new SimpleDateFormat("yyyy-MM-dd").format(user.getPaperTime()); } String s1 = @@ -299,6 +314,8 @@ + ",politicaloutlook = " + "'" + user.getPoliticaloutlook() + "'" + ",healstats = " + "'" + user.getHealstats() + "'" + ",height = " + "'" + user.getHeight() + "'" + ",fingerprint = " + "'" + url + "'" + ",my_picture = " + "'" + user.getMyPicture() + "'" + ",address = " + "'" + user.getAddress() + "'" + ",registered = " + "'" + user.getRegistered() + "'" + ",rtime = " + "'" + rtime + "'" @@ -309,6 +326,64 @@ + " " + "where id = " + "'" + user.getId() + "'"; FtpUtil.sqlFileUpload(s1); return R.success("修改成功"); } /** * 指纹图片上传 * @return * @throws Exception */ private String uploadBase64String (User user)throws Exception{ //图片上传 BASE64Decoder decoder = new BASE64Decoder(); // 解密 byte[] b = decoder.decodeBuffer(user.getFingerprint()); // 处理数据 for (int i = 0; i < b.length; ++i) { if (b[i] < 0) { b[i] += 256; } } //填写你文件上传的地址以及相应信息 String url = "http://223.82.109.183:2081"; String access = "zhbaadmin"; String secret = "zhbapassword"; String bucket = "zhba"; MinioClient minioClient = MinioClient.builder() .endpoint(url) .credentials(access, secret) .build(); // 检查存储桶是否已经存在 boolean isExist = minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucket).build()); if (!isExist) { // 创建一个名为zip的存储桶,用于zip文件。 minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucket).build()); minioClient.setBucketPolicy(SetBucketPolicyArgs.builder().bucket(bucket).build()); } String newName = "upload/picture/" + UUID.randomUUID().toString().replaceAll("-", "")+".jpg"; InputStream in = new ByteArrayInputStream(b); String[] split = newName.split("/"); //创建头部信息 Map<String, String> headers = new HashMap<>(1 << 2); //添加自定义内容类型 headers.put("Content-Type", "application/octet-stream"); //上传 minioClient.putObject( PutObjectArgs.builder().bucket(bucket).object(newName).stream( in, in.available(), -1) .headers(headers) .build()); InputStream inputStream = new ByteArrayInputStream(b); FtpUtil.uploadFile(FtpConfig.ftpHost, ftpPort, FtpConfig.ftpUserName, ftpPassword, ftpPath, "/", split[2], inputStream); in.close(); //外围url String urls = "http://223.82.109.183:2081/zhba/" + newName; //内网 String inUrl = FtpConfig.ip + "/zhba/" + newName; //返回 return urls+","+inUrl; } @@ -655,7 +730,7 @@ */ @PostMapping("/securitySave") @Transactional(rollbackFor = Exception.class) public R securitySave(@Valid @RequestBody Map<String, Object> userMap) { public R securitySave(@Valid @RequestBody Map<String, Object> userMap) throws Exception { //获取user User user = JSON.parseObject(JSON.toJSONString(userMap.get("user")), User.class); //分配保安角色 @@ -670,6 +745,16 @@ Integer userCount = userService.selectCount(user.getAccount()); if (userCount > 0 && Func.isEmpty(user.getId())) { throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); } String url = null; if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) { if (user.getFingerprint().length()>100) { String s = uploadBase64String(user); String[] split = s.split(","); user.setFingerprint(split[0]); url = split[1]; } } // } //未持证 @@ -708,11 +793,6 @@ user.setAvatar(FtpConfig.ip + user.getAvatar().substring(26)); } //指纹 if (null!=user.getFingerprint() && !user.getFingerprint().equals("")) { user.setFingerprint(FtpConfig.ip + user.getFingerprint().substring(26)); } 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," + @@ -733,7 +813,7 @@ "," + "'" + user.getCardid() + "'" + "," + "'" + user.getNativeplace() + "'" + "," + "'" + user.getNation() + "'" + "," + "'" + user.getFingerprint() + "'" + "," + "'" + url + "'" + "," + "'" + user.getEducation() + "'" + "," + "'" + user.getPoliticaloutlook() + "'" + "," + "'" + user.getHealstats() + "'"+ @@ -793,4 +873,22 @@ return R.data(list); } /** * 用户详情 * @param user * @return */ @GetMapping("/details") public R details(User user) { User user1 = userService.getById(user.getId()); if (null!=user1.getFingerprint() && !user1.getFingerprint().equals("")){ //url 转base64 String base64Url = ImageUtils.imageUrlToBase64(user1.getFingerprint()); System.out.println("base64Url = " + base64Url); user1.setFingerprint(base64Url); } return R.data(user1); } } src/main/java/org/springblade/modules/system/entity/User.java
@@ -183,7 +183,7 @@ private String examinationMx; /** * 是否采集指纹 * 指纹url */ private String fingerprint; @@ -198,7 +198,7 @@ private String dispatch; /** * 个人照片,电子照,用于展示保安证,准考证用 * 指纹特征 */ @TableField("my_picture") private String myPicture; src/main/java/org/springblade/modules/system/excel/UserExcel.java
@@ -38,12 +38,12 @@ public class UserExcel implements Serializable { private static final long serialVersionUID = 1L; @ExcelProperty("单位名称*") @ExcelProperty("机构名称*") private String deptId; @ColumnWidth(15) @ExcelProperty("警号*") private String account; private String code; @ColumnWidth(10) @ExcelProperty("姓名*") src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -24,6 +24,7 @@ import org.springblade.modules.system.entity.Dept; import org.springblade.modules.system.node.TreeNodes; import org.springblade.modules.system.vo.DeptVO; import org.springblade.modules.system.vo.UserVO; import java.util.List; import java.util.Map; @@ -152,4 +153,15 @@ */ List<DeptVO> lazyTreeJurisdiction(@Param("jurisdiction")String jurisdiction, @Param("deptId")Long parentId); List<DeptVO> lazyTreeCity(String tenantId, Long parentId); List<DeptVO> lazyTreeCityOne(String tenantId, Long parentId); /** * 查询用户信息 * @param userId * @return */ UserVO getUserInfoById(String userId); } src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -658,4 +658,73 @@ and (sj.id = #{param1} or sj.parent_id = #{param1}) </if> </select> <!--查询树菜单,区以下--> <select id="lazyTreeCity" resultMap="treeNodeResultMap" > (SELECT id, parent_id, dept_name AS title, id AS "value", id AS "key", 1 AS "has_children" from blade_dept where id = #{param2}) union ( SELECT dept.id, dept.parent_id, dept.dept_name AS title, dept.id AS "value", dept.id AS "key", ( SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM blade_dept WHERE parent_id = dept.id and is_deleted = 0 ) AS "has_children" FROM blade_dept dept WHERE dept.is_deleted = 0 <if test="param2!=null and param2!=0"> and dept.parent_id = #{param2} </if> <if test="param1!=null and param1!=''"> and dept.tenant_id = #{param1} </if> ) </select> <!--查询树菜单,区以下--> <select id="lazyTreeCityOne" resultMap="treeNodeResultMap" > SELECT id, parent_id, dept_name AS title, id AS "value", id AS "key", 0 AS "has_children" from blade_dept where id = #{param2} </select> <!--查询用户信息--> <select id="getUserInfoById" resultType="org.springblade.modules.system.vo.UserVO"> select bu.*,bd.dept_name deptName,br.role_alias roleAlias 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.id = #{param1} </select> </mapper> src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -140,13 +140,13 @@ on bd.id = bu.dept_id left join sys_information si on si.departmentid = bd.id left join sys_jurisdiction sj on sj.id = si.jurisdiction sj.id = bu.jurisdiction left join blade_role br on br.id = bu.role_id where bu.is_deleted = 0 <if test="user.tenantId!=null and user.tenantId != ''"> and tenant_id = #{user.tenantId} @@ -154,6 +154,9 @@ <if test="user.account!=null and user.account != ''"> and account like concat('%', #{user.account},'%') </if> <if test="user.roleId!=null and user.roleId != ''"> and br.role_alias = '公安管理员' </if> <if test="user.realName!=null and user.realName != ''"> and real_name like concat(concat('%', #{user.realName}),'%') </if> src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -57,7 +57,7 @@ * @param parentId * @return */ List<DeptVO> lazyTree(String tenantId, Long parentId); List<DeptVO> lazyTree(String tenantId, Long parentId,String userId); /** * 懒加载获取树形节点 src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -34,12 +34,16 @@ import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.system.entity.Dept; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.mapper.DeptMapper; import org.springblade.modules.system.node.TreeNode; import org.springblade.modules.system.node.TreeNodes; import org.springblade.modules.system.service.IDeptService; import org.springblade.modules.system.service.IUserService; import org.springblade.modules.system.vo.DeptVO; import org.springblade.modules.system.vo.UserVO; import org.springblade.modules.system.wrapper.DeptWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -54,14 +58,15 @@ * @author Chill */ @Service @AllArgsConstructor public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService { private static final String TENANT_ID = "tenantId"; private static final String PARENT_ID = "parentId"; private final IInformationService iInformationService; @Autowired private IInformationService iInformationService; private final JurisdictionService jurisdictionService; @Autowired private JurisdictionService jurisdictionService; @Override public List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param) { @@ -98,10 +103,32 @@ } @Override public List<DeptVO> lazyTree(String tenantId, Long parentId) { if (AuthUtil.isAdministrator()) { tenantId = StringPool.EMPTY; public List<DeptVO> lazyTree(String tenantId, Long parentId,String userId) { // if (AuthUtil.isAdministrator()) { // tenantId = StringPool.EMPTY; // } //获取用户信息,保安,民警 if (null!=userId && !userId.equals("")) { UserVO user = baseMapper.getUserInfoById(userId); if (user.getRoleAlias().equals("公安管理员")){ //公安管理员又分,如果是派出所,只返回当前值 if (user.getDeptName().contains("派出所")){ return ForestNodeMerger.merge(baseMapper.lazyTreeCityOne(tenantId, parentId)); }else { //市局,区级 Dept dept = this.getById(parentId); if (null != dept) { if (dept.getParentId().equals(1123598813738675201L)) { return ForestNodeMerger.merge(baseMapper.lazyTreeCity(tenantId, parentId)); } } } }else { //保安公司 return ForestNodeMerger.merge(baseMapper.securityLazyTree(null, parentId)); } } //admin return ForestNodeMerger.merge(baseMapper.lazyTree(tenantId, parentId)); } src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -43,6 +43,8 @@ import org.springblade.modules.dispatcher.vo.DispatcherVO; import org.springblade.modules.information.entity.Information; import org.springblade.modules.information.service.IInformationService; import org.springblade.modules.jurisdiction.entity.Jurisdiction; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.system.entity.*; import org.springblade.modules.system.excel.QrCodeExcel; import org.springblade.modules.system.excel.SecurityExcel; @@ -81,6 +83,7 @@ private final BladeTenantProperties tenantProperties; private final IInformationService iInformationService; private final IDeptService deptService; private final JurisdictionService jurisdictionService; @Override @Transactional(rollbackFor = Exception.class) @@ -381,35 +384,39 @@ return deleteLogic(Func.toLongList(userIds)); } /** * 用户民警的导入 * @param data * @param isCovered * @param deptId */ @Override // @Transactional(rollbackFor = Exception.class) 去除事务回滚 public void importUser(List<UserExcel> data, Boolean isCovered,String deptId) { //将不能导入的保安员账号存起来 //将不能导入的账号存起来 List<String> errorList = new ArrayList<>(); //将需要新增的保安员信息存入集合 List<User> insertList = 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()+"]不存在!"); } // 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.setDeptId(deptIds); //判断当前用户是否已在本单位,如果是的更新数据 User user1 = new User(); user1.setAccount(user.getCardid()); user1.setAccount(user.getDeptId()); // user1.setAccount(user.getCode()); user1.setIsDeleted(0); user1.setStatus(1); User user2 = this.getOne(Condition.getQueryWrapper(user1)); @@ -419,9 +426,15 @@ user.setTenantId("000000"); //默认在职 user.setStatus(1); //分配保安角色 user.setIsDeleted(0); user.setCreateTime(new Date()); user.setUpdateTime(new Date()); //设置账号 user.setAccount(userExcel.getDeptId()); //user.setAccount(user.getCode()); //分配角色 Role role = new Role(); role.setRoleAlias("保安"); role.setRoleAlias("公安管理员"); Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); user.setRoleId(oneRole.getId().toString()); //性别 @@ -434,18 +447,52 @@ } } //设置账号 user.setAccount(user.getCardid()); //获取辖区的数据 Jurisdiction jurisdiction = new Jurisdiction(); jurisdiction.setDeptName(userExcel.getDeptId()); Jurisdiction one = jurisdictionService.getOne(Condition.getQueryWrapper(jurisdiction)); user.setJurisdiction(one.getId().toString()); //获取默认密码配置 user.setPassword(user.getCardid().substring(user.getCardid().length() - 6)); // user.setPassword(ParamCache.getValue(DEFAULT_PARAM_PASSWORD)); user.setPassword("123456"); // user.setPassword(user.getCode()); //加密 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.submit(user); this.save(user); //内网同步 String s = "insert into blade_user(" + "id,tenant_id,code,account,password,real_name,phone,sex,role_id,dept_id," + "create_time,update_time,cardid,status,is_deleted,jurisdiction) " + "values(" + "'" + user.getId() + "'" + "," + "'" + user.getTenantId() + "'" + "," + "'" + user.getCode() + "'" + "," + "'" + user.getAccount() + "'" + "," + "'" + user.getPassword() + "'" + "," + "'" + user.getRealName() + "'" + "," + "'" + user.getPhone() + "'" + "," + "'" + user.getSex() + "'" + "," + "'" + user.getRoleId() + "'" + "," + "'" + user.getDeptId() + "'" + "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateTime()) + "'" + "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" + "," + "'" + user.getCardid() + "'" + "," + "'" + user.getStatus() + "'" + "," + "'" + user.getIsDeleted() + "'" + "," + "'" + user.getJurisdiction() + "'" + ")"; FtpUtil.sqlFileUpload(s); }else { //匹配组织机构是否一致,如果不一致 if(!user2.getDeptId().equals(user.getDeptId())){ Dept dept = deptService.getById(user2.getDeptId()); // throw new ServiceException("用户:"+"["+user.getCardid()+"]"+"已在其他单位存在!"); status.set(false); //加入集合 errorList.add(user.getCardid()); @@ -454,11 +501,29 @@ }else { //如果是一致,则更新用户数据 //更新用户数据 user2.setUpdateTime(new Date()); if (null!=user.getPhone() && !user.getPhone().equals("")){ user2.setPhone(user.getPhone()); } if (null!=user.getRealName() && !user.getRealName().equals("")){ user2.setRealName(user.getRealName()); } if (null!=user.getCardid() && !user.getCardid().equals("")){ user2.setCardid(user.getCardid()); } if (null!=user.getCode() && !user.getCode().equals("")){ user2.setCode(user.getCode()); user2.setAccount(user.getCode()); } user2.setAccount(userExcel.getDeptId()); this.updateById(user2); String s1 = "update blade_user set hold = " + "'" + user2.getHold() + "'" + ",securitynumber = " + "'" + user2.getSecuritynumber() + "'" + ",registered = " + "'" + user2.getRegistered() + "'" "update blade_user set account = " + "'" + user2.getAccount() + "'" + ",code = " + "'" + user2.getCode() + "'" + ",real_name = " + "'" + user2.getRealName() + "'" + ",phone = " + "'" + user2.getPhone() + "'" + ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user2.getUpdateTime()) + "'" + ",cardid = " + "'" + user2.getCardid() + "'" + " " + "where id = " + "'" + user2.getId() + "'"; FtpUtil.sqlFileUpload(s1); }