Commit f76f968ea6f56e41959908e8355ad325e1adb098

Authored by tangying
1 parent 390e249b

融合完毕版本,但是启动不了,需要修改错误

Showing 100 changed files with 3757 additions and 283 deletions

Too many changes to show.

To preserve performance only 88 of 100 files are displayed.

src/main/java/com/huaheng/common/exception/base/BaseException.java
... ... @@ -3,12 +3,14 @@ package com.huaheng.common.exception.base;
3 3 import org.springframework.util.StringUtils;
4 4 import com.huaheng.common.utils.MessageUtils;
5 5  
  6 +import java.io.Serializable;
  7 +
6 8 /**
7 9 * 基础异常
8 10 *
9 11 * @author huaheng
10 12 */
11   -public class BaseException extends RuntimeException
  13 +public class BaseException extends RuntimeException implements Serializable
12 14 {
13 15  
14 16 private static final long serialVersionUID = 1L;
... ...
src/main/java/com/huaheng/common/exception/service/ServiceException.java 0 → 100644
  1 +package com.huaheng.common.exception.service;
  2 +
  3 +import com.huaheng.common.exception.base.BaseException;
  4 +
  5 +import java.io.Serializable;
  6 +
  7 +/**
  8 + * @Description: 业务类异常
  9 + * @author 唐颖
  10 + * @date 2018/4/20 14:30
  11 + *
  12 + */
  13 +public class ServiceException extends BaseException implements Serializable{
  14 +
  15 + private static final long serialVersionUID = 1L;
  16 +
  17 + public ServiceException(String message) {
  18 + super(message);
  19 + }
  20 +
  21 + public ServiceException(String code, Object[] args)
  22 + {
  23 + super("user", code, args, null);
  24 + }
  25 +
  26 +}
0 27 \ No newline at end of file
... ...
src/main/java/com/huaheng/common/support/Convert.java
... ... @@ -291,7 +291,7 @@ public class Convert
291 291 /**
292 292 * 转换为Integer数组<br>
293 293 *
294   - * @param split 被转换的值
  294 + * @param str 被转换的值
295 295 * @return 结果
296 296 */
297 297 public static Integer[] toIntArray(String str)
... ... @@ -302,7 +302,7 @@ public class Convert
302 302 /**
303 303 * 转换为Long数组<br>
304 304 *
305   - * @param split 被转换的值
  305 + * @param str 被转换的值
306 306 * @return 结果
307 307 */
308 308 public static Long[] toLongArray(String str)
... ... @@ -336,8 +336,8 @@ public class Convert
336 336 /**
337 337 * 转换为Long数组<br>
338 338 *
339   - * @param isIgnoreConvertError 是否忽略转换错误,忽略则给值null
340   - * @param values 被转换的值
  339 + * @param split 分隔符
  340 + * @param str 被转换的值
341 341 * @return 结果
342 342 */
343 343 public static Long[] toLongArray(String split, String str)
... ... @@ -359,7 +359,7 @@ public class Convert
359 359 /**
360 360 * 转换为String数组<br>
361 361 *
362   - * @param split 被转换的值
  362 + * @param str 被转换的值
363 363 * @return 结果
364 364 */
365 365 public static String[] toStrArray(String str)
... ...
src/main/java/com/huaheng/common/utils/DataUtils.java 0 → 100644
  1 +package com.huaheng.common.utils;
  2 +
  3 +import java.lang.reflect.Field;
  4 +import java.lang.reflect.Method;
  5 +import java.math.BigDecimal;
  6 +import java.text.ParseException;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.Date;
  9 +
  10 +public class DataUtils {
  11 +
  12 + static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  13 +
  14 + /***
  15 + * 转化为Example方法名
  16 + * @param filedName 字段名
  17 + * @param methodSuffix 方法后缀
  18 + * @return
  19 + */
  20 + public static String ConvertMethodName(String filedName, String methodSuffix) {
  21 + String returnValue = null;
  22 + if (filedName.length() > 0)
  23 + {
  24 + char[] nameChar = filedName.toCharArray();
  25 + if (nameChar[0] >= 'a' && nameChar[0] <= 'z') {
  26 + nameChar[0] = (char) (nameChar[0] - 32);
  27 + }
  28 + returnValue = "and" + String.valueOf(nameChar) + methodSuffix;
  29 + }
  30 + return returnValue;
  31 + }
  32 +
  33 + /**
  34 + * 将对象转为字符串
  35 + * @param object
  36 + * @return
  37 + */
  38 + public static String getString(Object object)
  39 + {
  40 + if (object == null) return null;
  41 + else return object.toString();
  42 + }
  43 +
  44 + /**
  45 + * 将对象转为Integer
  46 + * @param object
  47 + * @return
  48 + */
  49 + public static Integer getInteger(Object object)
  50 + {
  51 + if (object == null) return null;
  52 + else return Integer.valueOf(object.toString());
  53 + }
  54 +
  55 + /**
  56 + * 将对象转为BigDecimal
  57 + * @param object
  58 + * @return
  59 + */
  60 + public static BigDecimal getBigDecimal(Object object)
  61 + {
  62 + if (object == null) return null;
  63 + else return new BigDecimal(object.toString());
  64 + }
  65 +
  66 +
  67 + /**
  68 + * 将对象转为Date
  69 + * @param object
  70 + * @return
  71 + */
  72 + public static Date getDateTime(Object object) throws ParseException
  73 + {
  74 + if (object == null)
  75 + {
  76 + return null;
  77 + }
  78 + else
  79 + {
  80 + return format.parse(object.toString());
  81 + }
  82 + }
  83 +
  84 +
  85 +
  86 +
  87 +// /**
  88 +// * 根据传过来实体类,自动拼接查询Condition,如果是字符类型就用LIKE查询,如果是日期类型就用>=或是<=,其他的用=
  89 +// * @param entityClass
  90 +// * @return
  91 +// * @throws Exception
  92 +// */
  93 +// public static <T> Condition createCondition (T entityClass) throws Exception {
  94 +// Condition condition = new Condition(entityClass.getClass());
  95 +// Field[] fields = entityClass.getClass().getDeclaredFields();
  96 +// Field.setAccessible(fields, true);
  97 +// for (int i = 0; i < fields.length; i++) {
  98 +// String filedName = fields[i].getName();
  99 +// Object filedValue = fields[i].get(entityClass);
  100 +// if (filedValue != null && filedValue.toString().length() > 0) {
  101 +// if (filedValue.getClass() == String.class) {
  102 +// condition.and().andLike(filedName, "%" + filedValue.toString() + "%");
  103 +// } else if(filedValue.getClass() == Date.class){
  104 +// if (filedName.startsWith("begin") || filedName.startsWith("create")) {
  105 +// condition.and().andGreaterThanOrEqualTo(filedName, filedValue);
  106 +// }else if (filedName.startsWith("end")|| filedName.startsWith("update")){
  107 +// condition.and().andLessThanOrEqualTo(filedName, filedValue);
  108 +// }
  109 +// } else {
  110 +// condition.and().andEqualTo(filedName, filedValue);
  111 +// }
  112 +// }
  113 +// }
  114 +// return condition;
  115 +// }
  116 +
  117 +// /**
  118 +// * 根据传过来实体类,自动拼接查询Example,如果是字符类型就用LIKE查询,如果是日期类型就用>=或是<=,其他的用=
  119 +// * @param entity 实体
  120 +// * @param example 需要生成的Example
  121 +// * @param <T> 实体类型
  122 +// * @param <V> Example类型
  123 +// * @throws Exception
  124 +// */
  125 +// public static <T, V> void createCriteria (T entity, V example) throws Exception {
  126 +// Field[] entityFields = entity.getClass().getDeclaredFields();
  127 +// Field.setAccessible(entityFields, true);
  128 +// Object criteria = example.getClass().getDeclaredMethod("createCriteria").invoke(example);
  129 +// Method[] exampleMethod = criteria.getClass().getDeclaredMethods();
  130 +// for (int i = 0; i < entityFields.length; i++) {
  131 +// String filedName = entityFields[i].getName();
  132 +// Object filedValue = entityFields[i].get(entity);
  133 +// if (filedName.equals("deleted")) filedValue = false;
  134 +// if (filedName.equals("warehouseCode")) filedValue = ShiroUtils.getWarehouseCode();
  135 +// if (filedValue != null && filedValue.toString().length() > 0) {
  136 +// String methodName = null;
  137 +// if (filedValue.getClass() == Integer.class || filedValue.getClass() == Boolean.class || filedName.equals("warehouseCode"))
  138 +// {
  139 +// methodName = ConvertMethodName(filedName, "EqualTo");
  140 +// }
  141 +// else if (filedValue.getClass() == String.class)
  142 +// {
  143 +// methodName = ConvertMethodName(filedName, "Like");
  144 +// filedValue = filedValue.toString() + "%";
  145 +// }
  146 +// else if(filedValue.getClass() == Date.class)
  147 +// {
  148 +// if (filedName.startsWith("begin") || filedName.startsWith("create")) {
  149 +// methodName = ConvertMethodName(filedName, "GreaterThanOrEqualTo");
  150 +// }else if (filedName.startsWith("end")|| filedName.startsWith("update")){
  151 +// methodName = ConvertMethodName(filedName, "andAddress1LessThanOrEqualTo");
  152 +// }
  153 +// }
  154 +// for (Method itemMethod : exampleMethod)
  155 +// {
  156 +// if (itemMethod.getName().equals(methodName)) {
  157 +// itemMethod.invoke(criteria, filedValue);
  158 +// }
  159 +// }
  160 +// }
  161 +// }
  162 +// }
  163 +
  164 +
  165 +}
... ...
src/main/java/com/huaheng/common/utils/MybatisPlus/PlusUtils.java 0 → 100644
  1 +package com.huaheng.common.utils.MybatisPlus;
  2 +
  3 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  4 +import java.lang.reflect.Field;
  5 +
  6 +public class PlusUtils {
  7 + public static <T> EntityWrapper getWrapper (T entity) throws IllegalAccessException {
  8 + EntityWrapper<T> entityWrapper = new EntityWrapper<T>();
  9 + Field[] fields = entity.getClass().getDeclaredFields();
  10 + Field.setAccessible(fields, true);
  11 + for (int i = 0; i < fields.length; i++) {
  12 + String filedName = fields[i].getName();
  13 + Object filedValue = fields[i].get(entity);
  14 + if (filedValue != null)
  15 + entityWrapper.eq(filedName, filedValue);
  16 + }
  17 + return entityWrapper;
  18 + }
  19 +}
... ...
src/main/java/com/huaheng/common/utils/security/PermissionUtils.java
... ... @@ -14,7 +14,7 @@ public class PermissionUtils
14 14 /**
15 15 * 权限错误消息提醒
16 16 *
17   - * @param errorMsg 错误信息
  17 + * @param permissionsStr 错误信息
18 18 * @return
19 19 */
20 20 public static String getMsg(String permissionsStr)
... ...
src/main/java/com/huaheng/framework/mybatisPlus/IPlusService.java 0 → 100644
  1 +package com.huaheng.framework.mybatisPlus;
  2 +
  3 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  4 +import com.baomidou.mybatisplus.plugins.Page;
  5 +import com.baomidou.mybatisplus.service.IService;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +
  9 +
  10 +public interface IPlusService<T> extends IService<T> {
  11 +
  12 + T selectFirstEntity(T entity) throws IllegalAccessException ;
  13 +
  14 +
  15 + List<T> selectListEntityByEqual(T entity) throws IllegalAccessException ;
  16 +
  17 +
  18 + List<Map<String, Object>> selectListMapByEqual(T entity, String SqlSelect) throws IllegalAccessException ;
  19 +
  20 +
  21 + Page<Map<String, Object>> selectMapsPage(Page page, T entity) throws IllegalAccessException ;
  22 +
  23 +
  24 + Page<T> selectPage(Page<T> page, T entity) throws IllegalAccessException ;
  25 +
  26 +
  27 + boolean updateByCondition(T record, T condition) throws IllegalAccessException;
  28 +
  29 +
  30 + boolean delete(T entity) throws IllegalAccessException ;
  31 +
  32 +
  33 + <T> EntityWrapper getWrapper (T entity) throws IllegalAccessException ;
  34 +}
... ...
src/main/java/com/huaheng/framework/mybatisPlus/PlusServiceImpl.java 0 → 100644
  1 +package com.huaheng.framework.mybatisPlus;
  2 +
  3 +import com.baomidou.mybatisplus.mapper.BaseMapper;
  4 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  5 +import com.baomidou.mybatisplus.mapper.Wrapper;
  6 +import com.baomidou.mybatisplus.plugins.Page;
  7 +import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  8 +import java.lang.reflect.Field;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +public class PlusServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IPlusService<T>
  13 +{
  14 + @Override
  15 + public T selectOne(Wrapper<T> wrapper) {
  16 + List<T> list = selectPage(new Page<T>(1, 1), wrapper).getRecords();
  17 + if (list.size() > 0) return list.get(0);
  18 + else return null;
  19 + }
  20 +
  21 + @Override
  22 + public T selectFirstEntity(T entity) throws IllegalAccessException {
  23 + List<T> list = selectPage(new Page<T>(1, 1), entity).getRecords();
  24 + if (list.size() > 0) return list.get(0);
  25 + else return null;
  26 + }
  27 +
  28 + @Override
  29 + public List<T> selectListEntityByEqual(T entity) throws IllegalAccessException {
  30 + EntityWrapper<T> entityWrapper = getWrapper(entity);
  31 + return super.selectList(entityWrapper);
  32 + }
  33 +
  34 + @Override
  35 + public List<Map<String, Object>> selectListMapByEqual(T entity, String SqlSelect) throws IllegalAccessException {
  36 + EntityWrapper<T> entityWrapper = getWrapper(entity);
  37 + entityWrapper.setSqlSelect(SqlSelect);
  38 + return super.selectMaps(entityWrapper);
  39 + }
  40 +
  41 + @Override
  42 + public Page<T> selectPage(Page<T> page, T entity) throws IllegalAccessException {
  43 + EntityWrapper<T> entityWrapper = getWrapper(entity);
  44 + return super.selectPage(page, entityWrapper);
  45 + }
  46 +
  47 + @Override
  48 + public Page<Map<String, Object>> selectMapsPage(Page page, T entity) throws IllegalAccessException {
  49 + EntityWrapper<T> entityWrapper = getWrapper(entity);
  50 + return super.selectMapsPage(page, entityWrapper);
  51 + }
  52 +
  53 + @Override
  54 + public boolean updateByCondition(T record, T condition) throws IllegalAccessException {
  55 + EntityWrapper<T> entityWrapper = getWrapper(condition);
  56 + return super.update(record, entityWrapper);
  57 + }
  58 +
  59 + @Override
  60 + public boolean delete(T entity) throws IllegalAccessException {
  61 + EntityWrapper<T> entityWrapper = getWrapper(entity);
  62 + return super.delete(entityWrapper);
  63 + }
  64 +
  65 + @Override
  66 + public <T> EntityWrapper getWrapper (T entity) throws IllegalAccessException {
  67 + EntityWrapper<T> entityWrapper = new EntityWrapper<T>();
  68 + Field[] fields = entity.getClass().getDeclaredFields();
  69 + Field.setAccessible(fields, true);
  70 + for (int i = 0; i < fields.length; i++) {
  71 + String filedName = fields[i].getName();
  72 + Object filedValue = fields[i].get(entity);
  73 + if (filedValue != null)
  74 + entityWrapper.eq(filedName, filedValue);
  75 + }
  76 + return entityWrapper;
  77 + }
  78 +}
... ...
src/main/java/com/huaheng/framework/web/controller/BaseController.java
1 1 package com.huaheng.framework.web.controller;
2 2  
3   -
4 3 import java.util.ArrayList;
5 4 import java.util.Date;
6 5 import java.util.List;
7 6 import java.text.SimpleDateFormat;
8 7 import com.baomidou.mybatisplus.plugins.Page;
9   -
10 8 import com.baomidou.mybatisplus.plugins.pagination.PageHelper;
11 9 import com.huaheng.common.constant.Constants;
12 10 import com.huaheng.common.utils.ServletUtils;
13   -import com.huaheng.project.general.company.domain.Company;
14 11 import org.springframework.beans.propertyeditors.CustomDateEditor;
15 12 import org.springframework.web.bind.WebDataBinder;
16 13 import org.springframework.web.bind.annotation.InitBinder;
17 14 import com.huaheng.common.utils.StringUtils;
18 15 import com.huaheng.common.utils.security.ShiroUtils;
19 16 import com.huaheng.framework.web.domain.AjaxResult;
20   -import com.huaheng.framework.web.page.PageDomain;
21 17 import com.huaheng.framework.web.page.TableDataInfo;
22   -import com.huaheng.framework.web.page.TableSupport;
23 18 import com.huaheng.project.system.user.domain.User;
24 19  
25 20 /**
... ... @@ -89,7 +84,7 @@ public class BaseController
89 84 TableDataInfo rspData = new TableDataInfo();
90 85 rspData.setCode(0);
91 86 rspData.setRows(list);
92   -// rspData.setTotal(new PageInfo(list).getTotal());
  87 +// rspData.setTotal(new Page(list).getTotal());
93 88 rspData.setTotal(PageHelper.freeTotal());
94 89 return rspData;
95 90 }
... ... @@ -134,7 +129,7 @@ public class BaseController
134 129 */
135 130 public AjaxResult success()
136 131 {
137   - return AjaxResult.success();
  132 + return AjaxResult.success("");
138 133 }
139 134  
140 135 /**
... ... @@ -142,7 +137,7 @@ public class BaseController
142 137 */
143 138 public AjaxResult error()
144 139 {
145   - return AjaxResult.error();
  140 + return AjaxResult.error("");
146 141 }
147 142  
148 143 /**
... ... @@ -150,7 +145,7 @@ public class BaseController
150 145 */
151 146 public AjaxResult success(String message)
152 147 {
153   - return AjaxResult.success(message);
  148 + return AjaxResult.success(message);
154 149 }
155 150  
156 151 /**
... ... @@ -161,13 +156,13 @@ public class BaseController
161 156 return AjaxResult.error(message);
162 157 }
163 158  
164   - /**
165   - * 返回错误码消息
166   - */
167   - public AjaxResult error(int code, String message)
168   - {
169   - return AjaxResult.error(code, message);
170   - }
  159 +// /**
  160 +// * 返回错误码消息
  161 +// */
  162 +// public AjaxResult error(int code, String message)
  163 +// {
  164 +// return AjaxResult.error(code, message);
  165 +// }
171 166  
172 167 /**
173 168 * 页面跳转
... ...
src/main/java/com/huaheng/framework/web/domain/AjaxResult.java
1 1 package com.huaheng.framework.web.domain;
2 2  
3   -import java.util.HashMap;
  3 +import com.alibaba.fastjson.JSON;
  4 +import java.io.Serializable;
4 5  
5 6 /**
6 7 * 操作消息提醒
7 8 *
8 9 * @author huaheng
9 10 */
10   -public class AjaxResult extends HashMap<String, Object>
  11 +public class AjaxResult<T> implements Serializable
11 12 {
12 13 private static final long serialVersionUID = 1L;
13 14  
14   - /**
15   - * 初始化一个新创建的 Message 对象
16   - */
17   - public AjaxResult()
18   - {
  15 + public int code;
  16 +
  17 + private String msg;
  18 +
  19 + private T data;
  20 +
  21 + public Boolean hasErr(){
  22 + if(code==RetCode.SUCCESS.getValue()){
  23 + return false;
  24 + }else {
  25 + return true;
  26 + }
19 27 }
20 28  
21   - /**
22   - * 返回错误消息
23   - *
24   - * @return 错误消息
25   - */
26   - public static AjaxResult error()
27   - {
28   - return error(1, "操作失败");
  29 + public AjaxResult<T> setCode(RetCode retCode) {
  30 + this.code = retCode.getValue();
  31 + return this;
29 32 }
30 33  
31   - /**
32   - * 返回错误消息
33   - *
34   - * @param msg 内容
35   - * @return 错误消息
36   - */
37   - public static AjaxResult error(String msg)
38   - {
39   - return error(500, msg);
  34 + public int getCode() {
  35 + return code;
  36 + }
  37 +
  38 + public AjaxResult<T> setCode(int code) {
  39 + this.code = code;
  40 + return this;
  41 + }
  42 +
  43 + public String getMsg() {
  44 + return msg;
  45 + }
  46 +
  47 + public AjaxResult<T> setMsg(String msg) {
  48 + this.msg = msg;
  49 + return this;
  50 + }
  51 +
  52 + public T getData() {
  53 + return data;
  54 + }
  55 +
  56 + public AjaxResult<T> setData(T data) {
  57 + this.data = data;
  58 + return this;
  59 + }
  60 +
  61 + @Override
  62 + public String toString() {
  63 + return JSON.toJSONString(this);
40 64 }
41 65  
42 66 /**
43   - * 返回错误消息
44   - *
45   - * @param code 错误码
46   - * @param msg 内容
47   - * @return 错误消息
  67 + * 返回成功消息
48 68 */
49   - public static AjaxResult error(int code, String msg)
  69 + public static AjaxResult success(String message)
50 70 {
51   - AjaxResult json = new AjaxResult();
52   - json.put("code", code);
53   - json.put("msg", msg);
54   - return json;
  71 + return new AjaxResult<>().setCode(RetCode.SUCCESS).setMsg(message);
55 72 }
56 73  
57 74 /**
58 75 * 返回成功消息
59   - *
60   - * @param msg 内容
61   - * @return 成功消息
62 76 */
63   - public static AjaxResult success(String msg)
  77 + public static <T> AjaxResult<T> success(T data)
64 78 {
65   - AjaxResult json = new AjaxResult();
66   - json.put("msg", msg);
67   - json.put("code", 0);
68   - return json;
  79 + return new AjaxResult<T>().setCode(RetCode.SUCCESS).setMsg("成功").setData(data);
69 80 }
70   -
  81 +
71 82 /**
72   - * 返回成功消息
73   - *
74   - * @return 成功消息
  83 + * 返回失败消息
75 84 */
76   - public static AjaxResult success()
  85 + public static AjaxResult error(String message)
77 86 {
78   - return AjaxResult.success("操作成功");
  87 + return new AjaxResult<>().setCode(RetCode.FAIL).setMsg(message);
79 88 }
80 89  
81 90 /**
82   - * 返回成功消息
83   - *
84   - * @param key 键值
85   - * @param value 内容
86   - * @return 成功消息
  91 + * 返回消息
87 92 */
88   - @Override
89   - public AjaxResult put(String key, Object value)
  93 + public static <T> AjaxResult<T> setResult(RetCode retCode, String message, T data)
90 94 {
91   - super.put(key, value);
92   - return this;
  95 + return new AjaxResult<T>().setCode(retCode).setMsg(message).setData(data);
93 96 }
  97 +
94 98 }
... ...
src/main/java/com/huaheng/framework/web/domain/BaseEntity.java
... ... @@ -3,14 +3,17 @@ package com.huaheng.framework.web.domain;
3 3 import java.io.Serializable;
4 4 import java.util.Date;
5 5 import java.util.Map;
  6 +
  7 +import com.baomidou.mybatisplus.activerecord.Model;
6 8 import com.fasterxml.jackson.annotation.JsonFormat;
  9 +import com.huaheng.project.general.container.domain.Container;
7 10  
8 11 /**
9 12 * Entity基类
10 13 *
11 14 * @author huaheng
12 15 */
13   -public class BaseEntity implements Serializable
  16 +public class BaseEntity<T extends Model> extends Model<Container>
14 17 {
15 18 private static final long serialVersionUID = 1L;
16 19  
... ... @@ -107,4 +110,8 @@ public class BaseEntity implements Serializable
107 110 this.params = params;
108 111 }
109 112  
  113 +
  114 + @Override
  115 + protected Serializable pkVal() { return null;}
  116 +
110 117 }
... ...
src/main/java/com/huaheng/framework/web/domain/RetCode.java 0 → 100644
  1 +package com.huaheng.framework.web.domain;
  2 +
  3 +/**
  4 + * @Description: 响应码枚举,参考HTTP状态码的语义
  5 + * @author 唐颖
  6 + * @date 2018/4/19 09:42
  7 + */
  8 +public enum RetCode {
  9 +
  10 + // 成功
  11 + SUCCESS(200),
  12 +
  13 + // 失败
  14 + FAIL(400),
  15 +
  16 + // 未认证(签名错误)
  17 + UNAUTHORIZED(401),
  18 +
  19 + // 找不到请求文件
  20 + NoHandlerFoundException(404),
  21 +
  22 + /** 未登录 */
  23 + UNAUTHEN(401),
  24 +
  25 + /** 未授权,拒绝访问 */
  26 + UNAUTHZ(403),
  27 +
  28 + // 服务器内部错误
  29 + INTERNAL_SERVER_ERROR(500);
  30 +
  31 + private int code;
  32 +
  33 + private RetCode(int code) {
  34 + this.code = code;
  35 + }
  36 +
  37 + public int getValue(){
  38 + return this.code;
  39 + }
  40 +}
... ...
src/main/java/com/huaheng/framework/web/exception/DefaultExceptionHandler.java
1 1 package com.huaheng.framework.web.exception;
2 2  
  3 +import com.alibaba.fastjson.JSONException;
  4 +import com.huaheng.common.exception.service.ServiceException;
  5 +import com.huaheng.framework.web.domain.RetCode;
3 6 import org.apache.shiro.authz.AuthorizationException;
4 7 import org.slf4j.Logger;
5 8 import org.slf4j.LoggerFactory;
  9 +import org.springframework.validation.ObjectError;
6 10 import org.springframework.web.HttpRequestMethodNotSupportedException;
  11 +import org.springframework.web.bind.MethodArgumentNotValidException;
7 12 import org.springframework.web.bind.annotation.ExceptionHandler;
8 13 import org.springframework.web.bind.annotation.RestControllerAdvice;
9 14  
... ... @@ -11,6 +16,8 @@ import com.huaheng.common.exception.DemoModeException;
11 16 import com.huaheng.common.utils.security.PermissionUtils;
12 17 import com.huaheng.framework.web.domain.AjaxResult;
13 18  
  19 +import javax.servlet.http.HttpServletResponse;
  20 +
14 21 /**
15 22 * 自定义异常处理器
16 23 *
... ... @@ -25,69 +32,71 @@ public class DefaultExceptionHandler
25 32 * 权限校验失败
26 33 */
27 34 @ExceptionHandler(AuthorizationException.class)
28   - public AjaxResult handleAuthorizationException(AuthorizationException e)
  35 + public AjaxResult handleAuthorizationException(AuthorizationException ex)
29 36 {
30   - log.error(e.getMessage(), e);
31   - return AjaxResult.error(PermissionUtils.getMsg(e.getMessage()));
  37 + log.error("权限异常:" + ex.getMessage(), ex);
  38 + return AjaxResult.error(PermissionUtils.getMsg(ex.getMessage()));
32 39 }
33 40  
34   -// /**
35   -// * JSON异常统一处理
36   -// */
37   -// @ExceptionHandler(value = JSONException.class)
38   -// public void jsonExceptionHandler(HttpServletResponse response, JSONException ex) {
39   -// RetResult<Object> result = new RetResult<>();
40   -// result.setCode(RetCode.FAIL).setMsg("转化JSON异常:" + ex.getMessage());
41   -// logger.error("转化JSON异常:" + ex.getMessage());
42   -// ex.printStackTrace();
43   -// responseResult(response, result);
44   -// }
45   -//
46   -// /**
47   -// * 方法参数验证异常的处理
48   -// */
49   -// @ExceptionHandler(value = MethodArgumentNotValidException.class)
50   -// public void validatedExceptionHandler(HttpServletResponse response, MethodArgumentNotValidException ex) {
51   -// StringBuilder sb = new StringBuilder();
52   -// for (ObjectError errorItem : ex.getBindingResult().getAllErrors()) {
53   -// sb.append(" " + errorItem.getDefaultMessage() + ",");
54   -//// sb.append(System.getProperty("line.separator"));
55   -// }
56   -// sb.deleteCharAt(sb.length() - 1);
57   -// RetResult<Object> result = new RetResult<>();
58   -// result.setCode(RetCode.FAIL).setMsg("方法参数验证出现异常:" + sb.toString()).setData(null);
59   -// logger.error("方法参数验证出现异常:" + sb.toString());
60   -// ex.printStackTrace();
61   -// responseResult(response, result);
62   -// }
  41 + /**
  42 + * JSON异常统一处理
  43 + */
  44 + @ExceptionHandler(value = JSONException.class)
  45 + public AjaxResult jsonExceptionHandler(JSONException ex) {
  46 + log.error("转化JSON异常:" + ex.getMessage(), ex);
  47 + return AjaxResult.error("转化JSON异常:" + ex.getMessage());
  48 + }
  49 +
  50 + /**
  51 + * 方法参数验证异常的处理
  52 + */
  53 + @ExceptionHandler(value = MethodArgumentNotValidException.class)
  54 + public AjaxResult validatedExceptionHandler(MethodArgumentNotValidException ex) {
  55 + StringBuilder sb = new StringBuilder();
  56 + for (ObjectError errorItem : ex.getBindingResult().getAllErrors()) {
  57 + sb.append(" " + errorItem.getDefaultMessage() + ",");
  58 + }
  59 + sb.deleteCharAt(sb.length() - 1);
  60 + log.error("方法参数验证出现异常:" + sb.toString(), ex);
  61 + return AjaxResult.error("方法参数验证出现异常:" + sb.toString());
  62 + }
  63 +
  64 + /**
  65 + * 业务异常的处理
  66 + */
  67 + @ExceptionHandler(value = ServiceException.class)
  68 + public AjaxResult serviceExceptionHandler(ServiceException ex) {
  69 + log.error("业务处理出现异常:" + ex.getMessage(), ex);
  70 + return AjaxResult.error("业务处理出现异常:" + ex.getMessage());
  71 + }
63 72  
64 73 /**
65 74 * 请求方式不支持
66 75 */
67 76 @ExceptionHandler({ HttpRequestMethodNotSupportedException.class })
68   - public AjaxResult handleException(HttpRequestMethodNotSupportedException e)
  77 + public AjaxResult handleException(HttpRequestMethodNotSupportedException ex)
69 78 {
70   - log.error(e.getMessage(), e);
71   - return AjaxResult.error("不支持' " + e.getMethod() + "'请求");
  79 + log.error("不支持' " + ex.getMethod() + "'请求:" + ex.getMessage(), ex);
  80 + return AjaxResult.error("不支持' " + ex.getMethod() + "'请求");
72 81 }
73 82  
74 83 /**
75 84 * 拦截未知的运行时异常
76 85 */
77 86 @ExceptionHandler(RuntimeException.class)
78   - public AjaxResult notFount(RuntimeException e)
  87 + public AjaxResult notFount(RuntimeException ex)
79 88 {
80   - log.error("运行时异常:", e);
81   - return AjaxResult.error("运行时异常:" + e.getMessage());
  89 + log.error("运行时异常:" + ex.getMessage(), ex);
  90 + return AjaxResult.error("运行时异常:" + ex.getMessage());
82 91 }
83 92  
84 93 /**
85 94 * 系统异常
86 95 */
87 96 @ExceptionHandler(Exception.class)
88   - public AjaxResult handleException(Exception e)
  97 + public AjaxResult handleException(Exception ex)
89 98 {
90   - log.error(e.getMessage(), e);
  99 + log.error("服务器错误:" + ex.getMessage(), ex);
91 100 return AjaxResult.error("服务器错误,请联系管理员");
92 101 }
93 102  
... ...
src/main/java/com/huaheng/framework/web/service/ConfigService.java
... ... @@ -18,7 +18,7 @@ public class ConfigService
18 18 /**
19 19 * 根据键名查询参数配置信息
20 20 *
21   - * @param configName 参数名称
  21 + * @param configKey 参数名称
22 22 * @return 参数键值
23 23 */
24 24 public String getKey(String configKey)
... ...
src/main/java/com/huaheng/project/general/container/domain/ContainerStatus.java 0 → 100644
  1 +package com.huaheng.project.general.container.domain;
  2 +
  3 +public enum ContainerStatus {
  4 + empty,
  5 + half,
  6 + full;
  7 +}
... ...
src/main/java/com/huaheng/project/general/container/service/ContainerServiceImpl.java
1 1 package com.huaheng.project.general.container.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.common.exception.service.ServiceException;
  5 +import com.huaheng.common.utils.MybatisPlus.PlusUtils;
  6 +import com.huaheng.common.utils.security.ShiroUtils;
  7 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  8 +import com.huaheng.framework.web.domain.AjaxResult;
4 9 import com.huaheng.project.general.container.domain.Container;
5 10 import com.huaheng.project.general.container.mapper.ContainerMapper;
  11 +import com.huaheng.project.general.location.domain.Location;
  12 +import com.huaheng.project.inventory.inventory.domain.Inventory;
  13 +import com.huaheng.project.inventory.inventory.service.IInventoryService;
  14 +import org.springframework.beans.factory.annotation.Autowired;
6 15 import org.springframework.stereotype.Service;
7 16  
  17 +import java.util.List;
  18 +
8 19  
9 20 /**
10 21 * 容器 服务层实现
... ... @@ -13,6 +24,57 @@ import org.springframework.stereotype.Service;
13 24 * @date 2018-08-19
14 25 */
15 26 @Service
16   -public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container> implements IContainerService {
  27 +public class ContainerServiceImpl extends PlusServiceImpl<ContainerMapper, Container> implements IContainerService {
  28 +
  29 + @Autowired
  30 + IInventoryService inventoryService;
  31 + /**
  32 + * 更新指定托盘状态
  33 + * @param id
  34 + */
  35 + @Override
  36 + public void updateContainerByCode(int id) throws IllegalAccessException {
  37 + //获取这个托盘
  38 + Container container = this.selectById(id);
  39 + //查询对应的库位
  40 + Location locationCondition = new Location();
  41 + locationCondition.setWarehouseCode(container.getWarehouseCode());
  42 + locationCondition.setWarehouseId(container.getWarehouseId());
  43 + locationCondition.setContainerId(container.getId());
  44 + List<Location> location = this.selectList(PlusUtils.getWrapper(locationCondition));
  45 + if(location.size() <1 ){
  46 + //如果托盘不在货位上,就不做处理
  47 + return;
  48 + }else {
  49 + //查询关联的库存
  50 + Inventory inventoryCondition = new Inventory();
  51 + inventoryCondition.setLocationId(location.get(0).getId());
  52 + inventoryCondition.setWarehouseId(location.get(0).getWarehouseId());
  53 + List<Inventory> inventories = inventoryService.selectList(PlusUtils.getWrapper(inventoryCondition));
  54 + if(inventories.size() > 0){
  55 + //如果有库存就设置为half
  56 + container.setStatus("half");
  57 + }else{
  58 + //如果没有库存就设置为empty
  59 + container.setStatus("empty");
  60 + }
  61 + }
  62 + this.updateById(container);
  63 + }
  64 +
  65 + @Override
  66 + public AjaxResult<Integer> CheckContainer(String containerCode) {
  67 + Container container = new Container();
  68 + container.setCode(containerCode);
  69 + container = baseMapper.selectOne(container);
  70 + if (container == null)
  71 + throw new ServiceException("容器没有在系统注册!");
  72 + if (container.getWarehouseId() != ShiroUtils.getUser().getWarehouseId())
  73 + throw new ServiceException("容器不在当前仓库!");
  74 + if (container.getLocationCode() != null && container.getLocationCode().length() > 1)
  75 + throw new ServiceException("容器已经在货架" + container.getLocationCode() + "上!");
  76 + return AjaxResult.success("");
  77 + }
  78 +
17 79  
18 80 }
... ...
src/main/java/com/huaheng/project/general/container/service/IContainerService.java
1 1 package com.huaheng.project.general.container.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
  4 +import com.huaheng.framework.web.domain.AjaxResult;
3 5 import com.huaheng.project.general.container.domain.Container;
4 6 import com.baomidou.mybatisplus.service.IService;
5 7 import java.util.List;
... ... @@ -10,8 +12,11 @@ import java.util.List;
10 12 * @author huaheng
11 13 * @date 2018-08-19
12 14 */
13   -public interface IContainerService extends IService<Container> {
  15 +public interface IContainerService extends IPlusService<Container> {
14 16  
  17 + void updateContainerByCode(int id) throws IllegalAccessException;
  18 +
  19 + AjaxResult<Integer> CheckContainer(String containerCode);
15 20 }
16 21  
17 22  
... ...
src/main/java/com/huaheng/project/general/location/service/ILocationService.java
1 1 package com.huaheng.project.general.location.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.general.location.domain.Location;
4   -import com.baomidou.mybatisplus.service.IService;
5   -import java.util.List;
  5 +
6 6  
7 7 /**
8 8 * 库位 服务层
... ... @@ -10,8 +10,9 @@ import java.util.List;
10 10 * @author huaheng
11 11 * @date 2018-08-19
12 12 */
13   -public interface ILocationService extends IService<Location> {
  13 +public interface ILocationService extends IPlusService<Location> {
14 14  
  15 + void updateLocationStatus(String location) throws IllegalAccessException;
15 16 }
16 17  
17 18  
... ...
src/main/java/com/huaheng/project/general/location/service/LocationServiceImpl.java
1 1 package com.huaheng.project.general.location.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.common.utils.MybatisPlus.PlusUtils;
  5 +import com.huaheng.common.utils.security.ShiroUtils;
  6 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 7 import com.huaheng.project.general.location.domain.Location;
5 8 import com.huaheng.project.general.location.mapper.LocationMapper;
  9 +import com.huaheng.project.task.task.domain.Task;
  10 +import com.huaheng.project.task.task.mapper.TaskMapper;
  11 +import com.huaheng.project.task.task.service.ITaskService;
  12 +import org.springframework.beans.factory.annotation.Autowired;
6 13 import org.springframework.stereotype.Service;
7 14  
  15 +import java.util.List;
  16 +
8 17  
9 18 /**
10 19 * 库位 服务层实现
... ... @@ -13,6 +22,41 @@ import org.springframework.stereotype.Service;
13 22 * @date 2018-08-19
14 23 */
15 24 @Service
16   -public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> implements ILocationService {
  25 +public class LocationServiceImpl extends PlusServiceImpl<LocationMapper, Location> implements ILocationService {
17 26  
  27 + @Autowired
  28 + TaskMapper taskMapper;
  29 + /**
  30 + * 更新货位状态
  31 + * @param location
  32 + */
  33 + @Override
  34 + public void updateLocationStatus(String location) throws IllegalAccessException {
  35 + //获取这个库位
  36 + Location condition = new Location();
  37 + condition.setCode(location);
  38 + condition.setWarehouseCode(ShiroUtils.getUser().getWarehouseCode());
  39 + List<Location> list = this.selectList(PlusUtils.getWrapper(condition));
  40 + if (list.size() < 1) return;
  41 + Location loc = list.get(0);
  42 + //获取关联在这个货位上的任务
  43 + Task task = taskMapper.getTaskByLocationCode(location, ShiroUtils.getUser().getWarehouseCode());
  44 + if(task != null){
  45 + //查看任务状态,一般情况下,对应一个库位的,只有一条在执行的主任务;
  46 + switch (task.getType()){
  47 + case 0:
  48 + case 10:
  49 + loc.setStatus("lock");
  50 + break;
  51 + case 20:
  52 + case 30:
  53 + loc.setStatus("occupy");
  54 + break;
  55 + }
  56 + }else {
  57 + //没有任务,则是空闲
  58 + loc.setStatus("empty");
  59 + }
  60 + this.updateById(loc);
  61 + }
18 62 }
... ...
src/main/java/com/huaheng/project/inventory/inventory/domain/InventorySearchModel.java 0 → 100644
  1 +package com.huaheng.project.inventory.inventory.domain;
  2 +
  3 +
  4 +import java.time.LocalDateTime;
  5 +
  6 +/**
  7 + * 对应Web界面查询表单model
  8 + */
  9 +public class InventorySearchModel {
  10 +
  11 + private String companyCode;
  12 +
  13 + private String materialCode;
  14 +
  15 + private String locationCode;
  16 +
  17 + private int warehouseId;
  18 +
  19 + /**
  20 + * 创建开始时间
  21 + */
  22 + private LocalDateTime beginTime;
  23 +
  24 + /**
  25 + * 创建结束时间
  26 + */
  27 + private LocalDateTime endTime;
  28 +
  29 + public int getWarehouseId() {
  30 + return warehouseId;
  31 + }
  32 +
  33 + public void setWarehouseId(int warehouseId) {
  34 + this.warehouseId = warehouseId;
  35 + }
  36 +
  37 + public String getCompanyCode() {
  38 + return companyCode;
  39 + }
  40 +
  41 + public void setCompanyCode(String companyCode) {
  42 + this.companyCode = companyCode;
  43 + }
  44 +
  45 + public String getMaterialCode() {
  46 + return materialCode;
  47 + }
  48 +
  49 + public void setMaterialCode(String materialCode) {
  50 + this.materialCode = materialCode;
  51 + }
  52 +
  53 + public String getLocationCode() {
  54 + return locationCode;
  55 + }
  56 +
  57 + public void setLocationCode(String locationCode) {
  58 + this.locationCode = locationCode;
  59 + }
  60 +
  61 + public LocalDateTime getBeginTime() {
  62 + return beginTime;
  63 + }
  64 +
  65 + public void setBeginTime(LocalDateTime beginTime) {
  66 + this.beginTime = beginTime;
  67 + }
  68 +
  69 + public LocalDateTime getEndTime() {
  70 + return endTime;
  71 + }
  72 +
  73 + public void setEndTime(LocalDateTime endTime) {
  74 + this.endTime = endTime;
  75 + }
  76 +}
... ...
src/main/java/com/huaheng/project/inventory/inventory/mapper/InventoryMapper.java
... ... @@ -2,6 +2,8 @@ package com.huaheng.project.inventory.inventory.mapper;
2 2  
3 3 import com.huaheng.project.inventory.inventory.domain.Inventory;
4 4 import com.baomidou.mybatisplus.mapper.BaseMapper;
  5 +import com.huaheng.project.inventory.inventory.domain.InventorySearchModel;
  6 +
5 7 import java.util.List;
6 8  
7 9 /**
... ... @@ -12,5 +14,7 @@ import java.util.List;
12 14 */
13 15 public interface InventoryMapper extends BaseMapper<Inventory> {
14 16  
  17 + List<Inventory> getInventoryBySearchModel(InventorySearchModel inventorySearchModel);
  18 +
15 19 }
16 20  
... ...
src/main/java/com/huaheng/project/inventory/inventory/service/IInventoryService.java
1 1 package com.huaheng.project.inventory.inventory.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.inventory.inventory.domain.Inventory;
4   -import com.baomidou.mybatisplus.service.IService;
5   -import java.util.List;
6 5  
7 6 /**
8 7 * 库存 服务层
... ... @@ -10,7 +9,7 @@ import java.util.List;
10 9 * @author huaheng
11 10 * @date 2018-08-19
12 11 */
13   -public interface IInventoryService extends IService<Inventory> {
  12 +public interface IInventoryService extends IPlusService<Inventory> {
14 13  
15 14 }
16 15  
... ...
src/main/java/com/huaheng/project/inventory/inventory/service/InventoryServiceImpl.java
1 1 package com.huaheng.project.inventory.inventory.service;
2 2  
3   -import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  3 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 4 import com.huaheng.project.inventory.inventory.domain.Inventory;
5 5 import com.huaheng.project.inventory.inventory.mapper.InventoryMapper;
6 6 import org.springframework.stereotype.Service;
... ... @@ -13,6 +13,6 @@ import org.springframework.stereotype.Service;
13 13 * @date 2018-08-19
14 14 */
15 15 @Service
16   -public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory> implements IInventoryService {
  16 +public class InventoryServiceImpl extends PlusServiceImpl<InventoryMapper, Inventory> implements IInventoryService {
17 17  
18 18 }
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerDetail/service/IReceiptContainerDetailService.java
1 1 package com.huaheng.project.receipt.receiptContainerDetail.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IReceiptContainerDetailService extends IService<ReceiptContainerDetail> {
  14 +public interface IReceiptContainerDetailService extends IPlusService<ReceiptContainerDetail> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerDetail/service/ReceiptContainerDetailServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptContainerDetail.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
5 6 import com.huaheng.project.receipt.receiptContainerDetail.mapper.ReceiptContainerDetailMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ReceiptContainerDetailServiceImpl extends ServiceImpl<ReceiptContainerDetailMapper, ReceiptContainerDetail> implements IReceiptContainerDetailService {
  17 +public class ReceiptContainerDetailServiceImpl extends PlusServiceImpl<ReceiptContainerDetailMapper, ReceiptContainerDetail> implements IReceiptContainerDetailService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerHeader/domain/ReceiptBillViewModel.java 0 → 100644
  1 +package com.huaheng.project.receipt.receiptContainerHeader.domain;
  2 +
  3 +import java.time.LocalDateTime;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * 入库页面模型
  8 + */
  9 +public class ReceiptBillViewModel {
  10 + //出库单号
  11 + private String receiptCode;
  12 +
  13 + //出库单类型
  14 + private String receiptType;
  15 +
  16 + //货主
  17 + private String company;
  18 +
  19 + //起始状态
  20 + private int firstStatus;
  21 +
  22 + //结束状态
  23 + private int lastStatus;
  24 +
  25 + //创建起始时间
  26 + private LocalDateTime beginTime;
  27 +
  28 + //创建结束时间
  29 + private LocalDateTime endTime;
  30 +
  31 + public String getReceiptType() {
  32 + return receiptType;
  33 + }
  34 +
  35 + public void setReceiptType(String receiptType) {
  36 + this.receiptType = receiptType;
  37 + }
  38 +
  39 + public String getCompany() {
  40 + return company;
  41 + }
  42 +
  43 + public void setCompany(String company) {
  44 + this.company = company;
  45 + }
  46 +
  47 + public String getReceiptCode() {
  48 + return receiptCode;
  49 + }
  50 +
  51 + public void setReceiptCode(String receiptCode) {
  52 + this.receiptCode = receiptCode;
  53 + }
  54 +
  55 + public int getFirstStatus() {
  56 + return firstStatus;
  57 + }
  58 +
  59 + public void setFirstStatus(int firstStatus) {
  60 + this.firstStatus = firstStatus;
  61 + }
  62 +
  63 + public int getLastStatus() {
  64 + return lastStatus;
  65 + }
  66 +
  67 + public void setLastStatus(int lastStatus) {
  68 + this.lastStatus = lastStatus;
  69 + }
  70 +
  71 + public LocalDateTime getBeginTime() {
  72 + return beginTime;
  73 + }
  74 +
  75 + public void setBeginTime(LocalDateTime beginTime) {
  76 + this.beginTime = beginTime;
  77 + }
  78 +
  79 + public LocalDateTime getEndTime() {
  80 + return endTime;
  81 + }
  82 +
  83 + public void setEndTime(LocalDateTime endTime) {
  84 + this.endTime = endTime;
  85 + }
  86 +}
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerHeader/domain/ReceiptContainerView.java 0 → 100644
  1 +package com.huaheng.project.receipt.receiptContainerHeader.domain;
  2 +
  3 +import java.math.BigDecimal;
  4 +
  5 +public class ReceiptContainerView {
  6 +
  7 + String receiptContainerCode;
  8 + Integer receiptDetailId;
  9 + BigDecimal qty;
  10 +
  11 + public String getReceiptContainerCode() {
  12 + return receiptContainerCode;
  13 + }
  14 +
  15 + public void setReceiptContainerCode(String receiptContainerCode) {
  16 + this.receiptContainerCode = receiptContainerCode;
  17 + }
  18 +
  19 + public Integer getReceiptDetailId() {
  20 + return receiptDetailId;
  21 + }
  22 +
  23 + public void setReceiptDetailId(Integer receiptDetailId) {
  24 + this.receiptDetailId = receiptDetailId;
  25 + }
  26 +
  27 + public BigDecimal getQty() {
  28 + return qty;
  29 + }
  30 +
  31 + public void setQty(BigDecimal qty) {
  32 + this.qty = qty;
  33 + }
  34 +
  35 +
  36 +
  37 +}
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerHeader/service/IReceiptContainerHeaderService.java
1 1 package com.huaheng.project.receipt.receiptContainerHeader.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
  4 +import com.huaheng.framework.web.domain.AjaxResult;
3 5 import com.huaheng.project.receipt.receiptContainerHeader.domain.ReceiptContainerHeader;
4   -import com.baomidou.mybatisplus.service.IService;
  6 +import com.huaheng.project.receipt.receiptContainerHeader.domain.ReceiptContainerView;
  7 +import org.springframework.transaction.annotation.Transactional;
  8 +
5 9 import java.util.List;
  10 +import java.util.Map;
6 11  
7 12 /**
8 13 * 入库组盘头 服务层
... ... @@ -10,8 +15,13 @@ import java.util.List;
10 15 * @author huaheng
11 16 * @date 2018-08-19
12 17 */
13   -public interface IReceiptContainerHeaderService extends IService<ReceiptContainerHeader> {
  18 +public interface IReceiptContainerHeaderService extends IPlusService<ReceiptContainerHeader> {
  19 +
  20 + @Transactional
  21 + AjaxResult<List<Map<String, String>>> batchSave(List<ReceiptContainerView> list) throws IllegalAccessException;
14 22  
  23 + @Transactional
  24 + AjaxResult<Map<String, String>> OneByOneSave(ReceiptContainerView record) throws IllegalAccessException;
15 25 }
16 26  
17 27  
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptContainerHeader.service;
2 2  
3   -import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  3 +import com.huaheng.common.exception.service.ServiceException;
  4 +import com.huaheng.common.utils.security.ShiroUtils;
  5 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  6 +import com.huaheng.framework.web.domain.AjaxResult;
  7 +import com.huaheng.project.general.container.service.IContainerService;
  8 +import com.huaheng.project.general.location.domain.Location;
  9 +import com.huaheng.project.general.location.service.ILocationService;
  10 +import com.huaheng.project.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
  11 +import com.huaheng.project.receipt.receiptContainerDetail.service.IReceiptContainerDetailService;
4 12 import com.huaheng.project.receipt.receiptContainerHeader.domain.ReceiptContainerHeader;
  13 +import com.huaheng.project.receipt.receiptContainerHeader.domain.ReceiptContainerView;
5 14 import com.huaheng.project.receipt.receiptContainerHeader.mapper.ReceiptContainerHeaderMapper;
  15 +import com.huaheng.project.receipt.receiptDetail.service.IReceiptDetailService;
  16 +import org.springframework.beans.factory.annotation.Autowired;
6 17 import org.springframework.stereotype.Service;
  18 +import org.springframework.transaction.annotation.Transactional;
  19 +import java.math.BigDecimal;
  20 +import java.util.ArrayList;
  21 +import java.util.List;
  22 +import java.util.Map;
7 23  
8 24  
9 25 /**
... ... @@ -13,6 +29,109 @@ import org.springframework.stereotype.Service;
13 29 * @date 2018-08-19
14 30 */
15 31 @Service
16   -public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContainerHeaderMapper, ReceiptContainerHeader> implements IReceiptContainerHeaderService {
  32 +public class ReceiptContainerHeaderServiceImpl extends PlusServiceImpl<ReceiptContainerHeaderMapper, ReceiptContainerHeader> implements IReceiptContainerHeaderService {
17 33  
  34 + @Autowired
  35 + IContainerService containerService;
  36 + @Autowired
  37 + ILocationService locationService;
  38 + @Autowired
  39 + IReceiptDetailService receiptDetailService;
  40 + @Autowired
  41 + IReceiptContainerDetailService receiptContainerDetailService;
  42 +
  43 + @Override
  44 + @Transactional
  45 + public AjaxResult<List<Map<String, String>>> batchSave(List<ReceiptContainerView> list) throws IllegalAccessException {
  46 + if (list.size() < 1) throw new ServiceException("收货明细是空!");
  47 + List<Map<String, String>> returnValue = new ArrayList<>();
  48 + containerService.CheckContainer(list.get(0).getReceiptContainerCode());
  49 + ReceiptContainerHeader receiptContainerHeaderId = receiptContainerHeaderAdd(list.get(0).getReceiptContainerCode());
  50 + for (ReceiptContainerView receiptContainerView : list) {
  51 + Map<String, String> map = receiptDetailService.receiptQtyAdd(receiptContainerView.getReceiptDetailId(), receiptContainerView.getQty());
  52 + receiptContainerDetailAdd(receiptContainerHeaderId.getId(), receiptContainerView.getReceiptDetailId(), receiptContainerView.getQty());
  53 + returnValue.add(map);
  54 + }
  55 + return AjaxResult.success(returnValue);
  56 + }
  57 +
  58 + @Override
  59 + @Transactional
  60 + public AjaxResult<Map<String, String>> OneByOneSave(ReceiptContainerView record) throws IllegalAccessException {
  61 + containerService.CheckContainer(record.getReceiptContainerCode());
  62 + Map<String, String> returnValue = receiptDetailService.receiptQtyAdd(record.getReceiptDetailId(), new BigDecimal("1"));
  63 + ReceiptContainerHeader receiptContainerHeaderId = receiptContainerHeaderAdd(record.getReceiptContainerCode());
  64 + receiptContainerDetailAdd(receiptContainerHeaderId.getId(), record.getReceiptDetailId(), new BigDecimal("1"));
  65 + return AjaxResult.success(returnValue);
  66 + }
  67 +
  68 + /**
  69 + * 增加组盘表头记录
  70 + * @param ContainerCode 托盘编码
  71 + */
  72 + private ReceiptContainerHeader receiptContainerHeaderAdd(String ContainerCode) throws IllegalAccessException {
  73 + //根据托盘查询组盘表头记录
  74 + ReceiptContainerHeader condition = new ReceiptContainerHeader();
  75 + condition.setReceiptContainerCode(ContainerCode);
  76 + ReceiptContainerHeader receiptContainerHeader = this.selectFirstEntity(condition);
  77 + if (receiptContainerHeader == null)
  78 + {
  79 + Location location = new Location();
  80 + location.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  81 + location.setContainerCode("");
  82 + location.setStatus("empty");
  83 + location.setEnable(true);
  84 + location.setDeleted(false);
  85 + location = locationService.selectFirstEntity(location);
  86 + if (location == null)
  87 + {
  88 + throw new ServiceException("没有库位可以存放容器了!");
  89 + }
  90 + else
  91 + {
  92 + location.setStatus("lock");
  93 + locationService.updateById(location);
  94 + }
  95 + receiptContainerHeader = new ReceiptContainerHeader();
  96 + receiptContainerHeader.setReceiptContainerCode(ContainerCode);
  97 + receiptContainerHeader.setStatus(0);
  98 + receiptContainerHeader.setTaskType(100);
  99 + receiptContainerHeader.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  100 + receiptContainerHeader.setWarehouseCode(ShiroUtils.getUser().getWarehouseCode());
  101 + receiptContainerHeader.setCreatedBy(ShiroUtils.getUser().getLoginName());
  102 + receiptContainerHeader.setLocationCode(location.getCode());
  103 + this.insert(receiptContainerHeader);
  104 + }
  105 + else
  106 + {
  107 + if (receiptContainerHeader.getStatus() > (short)10)
  108 + throw new ServiceException("容器已经在上架中,不能放物料了!");
  109 + }
  110 + return receiptContainerHeader;
  111 + }
  112 +
  113 + /**
  114 + * 增加组盘明细记录
  115 + * @param receiptContainerHeaderId
  116 + * @param receiptDetailId
  117 + * @param Qty
  118 + */
  119 + private void receiptContainerDetailAdd(Integer receiptContainerHeaderId, Integer receiptDetailId, BigDecimal Qty) throws IllegalAccessException {
  120 + // 根据表头ID和入库单明细ID找组盘明细
  121 + ReceiptContainerDetail condition = new ReceiptContainerDetail();
  122 + condition.setHeaderId(receiptContainerHeaderId);
  123 + condition.setReceiptDetailId(receiptDetailId);
  124 + ReceiptContainerDetail receiptContainerDetail = receiptContainerDetailService.selectFirstEntity(condition);
  125 + if (receiptContainerDetail == null)
  126 + {
  127 + condition.setQty(Qty);
  128 + condition.setCreatedBy(ShiroUtils.getUser().getLoginName());
  129 + receiptContainerDetailService.insert(condition);
  130 + }
  131 + else
  132 + {
  133 + receiptContainerDetail.setQty(receiptContainerDetail.getQty().add(Qty));
  134 + receiptContainerDetailService.updateById(receiptContainerDetail);
  135 + }
  136 + }
18 137 }
... ...
src/main/java/com/huaheng/project/receipt/receiptContainerHeader/service/ShipmentContainerDetailSearchModel.java 0 → 100644
  1 +package com.huaheng.project.receipt.receiptContainerHeader.service;
  2 +
  3 +
  4 +
  5 +/**
  6 + * 出库箱明细查询类
  7 + */
  8 +public class ShipmentContainerDetailSearchModel {
  9 + private int shipmentContainerHeaderId;
  10 +
  11 + public int getShipmentContainerHeaderId() {
  12 + return shipmentContainerHeaderId;
  13 + }
  14 +
  15 + public void setShipmentContainerHeaderId(int shipmentContainerHeaderId) {
  16 + this.shipmentContainerHeaderId = shipmentContainerHeaderId;
  17 + }
  18 +}
... ...
src/main/java/com/huaheng/project/receipt/receiptDetail/service/IReceiptDetailService.java
1 1 package com.huaheng.project.receipt.receiptDetail.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.receipt.receiptDetail.domain.ReceiptDetail;
4 5 import com.baomidou.mybatisplus.service.IService;
  6 +
  7 +import java.math.BigDecimal;
5 8 import java.util.List;
  9 +import java.util.Map;
6 10  
7 11 /**
8 12 * 入库明细 服务层
... ... @@ -10,8 +14,9 @@ import java.util.List;
10 14 * @author huaheng
11 15 * @date 2018-08-19
12 16 */
13   -public interface IReceiptDetailService extends IService<ReceiptDetail> {
  17 +public interface IReceiptDetailService extends IPlusService<ReceiptDetail> {
14 18  
  19 + Map<String, String> receiptQtyAdd(Integer receiptDetailId, BigDecimal Qty) throws IllegalAccessException;
15 20 }
16 21  
17 22  
... ...
src/main/java/com/huaheng/project/receipt/receiptDetail/service/ReceiptDetailServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptDetail.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.common.exception.service.ServiceException;
  5 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 6 import com.huaheng.project.receipt.receiptDetail.domain.ReceiptDetail;
5 7 import com.huaheng.project.receipt.receiptDetail.mapper.ReceiptDetailMapper;
6 8 import org.springframework.stereotype.Service;
7 9  
  10 +import java.math.BigDecimal;
  11 +import java.util.HashMap;
  12 +import java.util.Map;
  13 +
8 14  
9 15 /**
10 16 * 入库明细 服务层实现
... ... @@ -13,6 +19,27 @@ import org.springframework.stereotype.Service;
13 19 * @date 2018-08-19
14 20 */
15 21 @Service
16   -public class ReceiptDetailServiceImpl extends ServiceImpl<ReceiptDetailMapper, ReceiptDetail> implements IReceiptDetailService {
  22 +public class ReceiptDetailServiceImpl extends PlusServiceImpl<ReceiptDetailMapper, ReceiptDetail> implements IReceiptDetailService {
17 23  
  24 + /**
  25 + * 增加入库明细的收货数量
  26 + * @param receiptDetailId
  27 + * @param Qty
  28 + * @return
  29 + */
  30 + @Override
  31 + public Map<String, String> receiptQtyAdd(Integer receiptDetailId, BigDecimal Qty) throws IllegalAccessException {
  32 + ReceiptDetail receiptDetail = new ReceiptDetail();
  33 + receiptDetail.setId(receiptDetailId);
  34 + receiptDetail = this.selectFirstEntity(receiptDetail);
  35 + // 将入库单明细的收货数量 + 保存的数量,然后在存入明细表
  36 + receiptDetail.setQty(receiptDetail.getQty().add(Qty));
  37 + if (receiptDetail.getQty().compareTo(receiptDetail.getSysQty()) > 0)
  38 + throw new ServiceException("收货数大于待收数量!");
  39 + this.updateById(receiptDetail);
  40 + Map<String, String> returnValue = new HashMap<>();
  41 + returnValue.put("id", receiptDetailId.toString());
  42 + returnValue.put("qty", receiptDetail.getQty().toString());
  43 + return returnValue;
  44 + }
18 45 }
... ...
src/main/java/com/huaheng/project/receipt/receiptDetailHistory/service/IReceiptDetailHistoryService.java
1 1 package com.huaheng.project.receipt.receiptDetailHistory.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.receipt.receiptDetailHistory.domain.ReceiptDetailHistory;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IReceiptDetailHistoryService extends IService<ReceiptDetailHistory> {
  14 +public interface IReceiptDetailHistoryService extends IPlusService<ReceiptDetailHistory> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/receipt/receiptDetailHistory/service/ReceiptDetailHistoryServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptDetailHistory.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.receipt.receiptDetailHistory.domain.ReceiptDetailHistory;
5 6 import com.huaheng.project.receipt.receiptDetailHistory.mapper.ReceiptDetailHistoryMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ReceiptDetailHistoryServiceImpl extends ServiceImpl<ReceiptDetailHistoryMapper, ReceiptDetailHistory> implements IReceiptDetailHistoryService {
  17 +public class ReceiptDetailHistoryServiceImpl extends PlusServiceImpl<ReceiptDetailHistoryMapper, ReceiptDetailHistory> implements IReceiptDetailHistoryService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/receipt/receiptHeader/domain/ReceiptBillViewModel.java 0 → 100644
  1 +package com.huaheng.project.receipt.receiptHeader.domain;
  2 +
  3 +import java.time.LocalDateTime;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * 入库页面模型
  8 + */
  9 +public class ReceiptBillViewModel {
  10 + //出库单号
  11 + private String receiptCode;
  12 +
  13 + //出库单类型
  14 + private String receiptTypes;
  15 +
  16 + //货主
  17 + private String companys;
  18 +
  19 + //起始状态
  20 + private int firstStatus;
  21 +
  22 + //结束状态
  23 + private int lastStatus;
  24 +
  25 + //创建起始时间
  26 + private LocalDateTime beginTime;
  27 +
  28 + //创建结束时间
  29 + private LocalDateTime endTime;
  30 +
  31 +
  32 + public String getReceiptCode() {
  33 + return receiptCode;
  34 + }
  35 +
  36 + public void setReceiptCode(String receiptCode) {
  37 + this.receiptCode = receiptCode;
  38 + }
  39 +
  40 + public String getReceiptTypes() {
  41 + return receiptTypes;
  42 + }
  43 +
  44 + public void setReceiptTypes(String receiptTypes) {
  45 + this.receiptTypes = receiptTypes;
  46 + }
  47 +
  48 + public String getCompanys() {
  49 + return companys;
  50 + }
  51 +
  52 + public void setCompanys(String companys) {
  53 + this.companys = companys;
  54 + }
  55 +
  56 + public int getFirstStatus() {
  57 + return firstStatus;
  58 + }
  59 +
  60 + public void setFirstStatus(int firstStatus) {
  61 + this.firstStatus = firstStatus;
  62 + }
  63 +
  64 + public int getLastStatus() {
  65 + return lastStatus;
  66 + }
  67 +
  68 + public void setLastStatus(int lastStatus) {
  69 + this.lastStatus = lastStatus;
  70 + }
  71 +
  72 + public LocalDateTime getBeginTime() {
  73 + return beginTime;
  74 + }
  75 +
  76 + public void setBeginTime(LocalDateTime beginTime) {
  77 + this.beginTime = beginTime;
  78 + }
  79 +
  80 + public LocalDateTime getEndTime() {
  81 + return endTime;
  82 + }
  83 +
  84 + public void setEndTime(LocalDateTime endTime) {
  85 + this.endTime = endTime;
  86 + }
  87 +}
... ...
src/main/java/com/huaheng/project/receipt/receiptHeader/mapper/ReceiptHeaderMapper.java
... ... @@ -2,7 +2,10 @@ package com.huaheng.project.receipt.receiptHeader.mapper;
2 2  
3 3 import com.huaheng.project.receipt.receiptHeader.domain.ReceiptHeader;
4 4 import com.baomidou.mybatisplus.mapper.BaseMapper;
  5 +import org.apache.ibatis.annotations.Param;
  6 +
5 7 import java.util.List;
  8 +import java.util.Map;
6 9  
7 10 /**
8 11 * 入库单主 数据层
... ... @@ -12,5 +15,31 @@ import java.util.List;
12 15 */
13 16 public interface ReceiptHeaderMapper extends BaseMapper<ReceiptHeader> {
14 17  
  18 + /**
  19 + * 生成入库单编码
  20 + * @return
  21 + */
  22 + String createCode(String receiptTypeId);
  23 +
  24 + /**
  25 + * 将 收货单头表转到历史表
  26 + * @param code
  27 + * @return
  28 + */
  29 + int headerToHistory(@Param("code") String code);
  30 +
  31 + /**
  32 + * 将收货单明细表转到历史表
  33 + * @param code
  34 + * @return
  35 + */
  36 + int detailToHistory(@Param("code") String code);
  37 +
  38 + /**
  39 + * 根据收货单,返回物料明细信息
  40 + * @param code
  41 + * @return
  42 + */
  43 + List<Map<String, Object>> getDetail(@Param("code") String code);
15 44 }
16 45  
... ...
src/main/java/com/huaheng/project/receipt/receiptHeader/service/IReceiptHeaderService.java
1 1 package com.huaheng.project.receipt.receiptHeader.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
  4 +import com.huaheng.framework.web.domain.AjaxResult;
3 5 import com.huaheng.project.receipt.receiptHeader.domain.ReceiptHeader;
4 6 import com.baomidou.mybatisplus.service.IService;
  7 +import org.apache.ibatis.annotations.Param;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
5 10 import java.util.List;
  11 +import java.util.Map;
6 12  
7 13 /**
8 14 * 入库单主 服务层
... ... @@ -10,8 +16,50 @@ import java.util.List;
10 16 * @author huaheng
11 17 * @date 2018-08-19
12 18 */
13   -public interface IReceiptHeaderService extends IService<ReceiptHeader> {
  19 +public interface IReceiptHeaderService extends IPlusService<ReceiptHeader> {
  20 +
  21 +
  22 + String createCode(String prefix, String receiptType);
  23 +
  24 + /**
  25 + * 保存入库单头
  26 + * @param receiptHeader
  27 + * @return
  28 + */
  29 + AjaxResult<Boolean> saveHeader(ReceiptHeader receiptHeader) throws IllegalAccessException;
  30 +
  31 + /**
  32 + * 删除表头和明细
  33 + * @param id
  34 + * @return
  35 + * @throws IllegalAccessException
  36 + */
  37 + AjaxResult<Integer> deleteHeaderAndDetail(Integer id) throws IllegalAccessException;
  38 +
  39 + /**
  40 + * 收货
  41 + * @param receiptCode
  42 + * @return
  43 + * @throws IllegalAccessException
  44 + */
  45 + AjaxResult<List<Map<String, Object>>> scanReceiptCode(String receiptCode) throws IllegalAccessException;
  46 +
  47 + /**
  48 + * 检查状态
  49 + * @param headerId
  50 + * @param status
  51 + * @return
  52 + */
  53 + AjaxResult<Integer> checkStatus(Integer headerId, Short status);
14 54  
  55 + /**
  56 + * 检查状态
  57 + * @param receiptCode
  58 + * @param status
  59 + * @return
  60 + * @throws IllegalAccessException
  61 + */
  62 + AjaxResult<Integer> checkStatus(String receiptCode, Short status) throws IllegalAccessException;
15 63 }
16 64  
17 65  
... ...
src/main/java/com/huaheng/project/receipt/receiptHeader/service/ReceiptHeaderServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptHeader.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.common.exception.service.ServiceException;
  5 +import com.huaheng.common.utils.MybatisPlus.PlusUtils;
  6 +import com.huaheng.common.utils.security.ShiroUtils;
  7 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  8 +import com.huaheng.framework.web.domain.AjaxResult;
  9 +import com.huaheng.project.receipt.receiptDetail.domain.ReceiptDetail;
  10 +import com.huaheng.project.receipt.receiptDetail.service.IReceiptDetailService;
  11 +import com.huaheng.project.receipt.receiptDetail.service.ReceiptDetailServiceImpl;
4 12 import com.huaheng.project.receipt.receiptHeader.domain.ReceiptHeader;
5 13 import com.huaheng.project.receipt.receiptHeader.mapper.ReceiptHeaderMapper;
  14 +import com.huaheng.project.system.dict.service.IDictDataService;
  15 +import org.springframework.beans.factory.annotation.Autowired;
6 16 import org.springframework.stereotype.Service;
  17 +import org.springframework.transaction.annotation.Transactional;
  18 +
  19 +import java.text.SimpleDateFormat;
  20 +import java.util.Date;
  21 +import java.util.List;
  22 +import java.util.Map;
7 23  
8 24  
9 25 /**
... ... @@ -13,6 +29,133 @@ import org.springframework.stereotype.Service;
13 29 * @date 2018-08-19
14 30 */
15 31 @Service
16   -public class ReceiptHeaderServiceImpl extends ServiceImpl<ReceiptHeaderMapper, ReceiptHeader> implements IReceiptHeaderService {
  32 +public class ReceiptHeaderServiceImpl extends PlusServiceImpl<ReceiptHeaderMapper, ReceiptHeader> implements IReceiptHeaderService {
  33 +
  34 + @Autowired
  35 + IReceiptDetailService receiptDetailService;
  36 + @Autowired
  37 + IDictDataService dictDataService;
  38 +
  39 + @Override
  40 + public String createCode(String prefix, String receiptType)
  41 + {
  42 + String code = null;
  43 + Date now = new Date();
  44 + SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
  45 + String maxCode = this.baseMapper.createCode(receiptType);
  46 + //如果指定类型的最后的code存在,并且日期一致。那么 code = 入库单类型 + 年月日 + (排序号 + 1)
  47 + if (maxCode != null && maxCode.substring(maxCode.length() - 13, maxCode.length() - 5).equals(df.format(now)))
  48 + {
  49 + Integer Count = Integer.valueOf(maxCode.substring(maxCode.length() - 5, maxCode.length()));
  50 + code = prefix + df.format(now) + String.format("%05d", Count + 1);
  51 + }
  52 + else
  53 + {
  54 + code = prefix + df.format(now) + "00001";
  55 + }
  56 + return code;
  57 + }
  58 +
  59 + @Override
  60 + public AjaxResult<Boolean> saveHeader(ReceiptHeader receiptHeader) throws IllegalAccessException {
  61 + String receiptType = dictDataService.checkConfig(ShiroUtils.getUser().getWarehouseId(),"receiptType", receiptHeader.getCode());
  62 + String code = createCode(receiptHeader.getCode(), receiptType);
  63 + receiptHeader.setId(null);
  64 + receiptHeader.setLastUpdated(null);
  65 + receiptHeader.setLastUpdatedBy(null);
  66 + receiptHeader.setCreated(null);
  67 + receiptHeader.setCreatedBy(ShiroUtils.getUser().getLoginName());
  68 + receiptHeader.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  69 + receiptHeader.setWarehouseCode(ShiroUtils.getUser().getWarehouseCode());
  70 + receiptHeader.setCode(code);
  71 + receiptHeader.setType(receiptType);
  72 + this.insert(receiptHeader);
  73 + return AjaxResult.success("");
  74 + }
  75 +
  76 + @Override
  77 + @Transactional
  78 + public AjaxResult<Integer> deleteHeaderAndDetail(Integer id) throws IllegalAccessException {
  79 + ReceiptHeader receiptHeader = this.selectById(id);
  80 + if (receiptHeader == null) return AjaxResult.success("");
  81 + ReceiptDetail condition = new ReceiptDetail();
  82 + condition.setReceiptCode(receiptHeader.getCode());
  83 + if (receiptHeader.getFirstStatus() < 100)
  84 + {
  85 + this.deleteById(id);
  86 + receiptDetailService.delete(PlusUtils.getWrapper(condition));
  87 + return AjaxResult.success("");
  88 + }
  89 + else if (receiptHeader.getFirstStatus() < 120)
  90 + {
  91 + this.baseMapper.headerToHistory(receiptHeader.getCode());
  92 + this.baseMapper.detailToHistory(receiptHeader.getCode());
  93 + this.deleteById(id);
  94 + receiptDetailService.delete(PlusUtils.getWrapper(condition));
  95 + return AjaxResult.success("");
  96 + }
  97 + else
  98 + {
  99 + return AjaxResult.error("单据状态超过120已经不能删除");
  100 + }
  101 + }
  102 +
  103 + @Override
  104 + @Transactional
  105 + public AjaxResult<List<Map<String, Object>>> scanReceiptCode(String receiptCode) throws IllegalAccessException {
  106 + ReceiptHeader receiptHeader = new ReceiptHeader();
  107 + receiptHeader.setCode(receiptCode);
  108 + List<ReceiptHeader> list = this.selectList(PlusUtils.getWrapper(receiptHeader));
  109 + if (list.size() < 1)
  110 + return AjaxResult.error("收货单不存在!");
  111 + else
  112 + receiptHeader = list.get(0);
  113 + if (receiptHeader.getLastStatus() >= 900)
  114 + return AjaxResult.error("收货单已经完成,不能在收货!");
  115 + if (receiptHeader.getWarehouseId() != ShiroUtils.getUser().getWarehouseId())
  116 + return AjaxResult.error("不是当前仓库的货物!");
  117 + if (receiptHeader.getFirstStatus() < 200)
  118 + {
  119 + receiptHeader.setFirstStatus(200);
  120 + this.updateById(receiptHeader);
  121 + }
  122 + List<Map<String, Object>> detail = this.baseMapper.getDetail(receiptCode);
  123 + return AjaxResult.success(detail);
  124 + }
  125 +
  126 + @Override
  127 + public AjaxResult<Integer> checkStatus(Integer headerId, Short status){
  128 + ReceiptHeader receiptHeader = this.selectById(headerId);
  129 + if (receiptHeader == null)
  130 + {
  131 + throw new ServiceException("数据错误,没有表头!");
  132 + }
  133 + else if (receiptHeader.getFirstStatus() > status)
  134 + {
  135 + throw new ServiceException("单据状态超过" + status + "已经不可修改!");
  136 + }
  137 + else
  138 + {
  139 + return AjaxResult.success("");
  140 + }
  141 + }
17 142  
  143 + @Override
  144 + public AjaxResult<Integer> checkStatus(String receiptCode, Short status) throws IllegalAccessException {
  145 + ReceiptHeader condition = new ReceiptHeader();
  146 + condition.setCode(receiptCode);
  147 + List<ReceiptHeader> receiptHeaders = this.selectList(PlusUtils.getWrapper(condition));
  148 + if (receiptHeaders.size() < 1)
  149 + {
  150 + throw new ServiceException("数据错误,没有表头!");
  151 + }
  152 + else if (receiptHeaders.get(0).getFirstStatus() > status)
  153 + {
  154 + throw new ServiceException("单据状态超过" + status + "已经不可修改!");
  155 + }
  156 + else
  157 + {
  158 + return AjaxResult.success("");
  159 + }
  160 + }
18 161 }
... ...
src/main/java/com/huaheng/project/receipt/receiptHeaderHistory/service/IReceiptHeaderHistoryService.java
1 1 package com.huaheng.project.receipt.receiptHeaderHistory.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.receipt.receiptHeaderHistory.domain.ReceiptHeaderHistory;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IReceiptHeaderHistoryService extends IService<ReceiptHeaderHistory> {
  14 +public interface IReceiptHeaderHistoryService extends IPlusService<ReceiptHeaderHistory> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/receipt/receiptHeaderHistory/service/ReceiptHeaderHistoryServiceImpl.java
1 1 package com.huaheng.project.receipt.receiptHeaderHistory.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.receipt.receiptHeaderHistory.domain.ReceiptHeaderHistory;
5 6 import com.huaheng.project.receipt.receiptHeaderHistory.mapper.ReceiptHeaderHistoryMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ReceiptHeaderHistoryServiceImpl extends ServiceImpl<ReceiptHeaderHistoryMapper, ReceiptHeaderHistory> implements IReceiptHeaderHistoryService {
  17 +public class ReceiptHeaderHistoryServiceImpl extends PlusServiceImpl<ReceiptHeaderHistoryMapper, ReceiptHeaderHistory> implements IReceiptHeaderHistoryService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/shipment/customer/service/CustomerServiceImpl.java
1 1 package com.huaheng.project.shipment.customer.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.shipment.customer.domain.Customer;
5 6 import com.huaheng.project.shipment.customer.mapper.CustomerMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> implements ICustomerService {
  17 +public class CustomerServiceImpl extends PlusServiceImpl<CustomerMapper, Customer> implements ICustomerService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/shipment/customer/service/ICustomerService.java
1 1 package com.huaheng.project.shipment.customer.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.shipment.customer.domain.Customer;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface ICustomerService extends IService<Customer> {
  14 +public interface ICustomerService extends IPlusService<Customer> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerDetail/service/IShipmentContainerDetailService.java
1 1 package com.huaheng.project.shipment.shipmentContainerDetail.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IShipmentContainerDetailService extends IService<ShipmentContainerDetail> {
  14 +public interface IShipmentContainerDetailService extends IPlusService<ShipmentContainerDetail> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerDetail/service/ShipmentContainerDetailServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentContainerDetail.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
5 6 import com.huaheng.project.shipment.shipmentContainerDetail.mapper.ShipmentContainerDetailMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ShipmentContainerDetailServiceImpl extends ServiceImpl<ShipmentContainerDetailMapper, ShipmentContainerDetail> implements IShipmentContainerDetailService {
  17 +public class ShipmentContainerDetailServiceImpl extends PlusServiceImpl<ShipmentContainerDetailMapper, ShipmentContainerDetail> implements IShipmentContainerDetailService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerHeader/domain/ShipmentCombinationModel.java 0 → 100644
  1 +package com.huaheng.project.shipment.shipmentContainerHeader.domain;
  2 +
  3 +import java.math.BigDecimal;
  4 +
  5 +/**
  6 + * 用于出库租盘,前端给后端传递数据
  7 + */
  8 +public class ShipmentCombinationModel {
  9 +
  10 + //组盘时的出库明细Id
  11 + private int shipmentDetailId;
  12 + //组盘时选择的库存
  13 + private int inventoryId;
  14 + //组盘数量
  15 + private BigDecimal qty;
  16 + //组盘类型
  17 + private Short type;
  18 + //是否自动生成任务
  19 + private boolean auto=false;
  20 + //自动生成时,选择的任务类型
  21 + private String taskType;
  22 +
  23 + public String getTaskType() {
  24 + return taskType;
  25 + }
  26 +
  27 + public void setTaskType(String taskType) {
  28 + this.taskType = taskType;
  29 + }
  30 +
  31 + public int getShipmentDetailId() {
  32 + return shipmentDetailId;
  33 + }
  34 +
  35 + public void setShipmentDetailId(int shipmentDetailId) {
  36 + this.shipmentDetailId = shipmentDetailId;
  37 + }
  38 +
  39 + public int getInventoryId() {
  40 + return inventoryId;
  41 + }
  42 +
  43 + public void setInventoryId(int inventoryId) {
  44 + this.inventoryId = inventoryId;
  45 + }
  46 +
  47 + public BigDecimal getQty() {
  48 + return qty;
  49 + }
  50 +
  51 + public void setQty(BigDecimal qty) {
  52 + this.qty = qty;
  53 + }
  54 +
  55 + public Short getType() {
  56 + return type;
  57 + }
  58 +
  59 + public void setType(Short type) {
  60 + this.type = type;
  61 + }
  62 +
  63 + public boolean isAuto() {
  64 + return auto;
  65 + }
  66 +
  67 + public void setAuto(boolean auto) {
  68 + this.auto = auto;
  69 + }
  70 +}
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerHeader/mapper/ShipmentContainerHeaderMapper.java
1 1 package com.huaheng.project.shipment.shipmentContainerHeader.mapper;
2 2  
  3 +import com.baomidou.mybatisplus.plugins.pagination.Pagination;
3 4 import com.huaheng.project.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
4 5 import com.baomidou.mybatisplus.mapper.BaseMapper;
  6 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
  7 +import org.apache.ibatis.annotations.Param;
5 8 import java.util.List;
  9 +import java.util.Map;
6 10  
7 11 /**
8 12 * 出库组盘明细 数据层
... ... @@ -12,5 +16,13 @@ import java.util.List;
12 16 */
13 17 public interface ShipmentContainerHeaderMapper extends BaseMapper<ShipmentContainerHeader> {
14 18  
  19 + List<ShipmentHeader> listShipmentHeaders(@Param("model") ShipmentHeader shipmentHeader);
  20 +
  21 + ShipmentContainerHeader getShipmentContainerHeaderByContainerCode(@Param("containerCode")String containerCode);
  22 +
  23 + Map<String,Integer> getShipmentContainerMaxAndMinStatusByShipmentID(@Param("shipmentId") int shipmentId);
  24 +
  25 + List<ShipmentContainerHeader> getShipmentContainerHeaders(Pagination page, @Param("model") ShipmentContainerHeader ShipmentContainerHeader);
  26 +
15 27 }
16 28  
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerHeader/service/IShipmentContainerHeaderService.java
1 1 package com.huaheng.project.shipment.shipmentContainerHeader.service;
2 2  
  3 +import com.baomidou.mybatisplus.plugins.Page;
  4 +import com.huaheng.framework.mybatisPlus.IPlusService;
  5 +import com.huaheng.framework.web.domain.AjaxResult;
  6 +import com.huaheng.project.receipt.receiptContainerHeader.service.ShipmentContainerDetailSearchModel;
  7 +import com.huaheng.project.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
  8 +import com.huaheng.project.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel;
3 9 import com.huaheng.project.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
4 10 import com.baomidou.mybatisplus.service.IService;
  11 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
  12 +import org.apache.ibatis.annotations.Param;
  13 +import org.springframework.transaction.annotation.Transactional;
  14 +
5 15 import java.util.List;
  16 +import java.util.Map;
6 17  
7 18 /**
8 19 * 出库组盘明细 服务层
... ... @@ -10,8 +21,33 @@ import java.util.List;
10 21 * @author huaheng
11 22 * @date 2018-08-19
12 23 */
13   -public interface IShipmentContainerHeaderService extends IService<ShipmentContainerHeader> {
  24 +public interface IShipmentContainerHeaderService extends IPlusService<ShipmentContainerHeader> {
  25 +
  26 + @Transactional
  27 + AjaxResult combination(List<ShipmentCombinationModel> shipmentCombinationModels) throws IllegalAccessException;
  28 +
  29 + AjaxResult check(ShipmentCombinationModel shipmentCombinationModel);
  30 +
  31 + AjaxResult cancelCombination(List<Integer> shipmentContainerIds) throws IllegalAccessException;
  32 +
  33 + AjaxResult checkForCancelCombination(List<Integer> shipmentContainerIds);
  34 +
  35 + public List<ShipmentContainerDetail> listDetails(ShipmentContainerDetailSearchModel shipmentContainerDetailSearchModel) throws IllegalAccessException;
  36 +
  37 + AjaxResult cancelCombinationDetail(List<Integer> detailIds) throws IllegalAccessException;
  38 +
  39 + @Transactional
  40 + AjaxResult cancelCombinationDetailInner(List<ShipmentContainerDetail> shipmentContainerDetails) throws IllegalAccessException;
  41 +
  42 + void resetStatusShipmentContainer(String containerCode, Integer status) throws IllegalAccessException;
  43 +
  44 + List<ShipmentHeader> listShipmentHeaders(@Param("model") ShipmentHeader shipmentHeader);
  45 +
  46 + ShipmentContainerHeader getShipmentContainerHeaderByContainerCode(@Param("containerCode")String containerCode);
  47 +
  48 + Map<String,Integer> getShipmentContainerMaxAndMinStatusByShipmentID(@Param("shipmentId") int shipmentId);
14 49  
  50 + Page<List<ShipmentContainerHeader>> getShipmentContainerHeaders(Page page, @Param("model") ShipmentContainerHeader ShipmentContainerHeader);
15 51 }
16 52  
17 53  
... ...
src/main/java/com/huaheng/project/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentContainerHeader.service;
2 2  
3   -import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  3 +import com.baomidou.mybatisplus.plugins.Page;
  4 +import com.huaheng.common.utils.security.ShiroUtils;
  5 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  6 +import com.huaheng.framework.web.domain.AjaxResult;
  7 +import com.huaheng.framework.web.domain.RetCode;
  8 +import com.huaheng.project.general.location.domain.Location;
  9 +import com.huaheng.project.general.location.service.ILocationService;
  10 +import com.huaheng.project.inventory.inventory.domain.Inventory;
  11 +import com.huaheng.project.inventory.inventory.service.IInventoryService;
  12 +import com.huaheng.project.receipt.receiptContainerHeader.service.ShipmentContainerDetailSearchModel;
  13 +import com.huaheng.project.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
  14 +import com.huaheng.project.shipment.shipmentContainerDetail.service.IShipmentContainerDetailService;
  15 +import com.huaheng.project.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel;
4 16 import com.huaheng.project.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
5 17 import com.huaheng.project.shipment.shipmentContainerHeader.mapper.ShipmentContainerHeaderMapper;
  18 +import com.huaheng.project.shipment.shipmentDetail.domain.ShipmentDetail;
  19 +import com.huaheng.project.shipment.shipmentDetail.service.IShipmentDetailService;
  20 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
  21 +import com.huaheng.project.shipment.shipmentHeader.service.IShipmentHeaderService;
  22 +import org.springframework.beans.factory.annotation.Autowired;
6 23 import org.springframework.stereotype.Service;
  24 +import org.springframework.transaction.annotation.Transactional;
  25 +import java.math.BigDecimal;
  26 +import java.util.ArrayList;
  27 +import java.util.List;
  28 +import java.util.Map;
7 29  
8 30  
9 31 /**
... ... @@ -13,6 +35,287 @@ import org.springframework.stereotype.Service;
13 35 * @date 2018-08-19
14 36 */
15 37 @Service
16   -public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentContainerHeaderMapper, ShipmentContainerHeader> implements IShipmentContainerHeaderService {
  38 +public class ShipmentContainerHeaderServiceImpl extends PlusServiceImpl<ShipmentContainerHeaderMapper, ShipmentContainerHeader> implements IShipmentContainerHeaderService {
  39 + @Autowired
  40 + IInventoryService inventoryService;
  41 + @Autowired
  42 + ILocationService locationService;
  43 + @Autowired
  44 + IShipmentHeaderService shipmentHeaderService;
  45 + @Autowired
  46 + IShipmentDetailService shipmentDetailService;
  47 + @Autowired
  48 + IShipmentContainerDetailService shipmentContainerDetailService;
  49 +
  50 + /**
  51 + * 返回货箱头列表
  52 + * @param shipmentContainerHeader
  53 + * @return
  54 + */
  55 + @Override
  56 + public Page<List<ShipmentContainerHeader>> getShipmentContainerHeaders(Page page, ShipmentContainerHeader shipmentContainerHeader) {
  57 + shipmentContainerHeader.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  58 + this.baseMapper.getShipmentContainerHeaders(page, shipmentContainerHeader);
  59 + return page;
  60 + }
  61 +
  62 + /**
  63 + * 出库组盘
  64 + * @param shipmentCombinationModels
  65 + * @return
  66 + */
  67 + @Transactional
  68 + @Override
  69 + public AjaxResult combination(List<ShipmentCombinationModel> shipmentCombinationModels) throws IllegalAccessException {
  70 + //校验不通过就中止
  71 + for (ShipmentCombinationModel shipmentCombinationModel:shipmentCombinationModels){
  72 + AjaxResult AjaxResult = check(shipmentCombinationModel);
  73 + if(AjaxResult.hasErr()){
  74 + return AjaxResult;
  75 + }
  76 + }
  77 + for (ShipmentCombinationModel shipmentCombinationModel:shipmentCombinationModels){
  78 + //查询库存
  79 + Inventory inventory = inventoryService.selectById(shipmentCombinationModel.getInventoryId());
  80 + //库位
  81 + Location locationCondition = new Location();
  82 + locationCondition.setWarehouseCode(inventory.getWarehouseCode());
  83 + locationCondition.setCode(inventory.getLocationCode());
  84 + Location location = locationService.selectFirstEntity(locationCondition);
  85 + //查询有没有出库货箱头表,没有就创建,一次只允许使用一个未被使用的货箱
  86 + ShipmentContainerHeader shipmentContainerHeader = this.baseMapper.getShipmentContainerHeaderByContainerCode(location.getContainerCode());
  87 +
  88 + if(shipmentContainerHeader==null){
  89 + shipmentContainerHeader = new ShipmentContainerHeader();
  90 + shipmentContainerHeader.setStatus(0);
  91 + shipmentContainerHeader.setShipmentContainerCode(location.getContainerCode());
  92 + shipmentContainerHeader.setCreated(null);
  93 + shipmentContainerHeader.setCreatedBy(ShiroUtils.getUser().getLoginName());
  94 + shipmentContainerHeader.setWarehouseCode(ShiroUtils.getUser().getWarehouseCode());
  95 + shipmentContainerHeader.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  96 + this.insert(shipmentContainerHeader);
  97 + }else{
  98 + //判断状态
  99 + if(shipmentContainerHeader.getStatus()>9){
  100 + return AjaxResult.error("容器"+location.getContainerCode()+"已经生成任务,不能再添加明细;操作中止;");
  101 + }
  102 + }
  103 + //明细单
  104 + ShipmentDetail shipmentDetail = shipmentDetailService.selectById(shipmentCombinationModel.getShipmentDetailId());
  105 +
  106 + //查询对应的组盘明细
  107 + ShipmentContainerDetail condition = new ShipmentContainerDetail();
  108 + condition.setHeaderId(shipmentContainerHeader.getId());
  109 + List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.selectListEntityByEqual(condition);
  110 + int flag = 0;
  111 + if(shipmentContainerDetails!=null&&shipmentContainerDetails.size()>0){
  112 + for(ShipmentContainerDetail item : shipmentContainerDetails){
  113 + if(item.getInventoryId()==shipmentCombinationModel.getInventoryId()&&item.getShipmentDetailId()==shipmentCombinationModel.getShipmentDetailId()){
  114 + //如果库存Id和出库明细Id一致,则合并
  115 + item.setQty(item.getQty().add(shipmentCombinationModel.getQty()));
  116 + shipmentContainerDetailService.updateById(item);
  117 + flag=1;
  118 + break;
  119 + }
  120 + }
  121 + }
  122 + if(flag==0){
  123 + //构建明细
  124 + ShipmentContainerDetail shipmentContainerDetail = new ShipmentContainerDetail();
  125 + shipmentContainerDetail.setMaterialCode(shipmentDetail.getMaterialCode());
  126 + shipmentContainerDetail.setMaterialName(shipmentDetail.getMaterialName());
  127 + shipmentContainerDetail.setHeaderId(shipmentContainerHeader.getId());
  128 + shipmentContainerDetail.setCreated(null);
  129 + shipmentContainerDetail.setCreatedBy(ShiroUtils.getUser().getLoginName());
  130 + shipmentContainerDetail.setInventoryId(shipmentCombinationModel.getInventoryId());
  131 + shipmentContainerDetail.setQty(shipmentCombinationModel.getQty());
  132 + shipmentContainerDetail.setShipmentHeaderId(shipmentDetail.getShipmentId());
  133 + shipmentContainerDetail.setShipmentDetailId(shipmentCombinationModel.getShipmentDetailId());
  134 + shipmentContainerDetail.setHeaderId(shipmentContainerHeader.getId());
  135 + shipmentContainerDetailService.insert(shipmentContainerDetail);
  136 + }
  137 + //更新库存分配数、明细单据已发数
  138 + inventory.setTaskQty(inventory.getTaskQty().add(shipmentCombinationModel.getQty()));
  139 + inventoryService.updateById(inventory);
  140 + shipmentDetail.setQtyCompleted(shipmentDetail.getQtyCompleted().add(shipmentCombinationModel.getQty()));
  141 + shipmentDetailService.updateById(shipmentDetail);
  142 + //更新单据状态
  143 + shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId());
  144 + }
  145 + return AjaxResult.success("");
  146 + }
  147 +
  148 + /**
  149 + * 校验
  150 + * @param shipmentCombinationModel
  151 + * @return
  152 + */
  153 + @Override
  154 + public AjaxResult check(ShipmentCombinationModel shipmentCombinationModel) {
  155 + if(shipmentCombinationModel.getQty().compareTo(new BigDecimal("0"))<0){
  156 + return AjaxResult.error("数量不能小于0");
  157 + }
  158 + ShipmentDetail shipmentDetail = shipmentDetailService.selectById(shipmentCombinationModel.getShipmentDetailId());
  159 + if(shipmentDetail==null){
  160 + return AjaxResult.error("出库明细未找到");
  161 + }
  162 + Inventory inventory = inventoryService.selectById((shipmentCombinationModel.getInventoryId()));
  163 + if(inventory==null){
  164 + return AjaxResult.error("库存未找到");
  165 + }
  166 + //校验数量是否超出
  167 + if((shipmentDetail.getQty().subtract(shipmentDetail.getQtyCompleted())).compareTo(shipmentCombinationModel.getQty())<0){
  168 + return AjaxResult.error("录入数量超出明细待出数量");
  169 + }
  170 + //校验库存可用数量
  171 + if(inventory.getQty().subtract(inventory.getTaskQty()).compareTo(shipmentCombinationModel.getQty())<0){
  172 + return AjaxResult.error("录入数量超出可出数量");
  173 + }
  174 + if(!shipmentDetail.getMaterialCode().equals(inventory.getMaterialCode())){
  175 + return AjaxResult.error("配盘物料不一致");
  176 + }
  177 + return AjaxResult.success("");
  178 + }
  179 +
  180 + /**
  181 + * 取消组盘
  182 + * @param shipmentContainerIds
  183 + * @return
  184 + */
  185 + @Override
  186 + public AjaxResult cancelCombination(List<Integer> shipmentContainerIds) throws IllegalAccessException {
  187 +
  188 + AjaxResult result = checkForCancelCombination(shipmentContainerIds);
  189 + if(result.getCode()!= RetCode.SUCCESS.getValue()){
  190 + return result;
  191 + }
  192 + for(int id:shipmentContainerIds){
  193 + ShipmentContainerHeader shipmentContainerHeader = this.selectById(id);
  194 + ShipmentContainerDetail condition = new ShipmentContainerDetail();
  195 + condition.setHeaderId(shipmentContainerHeader.getId());
  196 + List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.selectListEntityByEqual(condition);
  197 + result = cancelCombinationDetailInner(shipmentContainerDetails);
  198 + if(result.hasErr()){
  199 + return result;
  200 + }
  201 + }
  202 +
  203 + return AjaxResult.success("");
  204 + }
  205 +
  206 + /**
  207 + * 检查是否可以进行取消配盘
  208 + * @param shipmentContainerIds
  209 + * @return
  210 + */
  211 + @Override
  212 + public AjaxResult checkForCancelCombination(List<Integer> shipmentContainerIds) {
  213 + for(int id : shipmentContainerIds){
  214 + ShipmentContainerHeader shipmentContainerHeader = this.selectById(id);
  215 + if(shipmentContainerHeader.getStatus()>9){
  216 + return AjaxResult.error("存在已生成任务的记录,请先取消任务再取消组盘");
  217 + }
  218 + }
  219 + return AjaxResult.success("");
  220 + }
  221 +
  222 + /**
  223 + * 根据出库货箱头id获取出库货箱明细
  224 + * @param shipmentContainerDetailSearchModel
  225 + * @return
  226 + */
  227 + @Override
  228 + public List<ShipmentContainerDetail> listDetails(ShipmentContainerDetailSearchModel shipmentContainerDetailSearchModel) throws IllegalAccessException {
  229 + ShipmentContainerDetail condition = new ShipmentContainerDetail();
  230 + condition.setHeaderId(shipmentContainerDetailSearchModel.getShipmentContainerHeaderId());
  231 + List<ShipmentContainerDetail> list = shipmentContainerDetailService.selectListEntityByEqual(condition);
  232 + return list;
  233 + }
  234 +
  235 + /**
  236 + * 取消组盘的一组明细
  237 + * @param detailIds
  238 + * @return
  239 + */
  240 + @Override
  241 + public AjaxResult cancelCombinationDetail(List<Integer> detailIds) throws IllegalAccessException {
  242 + List<ShipmentContainerDetail> shipmentContainerDetails = new ArrayList<>();
  243 + for(int detailId:detailIds){
  244 + ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.selectById(detailId);
  245 + shipmentContainerDetails.add(shipmentContainerDetail);
  246 + }
  247 + return cancelCombinationDetailInner(shipmentContainerDetails);
  248 + }
  249 + /**
  250 + * 取消组盘的一组明细
  251 + * @param shipmentContainerDetails
  252 + * @return
  253 + */
  254 + @Override
  255 + @Transactional
  256 + public AjaxResult cancelCombinationDetailInner(List<ShipmentContainerDetail> shipmentContainerDetails) throws IllegalAccessException {
  257 + for(ShipmentContainerDetail shipmentContainerDetail:shipmentContainerDetails){
  258 + //获取头
  259 + ShipmentContainerHeader shipmentContainerHeader = this.selectById(shipmentContainerDetail.getHeaderId());
  260 + if(shipmentContainerHeader.getStatus()>9){
  261 + return AjaxResult.error("容器"+shipmentContainerHeader.getShipmentContainerCode()+"非新建状态,不允许取消明细");
  262 + }
  263 + //库存
  264 + Inventory inventory = inventoryService.selectById(shipmentContainerDetail.getInventoryId());
  265 + //单据明细
  266 + ShipmentDetail shipmentDetail = shipmentDetailService.selectById(shipmentContainerDetail.getShipmentDetailId());
  267 + //恢复占用库存
  268 + inventory.setTaskQty(inventory.getTaskQty().subtract(shipmentContainerDetail.getQty()));
  269 + inventoryService.updateById(inventory);
  270 + //恢复单据发货数量
  271 + shipmentDetail.setQtyCompleted(shipmentDetail.getQtyCompleted().subtract(shipmentContainerDetail.getQty()));
  272 + shipmentDetailService.updateById(shipmentDetail);
  273 + //删除这个配盘明细
  274 + shipmentDetailService.deleteById(shipmentContainerDetail.getId());
  275 + //查询头表下还有没有明细,如果没有,则删了这个头表
  276 + ShipmentContainerDetail condition = new ShipmentContainerDetail();
  277 + condition.setHeaderId(shipmentContainerDetail.getHeaderId());
  278 + List<ShipmentContainerDetail> shipmentContainerDetailsList= shipmentContainerDetailService.selectListEntityByEqual(condition);
  279 + if(shipmentContainerDetailsList==null||shipmentContainerDetailsList.size()==0){
  280 + this.deleteById(shipmentContainerHeader.getId());
  281 + }
  282 + //更新单据状态
  283 + shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId());
  284 + }
  285 + return AjaxResult.success("");
  286 + }
  287 +
  288 + /**
  289 + * 强制重置货箱为指定的状态
  290 + * @param containerCode
  291 + * @param status
  292 + */
  293 + @Override
  294 + public void resetStatusShipmentContainer(String containerCode, Integer status) throws IllegalAccessException {
  295 + //找到这个货箱
  296 + ShipmentContainerHeader condition = new ShipmentContainerHeader();
  297 + condition.setShipmentContainerCode(containerCode);
  298 + ShipmentContainerHeader shipmentContainerHeader = this.selectFirstEntity(condition);
  299 + if(shipmentContainerHeader!=null){
  300 + shipmentContainerHeader.setStatus(status);
  301 + this.updateById(shipmentContainerHeader);
  302 + }
  303 + }
  304 +
  305 +
  306 + @Override
  307 + public List<ShipmentHeader> listShipmentHeaders(ShipmentHeader shipmentHeader) {
  308 + return this.baseMapper.listShipmentHeaders(shipmentHeader);
  309 + }
  310 +
  311 + @Override
  312 + public ShipmentContainerHeader getShipmentContainerHeaderByContainerCode(String containerCode) {
  313 + return this.baseMapper.getShipmentContainerHeaderByContainerCode(containerCode);
  314 + }
  315 +
  316 + @Override
  317 + public Map<String, Integer> getShipmentContainerMaxAndMinStatusByShipmentID(int shipmentId) {
  318 + return this.baseMapper.getShipmentContainerMaxAndMinStatusByShipmentID(shipmentId);
  319 + }
17 320  
18 321 }
... ...
src/main/java/com/huaheng/project/shipment/shipmentDetail/domain/ShipmentDetailSearchModel.java 0 → 100644
  1 +package com.huaheng.project.shipment.shipmentDetail.domain;
  2 +
  3 +
  4 +/**
  5 + * todo:出库明细查询类
  6 + */
  7 +public class ShipmentDetailSearchModel {
  8 + private int headerId;
  9 +
  10 + public int getHeaderId() {
  11 + return headerId;
  12 + }
  13 +
  14 + public void setHeaderId(int headerId) {
  15 + this.headerId = headerId;
  16 + }
  17 +}
... ...
src/main/java/com/huaheng/project/shipment/shipmentDetail/service/IShipmentDetailService.java
1 1 package com.huaheng.project.shipment.shipmentDetail.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
  4 +import com.huaheng.framework.web.domain.AjaxResult;
3 5 import com.huaheng.project.shipment.shipmentDetail.domain.ShipmentDetail;
4 6 import com.baomidou.mybatisplus.service.IService;
5 7 import java.util.List;
... ... @@ -10,7 +12,8 @@ import java.util.List;
10 12 * @author huaheng
11 13 * @date 2018-08-19
12 14 */
13   -public interface IShipmentDetailService extends IService<ShipmentDetail> {
  15 +public interface IShipmentDetailService extends IPlusService<ShipmentDetail> {
  16 +
14 17  
15 18 }
16 19  
... ...
src/main/java/com/huaheng/project/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentDetail.service;
2 2  
3   -import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  3 +import com.huaheng.common.utils.security.ShiroUtils;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  5 +import com.huaheng.framework.web.domain.AjaxResult;
4 6 import com.huaheng.project.shipment.shipmentDetail.domain.ShipmentDetail;
  7 +import com.huaheng.project.shipment.shipmentDetail.domain.ShipmentDetailSearchModel;
5 8 import com.huaheng.project.shipment.shipmentDetail.mapper.ShipmentDetailMapper;
  9 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
  10 +import com.huaheng.project.shipment.shipmentHeader.service.IShipmentHeaderService;
  11 +import org.springframework.beans.factory.annotation.Autowired;
6 12 import org.springframework.stereotype.Service;
7 13  
  14 +import java.util.List;
  15 +
8 16  
9 17 /**
10 18 * 出库明细 服务层实现
... ... @@ -13,6 +21,70 @@ import org.springframework.stereotype.Service;
13 21 * @date 2018-08-19
14 22 */
15 23 @Service
16   -public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper, ShipmentDetail> implements IShipmentDetailService {
  24 +public class ShipmentDetailServiceImpl extends PlusServiceImpl<ShipmentDetailMapper, ShipmentDetail> implements IShipmentDetailService {
  25 +
  26 + @Autowired
  27 + IShipmentHeaderService shipmentHeaderService;
  28 + /**
  29 + * 根据主单Id来获取明细并分页
  30 + * @param shipmentDetailSearchModel
  31 + * @return
  32 + */
  33 + public AjaxResult<List<ShipmentDetail>> listDetails(ShipmentDetailSearchModel shipmentDetailSearchModel) throws IllegalAccessException {
  34 + ShipmentDetail condition = new ShipmentDetail();
  35 + condition.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  36 + List<ShipmentDetail> list = this.selectListEntityByEqual(condition);
  37 + return AjaxResult.success(list);
  38 + }
  39 +
  40 + /**
  41 + * 新增出库明细
  42 + * @param shipmentDetail
  43 + * @return
  44 + */
  45 + public AjaxResult insertDetail(ShipmentDetail shipmentDetail) {
  46 + ShipmentHeader shipmentHeader = shipmentHeaderService.selectById(shipmentDetail.getShipmentId());
  47 + if(shipmentHeader==null){
  48 + return AjaxResult.error("找不到主单据");
  49 + }
  50 + if (shipmentHeader.getFirstStatus() > 199) {
  51 + //表示已经加入了波次
  52 + return AjaxResult.error("主单据状态不允许新增明细");
  53 + }
  54 + shipmentDetail.setId(null);
  55 + shipmentDetail.setCreated(null);
  56 + shipmentDetail.setCreatedBy(ShiroUtils.getUser().getLoginName());
  57 + shipmentDetail.setLastUpdated(null);
  58 + shipmentDetail.setLastUpdatedBy(null);
  59 + if(this.insert(shipmentDetail))
  60 + return AjaxResult.success("新增单据明细成功");
  61 + else
  62 + return AjaxResult.error("新增单据明细失败");
  63 + }
  64 +
  65 + /**
  66 + * 修改出库单据明细
  67 + * @param shipmentDetail
  68 + * @return
  69 + */
  70 + public AjaxResult updateDetail(ShipmentDetail shipmentDetail) {
  71 + ShipmentHeader sh = shipmentHeaderService.selectById(shipmentDetail.getShipmentId());
  72 + if(sh==null){
  73 + return AjaxResult.error("找不到主单据");
  74 + }
  75 + if(sh.getFirstStatus()>199){
  76 + return AjaxResult.error("单据状态不允许进行单据内容修改");
  77 + }
  78 + shipmentDetail.setCreated(null);
  79 + shipmentDetail.setCreatedBy(null);
  80 + shipmentDetail.setLastUpdatedBy(ShiroUtils.getUser().getLoginName());
  81 + shipmentDetail.setLastUpdated(null);
  82 + if (this.updateById(shipmentDetail))
  83 + return AjaxResult.success("编辑单据明细成功");
  84 + else
  85 + return AjaxResult.error("编辑单据明细失败");
  86 + }
  87 +
  88 +
17 89  
18 90 }
... ...
src/main/java/com/huaheng/project/shipment/shipmentDetailHistory/service/IShipmentDetailHistoryService.java
1 1 package com.huaheng.project.shipment.shipmentDetailHistory.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.shipment.shipmentDetailHistory.domain.ShipmentDetailHistory;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IShipmentDetailHistoryService extends IService<ShipmentDetailHistory> {
  14 +public interface IShipmentDetailHistoryService extends IPlusService<ShipmentDetailHistory> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/shipment/shipmentDetailHistory/service/ShipmentDetailHistoryServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentDetailHistory.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.shipment.shipmentDetailHistory.domain.ShipmentDetailHistory;
5 6 import com.huaheng.project.shipment.shipmentDetailHistory.mapper.ShipmentDetailHistoryMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ShipmentDetailHistoryServiceImpl extends ServiceImpl<ShipmentDetailHistoryMapper, ShipmentDetailHistory> implements IShipmentDetailHistoryService {
  17 +public class ShipmentDetailHistoryServiceImpl extends PlusServiceImpl<ShipmentDetailHistoryMapper, ShipmentDetailHistory> implements IShipmentDetailHistoryService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeader/domain/ShipmentBillViewModel.java 0 → 100644
  1 +package com.huaheng.project.shipment.shipmentHeader.domain;
  2 +
  3 +import java.time.LocalDateTime;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * 出库界面模型
  8 + */
  9 +public class ShipmentBillViewModel {
  10 + //出库单号
  11 + private String shipmentCode;
  12 +
  13 + public String getShipmentTypes() {
  14 + return shipmentTypes;
  15 + }
  16 +
  17 + //出库单类型
  18 + private String shipmentTypes;
  19 +
  20 + //货主
  21 + private String companys;
  22 +
  23 + //起始状态
  24 + private int firstStatus;
  25 +
  26 + //结束状态
  27 + private int lastStatus;
  28 +
  29 + //创建起始时间
  30 + private LocalDateTime beginTime;
  31 +
  32 + //创建结束时间
  33 + private LocalDateTime endTime;
  34 +
  35 + public String getShipmentCode() {
  36 + return shipmentCode;
  37 + }
  38 +
  39 + public void setShipmentCode(String shipmentCode) {
  40 + this.shipmentCode = shipmentCode;
  41 + }
  42 +
  43 + public void setShipmentTypes(String shipmentTypes) {
  44 + this.shipmentTypes = shipmentTypes;
  45 + }
  46 +
  47 + public String getCompanys() {
  48 + return companys;
  49 + }
  50 +
  51 + public void setCompanys(String companys) {
  52 + this.companys = companys;
  53 + }
  54 +
  55 + public int getFirstStatus() {
  56 + return firstStatus;
  57 + }
  58 +
  59 + public void setFirstStatus(int firstStatus) {
  60 + this.firstStatus = firstStatus;
  61 + }
  62 +
  63 + public int getLastStatus() {
  64 + return lastStatus;
  65 + }
  66 +
  67 + public void setLastStatus(int lastStatus) {
  68 + this.lastStatus = lastStatus;
  69 + }
  70 +
  71 + public LocalDateTime getBeginTime() {
  72 + return beginTime;
  73 + }
  74 +
  75 + public void setBeginTime(LocalDateTime beginTime) {
  76 + this.beginTime = beginTime;
  77 + }
  78 +
  79 + public LocalDateTime getEndTime() {
  80 + return endTime;
  81 + }
  82 +
  83 + public void setEndTime(LocalDateTime endTime) {
  84 + this.endTime = endTime;
  85 + }
  86 +}
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeader/mapper/ShipmentHeaderMapper.java
1 1 package com.huaheng.project.shipment.shipmentHeader.mapper;
2 2  
  3 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentBillViewModel;
3 4 import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
4 5 import com.baomidou.mybatisplus.mapper.BaseMapper;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
5 8 import java.util.List;
6 9  
7 10 /**
... ... @@ -12,5 +15,21 @@ import java.util.List;
12 15 */
13 16 public interface ShipmentHeaderMapper extends BaseMapper<ShipmentHeader> {
14 17  
  18 + /**
  19 + * 将 发货单头表转到历史表
  20 + * @param code
  21 + * @return
  22 + */
  23 + int HeaderToHistory(@Param("code") String code);
  24 +
  25 + /**
  26 + * 将发货单明细表转到历史表
  27 + * @param code
  28 + * @return
  29 + */
  30 + int DetailToHistory(@Param("code") String code);
  31 +
  32 + List<ShipmentHeader> list(@Param("model") ShipmentBillViewModel shipmentBillViewModel);
  33 +
15 34 }
16 35  
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeader/service/IShipmentHeaderService.java
1 1 package com.huaheng.project.shipment.shipmentHeader.service;
2 2  
  3 +import com.baomidou.mybatisplus.plugins.Page;
  4 +import com.huaheng.framework.mybatisPlus.IPlusService;
  5 +import com.huaheng.framework.web.domain.AjaxResult;
3 6 import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
4 7 import com.baomidou.mybatisplus.service.IService;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
5 10 import java.util.List;
6 11  
7 12 /**
... ... @@ -10,7 +15,34 @@ import java.util.List;
10 15 * @author huaheng
11 16 * @date 2018-08-19
12 17 */
13   -public interface IShipmentHeaderService extends IService<ShipmentHeader> {
  18 +public interface IShipmentHeaderService extends IPlusService<ShipmentHeader> {
  19 +
  20 + AjaxResult<Page<ShipmentHeader>> list(ShipmentHeader condition, Page<ShipmentHeader> page) throws IllegalAccessException;
  21 +
  22 + AjaxResult insertHeard(ShipmentHeader shipmentHeader);
  23 +
  24 + AjaxResult updateHeard(ShipmentHeader shipmentHeader);
  25 +
  26 + @Transactional
  27 + AjaxResult<Integer> deleteHeaderAndDetail(Integer id) throws IllegalAccessException;
  28 +
  29 + AjaxResult updateShipmentStatus(int shipmentId) throws IllegalAccessException;
  30 +
  31 + /**
  32 + * 检查单据状态是否可以操作
  33 + * @param headerId
  34 + * @param status
  35 + * @return
  36 + */
  37 + AjaxResult<Integer> checkSatas(Integer headerId, Short status);
  38 +
  39 + /**
  40 + * 检查单据状态是否可以操作
  41 + * @param receiptCode
  42 + * @param status
  43 + * @return
  44 + */
  45 + AjaxResult<Integer> checkSatas(String receiptCode, Short status) throws IllegalAccessException;
14 46  
15 47 }
16 48  
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeader/service/ShipmentHeaderServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentHeader.service;
2 2  
3   -import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  3 +import com.baomidou.mybatisplus.plugins.Page;
  4 +import com.huaheng.common.utils.security.ShiroUtils;
  5 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
  6 +import com.huaheng.framework.web.domain.AjaxResult;
  7 +import com.huaheng.project.shipment.shipmentContainerHeader.service.IShipmentContainerHeaderService;
  8 +import com.huaheng.project.shipment.shipmentDetail.domain.ShipmentDetail;
  9 +import com.huaheng.project.shipment.shipmentDetail.service.IShipmentDetailService;
4 10 import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
5 11 import com.huaheng.project.shipment.shipmentHeader.mapper.ShipmentHeaderMapper;
  12 +import org.springframework.beans.factory.annotation.Autowired;
6 13 import org.springframework.stereotype.Service;
  14 +import org.springframework.transaction.annotation.Transactional;
  15 +import java.util.List;
  16 +import java.util.Map;
7 17  
8 18  
9 19 /**
... ... @@ -13,6 +23,185 @@ import org.springframework.stereotype.Service;
13 23 * @date 2018-08-19
14 24 */
15 25 @Service
16   -public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, ShipmentHeader> implements IShipmentHeaderService {
  26 +public class ShipmentHeaderServiceImpl extends PlusServiceImpl<ShipmentHeaderMapper, ShipmentHeader> implements IShipmentHeaderService {
  27 +
  28 + @Autowired
  29 + IShipmentDetailService shipmentDetailService;
  30 + @Autowired
  31 + IShipmentContainerHeaderService shipmentContainerHeaderService;
  32 + /**
  33 + * 获取出库单头
  34 + * @param condition
  35 + * @return
  36 + */
  37 + @Override
  38 + public AjaxResult<Page<ShipmentHeader>> list(ShipmentHeader condition, Page<ShipmentHeader> page) throws IllegalAccessException {
  39 + condition.setWarehouseId(ShiroUtils.getUser().getWarehouseId());
  40 + page = this.selectPage(page, condition);
  41 + return AjaxResult.success(page);
  42 + }
  43 +
  44 + /**
  45 + * 新增出库头表
  46 + * @param shipmentHeader
  47 + * @return
  48 + */
  49 + @Override
  50 + public AjaxResult insertHeard(ShipmentHeader shipmentHeader) {
  51 + shipmentHeader.setId(null);
  52 + shipmentHeader.setCreated(null);
  53 + shipmentHeader.setCreatedBy(ShiroUtils.getUser().getLoginName());
  54 + shipmentHeader.setLastUpdated(null);
  55 + shipmentHeader.setLastUpdatedBy(null);
  56 + if (this.insert(shipmentHeader))
  57 + return AjaxResult.success("");
  58 + else
  59 + return AjaxResult.error("");
  60 + }
  61 +
  62 + /**
  63 + * 修改出库头
  64 + * @param shipmentHeader
  65 + * @return
  66 + */
  67 + @Override
  68 + public AjaxResult updateHeard(ShipmentHeader shipmentHeader) {
  69 + ShipmentHeader sh = this.selectById(shipmentHeader.getId());
  70 + if(sh == null){
  71 + return AjaxResult.error("未找到出库单头");
  72 + }
  73 + if(sh.getFirstStatus()>199){
  74 + return AjaxResult.error("单据状态不允许进行单据内容修改");
  75 + }
  76 + shipmentHeader.setCreated(null);
  77 + shipmentHeader.setCreatedBy(null);
  78 + shipmentHeader.setLastUpdatedBy(ShiroUtils.getUser().getLoginName());
  79 + shipmentHeader.setLastUpdated(null);
  80 + if (this.updateById(shipmentHeader))
  81 + return AjaxResult.success("");
  82 + else
  83 + return AjaxResult.error("");
  84 + }
  85 +
  86 + /**
  87 + * 删除出库单
  88 + * @param id
  89 + * @return
  90 + */
  91 + @Override
  92 + @Transactional
  93 + public AjaxResult<Integer> deleteHeaderAndDetail(Integer id) throws IllegalAccessException {
  94 + ShipmentHeader shipmentHeader = this.selectById(id);
  95 + if (shipmentHeader == null) return AjaxResult.success("");
  96 + ShipmentDetail condition = new ShipmentDetail();
  97 + condition.setShipmentCode(shipmentHeader.getCode());
  98 + if (shipmentHeader.getFirstStatus() < 100)
  99 + {
  100 + this.deleteById(id);
  101 + shipmentDetailService.delete(condition);
  102 + return AjaxResult.success("");
  103 + }
  104 + else if (shipmentHeader.getFirstStatus() < 120)
  105 + {
  106 + this.baseMapper.HeaderToHistory(shipmentHeader.getCode());
  107 + this.baseMapper.DetailToHistory(shipmentHeader.getCode());
  108 + this.deleteById(id);
  109 + shipmentDetailService.delete(condition);
  110 + return AjaxResult.success("");
  111 + }
  112 + else
  113 + {
  114 + return AjaxResult.error("单据状态超过120已经不能删除");
  115 + }
  116 + }
  117 +
  118 +
  119 + /**
  120 + * 根据Id更新这个单据的首尾状态
  121 + * @param shipmentId
  122 + * @return
  123 + */
  124 + @Override
  125 + public AjaxResult updateShipmentStatus(int shipmentId) throws IllegalAccessException {
  126 + //获取这个单
  127 + ShipmentHeader shipmentHeader = this.selectById(shipmentId);
  128 + if(shipmentHeader==null){
  129 + return AjaxResult.error("单据未找到,Id:"+shipmentId);
  130 + }
  131 +
  132 + //查询是否有生成出库货箱,如果有,则返回出库货箱的最高与最低状态
  133 + Map<String,Integer> map = shipmentContainerHeaderService.getShipmentContainerMaxAndMinStatusByShipmentID(shipmentId);
  134 + if(map==null){
  135 + //说明没有货箱,则直接首位均为新建
  136 + shipmentHeader.setFirstStatus(0);
  137 + shipmentHeader.setLastStatus(0);
  138 + this.updateById(shipmentHeader);
  139 + }else {
  140 + int firstStatus = map.get("maxStatus");
  141 + int lastStatus = map.get("minStatus");
  142 + if(firstStatus<30){
  143 + shipmentHeader.setFirstStatus(200);
  144 + }
  145 + if(firstStatus==30){
  146 + shipmentHeader.setFirstStatus(300);
  147 + }
  148 + if(lastStatus<30){
  149 + shipmentHeader.setLastStatus(200);
  150 + }
  151 + if(lastStatus==30){
  152 + shipmentHeader.setLastStatus(300);
  153 + }
  154 + //是否存在未配盘的数量,如果是,则尾状态为新建
  155 + ShipmentDetail condition = new ShipmentDetail();
  156 + condition.setShipmentId(shipmentId);
  157 + List<ShipmentDetail> shipmentDetails = shipmentDetailService.selectListEntityByEqual(condition);
  158 + for(ShipmentDetail shipmentDetail : shipmentDetails){
  159 + if(shipmentDetail.getQtyCompleted().compareTo(shipmentDetail.getQty())!=0){
  160 + shipmentHeader.setLastStatus(0);
  161 + break;
  162 + }
  163 + }
  164 + this.updateById(shipmentHeader);
  165 + }
  166 +
  167 + return AjaxResult.success("");
  168 +
  169 + }
  170 +
  171 + @Override
  172 + public AjaxResult checkSatas(Integer headerId, Short status){
  173 + ShipmentHeader shipmentHeader = this.selectById(headerId);
  174 + if (shipmentHeader == null)
  175 + {
  176 + return AjaxResult.error("数据错误,没有表头!");
  177 + }
  178 + else if (shipmentHeader.getFirstStatus() > status)
  179 + {
  180 + return AjaxResult.error(String .join("单据状态超过" + status + "已经不可修改!"));
  181 + }
  182 + else
  183 + {
  184 + return AjaxResult.success("");
  185 + }
  186 + }
  187 +
  188 + @Override
  189 + public AjaxResult checkSatas(String ShipmentCode, Short status) throws IllegalAccessException {
  190 + ShipmentHeader condition = new ShipmentHeader();
  191 + condition.setCode(ShipmentCode);
  192 + List<ShipmentHeader> shipmentHeaders = this.selectListEntityByEqual(condition);
  193 + if (shipmentHeaders.size() < 1)
  194 + {
  195 + return AjaxResult.error("数据错误,没有表头!");
  196 + }
  197 + else if (shipmentHeaders.get(0).getFirstStatus() > status)
  198 + {
  199 + return AjaxResult.error("单据状态超过" + status + "已经不可修改!");
  200 + }
  201 + else
  202 + {
  203 + return AjaxResult.success("");
  204 + }
  205 + }
17 206  
18 207 }
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeaderHistory/service/IShipmentHeaderHistoryService.java
1 1 package com.huaheng.project.shipment.shipmentHeaderHistory.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.shipment.shipmentHeaderHistory.domain.ShipmentHeaderHistory;
4 5 import com.baomidou.mybatisplus.service.IService;
5 6 import java.util.List;
... ... @@ -10,7 +11,7 @@ import java.util.List;
10 11 * @author huaheng
11 12 * @date 2018-08-19
12 13 */
13   -public interface IShipmentHeaderHistoryService extends IService<ShipmentHeaderHistory> {
  14 +public interface IShipmentHeaderHistoryService extends IPlusService<ShipmentHeaderHistory> {
14 15  
15 16 }
16 17  
... ...
src/main/java/com/huaheng/project/shipment/shipmentHeaderHistory/service/ShipmentHeaderHistoryServiceImpl.java
1 1 package com.huaheng.project.shipment.shipmentHeaderHistory.service;
2 2  
3 3 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  4 +import com.huaheng.framework.mybatisPlus.PlusServiceImpl;
4 5 import com.huaheng.project.shipment.shipmentHeaderHistory.domain.ShipmentHeaderHistory;
5 6 import com.huaheng.project.shipment.shipmentHeaderHistory.mapper.ShipmentHeaderHistoryMapper;
6 7 import org.springframework.stereotype.Service;
... ... @@ -13,6 +14,6 @@ import org.springframework.stereotype.Service;
13 14 * @date 2018-08-19
14 15 */
15 16 @Service
16   -public class ShipmentHeaderHistoryServiceImpl extends ServiceImpl<ShipmentHeaderHistoryMapper, ShipmentHeaderHistory> implements IShipmentHeaderHistoryService {
  17 +public class ShipmentHeaderHistoryServiceImpl extends PlusServiceImpl<ShipmentHeaderHistoryMapper, ShipmentHeaderHistory> implements IShipmentHeaderHistoryService {
17 18  
18 19 }
... ...
src/main/java/com/huaheng/project/system/config/domain/Config.java
... ... @@ -8,7 +8,7 @@ import com.huaheng.framework.web.domain.BaseEntity;
8 8 *
9 9 * @author huaheng
10 10 */
11   -public class Config extends BaseEntity
  11 +public class Config extends BaseEntity<Config>
12 12 {
13 13 private static final long serialVersionUID = 1L;
14 14  
... ...
src/main/java/com/huaheng/project/system/dept/controller/DeptController.java
... ... @@ -104,11 +104,11 @@ public class DeptController extends BaseController
104 104 {
105 105 if (deptService.selectDeptCount(deptId) > 0)
106 106 {
107   - return error(1, "存在下级部门,不允许删除");
  107 + return error("存在下级部门,不允许删除");
108 108 }
109 109 if (deptService.checkDeptExistUser(deptId))
110 110 {
111   - return error(1, "部门存在用户,不允许删除");
  111 + return error("部门存在用户,不允许删除");
112 112 }
113 113 return toAjax(deptService.deleteDeptById(deptId));
114 114 }
... ...
src/main/java/com/huaheng/project/system/dept/domain/Dept.java
... ... @@ -7,7 +7,7 @@ import com.huaheng.framework.web.domain.BaseEntity;
7 7 *
8 8 * @author huaheng
9 9 */
10   -public class Dept extends BaseEntity
  10 +public class Dept extends BaseEntity<Dept>
11 11 {
12 12 private static final long serialVersionUID = 1L;
13 13 /** 部门ID */
... ...
src/main/java/com/huaheng/project/system/dict/controller/DictTypeController.java
... ... @@ -94,7 +94,7 @@ public class DictTypeController extends BaseController
94 94 * 修改字典类型
95 95 */
96 96 @GetMapping("/edit/{dictId}")
97   - public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
  97 + public String edit(@PathVariable("dictId") Integer dictId, ModelMap mmap)
98 98 {
99 99 mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
100 100 return prefix + "/edit";
... ... @@ -133,7 +133,7 @@ public class DictTypeController extends BaseController
133 133 */
134 134 @RequiresPermissions("system:dict:list")
135 135 @GetMapping("/detail/{dictId}")
136   - public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
  136 + public String detail(@PathVariable("dictId") Integer dictId, ModelMap mmap)
137 137 {
138 138 mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
139 139 mmap.put("dictList", dictTypeService.selectDictTypeAll());
... ...
src/main/java/com/huaheng/project/system/dict/domain/DictData.java
... ... @@ -2,23 +2,27 @@ package com.huaheng.project.system.dict.domain;
2 2  
3 3 import com.huaheng.framework.aspectj.lang.annotation.Excel;
4 4 import com.huaheng.framework.web.domain.BaseEntity;
  5 +import java.io.Serializable;
5 6  
6 7 /**
7 8 * 字典数据表 sys_dict_data
8 9 *
9 10 * @author huaheng
10 11 */
11   -public class DictData extends BaseEntity
  12 +public class DictData extends BaseEntity<DictData>
12 13 {
13 14 private static final long serialVersionUID = 1L;
14 15  
15 16 /** 字典编码 */
16 17 @Excel(name = "字典编码")
17   - private Long dictCode;
  18 + private Integer dictCode;
  19 +
  20 + /** 字典头id */
  21 + private Integer headerId;
18 22  
19 23 /** 字典排序 */
20 24 @Excel(name = "字典排序")
21   - private Long dictSort;
  25 + private Integer dictSort;
22 26  
23 27 /** 字典标签 */
24 28 @Excel(name = "字典标签")
... ... @@ -43,26 +47,38 @@ public class DictData extends BaseEntity
43 47 @Excel(name = "是否默认")
44 48 private String isDefault;
45 49  
46   - /** 状态(0正常 1停用) */
47   - @Excel(name = "状态")
48   - private String status;
  50 + /** 启用(0未启用 1已启用) */
  51 + @Excel(name = "启用")
  52 + private Boolean enable;
  53 +
  54 + /** 删除(0未删除 1已删除) */
  55 + @Excel(name = "删除")
  56 + private Boolean deleted;
49 57  
50   - public Long getDictCode()
  58 + public Integer getDictCode()
51 59 {
52 60 return dictCode;
53 61 }
54 62  
55   - public void setDictCode(Long dictCode)
  63 + public void setDictCode(Integer dictCode)
56 64 {
57 65 this.dictCode = dictCode;
58 66 }
59 67  
60   - public Long getDictSort()
  68 + public Integer getHeaderId() {
  69 + return headerId;
  70 + }
  71 +
  72 + public void setHeaderId(Integer headerId) {
  73 + this.headerId = headerId;
  74 + }
  75 +
  76 + public Integer getDictSort()
61 77 {
62 78 return dictSort;
63 79 }
64 80  
65   - public void setDictSort(Long dictSort)
  81 + public void setDictSort(Integer dictSort)
66 82 {
67 83 this.dictSort = dictSort;
68 84 }
... ... @@ -127,22 +143,31 @@ public class DictData extends BaseEntity
127 143 this.isDefault = isDefault;
128 144 }
129 145  
130   - public String getStatus()
131   - {
132   - return status;
  146 + public Boolean getEnable() {
  147 + return enable;
133 148 }
134 149  
135   - public void setStatus(String status)
136   - {
137   - this.status = status;
  150 + public void setEnable(Boolean enable) {
  151 + this.enable = enable;
  152 + }
  153 +
  154 + public Boolean getDeleted() {
  155 + return deleted;
138 156 }
139 157  
  158 + public void setDeleted(Boolean deleted) {
  159 + this.deleted = deleted;
  160 + }
  161 +
  162 + @Override
  163 + protected Serializable pkVal() { return dictCode;}
  164 +
140 165 @Override
141 166 public String toString()
142 167 {
143 168 return "DictData [dictCode=" + dictCode + ", dictSort=" + dictSort + ", dictLabel=" + dictLabel + ", dictValue="
144 169 + dictValue + ", dictType=" + dictType + ", cssClass=" + cssClass + ", isDefault=" + isDefault
145   - + ", status=" + status + "]";
  170 + + ", enable=" + enable + ", deleted=" + deleted + "]";
146 171 }
147 172  
148 173 }
... ...
src/main/java/com/huaheng/project/system/dict/domain/DictType.java
... ... @@ -3,18 +3,21 @@ package com.huaheng.project.system.dict.domain;
3 3 import com.huaheng.framework.aspectj.lang.annotation.Excel;
4 4 import com.huaheng.framework.web.domain.BaseEntity;
5 5  
  6 +import java.io.Serializable;
  7 +import java.util.Date;
  8 +
6 9 /**
7 10 * 字典类型对象 sys_dict_type
8 11 *
9 12 * @author huaheng
10 13 */
11   -public class DictType extends BaseEntity
  14 +public class DictType extends BaseEntity<DictData>
12 15 {
13 16 private static final long serialVersionUID = 1L;
14 17  
15 18 /** 字典主键 */
16 19 @Excel(name = "字典主键")
17   - private Long dictId;
  20 + private Integer dictId;
18 21  
19 22 /** 字典名称 */
20 23 @Excel(name = "字典名称")
... ... @@ -24,16 +27,29 @@ public class DictType extends BaseEntity
24 27 @Excel(name = "字典类型 ")
25 28 private String dictType;
26 29  
27   - /** 状态(0正常 1停用) */
28   - @Excel(name = "状态")
29   - private String status;
  30 + /** 仓库Id */
  31 + @Excel(name = "仓库Id")
  32 + private Integer warehouseId;
  33 +
  34 + /** 仓库编码 */
  35 + @Excel(name = "仓库编码")
  36 + private String warehouseCode;
  37 +
  38 + /** 启用(0未启用 1已启用) */
  39 + @Excel(name = "启用")
  40 + private Boolean enable;
30 41  
31   - public Long getDictId()
  42 + /** 删除(0未删除 1已删除) */
  43 + @Excel(name = "删除")
  44 + private Boolean deleted;
  45 +
  46 +
  47 + public Integer getDictId()
32 48 {
33 49 return dictId;
34 50 }
35 51  
36   - public void setDictId(Long dictId)
  52 + public void setDictId(Integer dictId)
37 53 {
38 54 this.dictId = dictId;
39 55 }
... ... @@ -58,21 +74,46 @@ public class DictType extends BaseEntity
58 74 this.dictType = dictType;
59 75 }
60 76  
61   - public String getStatus()
62   - {
63   - return status;
  77 + public Integer getWarehouseId() {
  78 + return warehouseId;
64 79 }
65 80  
66   - public void setStatus(String status)
67   - {
68   - this.status = status;
  81 + public void setWarehouseId(Integer warehouseId) {
  82 + this.warehouseId = warehouseId;
  83 + }
  84 +
  85 + public String getWarehouseCode() {
  86 + return warehouseCode;
  87 + }
  88 +
  89 + public void setWarehouseCode(String warehouseCode) {
  90 + this.warehouseCode = warehouseCode;
69 91 }
70 92  
  93 + public Boolean getEnable() {
  94 + return enable;
  95 + }
  96 +
  97 + public void setEnable(Boolean enable) {
  98 + this.enable = enable;
  99 + }
  100 +
  101 + public Boolean getDeleted() {
  102 + return deleted;
  103 + }
  104 +
  105 + public void setDeleted(Boolean deleted) {
  106 + this.deleted = deleted;
  107 + }
  108 +
  109 + @Override
  110 + protected Serializable pkVal() { return dictId;}
  111 +
71 112 @Override
72 113 public String toString()
73 114 {
74   - return "DictType [dictId=" + dictId + ", dictName=" + dictName + ", dictType=" + dictType + ", status=" + status
75   - + "]";
  115 + return "DictType [dictId=" + dictId + ", dictName=" + dictName + ", dictType=" + dictType +
  116 + ", enable=" + enable + ", deleted=" + deleted + ", warehouseId=" + warehouseId + ", warehouseCode=" + warehouseCode + "]";
76 117 }
77 118  
78 119 }
... ...
src/main/java/com/huaheng/project/system/dict/mapper/DictDataMapper.java
1 1 package com.huaheng.project.system.dict.mapper;
2 2  
3 3 import java.util.List;
  4 +
  5 +import com.baomidou.mybatisplus.mapper.BaseMapper;
  6 +import com.huaheng.project.shipment.shipmentHeader.domain.ShipmentHeader;
4 7 import org.apache.ibatis.annotations.Param;
5 8 import com.huaheng.project.system.dict.domain.DictData;
6 9  
... ... @@ -9,7 +12,7 @@ import com.huaheng.project.system.dict.domain.DictData;
9 12 *
10 13 * @author huaheng
11 14 */
12   -public interface DictDataMapper
  15 +public interface DictDataMapper extends BaseMapper<DictData>
13 16 {
14 17  
15 18 /**
... ...
src/main/java/com/huaheng/project/system/dict/mapper/DictTypeMapper.java
1 1 package com.huaheng.project.system.dict.mapper;
2 2  
3 3 import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.baomidou.mybatisplus.mapper.BaseMapper;
4 7 import org.apache.ibatis.annotations.Mapper;
5 8 import com.huaheng.project.system.dict.domain.DictType;
  9 +import org.apache.ibatis.annotations.Param;
6 10  
7 11 /**
8 12 * 字典表 数据层
... ... @@ -10,7 +14,7 @@ import com.huaheng.project.system.dict.domain.DictType;
10 14 * @author huaheng
11 15 */
12 16 @Mapper
13   -public interface DictTypeMapper
  17 +public interface DictTypeMapper extends BaseMapper<DictType>
14 18 {
15 19 /**
16 20 * 根据条件分页查询字典类型
... ... @@ -33,7 +37,7 @@ public interface DictTypeMapper
33 37 * @param dictId 字典类型ID
34 38 * @return 字典类型
35 39 */
36   - public DictType selectDictTypeById(Long dictId);
  40 + public DictType selectDictTypeById(Integer dictId);
37 41  
38 42 /**
39 43 * 通过字典ID删除字典信息
... ... @@ -41,7 +45,7 @@ public interface DictTypeMapper
41 45 * @param dictId 字典ID
42 46 * @return 结果
43 47 */
44   - public int deleteDictTypeById(Long dictId);
  48 + public int deleteDictTypeById(Integer dictId);
45 49  
46 50 /**
47 51 * 批量删除字典类型
... ... @@ -49,7 +53,7 @@ public interface DictTypeMapper
49 53 * @param ids 需要删除的数据
50 54 * @return 结果
51 55 */
52   - public int deleteDictTypeByIds(Long[] ids);
  56 + public int deleteDictTypeByIds(Integer[] ids);
53 57  
54 58 /**
55 59 * 新增字典类型信息
... ... @@ -74,4 +78,11 @@ public interface DictTypeMapper
74 78 * @return 结果
75 79 */
76 80 public DictType checkDictTypeUnique(String dictType);
  81 +
  82 + /**
  83 + * 获取指定仓库id的字典
  84 + * @param wareHouseId
  85 + * @return
  86 + */
  87 + List<Map<String, Object>> getConfig(@Param("wareHouseId") Integer wareHouseId, @Param("identifier") String identifier);
77 88 }
... ...
src/main/java/com/huaheng/project/system/dict/service/DictDataServiceImpl.java
1 1 package com.huaheng.project.system.dict.service;
2 2  
3   -import java.util.List;
  3 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  4 +import com.baomidou.mybatisplus.service.impl.ServiceImpl;
  5 +import com.huaheng.common.exception.service.ServiceException;
  6 +import com.huaheng.common.utils.MybatisPlus.PlusUtils;
  7 +import com.huaheng.project.system.dict.domain.DictType;
4 8 import org.springframework.beans.factory.annotation.Autowired;
5 9 import org.springframework.stereotype.Service;
6 10 import com.huaheng.common.support.Convert;
... ... @@ -8,16 +12,19 @@ import com.huaheng.common.utils.security.ShiroUtils;
8 12 import com.huaheng.project.system.dict.domain.DictData;
9 13 import com.huaheng.project.system.dict.mapper.DictDataMapper;
10 14  
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
11 18 /**
12 19 * 字典 业务层处理
13 20 *
14 21 * @author huaheng
15 22 */
16 23 @Service
17   -public class DictDataServiceImpl implements IDictDataService
  24 +public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements IDictDataService
18 25 {
19 26 @Autowired
20   - private DictDataMapper dictDataMapper;
  27 + private IDictTypeService dictTypeService;
21 28  
22 29 /**
23 30 * 根据条件分页查询字典数据
... ... @@ -28,7 +35,7 @@ public class DictDataServiceImpl implements IDictDataService
28 35 @Override
29 36 public List<DictData> selectDictDataList(DictData dictData)
30 37 {
31   - return dictDataMapper.selectDictDataList(dictData);
  38 + return baseMapper.selectDictDataList(dictData);
32 39 }
33 40  
34 41 /**
... ... @@ -40,7 +47,7 @@ public class DictDataServiceImpl implements IDictDataService
40 47 @Override
41 48 public List<DictData> selectDictDataByType(String dictType)
42 49 {
43   - return dictDataMapper.selectDictDataByType(dictType);
  50 + return baseMapper.selectDictDataByType(dictType);
44 51 }
45 52  
46 53 /**
... ... @@ -53,7 +60,7 @@ public class DictDataServiceImpl implements IDictDataService
53 60 @Override
54 61 public String selectDictLabel(String dictType, String dictValue)
55 62 {
56   - return dictDataMapper.selectDictLabel(dictType, dictValue);
  63 + return baseMapper.selectDictLabel(dictType, dictValue);
57 64 }
58 65  
59 66 /**
... ... @@ -65,7 +72,7 @@ public class DictDataServiceImpl implements IDictDataService
65 72 @Override
66 73 public DictData selectDictDataById(Long dictCode)
67 74 {
68   - return dictDataMapper.selectDictDataById(dictCode);
  75 + return baseMapper.selectDictDataById(dictCode);
69 76 }
70 77  
71 78 /**
... ... @@ -77,7 +84,7 @@ public class DictDataServiceImpl implements IDictDataService
77 84 @Override
78 85 public int deleteDictDataById(Long dictCode)
79 86 {
80   - return dictDataMapper.deleteDictDataById(dictCode);
  87 + return baseMapper.deleteDictDataById(dictCode);
81 88 }
82 89  
83 90 /**
... ... @@ -89,7 +96,7 @@ public class DictDataServiceImpl implements IDictDataService
89 96 @Override
90 97 public int deleteDictDataByIds(String ids)
91 98 {
92   - return dictDataMapper.deleteDictDataByIds(Convert.toStrArray(ids));
  99 + return baseMapper.deleteDictDataByIds(Convert.toStrArray(ids));
93 100 }
94 101  
95 102 /**
... ... @@ -102,7 +109,7 @@ public class DictDataServiceImpl implements IDictDataService
102 109 public int insertDictData(DictData dictData)
103 110 {
104 111 dictData.setCreateBy(ShiroUtils.getLoginName());
105   - return dictDataMapper.insertDictData(dictData);
  112 + return baseMapper.insertDictData(dictData);
106 113 }
107 114  
108 115 /**
... ... @@ -115,7 +122,38 @@ public class DictDataServiceImpl implements IDictDataService
115 122 public int updateDictData(DictData dictData)
116 123 {
117 124 dictData.setUpdateBy(ShiroUtils.getLoginName());
118   - return dictDataMapper.updateDictData(dictData);
  125 + return baseMapper.updateDictData(dictData);
  126 + }
  127 +
  128 + /**
  129 + * 验证指定仓库id的code是否存在
  130 + * @param dictValue
  131 + * @param warehouseId
  132 + * @param type
  133 + * @return
  134 + */
  135 + @Override
  136 + public String checkConfig(Integer warehouseId, String type, String dictValue) throws IllegalAccessException {
  137 +
  138 + DictType dictType = new DictType();
  139 + dictType.setWarehouseId(warehouseId);
  140 + dictType.setDictType(type);
  141 + dictType.setDeleted(false);
  142 + dictType.setEnable(true);
  143 + EntityWrapper<DictType> entityWrapper = PlusUtils.getWrapper(dictType);
  144 + entityWrapper.setSqlSelect("id");
  145 + List<Map<String, Object>> list = dictTypeService.selectMaps(entityWrapper);
  146 + if (list.size() < 1)
  147 + throw new ServiceException("字典表头没有入库单类型字典,请在字典表头设置");
  148 +
  149 + DictData dictData = new DictData();
  150 + dictData.setHeaderId(Integer.parseInt(list.get(0).get("id").toString()));
  151 + dictData.setDictType(dictValue);
  152 + dictData.setDictValue(dictValue);
  153 + dictData = baseMapper.selectOne(dictData);
  154 + if (dictData == null)
  155 + throw new ServiceException("没有该入库类型,请在字典表设置");
  156 + return dictData.getDictValue();
119 157 }
120 158  
121 159 }
... ...
src/main/java/com/huaheng/project/system/dict/service/DictTypeServiceImpl.java
1 1 package com.huaheng.project.system.dict.service;
2 2  
3   -import java.util.List;
  3 +import com.baomidou.mybatisplus.service.impl.ServiceImpl;
4 4 import org.springframework.beans.factory.annotation.Autowired;
5 5 import org.springframework.stereotype.Service;
6 6 import com.huaheng.common.constant.UserConstants;
... ... @@ -10,6 +10,8 @@ import com.huaheng.common.utils.security.ShiroUtils;
10 10 import com.huaheng.project.system.dict.domain.DictType;
11 11 import com.huaheng.project.system.dict.mapper.DictDataMapper;
12 12 import com.huaheng.project.system.dict.mapper.DictTypeMapper;
  13 +import java.util.List;
  14 +import java.util.Map;
13 15  
14 16 /**
15 17 * 字典 业务层处理
... ... @@ -17,12 +19,9 @@ import com.huaheng.project.system.dict.mapper.DictTypeMapper;
17 19 * @author huaheng
18 20 */
19 21 @Service
20   -public class DictTypeServiceImpl implements IDictTypeService
  22 +public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements IDictTypeService
21 23 {
22 24 @Autowired
23   - private DictTypeMapper dictTypeMapper;
24   -
25   - @Autowired
26 25 private DictDataMapper dictDataMapper;
27 26  
28 27 /**
... ... @@ -34,7 +33,7 @@ public class DictTypeServiceImpl implements IDictTypeService
34 33 @Override
35 34 public List<DictType> selectDictTypeList(DictType dictType)
36 35 {
37   - return dictTypeMapper.selectDictTypeList(dictType);
  36 + return baseMapper.selectDictTypeList(dictType);
38 37 }
39 38  
40 39 /**
... ... @@ -45,19 +44,12 @@ public class DictTypeServiceImpl implements IDictTypeService
45 44 @Override
46 45 public List<DictType> selectDictTypeAll()
47 46 {
48   - return dictTypeMapper.selectDictTypeAll();
  47 + return baseMapper.selectDictTypeAll();
49 48 }
50 49  
51   - /**
52   - * 根据字典类型ID查询信息
53   - *
54   - * @param dictId 字典类型ID
55   - * @return 字典类型
56   - */
57 50 @Override
58   - public DictType selectDictTypeById(Long dictId)
59   - {
60   - return dictTypeMapper.selectDictTypeById(dictId);
  51 + public DictType selectDictTypeById(Integer dictId) {
  52 + return baseMapper.selectById(dictId);
61 53 }
62 54  
63 55 /**
... ... @@ -67,9 +59,9 @@ public class DictTypeServiceImpl implements IDictTypeService
67 59 * @return 结果
68 60 */
69 61 @Override
70   - public int deleteDictTypeById(Long dictId)
  62 + public int deleteDictTypeById(Integer dictId)
71 63 {
72   - return dictTypeMapper.deleteDictTypeById(dictId);
  64 + return baseMapper.deleteDictTypeById(dictId);
73 65 }
74 66  
75 67 /**
... ... @@ -81,8 +73,8 @@ public class DictTypeServiceImpl implements IDictTypeService
81 73 @Override
82 74 public int deleteDictTypeByIds(String ids) throws Exception
83 75 {
84   - Long[] dictIds = Convert.toLongArray(ids);
85   - for (Long dictId : dictIds)
  76 + Integer[] dictIds = Convert.toIntArray(ids);
  77 + for (Integer dictId : dictIds)
86 78 {
87 79 DictType dictType = selectDictTypeById(dictId);
88 80 if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
... ... @@ -91,7 +83,7 @@ public class DictTypeServiceImpl implements IDictTypeService
91 83 }
92 84 }
93 85  
94   - return dictTypeMapper.deleteDictTypeByIds(dictIds);
  86 + return baseMapper.deleteDictTypeByIds(dictIds);
95 87 }
96 88  
97 89 /**
... ... @@ -104,7 +96,7 @@ public class DictTypeServiceImpl implements IDictTypeService
104 96 public int insertDictType(DictType dictType)
105 97 {
106 98 dictType.setCreateBy(ShiroUtils.getLoginName());
107   - return dictTypeMapper.insertDictType(dictType);
  99 + return baseMapper.insertDictType(dictType);
108 100 }
109 101  
110 102 /**
... ... @@ -117,26 +109,39 @@ public class DictTypeServiceImpl implements IDictTypeService
117 109 public int updateDictType(DictType dictType)
118 110 {
119 111 dictType.setUpdateBy(ShiroUtils.getLoginName());
120   - DictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
  112 + DictType oldDict = baseMapper.selectDictTypeById(dictType.getDictId());
121 113 dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
122   - return dictTypeMapper.updateDictType(dictType);
  114 + return baseMapper.updateDictType(dictType);
123 115 }
124 116  
125 117 /**
126 118 * 校验字典类型称是否唯一
127 119 *
128   - * @param dictType 字典类型
  120 + * @param dict 字典类型
129 121 * @return 结果
130 122 */
131 123 @Override
132 124 public String checkDictTypeUnique(DictType dict)
133 125 {
134 126 Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
135   - DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
  127 + DictType dictType = baseMapper.checkDictTypeUnique(dict.getDictType());
136 128 if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
137 129 {
138 130 return UserConstants.DICT_TYPE_NOT_UNIQUE;
139 131 }
140 132 return UserConstants.DICT_TYPE_UNIQUE;
141 133 }
  134 +
  135 + /**
  136 + * 验证指定仓库的标识是否存在
  137 + * @param warehouseId
  138 + * @param identifier
  139 + * @return
  140 + */
  141 + @Override
  142 + public List<Map<String, Object>> getConfig(Integer warehouseId, String identifier) {
  143 + return baseMapper.getConfig(warehouseId, identifier);
  144 + }
  145 +
  146 +
142 147 }
... ...
src/main/java/com/huaheng/project/system/dict/service/IDictDataService.java
1 1 package com.huaheng.project.system.dict.service;
2 2  
3   -import java.util.List;
  3 +import com.baomidou.mybatisplus.service.IService;
4 4 import com.huaheng.project.system.dict.domain.DictData;
  5 +import java.util.List;
5 6  
6 7 /**
7 8 * 字典 业务层
8 9 *
9 10 * @author huaheng
10 11 */
11   -public interface IDictDataService
  12 +public interface IDictDataService extends IService<DictData>
12 13 {
13 14  
14 15 /**
... ... @@ -76,4 +77,13 @@ public interface IDictDataService
76 77 */
77 78 public int updateDictData(DictData dictData);
78 79  
  80 + /**
  81 + * 检查 指定标识的代码在字典是否存在,并且返回字典名字id
  82 + * @param warehouseId
  83 + * @param identifier
  84 + * @param code
  85 + * @return
  86 + */
  87 + String checkConfig(Integer warehouseId, String identifier, String code) throws IllegalAccessException;
  88 +
79 89 }
... ...
src/main/java/com/huaheng/project/system/dict/service/IDictTypeService.java
1 1 package com.huaheng.project.system.dict.service;
2 2  
3   -import java.util.List;
  3 +import com.baomidou.mybatisplus.service.IService;
4 4 import com.huaheng.project.system.dict.domain.DictType;
  5 +import java.util.List;
  6 +import java.util.Map;
5 7  
6 8 /**
7 9 * 字典 业务层
8 10 *
9 11 * @author huaheng
10 12 */
11   -public interface IDictTypeService
  13 +public interface IDictTypeService extends IService<DictType>
12 14 {
13 15 /**
14 16 * 根据条件分页查询字典类型
... ... @@ -31,7 +33,7 @@ public interface IDictTypeService
31 33 * @param dictId 字典类型ID
32 34 * @return 字典类型
33 35 */
34   - public DictType selectDictTypeById(Long dictId);
  36 + public DictType selectDictTypeById(Integer dictId);
35 37  
36 38 /**
37 39 * 通过字典ID删除字典信息
... ... @@ -39,7 +41,7 @@ public interface IDictTypeService
39 41 * @param dictId 字典ID
40 42 * @return 结果
41 43 */
42   - public int deleteDictTypeById(Long dictId);
  44 + public int deleteDictTypeById(Integer dictId);
43 45  
44 46 /**
45 47 * 批量删除字典类型
... ... @@ -73,4 +75,14 @@ public interface IDictTypeService
73 75 * @return 结果
74 76 */
75 77 public String checkDictTypeUnique(DictType dictType);
  78 +
  79 + /**
  80 + * 获取指定仓库的字典列表
  81 + * @param warehouseId
  82 + * @param identifier
  83 + * @return
  84 + */
  85 + List<Map<String, Object>> getConfig(Integer warehouseId, String identifier);
  86 +
  87 +
76 88 }
... ...
src/main/java/com/huaheng/project/system/menu/controller/MenuController.java
... ... @@ -62,11 +62,11 @@ public class MenuController extends BaseController
62 62 {
63 63 if (menuService.selectCountMenuByParentId(menuId) > 0)
64 64 {
65   - return error(1, "存在子菜单,不允许删除");
  65 + return error("存在子菜单,不允许删除");
66 66 }
67 67 if (menuService.selectCountRoleMenuByMenuId(menuId) > 0)
68 68 {
69   - return error(1, "菜单已分配,不允许删除");
  69 + return error("菜单已分配,不允许删除");
70 70 }
71 71 return toAjax(menuService.deleteMenuById(menuId));
72 72 }
... ...
src/main/java/com/huaheng/project/system/menu/domain/Menu.java
... ... @@ -9,7 +9,7 @@ import com.huaheng.framework.web.domain.BaseEntity;
9 9 *
10 10 * @author huaheng
11 11 */
12   -public class Menu extends BaseEntity
  12 +public class Menu extends BaseEntity<Menu>
13 13 {
14 14 private static final long serialVersionUID = 1L;
15 15 /** 菜单ID */
... ...
src/main/java/com/huaheng/project/system/menu/mapper/MenuMapper.java
... ... @@ -72,7 +72,7 @@ public interface MenuMapper
72 72 * @param parentId 菜单父ID
73 73 * @return 结果
74 74 */
75   - public int selectCountMenuByParentId(Long parentId);
  75 + Integer selectCountMenuByParentId(Long parentId);
76 76  
77 77 /**
78 78 * 新增菜单信息
... ... @@ -80,7 +80,7 @@ public interface MenuMapper
80 80 * @param menu 菜单信息
81 81 * @return 结果
82 82 */
83   - public int insertMenu(Menu menu);
  83 + int insertMenu(Menu menu);
84 84  
85 85 /**
86 86 * 修改菜单信息
... ... @@ -88,7 +88,7 @@ public interface MenuMapper
88 88 * @param menu 菜单信息
89 89 * @return 结果
90 90 */
91   - public int updateMenu(Menu menu);
  91 + int updateMenu(Menu menu);
92 92  
93 93 /**
94 94 * 校验菜单名称是否唯一
... ... @@ -96,6 +96,6 @@ public interface MenuMapper
96 96 * @param menuName 菜单名称
97 97 * @return 结果
98 98 */
99   - public Menu checkMenuNameUnique(String menuName);
  99 + Menu checkMenuNameUnique(String menuName);
100 100  
101 101 }
... ...
src/main/java/com/huaheng/project/system/menu/service/MenuServiceImpl.java
... ... @@ -222,7 +222,7 @@ public class MenuServiceImpl implements IMenuService
222 222 /**
223 223 * 查询子菜单数量
224 224 *
225   - * @param menuId 菜单ID
  225 + * @param parentId 菜单ID
226 226 * @return 结果
227 227 */
228 228 @Override
... ...
src/main/java/com/huaheng/project/system/notice/domain/Notice.java
... ... @@ -7,7 +7,7 @@ import com.huaheng.framework.web.domain.BaseEntity;
7 7 *
8 8 * @author huaheng
9 9 */
10   -public class Notice extends BaseEntity
  10 +public class Notice extends BaseEntity<Notice>
11 11 {
12 12 private static final long serialVersionUID = 1L;
13 13  
... ...
src/main/java/com/huaheng/project/system/role/domain/Role.java
... ... @@ -9,7 +9,7 @@ import com.huaheng.framework.web.domain.BaseEntity;
9 9 *
10 10 * @author huaheng
11 11 */
12   -public class Role extends BaseEntity
  12 +public class Role extends BaseEntity<Role>
13 13 {
14 14 private static final long serialVersionUID = 1L;
15 15  
... ...
src/main/java/com/huaheng/project/system/user/domain/ClientType.java 0 → 100644
  1 +package com.huaheng.project.system.user.domain;
  2 +
  3 +public enum ClientType {
  4 +
  5 + PC(0),
  6 + Mobile(1);
  7 +
  8 + private int data;
  9 +
  10 + ClientType(int data) {
  11 + this.data = data;
  12 + }
  13 +
  14 + int getValue() {
  15 + return data;
  16 + }
  17 +
  18 +}
... ...
src/main/java/com/huaheng/project/system/user/domain/User.java
... ... @@ -12,7 +12,7 @@ import com.huaheng.project.system.dept.domain.Dept;
12 12 *
13 13 * @author huaheng
14 14 */
15   -public class User extends BaseEntity
  15 +public class User extends BaseEntity<User>
16 16 {
17 17 private static final long serialVersionUID = 1L;
18 18  
... ... @@ -73,6 +73,18 @@ public class User extends BaseEntity
73 73 /** 部门对象 */
74 74 private Dept dept;
75 75  
  76 + /** 货主ID */
  77 + private Integer companyId;
  78 +
  79 + /** 货主编码 */
  80 + private String companyCode;
  81 +
  82 + /** 仓库ID */
  83 + private Integer warehouseId;
  84 +
  85 + /** 仓库编码 */
  86 + private String warehouseCode;
  87 +
76 88 /** 角色组 */
77 89 private Long[] roleIds;
78 90  
... ... @@ -109,6 +121,38 @@ public class User extends BaseEntity
109 121 this.deptId = deptId;
110 122 }
111 123  
  124 + public Integer getCompanyId() {
  125 + return companyId;
  126 + }
  127 +
  128 + public void setCompanyId(Integer companyId) {
  129 + this.companyId = companyId;
  130 + }
  131 +
  132 + public String getCompanyCode() {
  133 + return companyCode;
  134 + }
  135 +
  136 + public void setCompanyCode(String companyCode) {
  137 + this.companyCode = companyCode;
  138 + }
  139 +
  140 + public Integer getWarehouseId() {
  141 + return warehouseId;
  142 + }
  143 +
  144 + public void setWarehouseId(Integer warehouseId) {
  145 + this.warehouseId = warehouseId;
  146 + }
  147 +
  148 + public String getWarehouseCode() {
  149 + return warehouseCode;
  150 + }
  151 +
  152 + public void setWarehouseCode(String warehouseCode) {
  153 + this.warehouseCode = warehouseCode;
  154 + }
  155 +
112 156 public Long getParentId()
113 157 {
114 158 return parentId;
... ...
src/main/java/com/huaheng/project/system/user/mapper/UserMapper.java
1 1 package com.huaheng.project.system.user.mapper;
2 2  
3 3 import com.huaheng.project.system.user.domain.User;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
4 6 import java.util.List;
  7 +import java.util.Map;
5 8  
6 9 /**
7 10 * 用户表 数据层
... ... @@ -106,4 +109,18 @@ public interface UserMapper
106 109 * @return 结果
107 110 */
108 111 public User checkEmailUnique(String email);
  112 +
  113 + /**
  114 + * 根据用户id查询该用户所有仓库
  115 + * @param userId
  116 + * @return
  117 + */
  118 + public List<Map<String, Object>> getWarehouseByUserId(@Param("userId")Integer userId);
  119 +
  120 + /**
  121 + * 根据用户编码查询该用户所有仓库
  122 + * @param userCode
  123 + * @return
  124 + */
  125 + public List<Map<String, Object>> getWarehouseByUserCode(@Param("userCode")String userCode);
109 126 }
... ...
src/main/java/com/huaheng/project/system/user/service/IUserService.java
1 1 package com.huaheng.project.system.user.service;
2 2  
  3 +import com.huaheng.project.system.user.domain.ClientType;
3 4 import com.huaheng.project.system.user.domain.User;
4 5 import java.util.List;
  6 +import java.util.Map;
5 7  
6 8 /**
7 9 * 用户 业务层
... ... @@ -139,4 +141,24 @@ public interface IUserService
139 141 * @return 结果
140 142 */
141 143 public String selectUserCompanyGroup(Long userId);
  144 +
  145 + /**
  146 + * 根据用户id获取用户能操作的仓库
  147 + * @param userId
  148 + * @return
  149 + */
  150 + public List<Map<String, Object>> getWarehouseByUserId(Integer userId);
  151 +
  152 + /**
  153 + * 根据用户code获取用户能操作的仓库
  154 + * @param userCode
  155 + * @return
  156 + */
  157 + public List<Map<String, Object>> getWarehouseByUserCode(String userCode);
  158 +
  159 + /**
  160 + * 获取用户所有的模块
  161 + * @return
  162 + */
  163 + public List<Map<String, Object>> getModules(Integer warehouseId, String warehouseCode, ClientType clientType);
142 164 }
... ...
src/main/java/com/huaheng/project/system/user/service/UserServiceImpl.java
1 1 package com.huaheng.project.system.user.service;
2 2  
3 3 import java.util.ArrayList;
  4 +import java.util.HashSet;
4 5 import java.util.List;
  6 +import java.util.Map;
5 7  
6 8 import com.huaheng.project.general.company.domain.Company;
7 9 import com.huaheng.project.general.company.mapper.CompanyMapper;
  10 +import com.huaheng.project.system.user.domain.ClientType;
8 11 import com.huaheng.project.system.user.domain.UserCompany;
9 12 import com.huaheng.project.system.user.mapper.UserCompanyMapper;
  13 +import org.apache.shiro.SecurityUtils;
10 14 import org.springframework.beans.factory.annotation.Autowired;
11 15 import org.springframework.stereotype.Service;
12 16 import com.huaheng.common.constant.UserConstants;
... ... @@ -353,4 +357,89 @@ public class UserServiceImpl implements IUserService
353 357 }
354 358 return idsStr.toString();
355 359 }
  360 +
  361 + @Override
  362 + public List<Map<String, Object>> getWarehouseByUserId(Integer userId){
  363 + return userMapper.getWarehouseByUserId(userId);
  364 + }
  365 +
  366 + @Override
  367 + public List<Map<String, Object>> getWarehouseByUserCode(String userCode){
  368 +// if (userCode.equals("superAdmin"))
  369 +// {
  370 +// return warehouseService.selectListMapByEqual(columnList, condition);
  371 +// }
  372 +// else
  373 +// {
  374 + return userMapper.getWarehouseByUserCode(userCode);
  375 +// }
  376 + }
  377 +
  378 + @Override
  379 + public List<Map<String, Object>> getModules(Integer warehouseId, String warehouseCode, ClientType clientType)
  380 + {
  381 +// List<String> permList= new ArrayList();
  382 +// List<String> moduleColumnList = new ArrayList();
  383 +// moduleColumnList.add("id");
  384 +// moduleColumnList.add("type");
  385 +// moduleColumnList.add("parentId");
  386 +// moduleColumnList.add("url");
  387 +// moduleColumnList.add("moduleName");
  388 +// moduleColumnList.add("modulePhto");
  389 +// SysModules moduleCondition = new SysModules();
  390 +// if (clientType == ClientType.PC)
  391 +// moduleCondition.setIsMobile(false);
  392 +// else if (clientType == ClientType.Mobile)
  393 +// moduleCondition.setIsMobile(true);
  394 +
  395 + List<Map<String, Object>> returnList = new ArrayList();
  396 +// List<Map<String, Object>> moduleList = sysModulesService.selectListMapByEqual(moduleColumnList, moduleCondition);
  397 +//
  398 +// //从session取出用户信息
  399 +// UserInfo userInfo = (UserInfo) SecurityUtils.getSubject().getPrincipal();
  400 +// if (userInfo.getCode().equals("superAdmin"))
  401 +// {
  402 +// List<String> columnList = new ArrayList<>();
  403 +// columnList.add("id");
  404 +// SysPerm condition = new SysPerm();
  405 +// condition.setEnable(true);
  406 +// condition.setDeleted(false);
  407 +// List<Map<String, Object>> permListMap = sysPermService.selectListMapByEqual(columnList, condition);
  408 +// for (Map<String, Object> map : permListMap) {
  409 +// permList.add(map.get("id").toString());
  410 +// }
  411 +// returnList = moduleList;
  412 +// }
  413 +// else {
  414 +// //不是超级管理员的话,需要验证对应的仓库权限
  415 +// List<Map<String, Object>> permListMap = userInfoMapper.getPermByUserId(userInfo.getId(), warehouseId);
  416 +// for (Map<String, Object> permMap : permListMap) {
  417 +// permList.add(permMap.get("id").toString());
  418 +// }
  419 +// // 如果模块类型为2,且id等于权限的模块id,那么就添加到返回的模块列表
  420 +// for (Map<String, Object> moduleMap : moduleList) {
  421 +// if(moduleMap.get("type").equals("2")) {
  422 +// for (Map<String, Object> permMap : permListMap) {
  423 +// if (moduleMap.get("id").equals(permMap.get("moduleId"))) {
  424 +// returnList.add(moduleMap);
  425 +// break;
  426 +// }
  427 +// }
  428 +// }
  429 +// }
  430 +// // 将模块列表和返回模块列表进行对比,把父模块也放进去
  431 +// for (Map<String, Object> moduleMap : moduleList)
  432 +// for (Map<String, Object> returnMap : returnList)
  433 +// if (moduleMap.get("id").equals(returnMap.get("parentId"))) {
  434 +// returnList.add(moduleMap);
  435 +// break;
  436 +// }
  437 +// }
  438 +// userInfo.setWarehouseId(warehouseId);
  439 +// userInfo.setWarehouseCode(warehouseCode);
  440 +// userInfo.setPerms(new HashSet(permList));
  441 +
  442 + return returnList;
  443 + }
  444 +
356 445 }
... ...
src/main/java/com/huaheng/project/task/task/domain/ShipmentTaskCreateModel.java 0 → 100644
  1 +package com.huaheng.project.task.task.domain;
  2 +
  3 +/**
  4 + * 出库任务创建模型类
  5 + */
  6 +public class ShipmentTaskCreateModel {
  7 + /**
  8 + * 需要创建任务的出库货箱列表
  9 + */
  10 + private int[] shipmentContainerHeaderIds;
  11 + /**
  12 + * 是否优先创建整出任务,1,表示可以创建整出就优先创建整出,不能的话就创建拣选出;2,表示只创建拣选出;
  13 + */
  14 + private int taskType;
  15 +
  16 + /**
  17 + * 优先级
  18 + */
  19 + private short priority;
  20 +
  21 + public short getPriority() {
  22 + return priority;
  23 + }
  24 +
  25 + public void setPriority(short priority) {
  26 + this.priority = priority;
  27 + }
  28 +
  29 + public int[] getShipmentContainerHeaderIds() {
  30 + return shipmentContainerHeaderIds;
  31 + }
  32 +
  33 + public void setShipmentContainerHeaderIds(int[] shipmentContainerHeaderIds) {
  34 + this.shipmentContainerHeaderIds = shipmentContainerHeaderIds;
  35 + }
  36 +
  37 + public int getTaskType() {
  38 + return taskType;
  39 + }
  40 +
  41 + public void setTaskType(int taskType) {
  42 + this.taskType = taskType;
  43 + }
  44 +}
... ...
src/main/java/com/huaheng/project/task/task/domain/ShipmentTaskCreateResponse.java 0 → 100644
  1 +package com.huaheng.project.task.task.domain;
  2 +
  3 +/**
  4 + * 由出库货箱创建任务后,返回给前端的创建详情
  5 + */
  6 +public class ShipmentTaskCreateResponse {
  7 + private int shipmentContainerId;
  8 + //true创建成功
  9 + private boolean flag;
  10 + private String msg;
  11 +
  12 + public int getShipmentContainerId() {
  13 + return shipmentContainerId;
  14 + }
  15 +
  16 + public void setShipmentContainerId(int shipmentContainerId) {
  17 + this.shipmentContainerId = shipmentContainerId;
  18 + }
  19 +
  20 + public boolean isFlag() {
  21 + return flag;
  22 + }
  23 +
  24 + public void setFlag(boolean flag) {
  25 + this.flag = flag;
  26 + }
  27 +
  28 + public String getMsg() {
  29 + return msg;
  30 + }
  31 +
  32 + public void setMsg(String msg) {
  33 + this.msg = msg;
  34 + }
  35 +}
... ...
src/main/java/com/huaheng/project/task/task/domain/TaskDetailSearchModel.java 0 → 100644
  1 +package com.huaheng.project.task.task.domain;
  2 +
  3 +
  4 +
  5 +/**
  6 + * 任务明细查询类
  7 + */
  8 +public class TaskDetailSearchModel {
  9 + private int taskHeaderId;
  10 +
  11 + public int getTaskHeaderId() {
  12 + return taskHeaderId;
  13 + }
  14 +
  15 + public void setTaskHeaderId(int taskHeaderId) {
  16 + this.taskHeaderId = taskHeaderId;
  17 + }
  18 +}
... ...
src/main/java/com/huaheng/project/task/task/domain/TaskDetailsResponseModel.java 0 → 100644
  1 +package com.huaheng.project.task.task.domain;
  2 +
  3 +public class TaskDetailsResponseModel {
  4 + private int taskDetailId;
  5 + private boolean isSuccess;
  6 + private String message;
  7 +
  8 + public TaskDetailsResponseModel(int taskDetailId, boolean isSuccess, String message) {
  9 + this.taskDetailId = taskDetailId;
  10 + this.isSuccess = isSuccess;
  11 + this.message = message;
  12 + }
  13 +
  14 + public int getTaskDetailId() {
  15 + return taskDetailId;
  16 + }
  17 +
  18 + public void setTaskDetailId(int taskDetailId) {
  19 + this.taskDetailId = taskDetailId;
  20 + }
  21 +
  22 + public boolean isSuccess() {
  23 + return isSuccess;
  24 + }
  25 +
  26 + public void setSuccess(boolean success) {
  27 + isSuccess = success;
  28 + }
  29 +
  30 + public String getMessage() {
  31 + return message;
  32 + }
  33 +
  34 + public void setMessage(String message) {
  35 + this.message = message;
  36 + }
  37 +}
... ...
src/main/java/com/huaheng/project/task/task/mapper/TaskMapper.java
1 1 package com.huaheng.project.task.task.mapper;
2 2  
  3 +import com.baomidou.mybatisplus.plugins.Page;
3 4 import com.huaheng.project.task.task.domain.Task;
4 5 import com.baomidou.mybatisplus.mapper.BaseMapper;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
5 8 import java.util.List;
  9 +import java.util.Map;
6 10  
7 11 /**
8 12 * 立库任务 数据层
... ... @@ -12,5 +16,31 @@ import java.util.List;
12 16 */
13 17 public interface TaskMapper extends BaseMapper<Task> {
14 18  
  19 + /**
  20 + *
  21 + * @param location
  22 + * @param warehouse
  23 + * @return
  24 + */
  25 + Task getTaskByLocationCode(@Param("location") String location, @Param("warehouse") String warehouse);
  26 +
  27 + /**
  28 + * 获取容器里面的物料信息
  29 + * @param containerCode
  30 + * @return
  31 + */
  32 + List<Map<String, Object>> getContainerMaterial(@Param("containerCode") String containerCode);
  33 +
  34 +
  35 + /**
  36 + * 更改组盘表状态
  37 + * @param taskId
  38 + * @return
  39 + */
  40 + List<Map<String, Object>> getTaskReceipt(@Param("taskId") Integer taskId);
  41 +
  42 +
  43 + List<Task> getTasks(Page page, @Param("model") Task task);
  44 +
15 45 }
16 46  
... ...
src/main/java/com/huaheng/project/task/task/service/ITaskService.java
1 1 package com.huaheng.project.task.task.service;
2 2  
  3 +import com.huaheng.framework.mybatisPlus.IPlusService;
3 4 import com.huaheng.project.task.task.domain.Task;
4   -import com.baomidou.mybatisplus.service.IService;
5   -import java.util.List;
  5 +
6 6  
7 7 /**
8 8 * 立库任务 服务层
... ... @@ -10,7 +10,7 @@ import java.util.List;
10 10 * @author huaheng
11 11 * @date 2018-08-19
12 12 */
13   -public interface ITaskService extends IService<Task> {
  13 +public interface ITaskService extends IPlusService<Task> {
14 14  
15 15 }
16 16  
... ...