Commit 3802a5467e57f98bf83456df62215b1c716c3ea6

Authored by xqs
2 parents 817deae4 2ad883ca

Merge branch 'WMSV2-HH' of http://www.huahengrobot.com:90/wms/wms2 into develop

src/main/java/com/huaheng/common/utils/StringUtils.java
... ... @@ -23,6 +23,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
23 23 */
24 24 private static final char SEPARATOR = '_';
25 25  
  26 + /**objet NULL判断非empty*/
  27 + public static boolean isNullNew(Object object)
  28 + {
  29 + return object == null;
  30 + }
  31 +
26 32 /**
27 33 * 获取参数不为空值
28 34 *
... ... @@ -40,7 +46,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
40 46 * @return true:为空 false:非空
41 47 */
42 48 public static boolean isEmpty(Collection<?> coll) {
43   - return isNull(coll) || coll.isEmpty();
  49 + return isNullNew(coll) || coll.isEmpty();
44 50 }
45 51  
46 52 /**
... ... @@ -60,7 +66,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
60 66 * * @return true:为空 false:非空
61 67 */
62 68 public static boolean isEmpty(Object[] objects) {
63   - return isNull(objects) || (objects.length == 0);
  69 + return isNullNew(objects) || (objects.length == 0);
64 70 }
65 71  
66 72 /**
... ... @@ -80,7 +86,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
80 86 * @return true:为空 false:非空
81 87 */
82 88 public static boolean isEmpty(Map<?, ?> map) {
83   - return isNull(map) || map.isEmpty();
  89 + return isNullNew(map) || map.isEmpty();
84 90 }
85 91  
86 92 /**
... ... @@ -100,7 +106,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
100 106 * @return true:为空 false:非空
101 107 */
102 108 public static boolean isEmpty(String str) {
103   - return isNull(str) || NULLSTR.equals(str.trim());
  109 + return isNullNew(str) || NULLSTR.equals(str.trim());
104 110 }
105 111  
106 112 /**
... ... @@ -173,7 +179,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
173 179 * @return true:是数组 false:不是数组
174 180 */
175 181 public static boolean isArray(Object object) {
176   - return isNotNull(object) && object.getClass().isArray();
  182 + return !isNullNew(object) && object.getClass().isArray();
177 183 }
178 184  
179 185 /**
... ...
src/main/java/com/huaheng/pc/system/user/controller/UserController.java
... ... @@ -138,8 +138,8 @@ public class UserController extends BaseController
138 138 {
139 139 mmap.put("user", userService.selectUserById(id));
140 140 mmap.put("roles", roleService.selectRolesByUserId(id));
141   - mmap.put("companys", companyService.selectCompanyByUserId(id));
142   - mmap.put("warehouses", warehouseService.selectWarehouseByUserId(id));
  141 + mmap.put("companyList", companyService.selectCompanyByUserId(id));
  142 + mmap.put("warehouseList", warehouseService.selectWarehouseByUserId(id));
143 143 return prefix + "/edit";
144 144 }
145 145  
... ...
src/main/java/com/huaheng/pc/system/user/domain/UserCompany.java
... ... @@ -39,6 +39,47 @@ public class UserCompany{
39 39 @TableField(value = "companyCode")
40 40 private String companyCode;
41 41  
  42 + private String name;
  43 +
  44 + public Integer getId() {
  45 + return id;
  46 + }
  47 +
  48 + public void setId(Integer id) {
  49 + this.id = id;
  50 + }
  51 +
  52 + public Integer getUserId() {
  53 + return userId;
  54 + }
  55 +
  56 + public void setUserId(Integer userId) {
  57 + this.userId = userId;
  58 + }
  59 +
  60 + public Integer getCompanyId() {
  61 + return companyId;
  62 + }
  63 +
  64 + public void setCompanyId(Integer companyId) {
  65 + this.companyId = companyId;
  66 + }
  67 +
  68 + public String getCompanyCode() {
  69 + return companyCode;
  70 + }
  71 +
  72 + public void setCompanyCode(String companyCode) {
  73 + this.companyCode = companyCode;
  74 + }
  75 +
  76 + public String getName() {
  77 + return name;
  78 + }
  79 +
  80 + public void setName(String name) {
  81 + this.name = name;
  82 + }
42 83 }
43 84  
44 85  
... ...
src/main/java/com/huaheng/pc/system/user/service/UserServiceImpl.java
... ... @@ -7,6 +7,7 @@ import java.util.Map;
7 7 import java.util.stream.Collectors;
8 8  
9 9 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  10 +import com.huaheng.common.exception.service.ServiceException;
10 11 import com.huaheng.framework.web.domain.AjaxResult;
11 12 import com.huaheng.pc.config.company.domain.Company;
12 13 import com.huaheng.pc.config.company.mapper.CompanyMapper;
... ... @@ -258,14 +259,29 @@ public class UserServiceImpl implements IUserService
258 259 user.randomSalt();
259 260 user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
260 261 user.setCreateBy(ShiroUtils.getLoginName());
261   - // 新增用户信息
262   - int rows = userMapper.insertUser(user);
263   - // 新增用户货主关联
264   - insertUserCompany(user);
265   - // 新增用户与角色管理
266   - insertUserRole(user);
267   - // 新增用户与仓库管理
268   - insertUserWarehouse(user);
  262 + //新建用户名不能重复/
  263 + User u = userMapper.selectUserByLoginName(user.getLoginName());
  264 + int rows = 0;
  265 + if(!StringUtils.isNull(u)){
  266 + //新增用户时,如果已经有逻辑删除的则是修改
  267 + if(u.getDeleted()){
  268 + user.setId(u.getId());
  269 + user.setDeleted(false);
  270 + //修改用户
  271 + rows = this.updateUser(user);
  272 + }else{
  273 + throw new ServiceException("用户名重复!");
  274 + }
  275 + }else{
  276 + // 新增用户信息
  277 + rows = userMapper.insertUser(user);
  278 + // 新增用户货主关联
  279 + this.insertUserCompany(user);
  280 + // 新增用户与角色
  281 + this.insertUserRole(user);
  282 + // 新增用户与仓库
  283 + this.insertUserWarehouse(user);
  284 + }
269 285 return rows;
270 286 }
271 287  
... ...
src/main/resources/mybatis/config/CompanyMapper.xml
... ... @@ -53,8 +53,11 @@
53 53 INNER JOIN company c ON suc.companyId = c.id AND suc.userId = #{userId}
54 54 INNER JOIN warehouse_company wc ON wc.companyId=c.id AND wc.warehouseCode = #{warehouseCode}
55 55 </select>
56   - <select id="selectByWarehouseCode" resultType="com.huaheng.pc.config.company.domain.Company">
57   - select c.id, c.name ,c.code from company c INNER JOIN warehouse_company w ON c.id = w.companyId
  56 +
  57 + <select id="selectByWarehouseCode" resultType="com.huaheng.pc.config.company.domain.Company">
  58 + select c.id , c.code, c.name, c.warehouseCode, c.deleted
  59 + from company c
  60 + INNER JOIN warehouse_company wc ON c.id = wc.companyId
58 61 where c.warehouseCode = #{warehouseCode}
59 62 </select>
60 63  
... ...
src/main/resources/mybatis/config/WarehouseMapper.xml
... ... @@ -35,21 +35,25 @@
35 35 <result column="deleted" jdbcType="BIT" property="deleted" />
36 36 </resultMap>
37 37 <select id="wareHouseAll" resultType="com.huaheng.pc.system.user.domain.SysUserWarehouse">
38   - select * from warehouse
  38 + select code, address1, address2, city, `state`, district, country, postalCode, attentionTo,
  39 + phoneNum, faxNum, email, hostCode, `name`, `enable`, orgCode, created, createdBy,
  40 + lastUpdated, lastUpdatedBy, version, userDef1, userDef2, userDef3, userDef4, userDef5,
  41 + userDef6, userDef7, userDef8, deleted from warehouse
39 42 </select>
40 43  
41   - <select id="selectWarehouseByUserId"
42   - resultType="com.huaheng.pc.config.warehouse.domain.Warehouse">
43   - SELECT r.`name`, r.code
44   - FROM sys_user u
45   - LEFT JOIN sys_user_warehouse ur ON u.id = ur.userId
46   - LEFT JOIN warehouse r ON ur.warehouseCode = r.code
  44 + <select id="selectWarehouseByUserId" resultType="com.huaheng.pc.config.warehouse.domain.Warehouse">
  45 + SELECT r.`name`, r.code ,r.enable
  46 + FROM sys_user_warehouse ur
  47 + LEFT JOIN warehouse r ON r.code = ur.warehouseCode
47 48 WHERE ur.userId =#{userId}
48 49 </select>
49 50  
50   - <select id="selectWarehouseAll"
51   - resultType="com.huaheng.pc.config.warehouse.domain.Warehouse">
52   - select * from warehouse where deleted =false
  51 + <select id="selectWarehouseAll" resultType="com.huaheng.pc.config.warehouse.domain.Warehouse">
  52 + select code, address1, address2, city, `state`, district, country, postalCode, attentionTo,
  53 + phoneNum, faxNum, email, hostCode, `name`, `enable`, orgCode, created, createdBy,
  54 + lastUpdated, lastUpdatedBy, version, userDef1, userDef2, userDef3, userDef4, userDef5,
  55 + userDef6, userDef7, userDef8, deleted
  56 + from warehouse where deleted =false
53 57 </select>
54 58  
55 59  
... ...
src/main/resources/mybatis/system/UserCompanyMapper.xml
... ... @@ -3,22 +3,23 @@
3 3 <mapper namespace="com.huaheng.pc.system.user.mapper.UserCompanyMapper">
4 4  
5 5 <select id="selectListEntityByEqual" resultType="com.huaheng.pc.system.user.domain.UserCompany">
6   - SELECT id, userId, companyId, companyCode
7   - FROM sys_user_company
8   - <where>
9   - <if test="id != null">
10   - AND id = #{id}
11   - </if>
12   - <if test="userId != null">
13   - AND userId = #{userId}
14   - </if>
15   - <if test="companyId != null">
16   - AND companyId = #{companyId}
17   - </if>
18   - <if test="companyCode != null">
19   - AND companyCode = #{companyCode}
20   - </if>
21   - </where>
  6 + SELECT sc.id, sc.userId, sc.companyId, sc.companyCode, c.name
  7 + FROM sys_user_company sc
  8 + inner join company c on c.id = sc.companyId
  9 + <where>
  10 + <if test="id != null">
  11 + AND sc.id = #{id}
  12 + </if>
  13 + <if test="userId != null">
  14 + AND sc.userId = #{userId}
  15 + </if>
  16 + <if test="companyId != null">
  17 + AND sc.companyId = #{companyId}
  18 + </if>
  19 + <if test="companyCode != null">
  20 + AND sc.companyCode = #{companyCode}
  21 + </if>
  22 + </where>
22 23 </select>
23 24  
24 25 <select id="countUserCompanyById" resultType="java.lang.Integer">
... ...
src/main/resources/mybatis/system/UserMapper.xml
... ... @@ -42,7 +42,8 @@
42 42 </sql>
43 43  
44 44 <select id="selectUserList" resultMap="UserResult">
45   - select u.id, u.deptId, u.loginName, u.userName, u.email, u.phoneNumber, u.password, u.sex, u.avatar, u.salt, u.enable, u.deleted, u.loginIp, u.loginDate, u.createBy, u.createTime, u.remark, d.deptName
  45 + select u.id, u.deptId, u.loginName, u.userName, u.email, u.phoneNumber, u.password, u.sex, u.avatar, u.salt, u.enable, u.deleted,
  46 + u.loginIp, u.loginDate, u.createBy, u.createTime, u.updateTime, u.updateBy, u.remark, d.deptName
46 47 from sys_user u
47 48 left join sys_dept d on u.deptId = d.id
48 49 WHERE u.deleted = false
... ... @@ -103,7 +104,8 @@
103 104 </select>
104 105  
105 106 <select id="selectmen" resultType="com.huaheng.pc.system.user.domain.User">
106   - select * from sys_user where loginName = #{loginName}
  107 + select id, deptId, loginName, userName, email, phoneNumber, password, sex, avatar, salt, enable, deleted,
  108 + loginIp, loginDate, createBy, createTime, updateTime, updateBy, remark from sys_user where loginName = #{loginName}
107 109 </select>
108 110  
109 111 <delete id="deleteUserById">
... ...
src/main/resources/static/css/style.css
... ... @@ -3341,9 +3341,10 @@ nav.page-tabs .page-tabs-content {
3341 3341 color: #999;
3342 3342 display: block;
3343 3343 }
3344   -.xx_box a:hover{
  3344 +.xx_box a.xx:hover{
3345 3345 background: #f2f2f2;
3346 3346 }
  3347 +
3347 3348 .xx sup{
3348 3349 /*line-height: 12px;
3349 3350 padding: 2px 5px;*/
... ...
src/main/resources/templates/system/user/add.html
... ... @@ -85,7 +85,7 @@
85 85 <label class="col-sm-3 control-label">角色:</label>
86 86 <div class="col-sm-8">
87 87 <label th:each="role:${roles}" class="checkbox-inline i-checks">
88   - <input name="role" type="checkbox" th:value="${role.id}" th:text="${role.roleName}" th:disabled="${role.enable == false}">
  88 + <input name="role" type="radio" th:value="${role.id}" th:text="${role.roleName}" th:disabled="${role.enable == false}">
89 89 </label>
90 90 </div>
91 91 </div>
... ... @@ -200,7 +200,7 @@
200 200 var phoneNumber = $("input[name='phoneNumber']").val();
201 201 var sex = $("#sex option:selected").val();
202 202 var enable = $("input[name='enable']").is(':checked') == true ? 1 : 0;
203   - var roleIds = $.form.selectCheckeds("role");
  203 + var roleIds = $("input[name='role']").is(':checked') == true ? 1 : 0;
204 204 var warehouseCodeList = $.form.selectCheckeds("warehouseCode");
205 205 var companyIdList = $.form.selectCheckeds("company");
206 206 $.ajax({
... ...
src/main/resources/templates/system/user/edit.html
... ... @@ -61,18 +61,18 @@
61 61 <div class="form-group">
62 62 <label class="col-sm-3 control-label">货主:</label>
63 63 <div class="col-sm-8">
64   - <label th:each="company:${companys}" class="checkbox-inline i-checks">
65   - <input name="company" type="checkbox" th:value="${company.id}" th:text=" ${company.name}" th:checked="${company.flag}" >
66   - </label>
  64 + <label th:each="company:${companyList}" class="checkbox-inline i-checks">
  65 + <input name="company" id ="company" type="checkbox" th:value="${company.id}" th:text=" ${company.name}" th:checked="${company.flag}" th:disabled="${company.deleted == true}">
  66 + </label>
67 67 </div>
68 68 </div>
69 69  
70 70 <div class="form-group">
71 71 <label class="col-sm-3 control-label">仓库:</label>
72 72 <div class="col-sm-8">
73   - <label th:each="warehouse:${warehouses}" class="checkbox-inline i-checks">
74   - <input name="warehouse" type="checkbox" th:value="${warehouse.code}" th:text="${warehouse.name}" th:checked="${warehouse.flag}" th:disabled="${warehouse.enable == false}">
75   - </label>
  73 + <label th:each="warehouse:${warehouseList}" class="checkbox-inline i-checks">
  74 + <input name="warehouse" id ="warehouse" type="checkbox" th:value="${warehouse.code}" th:text="${warehouse.name}" th:checked="${warehouse.flag}" th:disabled="${warehouse.enable == true}">
  75 + </label>
76 76 </div>
77 77 </div>
78 78  
... ... @@ -80,7 +80,7 @@
80 80 <label class="col-sm-3 control-label">角色:</label>
81 81 <div class="col-sm-8">
82 82 <label th:each="role:${roles}" class="checkbox-inline i-checks">
83   - <input name="role" type="checkbox" th:value="${role.id}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.enable == false}">
  83 + <input name="role" type="radio" th:value="${role.id}" th:text="${role.roleName}" th:checked="${role.flag}" th:disabled="${role.enable == false}">
84 84 </label>
85 85 </div>
86 86 </div>
... ... @@ -169,7 +169,7 @@
169 169 var phoneNumber = $("input[name='phoneNumber']").val();
170 170 var sex = $("#sex option:selected").val();
171 171 var enable = $("input[name='enable']").is(':checked') == true ? 1 : 0;
172   - var roleIds = $.form.selectCheckeds("role");
  172 + var roleIds = $("input[name='role']").is(':checked') == true ? 1 : 0;
173 173 var warehouseCodeList = $.form.selectCheckeds("warehouse");
174 174 var companyIdList = $.form.selectCheckeds("company");
175 175 $.ajax({
... ...
src/main/resources/templates/system/user/user.html
... ... @@ -150,6 +150,16 @@
150 150 title: '创建时间',
151 151 sortable: true
152 152 },
  153 + {
  154 + field: 'createBy',
  155 + title: '创建人',
  156 + visible: false,
  157 + },
  158 + {
  159 + field: 'updateTime',
  160 + title: '修改时间',
  161 + sortable: true
  162 + },
153 163 {
154 164 title: '操作',
155 165 align: 'center',
... ...