springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/controller/BaseController.java
@@ -7,7 +7,7 @@ import com.panzhihua.common.exceptions.UnAuthenticationException; import com.panzhihua.common.model.vos.LoginUserInfoVO; import com.panzhihua.common.model.vos.community.ComActVO; import com.panzhihua.common.model.vos.sangeshenbian.SystemUserVo; import com.panzhihua.common.model.vos.west.SystemUserVo; import com.panzhihua.common.utlis.AES; import com.panzhihua.common.utlis.StringUtils; import lombok.SneakyThrows; springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/west/SystemUserVo.java
New file @@ -0,0 +1,121 @@ package com.panzhihua.common.model.vos.west; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.time.LocalDateTime; import java.util.Set; /** * @author zhibing.pu * @Date 2025/2/23 0:28 */ @Data public class SystemUserVo { /** * 主键 */ @ApiModelProperty(value = "数据ID") private Integer id; /** * 姓名 */ @ApiModelProperty(value = "姓名", required = true) private String name; /** * 手机号 */ @ApiModelProperty(value = "手机号", required = true) private String phone; /** * 密码 */ @ApiModelProperty(value = "密码", required = true) private String password; /** * 一级单位id */ @ApiModelProperty(value = "一级单位id", required = true) private Integer oneDepartmentId; /** * 二级单位id */ @ApiModelProperty(value = "二级单位id") private Integer twoDepartmentId; /** * 三级单位id */ @ApiModelProperty(value = "三级单位id") private Integer threeDepartmentId; /** * 四级单位id */ @ApiModelProperty(value = "四级单位id") private Integer fourDepartmentId; /** * 是否是管理员(0=否,1=是) */ @ApiModelProperty(value = "是否是管理员(0=否,1=是)", required = true) private Integer isAdmin; /** * 职位id */ @ApiModelProperty(value = "职位id", required = true) private Integer systemPostId; /** * 角色id */ @ApiModelProperty(value = "角色id", required = true) private Integer systemRoleId; /** * 账号层级(1=市级账号,2=区县账号,3=街道账号,4=社区账号) */ @ApiModelProperty(value = "账号层级(1=市级账号,2=区县账号,3=街道账号,4=社区账号)", required = true) private Integer accountLevel; /** * 所属区县 */ @ApiModelProperty(value = "所属区县") private String districts; /** * 区县编号 */ @ApiModelProperty(value = "区县编号") private String districtsCode; /** * 街道 */ @ApiModelProperty(value = "街道") private String street; /** * 街道编号 */ @ApiModelProperty(value = "街道ID") private String streetId; /** * 社区 */ @ApiModelProperty(value = "社区") private String community; /** * 社区编号 */ @ApiModelProperty(value = "社区ID") @JsonSerialize(using = ToStringSerializer.class) private Long communityId; /** * 状态(1=正常,2=冻结,3=删除) */ private Integer status; /** * 添加时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime createTime; @ApiModelProperty("权限集合") private Set<String> permissions; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/DateUtils.java
@@ -426,7 +426,9 @@ long min = diff / nm; return (int)hour; } public static int getDay(Date stardate, Date enddate) { } public static int getDay(Date stardate, Date enddate) { long nd = 1000 * 24 * 60 * 60; long nh = 1000 * 60 * 60; long nm = 1000 * 60; springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/DepartmentController.java
@@ -16,6 +16,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.*; @@ -226,4 +227,26 @@ List<Department> list = departmentService.list(new LambdaQueryWrapper<Department>().eq(Department::getTier, tier)); return R.ok(list); } @ResponseBody @PostMapping("/importDepartment") @ApiOperation(value = "单位导入", tags = {"西区纪委后台-单位管理"}) public R<?> importDepartment(MultipartFile file) { String s = file.getOriginalFilename(); if (s == null || !("xls".equals(s.substring(s.lastIndexOf(".") + 1)) || "xlsx".equals(s.substring(s.lastIndexOf(".") + 1)))) { return R.fail("只能上传.xls或.xlsx格式的文件"); } SystemUserVo loginUserInfoWest = getLoginUserInfoWest(); String name = loginUserInfoWest.getName(); Integer id = loginUserInfoWest.getId(); try { return departmentService.importDepartment(s, file,name,id); } catch (Exception e) { e.printStackTrace(); } return R.ok(); } } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/api/SystemUserController.java
@@ -25,6 +25,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.time.LocalDateTime; @@ -451,4 +452,25 @@ @ResponseBody @PostMapping("/importUser") @ApiOperation(value = "用户导入", tags = {"西区纪委后台-人员管理"}) public R<?> importUser(MultipartFile file) { String s = file.getOriginalFilename(); if (s == null || !("xls".equals(s.substring(s.lastIndexOf(".") + 1)) || "xlsx".equals(s.substring(s.lastIndexOf(".") + 1)))) { return R.fail("只能上传.xls或.xlsx格式的文件"); } try { return systemUserService.importUser(s, file); } catch (Exception e) { e.printStackTrace(); } return R.ok(); } } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/IDepartmentService.java
@@ -1,11 +1,17 @@ package com.panzhihua.westcommittee.service; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.vos.R; import com.panzhihua.westcommittee.model.entity.Department; import org.springframework.web.multipart.MultipartFile; /** * @author zhibing.pu * @Date 2025/2/19 17:43 */ public interface IDepartmentService extends IService<Department> { R<?> importDepartment(String s, MultipartFile file,String name,Integer id); } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/ISystemUserService.java
@@ -2,11 +2,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.west.SystemUserVo; import com.panzhihua.westcommittee.model.entity.SystemUser; import com.panzhihua.westcommittee.model.vo.RegionVO; import com.panzhihua.westcommittee.warpper.SystemUserList; import com.panzhihua.westcommittee.warpper.SystemUserListVo; import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Optional; @@ -68,4 +70,6 @@ String getCreateByIdPhone(Long createBy); R<?> importUser(String s, MultipartFile file); } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/DepartmentServiceImpl.java
@@ -1,10 +1,29 @@ package com.panzhihua.westcommittee.service.impl; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.west.SystemUserVo; import com.panzhihua.common.utlis.StringUtils; import com.panzhihua.westcommittee.dao.DepartmentMapper; import com.panzhihua.westcommittee.model.entity.BcRegion; import com.panzhihua.westcommittee.model.entity.ComAct; import com.panzhihua.westcommittee.model.entity.ComStreet; import com.panzhihua.westcommittee.model.entity.Department; import com.panzhihua.westcommittee.service.IBcRegionService; import com.panzhihua.westcommittee.service.IComActService; import com.panzhihua.westcommittee.service.IComStreetService; import com.panzhihua.westcommittee.service.IDepartmentService; import com.panzhihua.westcommittee.utils.ExcelUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.util.Date; import java.util.List; /** * @author zhibing.pu @@ -12,4 +31,57 @@ */ @Service public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements IDepartmentService { @Autowired private ExcelUtil excelUtil; @Autowired private IComStreetService streetService; @Autowired private IComActService comActService; @Override public R<?> importDepartment(String s, MultipartFile file,String name,Integer id) { List<List<List<String>>> upload = excelUtil.upload( s,file); List<List<String>> lists = upload.get(0); for (List<String> list : lists) { String deptName = list.get(0); String level = list.get(1); String districts = list.get(2); String street = list.get(3); String community = list.get(4); String remark = list.get(5); Department department = new Department(); department.setName(deptName); department.setTier(Integer.parseInt(level)); department.setDistricts(districts); department.setDistrictsCode("510403"); if(StringUtils.isNotEmpty(street)){ department.setStreet(street); ComStreet one = streetService.getOne(new LambdaQueryWrapper<ComStreet>().eq(ComStreet::getName, street).eq(ComStreet::getAppId,"wx0cef797390444b75")); department.setStreetId(one.getStreetId()); } if(StringUtils.isNotEmpty(community)){ department.setCommunity(community); ComAct one = comActService.getOne(new LambdaQueryWrapper<ComAct>().eq(ComAct::getName, community).eq(ComAct::getAppId,"wx0cef797390444b75")); department.setCommunityId(one.getCommunityId()); } department.setRemark(remark); department.setCreateTime(new Date()); department.setUpdateTime(new Date()); department.setOperName(name); department.setOperId(id); department.setStatus(1); try { this.save(department); }catch (Exception e){ e.printStackTrace(); } } return R.ok(); } } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/java/com/panzhihua/westcommittee/service/impl/SystemUserServiceImpl.java
@@ -1,29 +1,35 @@ package com.panzhihua.westcommittee.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.beust.jcommander.internal.Lists; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.west.SystemUserVo; import com.panzhihua.common.utlis.PayUtil; import com.panzhihua.common.utlis.StringUtils; import com.panzhihua.westcommittee.dao.SystemUserLevelMapper; import com.panzhihua.westcommittee.dao.SystemUserMapper; import com.panzhihua.westcommittee.model.entity.ComAct; import com.panzhihua.westcommittee.model.entity.ComStreet; import com.panzhihua.westcommittee.model.entity.SystemUser; import com.panzhihua.westcommittee.model.entity.*; import com.panzhihua.westcommittee.model.vo.RegionVO; import com.panzhihua.westcommittee.service.IComActService; import com.panzhihua.westcommittee.service.IComStreetService; import com.panzhihua.westcommittee.service.ISystemUserService; import com.panzhihua.westcommittee.service.*; import com.panzhihua.westcommittee.utils.ExcelUtil; import com.panzhihua.westcommittee.warpper.SystemUserList; import com.panzhihua.westcommittee.warpper.SystemUserListVo; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import sun.security.util.Password; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Optional; @@ -38,6 +44,10 @@ private final IComActService comActService; private final SystemUserLevelMapper systemUserLevelMapper; private final IComStreetService comStreetService; private final ExcelUtil excelUtil; private final IDepartmentService departmentService; private final ISystemPostService systemPostService; /** * 获取列表数据 * @param query @@ -175,4 +185,58 @@ return this.baseMapper.getCreateByIdPhone(createBy); } @SneakyThrows @Override public R<?> importUser(String s, MultipartFile file) { List<List<List<String>>> upload = excelUtil.upload(s, file); List<List<String>> lists = upload.get(0); for (List<String> list : lists) { String name = list.get(0); String postName = list.get(1); String deptName = list.get(2); String roleId = list.get(3); String phone = list.get(4); String pwd = list.get(5); long count = this.count(new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getPhone, phone).ne(SystemUser::getStatus, 3)); if (0 == count) { SystemUser systemUser = new SystemUser(); systemUser.setName(name); systemUser.setPhone(phone); systemUser.setPassword(PayUtil.MD5(pwd).toLowerCase()); try { Department name1 = departmentService.getOne(new QueryWrapper<Department>().eq("name", deptName)); systemUser.setOneDepartmentId(name1.getId()); systemUser.setDistricts(name1.getDistricts()); systemUser.setDistrictsCode(name1.getDistrictsCode()); systemUser.setStreet(name1.getStreet()); systemUser.setStreetId(name1.getStreetId()); systemUser.setCommunity(name1.getCommunity()); systemUser.setCommunityId(name1.getCommunityId()); systemUser.setAccountLevel(name1.getTier()); systemUser.setStatus(1); systemUser.setSystemRoleId(Integer.valueOf(roleId)); systemUser.setCreateTime(LocalDateTime.now()); SystemPost name2 = systemPostService.getOne(new QueryWrapper<SystemPost>().eq("name", postName)); systemUser.setSystemPostId(name2.getId()); save(systemUser); } catch (Exception e) { System.out.println(deptName); System.out.println(postName); e.printStackTrace(); } } } return R.ok(); } public static void main(String[] args) throws Exception { System.out.println(PayUtil.MD5("111111").toLowerCase()); } } springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/SystemPostMapper.xml
@@ -17,4 +17,5 @@ </if> order by create_time desc </select> </mapper> springcloud_k8s_panzhihuazhihuishequ/service_westcommittee/src/main/resources/mapper/SystemUserMapper.xml
@@ -43,7 +43,7 @@ <select id="getStreet" resultType="com.panzhihua.westcommittee.model.vo.RegionVO"> select CAST(street_id AS CHAR) as id, name as name from com_street where area_code = #{areaCode} select CAST(street_id AS CHAR) as id, name as name from com_street where app_id ='wx0cef797390444b75' </select> @@ -52,7 +52,7 @@ </select> <select id="getCreateByIdPhone" resultType="java.lang.String"> select phone from sys_user where id = #{createBy} select phone from sys_user where user_id = #{createBy} </select> </mapper>