Commit e8833f851044042caa496591104d543df7f1c91f
1 parent
a038cd7d
操作日志第二版提交
Signed-off-by: TanYibin <5491541@qq.com>
Showing
16 changed files
with
188 additions
and
113 deletions
ant-design-vue-jeecg/src/views/system/DictList.vue
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <a-row :gutter="12"> |
8 | 8 | <a-col :md="7" :sm="8"> |
9 | 9 | <a-form-item label="字典名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}"> |
10 | - <a-input placeholder="请输入字典名称" v-model="queryParam.dictName"></a-input> | |
10 | + <j-input placeholder="请输入字典名称" v-model="queryParam.dictName"></j-input> | |
11 | 11 | </a-form-item> |
12 | 12 | </a-col> |
13 | 13 | <a-col :md="7" :sm="8"> |
... | ... |
ant-design-vue-jeecg/src/views/system/monitor/OperationLog.vue
... | ... | @@ -11,18 +11,30 @@ |
11 | 11 | </a-col> |
12 | 12 | <a-col :xl="6" :lg="7" :md="8" :sm="24"> |
13 | 13 | <a-form-item label="业务类型"> |
14 | - <a-input placeholder="请输入业务类型" v-model="queryParam.bizType"></a-input> | |
14 | + <j-dict-select-tag placeholder="请选择业务类型" v-model="queryParam.bizType" dictCode="operation_log_type"/> | |
15 | 15 | </a-form-item> |
16 | 16 | </a-col> |
17 | 17 | <a-col :xl="6" :lg="7" :md="8" :sm="24"> |
18 | + <a-form-item label="业务标签"> | |
19 | + <j-multi-select-tag placeholder="请选择业务标签" v-model="queryParam.bizTag" dictCode="operation_log_tag"/> | |
20 | + </a-form-item> | |
21 | + </a-col> | |
22 | + <template v-if="toggleSearchStatus"> | |
23 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
18 | 24 | <a-form-item label="操作内容"> |
19 | 25 | <j-input placeholder="请输入操作内容" v-model="queryParam.operationMsg"></j-input> |
20 | 26 | </a-form-item> |
21 | 27 | </a-col> |
28 | + </template> | |
22 | 29 | <a-col :xl="6" :lg="7" :md="8" :sm="24"> |
23 | 30 | <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons"> |
24 | 31 | <a-button type="primary" @click="searchQuery" icon="search">查询</a-button> |
32 | + <a-button type="primary" @click="handleExportXls('操作记录')" icon="download" style="margin-left: 8px">导出</a-button> | |
25 | 33 | <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button> |
34 | + <a @click="handleToggleSearch" style="margin-left: 8px"> | |
35 | + {{ toggleSearchStatus ? '收起' : '展开' }} | |
36 | + <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/> | |
37 | + </a> | |
26 | 38 | </span> |
27 | 39 | </a-col> |
28 | 40 | </a-row> |
... | ... | @@ -30,14 +42,6 @@ |
30 | 42 | </div> |
31 | 43 | <!-- 查询区域-END --> |
32 | 44 | |
33 | - <!-- 操作按钮区域 --> | |
34 | - <div class="table-operator"> | |
35 | - <a-button type="primary" icon="download" @click="handleExportXls('操作记录表')">导出</a-button> | |
36 | - <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel"> | |
37 | - <a-button type="primary" icon="import">导入</a-button> | |
38 | - </a-upload> | |
39 | - </div> | |
40 | - | |
41 | 45 | <!-- table区域-begin --> |
42 | 46 | <div> |
43 | 47 | <a-table |
... | ... | @@ -113,6 +117,11 @@ |
113 | 117 | dataIndex: 'bizType' |
114 | 118 | }, |
115 | 119 | { |
120 | + title:'业务标签', | |
121 | + align:"center", | |
122 | + dataIndex: 'bizTag' | |
123 | + }, | |
124 | + { | |
116 | 125 | title:'操作内容', |
117 | 126 | align:"center", |
118 | 127 | dataIndex: 'operationMsg' |
... | ... | @@ -133,21 +142,6 @@ |
133 | 142 | dataIndex: 'operationCostTime' |
134 | 143 | }, |
135 | 144 | { |
136 | - title:'方法返回内容', | |
137 | - align:"center", | |
138 | - dataIndex: 'contentReturn' | |
139 | - }, | |
140 | - { | |
141 | - title:'方法异常内容', | |
142 | - align:"center", | |
143 | - dataIndex: 'contentException' | |
144 | - }, | |
145 | - { | |
146 | - title:'操作人ID', | |
147 | - align:"center", | |
148 | - dataIndex: 'operatorId' | |
149 | - }, | |
150 | - { | |
151 | 145 | title:'操作人姓名', |
152 | 146 | align:"center", |
153 | 147 | dataIndex: 'operatorName' |
... | ... | @@ -207,7 +201,6 @@ |
207 | 201 | fieldList.push({type:'int',value:'operationCostTime',text:'操作耗时',dictCode:''}) |
208 | 202 | fieldList.push({type:'string',value:'contentReturn',text:'方法返回内容',dictCode:''}) |
209 | 203 | fieldList.push({type:'string',value:'contentException',text:'方法异常内容',dictCode:''}) |
210 | - fieldList.push({type:'string',value:'operatorId',text:'操作人ID',dictCode:''}) | |
211 | 204 | fieldList.push({type:'string',value:'operatorName',text:'操作人姓名',dictCode:''}) |
212 | 205 | this.superFieldList = fieldList |
213 | 206 | } |
... | ... |
ant-design-vue-jeecg/src/views/system/monitor/modules/OperationLogForm.vue
... | ... | @@ -14,6 +14,11 @@ |
14 | 14 | </a-form-model-item> |
15 | 15 | </a-col> |
16 | 16 | <a-col :span="24"> |
17 | + <a-form-model-item label="业务标签" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bizTag"> | |
18 | + <a-input v-model="model.bizTag" placeholder="请输入业务标签" ></a-input> | |
19 | + </a-form-model-item> | |
20 | + </a-col> | |
21 | + <a-col :span="24"> | |
17 | 22 | <a-form-model-item label="操作内容" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operationMsg"> |
18 | 23 | <a-input v-model="model.operationMsg" placeholder="请输入操作内容" ></a-input> |
19 | 24 | </a-form-model-item> |
... | ... | @@ -44,11 +49,6 @@ |
44 | 49 | </a-form-model-item> |
45 | 50 | </a-col> |
46 | 51 | <a-col :span="24"> |
47 | - <a-form-model-item label="操作人ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operatorId"> | |
48 | - <a-input v-model="model.operatorId" placeholder="请输入操作人ID" ></a-input> | |
49 | - </a-form-model-item> | |
50 | - </a-col> | |
51 | - <a-col :span="24"> | |
52 | 52 | <a-form-model-item label="操作人姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operatorName"> |
53 | 53 | <a-input v-model="model.operatorName" placeholder="请输入操作人姓名" ></a-input> |
54 | 54 | </a-form-model-item> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/cas/controller/CasClientController.java
... | ... | @@ -6,6 +6,8 @@ import javax.servlet.http.HttpServletRequest; |
6 | 6 | import javax.servlet.http.HttpServletResponse; |
7 | 7 | |
8 | 8 | import cn.hutool.crypto.SecureUtil; |
9 | +import cn.monitor4all.logRecord.annotation.OperationLog; | |
10 | + | |
9 | 11 | import org.apache.commons.lang.StringUtils; |
10 | 12 | import org.jeecg.common.api.vo.Result; |
11 | 13 | import org.jeecg.common.constant.CacheConstant; |
... | ... | @@ -71,7 +73,7 @@ public class CasClientController { |
71 | 73 | if (StringUtils.isEmpty(principal)) { |
72 | 74 | throw new Exception("No principal was found in the response from the CAS server."); |
73 | 75 | } |
74 | - log.info("-------token----username---" + principal); | |
76 | + log.info("---token---username---" + principal); | |
75 | 77 | // 1. 校验用户是否有效 |
76 | 78 | SysUser sysUser = sysUserService.getUserByName(principal); |
77 | 79 | result = sysUserService.checkUserIsEffective(sysUser); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java
... | ... | @@ -9,24 +9,21 @@ import org.jeecg.common.api.vo.Result; |
9 | 9 | import org.jeecg.modules.wms.api.acs.entity.AcsStatus; |
10 | 10 | import org.jeecg.modules.wms.api.acs.service.IAcsService; |
11 | 11 | import org.jeecg.modules.wms.config.address.service.IAddressService; |
12 | -import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication; | |
13 | -import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication.ApiAuthenticationBuild; | |
14 | 12 | import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; |
15 | 13 | import org.jeecg.modules.wms.framework.controller.HuahengBaseController; |
16 | 14 | import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService; |
17 | -import org.jeecg.utils.OkHttpUtils; | |
15 | +import org.jeecg.utils.HuahengJwtUtil; | |
18 | 16 | import org.jeecg.utils.StringUtils; |
19 | 17 | import org.jeecg.utils.constant.QuantityConstant; |
20 | 18 | import org.springframework.transaction.annotation.Transactional; |
21 | 19 | import org.springframework.web.bind.annotation.PostMapping; |
22 | 20 | import org.springframework.web.bind.annotation.RequestBody; |
23 | -import org.springframework.web.bind.annotation.RequestHeader; | |
24 | 21 | import org.springframework.web.bind.annotation.RequestMapping; |
25 | 22 | import org.springframework.web.bind.annotation.ResponseBody; |
26 | 23 | import org.springframework.web.bind.annotation.RestController; |
27 | 24 | |
28 | -import com.alibaba.fastjson.JSON; | |
29 | - | |
25 | +import cn.monitor4all.logRecord.annotation.OperationLog; | |
26 | +import cn.monitor4all.logRecord.context.LogRecordContext; | |
30 | 27 | import io.swagger.annotations.ApiOperation; |
31 | 28 | |
32 | 29 | @RestController |
... | ... | @@ -46,12 +43,15 @@ public class AcsController extends HuahengBaseController { |
46 | 43 | // @ApiLogger(apiName = "API接口第三方Token校验测试", from = "TEST") |
47 | 44 | @ResponseBody |
48 | 45 | @PostMapping(value = "/testTokenCheck") |
46 | + @OperationLog(bizType = "'物料追踪'", tag = "'入库完成'", bizId = "#paramMap.get('bizId')",extra = "#jsonString", msg = "'测试操作日志'", | |
47 | + operatorId = "#username", recordReturnValue = true) | |
49 | 48 | public Result<?> testTokenCheck(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { |
50 | - String audience = ApiAuthentication.getInstance().getAudience(); | |
51 | - String url = "http://127.0.0.1:8080/wms/api/wms/acs/testTokenCheck"; | |
52 | - String body = OkHttpUtils.sendPostByJsonStr(url, JSON.toJSONString(paramMap)); | |
49 | +// String audience = ApiAuthentication.getInstance().getAudience(); | |
50 | +// String url = "http://localhost:8080/wms/api/wms/acs/testTokenCheck"; | |
51 | +// String body = OkHttpUtils.sendPostByJsonStr(url, JSON.toJSONString(paramMap)); | |
53 | 52 | // String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_AGV_TASK_ASSIGN); |
54 | - return Result.ok(body); | |
53 | + LogRecordContext.putVariable("username", HuahengJwtUtil.getCurrentOperator()); | |
54 | + return Result.ok(); | |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/dto/ApiAuthentication.java
... | ... | @@ -22,7 +22,7 @@ public class ApiAuthentication { |
22 | 22 | private String operator; |
23 | 23 | |
24 | 24 | /** Token使用方 */ |
25 | - private String audience; // 观众,相当于接受者 | |
25 | + private String audience = "Unknown"; // 观众,相当于接受者 | |
26 | 26 | |
27 | 27 | /** Token签发方(WMS) */ |
28 | 28 | private String issuer = HuahengJwtUtil.HUAHENG_SYSTEM_ID; |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/controller/TestController.java
... | ... | @@ -2,29 +2,27 @@ package org.jeecg.modules.wms.framework.controller; |
2 | 2 | |
3 | 3 | import java.security.NoSuchAlgorithmException; |
4 | 4 | import java.security.SecureRandom; |
5 | -import java.util.Date; | |
6 | 5 | import java.util.Map; |
6 | +import java.util.concurrent.ConcurrentHashMap; | |
7 | 7 | |
8 | 8 | import javax.servlet.http.HttpServletRequest; |
9 | 9 | |
10 | 10 | import org.jeecg.common.api.vo.Result; |
11 | -import org.jeecg.common.aspect.annotation.AutoLog; | |
12 | -import org.jeecg.modules.system.entity.SysDataLog; | |
13 | 11 | import org.jeecg.modules.system.service.ISysDataLogService; |
14 | -import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; | |
12 | +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; | |
13 | +import org.jeecg.utils.HuahengJwtUtil; | |
15 | 14 | import org.jeecg.utils.HuahengRedisUtil; |
16 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
17 | -import org.springframework.transaction.annotation.Transactional; | |
18 | 16 | import org.springframework.web.bind.annotation.PostMapping; |
19 | 17 | import org.springframework.web.bind.annotation.RequestBody; |
20 | -import org.springframework.web.bind.annotation.RequestMapping; | |
21 | 18 | import org.springframework.web.bind.annotation.ResponseBody; |
22 | 19 | import org.springframework.web.bind.annotation.RestController; |
23 | 20 | |
24 | 21 | import com.alibaba.fastjson.JSON; |
25 | -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
26 | -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |
22 | +import com.alibaba.fastjson.TypeReference; | |
27 | 23 | |
24 | +import cn.monitor4all.logRecord.annotation.OperationLog; | |
25 | +import cn.monitor4all.logRecord.context.LogRecordContext; | |
28 | 26 | import lombok.extern.slf4j.Slf4j; |
29 | 27 | |
30 | 28 | /** |
... | ... | @@ -41,8 +39,7 @@ public class TestController extends HuahengBaseController { |
41 | 39 | |
42 | 40 | @Autowired |
43 | 41 | private ISysDataLogService sysDataLogService; |
44 | - | |
45 | - | |
42 | + | |
46 | 43 | // @ApiLogger(apiName = "API接口第三方Token校验测试", from = "TEST") |
47 | 44 | // @ResponseBody |
48 | 45 | // @PostMapping(value = "/api/wms/testTokenCheck") |
... | ... | @@ -51,42 +48,54 @@ public class TestController extends HuahengBaseController { |
51 | 48 | // |
52 | 49 | // return new Result<>(); |
53 | 50 | // } |
54 | - | |
55 | 51 | |
56 | - @AutoLog(value = "TestController-testRedis") | |
52 | +// @AutoLog(value = "TestController-testRedis") | |
57 | 53 | @ResponseBody |
58 | 54 | @PostMapping(value = "/test/testRedis") |
59 | - public Result<?> testRedis(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { | |
60 | - | |
61 | -// log.info("testRedis in paramMap:{}", JSON.toJSONString(paramMap)); | |
62 | -// String key = "testKey"; | |
63 | -// Map<String, ReceiptHeader> receiptHeaderMap = new ConcurrentHashMap<String, ReceiptHeader>(); | |
64 | -// ReceiptHeader receiptHeader = new ReceiptHeader(); | |
65 | -// receiptHeader.setCode("001"); | |
66 | -// receiptHeaderMap.put("receiptHeaderKey", receiptHeader); | |
67 | -// Map<String, ReceiptHeader> value = redisUtil.getAndSet(key, receiptHeaderMap, new TypeReference<Map<String, ReceiptHeader>>() {}, 10); | |
68 | -// Long rxpireTime = redisUtil.getExpire(key); | |
69 | -// log.info("redisUtil.getAndSet {} -> {} rxpireTime -> {}", key, JSON.toJSONString(value), rxpireTime); | |
70 | -// | |
71 | -// Thread.sleep(2000l); | |
55 | + @OperationLog(bizType = "'物料追踪'", tag = "'分配库位'", bizId = "#paramMap.get('bizId')",extra = "#jsonString", msg = "'测试操作日志'", | |
56 | + operatorId = "#username", recordReturnValue = true) | |
57 | + public Result<?> testRedis(@RequestBody Map<String, String> paramMap, HttpServletRequest request) throws InterruptedException { | |
58 | + Result result = new Result<>(); | |
59 | + String testString = "我是testString1"; | |
60 | + LogRecordContext.putVariable("testString1", testString); | |
61 | + testString = "我是testString2"; | |
62 | + LogRecordContext.putVariable("testString2", testString); | |
63 | + result.setMessage(testString); | |
64 | + log.info("testRedis in paramMap:{}", JSON.toJSONString(paramMap)); | |
65 | + String key = "testKey"; | |
66 | + Map<String, ReceiptHeader> receiptHeaderMap = new ConcurrentHashMap<String, ReceiptHeader>(); | |
67 | + ReceiptHeader receiptHeader = new ReceiptHeader(); | |
68 | + receiptHeader.setCode(paramMap.get("bizId")); | |
69 | + receiptHeaderMap.put("receiptHeaderKey", receiptHeader); | |
70 | + LogRecordContext.putVariable("jsonString", JSON.toJSONString(receiptHeaderMap)); | |
71 | + Map<String, ReceiptHeader> value = redisUtil.getAndSet(key, receiptHeaderMap, new TypeReference<Map<String, ReceiptHeader>>() {}, 10); | |
72 | + Long rxpireTime = redisUtil.getExpire(key); | |
73 | + log.info("redisUtil.getAndSet {} -> {} rxpireTime -> {}", key, JSON.toJSONString(value), rxpireTime); | |
74 | + LogRecordContext.putVariable("username", HuahengJwtUtil.getCurrentOperator()); | |
75 | +// result.setSuccess(false); | |
76 | +// LogRecordContext.putVariable("isSuccess", result.isSuccess()); | |
77 | + | |
78 | + Thread.sleep(2000l); | |
79 | +// throw new RuntimeException("自定义失败"); | |
80 | + return result; | |
72 | 81 | // receiptHeaderMap = redisUtil.get(key, new TypeReference<Map<String, ReceiptHeader>>() {}); |
73 | 82 | // rxpireTime = redisUtil.getExpire(key); |
74 | 83 | // log.info("redisUtil.get {} sleep 2s -> {} rxpireTime -> {}", key, JSON.toJSONString(value), rxpireTime); |
75 | 84 | |
76 | - Result result = handleMultiProcess("testRedis", paramMap.get("username"), new MultiProcessListener() { | |
77 | - | |
78 | - @Override | |
79 | - @Transactional(timeout = 10) | |
80 | - public Result<?> doProcess() throws Exception { | |
81 | - LambdaUpdateWrapper<SysDataLog> updateWrapper = new UpdateWrapper().lambda(); | |
82 | - updateWrapper.set(SysDataLog::getUpdateTime, new Date()); | |
83 | - updateWrapper.eq(SysDataLog::getId, 10); | |
84 | - Thread.sleep(1000); | |
85 | - sysDataLogService.update(updateWrapper); | |
86 | - return new Result<>(); | |
87 | - } | |
88 | - | |
89 | - }); | |
85 | +// Result result = handleMultiProcess("testRedis", paramMap.get("username"), new MultiProcessListener() { | |
86 | +// | |
87 | +// @Override | |
88 | +// @Transactional(timeout = 10) | |
89 | +// public Result<?> doProcess() throws Exception { | |
90 | +// LambdaUpdateWrapper<SysDataLog> updateWrapper = new UpdateWrapper().lambda(); | |
91 | +// updateWrapper.set(SysDataLog::getUpdateTime, new Date()); | |
92 | +// updateWrapper.eq(SysDataLog::getId, 10); | |
93 | +// Thread.sleep(1000); | |
94 | +// sysDataLogService.update(updateWrapper); | |
95 | +// return new Result<>(); | |
96 | +// } | |
97 | +// | |
98 | +// }); | |
90 | 99 | |
91 | 100 | // Long count = redisUtil.decr("countKey", 10); |
92 | 101 | // rxpireTime = redisUtil.getExpire("countKey"); |
... | ... | @@ -119,8 +128,8 @@ public class TestController extends HuahengBaseController { |
119 | 128 | // rxpireTime = redisUtil.getExpire("countKey"); |
120 | 129 | // log.info("countKey sleep 10s get -> {} rxpireTime -> {}", count, rxpireTime); |
121 | 130 | // log.info("countKey hasKey -> {}",redisUtil.hasKey("countKey")); |
122 | - | |
123 | - return result; | |
131 | +// LogRecordContext.putVariable("result", result); | |
132 | +// return result; | |
124 | 133 | } |
125 | 134 | |
126 | 135 | private int generateInt(int min, int max) throws NoSuchAlgorithmException { |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/operation/controller/OperationLogController.java
... | ... | @@ -58,6 +58,7 @@ public class OperationLogController extends JeecgController<OperationLog, IOpera |
58 | 58 | public Result<IPage<OperationLog>> queryPageList(OperationLog operationLog, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
59 | 59 | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) { |
60 | 60 | QueryWrapper<OperationLog> queryWrapper = QueryGenerator.initQueryWrapper(operationLog, req.getParameterMap()); |
61 | + queryWrapper.orderByAsc("operation_time"); | |
61 | 62 | Page<OperationLog> page = new Page<OperationLog>(pageNo, pageSize); |
62 | 63 | IPage<OperationLog> pageList = operationLogService.page(page, queryWrapper); |
63 | 64 | return Result.OK(pageList); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/operation/entity/OperationLog.java
... | ... | @@ -43,6 +43,10 @@ public class OperationLog implements Serializable { |
43 | 43 | @Excel(name = "业务类型", width = 15) |
44 | 44 | @ApiModelProperty(value = "业务类型") |
45 | 45 | private java.lang.String bizType; |
46 | + /**业务标签*/ | |
47 | + @Excel(name = "业务标签", width = 15) | |
48 | + @ApiModelProperty(value = "业务标签") | |
49 | + private java.lang.String bizTag; | |
46 | 50 | /**操作内容*/ |
47 | 51 | @Excel(name = "操作内容", width = 15) |
48 | 52 | @ApiModelProperty(value = "操作内容") |
... | ... | @@ -67,10 +71,6 @@ public class OperationLog implements Serializable { |
67 | 71 | @Excel(name = "方法异常内容", width = 15) |
68 | 72 | @ApiModelProperty(value = "方法异常内容") |
69 | 73 | private java.lang.String contentException; |
70 | - /**操作人ID*/ | |
71 | - @Excel(name = "操作人ID", width = 15) | |
72 | - @ApiModelProperty(value = "操作人ID") | |
73 | - private java.lang.String operatorId; | |
74 | 74 | /**操作人姓名*/ |
75 | 75 | @Excel(name = "操作人姓名", width = 15) |
76 | 76 | @ApiModelProperty(value = "操作人姓名") |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/operation/service/impl/OperationLogServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.monitor.operation.service.impl; |
2 | 2 | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.List; | |
5 | + | |
3 | 6 | import org.jeecg.modules.wms.monitor.operation.entity.OperationLog; |
4 | 7 | import org.jeecg.modules.wms.monitor.operation.mapper.OperationLogMapper; |
5 | 8 | import org.jeecg.modules.wms.monitor.operation.service.IOperationLogService; |
9 | +import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerDetail; | |
10 | +import org.jeecg.utils.StringUtils; | |
6 | 11 | import org.springframework.stereotype.Service; |
12 | +import org.springframework.util.CollectionUtils; | |
7 | 13 | |
8 | 14 | import com.alibaba.fastjson.JSON; |
9 | 15 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
10 | 16 | |
17 | +import cn.hutool.core.util.StrUtil; | |
11 | 18 | import cn.monitor4all.logRecord.bean.LogDTO; |
12 | 19 | import cn.monitor4all.logRecord.service.IOperationLogGetService; |
13 | 20 | import lombok.extern.slf4j.Slf4j; |
... | ... | @@ -25,26 +32,54 @@ public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, Ope |
25 | 32 | @Override |
26 | 33 | public boolean createLog(LogDTO logDTO) throws Exception { |
27 | 34 | try { |
28 | - log.debug(">>>>>> create OperationLog: [{}]", JSON.toJSONString(logDTO)); | |
29 | - if (null == logDTO.getBizId()) { | |
30 | - log.error(">>>>>> create OperationLog bizId is null"); | |
31 | - return false; | |
35 | + log.debug(">>>>>> create OperationLog:{} <<<<<<", JSON.toJSONString(logDTO)); | |
36 | + List<OperationLog> operationLogList = new ArrayList<OperationLog>(); | |
37 | + if (!StringUtils.isEmpty(logDTO.getExtra())) { | |
38 | + if (logDTO.getBizType().equals("物料追踪") && logDTO.getTag().equals("入库组盘")) { | |
39 | + List<ReceiptContainerDetail> receiptContainerDetailList = JSON.parseArray(logDTO.getExtra(), ReceiptContainerDetail.class); | |
40 | + if (CollectionUtils.isEmpty(receiptContainerDetailList)) { | |
41 | + return true; | |
42 | + } | |
43 | + for (ReceiptContainerDetail receiptContainerDetail : receiptContainerDetailList) { | |
44 | + if (receiptContainerDetail == null || receiptContainerDetail.getUniqueCode() == null) { | |
45 | + continue; | |
46 | + } | |
47 | + String msg = StrUtil.format("上游单号:{},入库单据号:{},仓库编码:{},托盘编码:{},物料编码:{},入库数量:{}", receiptContainerDetail.getReferCode(), | |
48 | + receiptContainerDetail.getReceiptCode(), receiptContainerDetail.getWarehouseCode(), receiptContainerDetail.getReceiptContainerId(), | |
49 | + receiptContainerDetail.getMaterialCode(), receiptContainerDetail.getQty()); | |
50 | + OperationLog operationLog = new OperationLog(); | |
51 | + operationLog.setBizId(receiptContainerDetail.getUniqueCode()); | |
52 | + operationLog.setBizType(logDTO.getBizType()); | |
53 | + operationLog.setBizTag(logDTO.getTag()); | |
54 | + operationLog.setContentException(StringUtils.substring(logDTO.getException(), 0, 1000)); | |
55 | + operationLog.setContentReturn(StringUtils.substring(logDTO.getReturnStr(), 0, 1000)); | |
56 | + operationLog.setOperationCostTime(logDTO.getExecutionTime()); | |
57 | + operationLog.setOperationMsg(StringUtils.substring(msg, 0, 1000)); | |
58 | + operationLog.setOperationStatus(logDTO.getSuccess().equals(true) ? 1 : 0); | |
59 | + operationLog.setOperationTime(logDTO.getOperateDate()); | |
60 | + operationLog.setOperatorName(logDTO.getOperatorId()); | |
61 | + operationLogList.add(operationLog); | |
62 | + } | |
63 | + } | |
64 | + } | |
65 | + if (!StringUtils.isEmpty(logDTO.getBizId())) { | |
66 | + OperationLog operationLog = new OperationLog(); | |
67 | + operationLog.setBizId(logDTO.getBizId()); | |
68 | + operationLog.setBizType(logDTO.getBizType()); | |
69 | + operationLog.setBizTag(logDTO.getTag()); | |
70 | + operationLog.setContentException(StringUtils.substring(logDTO.getException(), 0, 1000)); | |
71 | + operationLog.setContentReturn(StringUtils.substring(logDTO.getReturnStr(), 0, 1000)); | |
72 | + operationLog.setOperationCostTime(logDTO.getExecutionTime()); | |
73 | + operationLog.setOperationMsg(StringUtils.substring(logDTO.getMsg(), 0, 1000)); | |
74 | + operationLog.setOperationStatus(logDTO.getSuccess().equals(true) ? 1 : 0); | |
75 | + operationLog.setOperationTime(logDTO.getOperateDate()); | |
76 | + operationLog.setOperatorName(logDTO.getOperatorId()); | |
77 | + operationLogList.add(operationLog); | |
32 | 78 | } |
33 | - OperationLog operationLog = new OperationLog(); | |
34 | - operationLog.setBizId(logDTO.getBizId()); | |
35 | - operationLog.setBizType(logDTO.getBizType()); | |
36 | - operationLog.setContentException(logDTO.getException()); | |
37 | - operationLog.setContentReturn(logDTO.getReturnStr()); | |
38 | - operationLog.setOperationCostTime(logDTO.getExecutionTime()); | |
39 | - operationLog.setOperationMsg(logDTO.getMsg()); | |
40 | - operationLog.setOperationStatus(logDTO.getSuccess().equals(true) ? 1 : 0); | |
41 | - operationLog.setOperationTime(logDTO.getOperateDate()); | |
42 | - operationLog.setOperatorId(logDTO.getOperatorId()); | |
43 | - operationLog.setOperatorName(logDTO.getOperatorId()); | |
44 | - this.save(operationLog); | |
79 | + this.saveBatch(operationLogList); | |
45 | 80 | return true; |
46 | 81 | } catch (Exception e) { |
47 | - log.error(">>>>>> create OperationLog error:{}", e.getMessage(), e); | |
82 | + log.error(">>>>>> create OperationLog error:{} <<<<<<", e.getMessage(), e); | |
48 | 83 | return false; |
49 | 84 | } |
50 | 85 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/entity/ReceiptContainerDetail.java
... | ... | @@ -50,6 +50,10 @@ public class ReceiptContainerDetail implements Serializable { |
50 | 50 | @Excel(name = "货主编码", width = 15) |
51 | 51 | @ApiModelProperty(value = "货主编码") |
52 | 52 | private String companyCode; |
53 | + /** 上游单号 */ | |
54 | + @Excel(name = "上游单号", width = 15) | |
55 | + @ApiModelProperty(value = "上游单号") | |
56 | + private String referCode; | |
53 | 57 | /** 物料编码 */ |
54 | 58 | @Excel(name = "物料编码", width = 15) |
55 | 59 | @ApiModelProperty(value = "物料编码") |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java
... | ... | @@ -287,7 +287,7 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec |
287 | 287 | String selections = request.getParameter("selections"); |
288 | 288 | if (oConvertUtils.isNotEmpty(selections)) { |
289 | 289 | List<String> selectionList = Arrays.asList(selections.split(",")); |
290 | - exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); | |
290 | + exportList = pageList.stream().filter(item -> selectionList.contains(item.getId().toString())).collect(Collectors.toList()); | |
291 | 291 | } else { |
292 | 292 | exportList = pageList; |
293 | 293 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiving/domain/Receive.java
... | ... | @@ -7,8 +7,9 @@ import java.math.BigDecimal; |
7 | 7 | @Data |
8 | 8 | public class Receive { |
9 | 9 | |
10 | - private Integer id; | |
11 | - private String containerCode; | |
10 | + private Integer id;// 入库详情ID | |
11 | + private String containerCode; // 托盘号 | |
12 | + private String uniqueCode;// 唯一号 | |
12 | 13 | private String materialCode; |
13 | 14 | private String materialName; |
14 | 15 | private String mateiralSpec; |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiving/service/impl/ReceiveServiceImpl.java
1 | 1 | package org.jeecg.modules.wms.receipt.receiving.service.impl; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSON; | |
3 | 4 | import com.aliyun.oss.ServiceException; |
4 | 5 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
5 | 6 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
6 | 7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
8 | + | |
9 | +import cn.monitor4all.logRecord.annotation.OperationLog; | |
10 | +import cn.monitor4all.logRecord.context.LogRecordContext; | |
11 | + | |
7 | 12 | import org.jeecg.common.api.vo.Result; |
8 | 13 | import org.jeecg.modules.wms.config.container.entity.Container; |
9 | 14 | import org.jeecg.modules.wms.config.container.service.IContainerService; |
... | ... | @@ -23,6 +28,7 @@ import org.jeecg.modules.wms.receipt.receiving.domain.Receive; |
23 | 28 | import org.jeecg.modules.wms.receipt.receiving.mapper.ReceiveMapper; |
24 | 29 | import org.jeecg.modules.wms.receipt.receiving.service.IReceiveService; |
25 | 30 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
31 | +import org.jeecg.utils.HuahengJwtUtil; | |
26 | 32 | import org.jeecg.utils.StringUtils; |
27 | 33 | import org.jeecg.utils.constant.QuantityConstant; |
28 | 34 | import org.springframework.stereotype.Service; |
... | ... | @@ -82,6 +88,8 @@ public class ReceiveServiceImpl extends ServiceImpl<ReceiveMapper, Receive> impl |
82 | 88 | */ |
83 | 89 | @Override |
84 | 90 | @Transactional(rollbackFor = ServiceException.class) |
91 | + @OperationLog(bizId = "''", bizType = "'物料追踪'", tag = "'入库组盘'", extra = "#extraJsonString", msg = "''", | |
92 | + operatorId = "#username", recordReturnValue = true) | |
85 | 93 | public Result<ReceiptContainerHeader> receiving(List<Receive> receiveList, String warehouseCode) { |
86 | 94 | boolean result = false; |
87 | 95 | if (receiveList == null || receiveList.size() == 0) { |
... | ... | @@ -144,12 +152,15 @@ public class ReceiveServiceImpl extends ServiceImpl<ReceiveMapper, Receive> impl |
144 | 152 | List<ReceiptDetail> receiptDetailList = new ArrayList<>(); |
145 | 153 | List<ReceiptContainerDetail> receiptContainerDetailList = new ArrayList<>(); |
146 | 154 | for (Receive receive : receiveList) { |
147 | - // 待收数量 | |
155 | + // 可收数量 | |
148 | 156 | BigDecimal qty = receive.getQty(); |
149 | 157 | // 收货数量 |
150 | 158 | BigDecimal taskQty = receive.getTaskQty(); |
159 | + if (qty == null || taskQty == null) { | |
160 | + throw new ServiceException("收货数量或可收数量为空"); | |
161 | + } | |
151 | 162 | if (taskQty.compareTo(qty) > 0) { |
152 | - throw new ServiceException("收货数量不能可收数量,收货数量:" + taskQty + " 可收数量:" + qty); | |
163 | + throw new ServiceException("收货数量不能大于可收数量,收货数量:" + taskQty + "可收数量:" + qty); | |
153 | 164 | } |
154 | 165 | if (taskQty.compareTo(BigDecimal.ZERO) <= 0) { |
155 | 166 | continue; |
... | ... | @@ -194,6 +205,8 @@ public class ReceiveServiceImpl extends ServiceImpl<ReceiveMapper, Receive> impl |
194 | 205 | } else { |
195 | 206 | receiptContainerDetail = new ReceiptContainerDetail(); |
196 | 207 | receiptContainerDetail.setCompanyCode(receiptDetail.getCompanyCode()); |
208 | + receiptContainerDetail.setReferCode(receiptDetail.getReferCode()); | |
209 | + receiptContainerDetail.setUniqueCode(receive.getUniqueCode()); | |
197 | 210 | receiptContainerDetail.setReceiptDetailId(receiptDetail.getId()); |
198 | 211 | receiptContainerDetail.setReceiptId(receiptDetail.getReceiptId()); |
199 | 212 | receiptContainerDetail.setReceiptCode(receiptDetail.getReceiptCode()); |
... | ... | @@ -210,8 +223,8 @@ public class ReceiveServiceImpl extends ServiceImpl<ReceiveMapper, Receive> impl |
210 | 223 | receiptContainerDetail.setInventoryStatus(receiptDetail.getInventoryStatus()); |
211 | 224 | receiptContainerDetailList.add(receiptContainerDetail); |
212 | 225 | } |
213 | - | |
214 | 226 | } |
227 | + | |
215 | 228 | result = receiptDetailService.updateBatchById(receiptDetailList); |
216 | 229 | if (!result) { |
217 | 230 | throw new ServiceException("批量更新入库单详情失败"); |
... | ... | @@ -223,7 +236,8 @@ public class ReceiveServiceImpl extends ServiceImpl<ReceiveMapper, Receive> impl |
223 | 236 | throw new ServiceException("保存入库组盘详情失败"); |
224 | 237 | } |
225 | 238 | } |
226 | - | |
239 | + LogRecordContext.putVariable("username", HuahengJwtUtil.getCurrentOperator()); | |
240 | + LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(receiptContainerDetailList)); | |
227 | 241 | return Result.OK("收货成功", receiptContainerHeader); |
228 | 242 | } |
229 | 243 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/HuahengJwtUtil.java
... | ... | @@ -6,7 +6,9 @@ import java.util.UUID; |
6 | 6 | |
7 | 7 | import javax.servlet.http.HttpServletRequest; |
8 | 8 | |
9 | +import org.apache.shiro.SecurityUtils; | |
9 | 10 | import org.jeecg.common.exception.JeecgBootException; |
11 | +import org.jeecg.common.system.vo.LoginUser; | |
10 | 12 | import org.jeecg.common.util.oConvertUtils; |
11 | 13 | import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication; |
12 | 14 | import org.jeecg.modules.wms.framework.aspectj.dto.RSA256Key; |
... | ... | @@ -141,6 +143,20 @@ public class HuahengJwtUtil { |
141 | 143 | } |
142 | 144 | |
143 | 145 | /** |
146 | + * 获取当前操作人 | |
147 | + * @author TanYibin | |
148 | + * @createDate 2023年2月22日 | |
149 | + * @return | |
150 | + */ | |
151 | + public static String getCurrentOperator() { | |
152 | + LoginUser loginUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser)SecurityUtils.getSubject().getPrincipal() : null; | |
153 | + if (loginUser != null) { | |
154 | + return loginUser.getRealname(); | |
155 | + } | |
156 | + return ApiAuthentication.getInstance().getAudience(); | |
157 | + } | |
158 | + | |
159 | + /** | |
144 | 160 | * 获得token中的信息无需secret解密也能获得 |
145 | 161 | * @return token中包含的用户名 |
146 | 162 | */ |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/interceptor/HuahengBatisInterceptor.java
... | ... | @@ -24,7 +24,7 @@ public class HuahengBatisInterceptor implements Interceptor { |
24 | 24 | @Override |
25 | 25 | public Object intercept(Invocation invocation) throws Throwable { |
26 | 26 | MappedStatement mappedStatement = (MappedStatement)invocation.getArgs()[0]; |
27 | - String sqlId = mappedStatement.getId(); | |
27 | +// String sqlId = mappedStatement.getId(); | |
28 | 28 | // log.debug("------sqlId------" + sqlId); |
29 | 29 | SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType(); |
30 | 30 | Object parameter = invocation.getArgs()[1]; |
... | ... |