Commit 2b384db9fa556174c00bd492eb1816973e32b663
Merge remote-tracking branch 'origin/develop' into develop
Showing
10 changed files
with
124 additions
and
76 deletions
huaheng-wms-core/pom.xml
... | ... | @@ -63,6 +63,11 @@ |
63 | 63 | <artifactId>DmJdbcDriver18</artifactId> |
64 | 64 | <version>8.1.2.192</version> |
65 | 65 | </dependency> |
66 | + <dependency> | |
67 | + <groupId>com.mchange</groupId> | |
68 | + <artifactId>c3p0</artifactId> | |
69 | + <version>0.9.5.2</version> | |
70 | + </dependency> | |
66 | 71 | <!-- jeewx api --> |
67 | 72 | <dependency> |
68 | 73 | <groupId>org.jeecgframework</groupId> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/home/controller/HomePageViewController.java
... | ... | @@ -39,6 +39,8 @@ import org.jeecg.utils.support.Convert; |
39 | 39 | import org.springframework.web.bind.annotation.*; |
40 | 40 | |
41 | 41 | import javax.annotation.Resource; |
42 | +import javax.servlet.http.HttpServletRequest; | |
43 | + | |
42 | 44 | import java.math.BigDecimal; |
43 | 45 | import java.text.SimpleDateFormat; |
44 | 46 | import java.util.*; |
... | ... | @@ -62,8 +64,8 @@ public class HomePageViewController { |
62 | 64 | * @return |
63 | 65 | */ |
64 | 66 | @RequestMapping(value = "/deliveringAmount", method = {RequestMethod.PUT, RequestMethod.POST}) |
65 | - public Result<String> deliveringAmount() { | |
66 | - return homePageViewService.deliveringAmount(); | |
67 | + public Result<String> deliveringAmount(HttpServletRequest request) { | |
68 | + return homePageViewService.deliveringAmount(request); | |
67 | 69 | } |
68 | 70 | |
69 | 71 | /** |
... | ... | @@ -71,8 +73,8 @@ public class HomePageViewController { |
71 | 73 | * @return |
72 | 74 | */ |
73 | 75 | @RequestMapping(value = "/inventoryUtilization", method = {RequestMethod.PUT, RequestMethod.POST}) |
74 | - public Result<String> inventoryUtilization() { | |
75 | - return homePageViewService.inventoryUtilization(); | |
76 | + public Result<String> inventoryUtilization(HttpServletRequest request) { | |
77 | + return homePageViewService.inventoryUtilization(request); | |
76 | 78 | } |
77 | 79 | |
78 | 80 | /** |
... | ... | @@ -80,8 +82,8 @@ public class HomePageViewController { |
80 | 82 | * @return |
81 | 83 | */ |
82 | 84 | @RequestMapping(value = "/inventoryStatus", method = {RequestMethod.PUT, RequestMethod.POST}) |
83 | - public Result<String> inventoryStatus() { | |
84 | - return homePageViewService.inventoryStatus(); | |
85 | + public Result<String> inventoryStatus(HttpServletRequest request) { | |
86 | + return homePageViewService.inventoryStatus(request); | |
85 | 87 | } |
86 | 88 | |
87 | 89 | /** |
... | ... | @@ -89,8 +91,8 @@ public class HomePageViewController { |
89 | 91 | * @return |
90 | 92 | */ |
91 | 93 | @RequestMapping(value = "/inventoryOverview", method = {RequestMethod.PUT, RequestMethod.POST}) |
92 | - public Result<String> inventoryOverview() { | |
93 | - return homePageViewService.inventoryOverview(); | |
94 | + public Result<String> inventoryOverview(HttpServletRequest request) { | |
95 | + return homePageViewService.inventoryOverview(request); | |
94 | 96 | } |
95 | 97 | |
96 | 98 | /** |
... | ... | @@ -98,8 +100,8 @@ public class HomePageViewController { |
98 | 100 | * @return |
99 | 101 | */ |
100 | 102 | @RequestMapping(value = "/getCommonData", method = {RequestMethod.PUT, RequestMethod.POST}) |
101 | - public Result getCommonData() { | |
102 | - return homePageViewService.getCommonData(); | |
103 | + public Result getCommonData(HttpServletRequest request) { | |
104 | + return homePageViewService.getCommonData(request); | |
103 | 105 | } |
104 | 106 | |
105 | 107 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/home/service/HomePageViewService.java
... | ... | @@ -8,6 +8,8 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
8 | 8 | import java.io.Serializable; |
9 | 9 | import java.util.Collection; |
10 | 10 | |
11 | +import javax.servlet.http.HttpServletRequest; | |
12 | + | |
11 | 13 | /** |
12 | 14 | * @Description: 任务表 |
13 | 15 | * @Author: jeecg-boot |
... | ... | @@ -16,14 +18,14 @@ import java.util.Collection; |
16 | 18 | */ |
17 | 19 | public interface HomePageViewService { |
18 | 20 | |
19 | - Result<String> deliveringAmount(); | |
21 | + Result<String> deliveringAmount(HttpServletRequest request); | |
20 | 22 | |
21 | - Result<String> inventoryUtilization(); | |
23 | + Result<String> inventoryUtilization(HttpServletRequest request); | |
22 | 24 | |
23 | - Result<String> inventoryStatus(); | |
25 | + Result<String> inventoryStatus(HttpServletRequest request); | |
24 | 26 | |
25 | - Result<String> inventoryOverview(); | |
27 | + Result<String> inventoryOverview(HttpServletRequest request); | |
26 | 28 | |
27 | - Result getCommonData(); | |
29 | + Result getCommonData(HttpServletRequest request); | |
28 | 30 | |
29 | 31 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/home/service/impl/HomePageViewServiceImpl.java
... | ... | @@ -36,12 +36,15 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; |
36 | 36 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
37 | 37 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl; |
38 | 38 | import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl; |
39 | +import org.jeecg.utils.HuahengJwtUtil; | |
39 | 40 | import org.jeecg.utils.StringUtils; |
40 | 41 | import org.jeecg.utils.constant.QuantityConstant; |
41 | 42 | import org.jeecg.utils.support.Convert; |
42 | 43 | import org.springframework.stereotype.Service; |
43 | 44 | |
44 | 45 | import javax.annotation.Resource; |
46 | +import javax.servlet.http.HttpServletRequest; | |
47 | + | |
45 | 48 | import java.math.BigDecimal; |
46 | 49 | import java.text.SimpleDateFormat; |
47 | 50 | import java.util.*; |
... | ... | @@ -58,37 +61,46 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
58 | 61 | |
59 | 62 | @Resource |
60 | 63 | ShipmentHeaderServiceImpl shipmentHeaderServiceImpl; |
64 | + | |
61 | 65 | @Resource |
62 | 66 | ReceiptHeaderServiceImpl receiptHeaderServiceImpl; |
67 | + | |
63 | 68 | @Resource |
64 | 69 | SysDictItemServiceImpl sysDictItemServiceImpl; |
70 | + | |
65 | 71 | @Resource |
66 | 72 | LocationServiceImpl locationServiceImpl; |
73 | + | |
67 | 74 | @Resource |
68 | 75 | InventoryDetailServiceImpl inventoryDetailServiceImpl; |
76 | + | |
69 | 77 | @Resource |
70 | 78 | InventoryHeaderServiceImpl inventoryHeaderServiceImpl; |
79 | + | |
71 | 80 | @Resource |
72 | 81 | TaskDetailServiceImpl taskDetailServiceImpl; |
82 | + | |
73 | 83 | @Resource |
74 | 84 | TaskHeaderServiceImpl taskHeaderService; |
85 | + | |
75 | 86 | @Resource |
76 | 87 | HomePageViewService homePageViewService; |
88 | + | |
77 | 89 | @Resource |
78 | 90 | InventoryTransactionServiceImpl inventoryTransactionServiceImpl; |
79 | 91 | |
80 | 92 | @Override |
81 | - public Result<String> deliveringAmount() { | |
82 | - //通过库存交易记录来查询 | |
93 | + public Result<String> deliveringAmount(HttpServletRequest request) { | |
94 | + // 通过库存交易记录来查询 | |
83 | 95 | LambdaQueryWrapper<InventoryTransaction> inventoryTransactionLambdaQueryWrapper = Wrappers.lambdaQuery(); |
84 | - inventoryTransactionLambdaQueryWrapper.select(InventoryTransaction::getCreateTime, InventoryTransaction::getQty,InventoryTransaction::getType); | |
96 | + HuahengJwtUtil.setWarehouseCode(inventoryTransactionLambdaQueryWrapper, InventoryTransaction.class, request); | |
97 | + inventoryTransactionLambdaQueryWrapper.select(InventoryTransaction::getCreateTime, InventoryTransaction::getQty, InventoryTransaction::getType); | |
85 | 98 | List<InventoryTransaction> inventoryTransactions = inventoryTransactionServiceImpl.list(inventoryTransactionLambdaQueryWrapper); |
86 | 99 | |
87 | - | |
88 | 100 | // 查询出库单的7天出库量 |
89 | - List<InventoryTransaction> shipmentHeaders=new ArrayList<>(); | |
101 | + List<InventoryTransaction> shipmentHeaders = new ArrayList<>(); | |
90 | 102 | shipmentHeaders.addAll(inventoryTransactions); |
91 | - shipmentHeaders.removeIf(Inventory->Inventory.getType()!=20); | |
103 | + shipmentHeaders.removeIf(Inventory -> Inventory.getType() != 20); | |
92 | 104 | LinkedHashMap<String, String> list = new LinkedHashMap<>(); |
93 | 105 | |
94 | 106 | for (int i = 6; i >= 0; i--) { |
... | ... | @@ -96,26 +108,21 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
96 | 108 | List<InventoryTransaction> collect = shipmentHeaders.stream() |
97 | 109 | .filter(shipmentHeader -> new SimpleDateFormat("yyyy-MM-dd").format(shipmentHeader.getCreateTime()).toString().contains(today)) |
98 | 110 | .collect(Collectors.toList()); |
99 | - if (collect.size()!=0) | |
100 | - { | |
101 | - BigDecimal sum=new BigDecimal(0); | |
102 | - for (InventoryTransaction item : collect) | |
103 | - { | |
104 | - sum=sum.add(item.getQty()); | |
111 | + if (collect.size() != 0) { | |
112 | + BigDecimal sum = new BigDecimal(0); | |
113 | + for (InventoryTransaction item : collect) { | |
114 | + sum = sum.add(item.getQty()); | |
105 | 115 | } |
106 | - list.put(today,String.valueOf(sum)); | |
107 | - }else | |
108 | - { | |
109 | - list.put(today,"0"); | |
116 | + list.put(today, String.valueOf(sum)); | |
117 | + } else { | |
118 | + list.put(today, "0"); | |
110 | 119 | } |
111 | - | |
112 | 120 | } |
113 | 121 | |
114 | 122 | // 查询入库单的7天入库量 |
115 | - | |
116 | 123 | List<InventoryTransaction> receiptHeaders = new ArrayList<>(); |
117 | 124 | receiptHeaders.addAll(inventoryTransactions); |
118 | - receiptHeaders.removeIf(Inventory->Inventory.getType()!=10); | |
125 | + receiptHeaders.removeIf(Inventory -> Inventory.getType() != 10); | |
119 | 126 | LinkedHashMap<String, String> list2 = new LinkedHashMap<>(); |
120 | 127 | for (int i = 6; i >= 0; i--) { |
121 | 128 | List<InventoryTransaction> receiptHeadersCop = receiptHeaders; |
... | ... | @@ -123,22 +130,17 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
123 | 130 | List<InventoryTransaction> collect = receiptHeadersCop.stream() |
124 | 131 | .filter(ReceiptHeader -> new SimpleDateFormat("yyyy-MM-dd").format(ReceiptHeader.getCreateTime()).toString().contains(today)) |
125 | 132 | .collect(Collectors.toList()); |
126 | - if (collect.size()!=0) | |
127 | - { | |
128 | - BigDecimal sum=new BigDecimal(0); | |
129 | - for (InventoryTransaction item : collect) | |
130 | - { | |
131 | - sum=sum.add(item.getQty()); | |
133 | + if (collect.size() != 0) { | |
134 | + BigDecimal sum = new BigDecimal(0); | |
135 | + for (InventoryTransaction item : collect) { | |
136 | + sum = sum.add(item.getQty()); | |
132 | 137 | } |
133 | - list2.put(today,String.valueOf(sum)); | |
134 | - }else | |
135 | - { | |
136 | - list2.put(today,"0"); | |
138 | + list2.put(today, String.valueOf(sum)); | |
139 | + } else { | |
140 | + list2.put(today, "0"); | |
137 | 141 | } |
138 | 142 | } |
139 | 143 | |
140 | - | |
141 | - | |
142 | 144 | Option option = new Option(); |
143 | 145 | option.tooltip().trigger(Trigger.axis).axisPointer().type(PointerType.cross); |
144 | 146 | option.grid().setLeft("3%"); |
... | ... | @@ -162,7 +164,6 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
162 | 164 | axis.data().add(o1); |
163 | 165 | line.data().add(o2); |
164 | 166 | } |
165 | - | |
166 | 167 | Line line2 = new Line(); |
167 | 168 | line2.setName("收货量"); |
168 | 169 | for (String key : list2.keySet()) { |
... | ... | @@ -170,7 +171,6 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
170 | 171 | Object o2 = list2.get(key); |
171 | 172 | line2.data().add(o2); |
172 | 173 | } |
173 | - | |
174 | 174 | option.setxAxis(Arrays.asList(axis)); |
175 | 175 | ValueAxis yAxis = new ValueAxis(); |
176 | 176 | option.setyAxis(Arrays.asList(yAxis)); |
... | ... | @@ -180,19 +180,20 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
180 | 180 | } |
181 | 181 | |
182 | 182 | @Override |
183 | - public Result<String> inventoryUtilization() { | |
183 | + public Result<String> inventoryUtilization(HttpServletRequest request) { | |
184 | 184 | // 先存储总数 |
185 | 185 | Integer allStock = locationServiceImpl.count(); |
186 | 186 | |
187 | 187 | // 有货数量 = 总库位删除为空的数量长度 |
188 | 188 | LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); |
189 | + HuahengJwtUtil.setWarehouseCode(locationLambdaQueryWrapper, Location.class, request); | |
189 | 190 | locationLambdaQueryWrapper.isNotNull(Location::getContainerCode).ne(Location::getContainerCode, ""); |
190 | 191 | int locationStock = locationServiceImpl.count(locationLambdaQueryWrapper); |
191 | 192 | |
192 | 193 | // 无货数量 = 总数 - 有货数量 |
193 | 194 | Integer inStock = allStock - locationStock; |
194 | 195 | Option option = new Option(); |
195 | -// option.title("库存状态分布").title().x("center"); | |
196 | + // option.title("库存状态分布").title().x("center"); | |
196 | 197 | option.tooltip(Trigger.item).tooltip().formatter("{a} <br/>{b} : {c} ({d}%)"); |
197 | 198 | option.legend().setOrient(Orient.vertical); |
198 | 199 | option.legend().setRight(10); |
... | ... | @@ -230,7 +231,7 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
230 | 231 | } |
231 | 232 | |
232 | 233 | @Override |
233 | - public Result<String> inventoryStatus() { | |
234 | + public Result<String> inventoryStatus(HttpServletRequest request) { | |
234 | 235 | Option option = new Option(); |
235 | 236 | option.tooltip(Trigger.item).tooltip().formatter("{a} <br/>{b} : {c} ({d}%)"); |
236 | 237 | option.legend().setOrient(Orient.vertical); |
... | ... | @@ -259,7 +260,8 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
259 | 260 | pie.itemStyle().emphasis().setShadowColor("rgba(0, 0, 0, 0.4)"); |
260 | 261 | |
261 | 262 | QueryWrapper<InventoryDetail> queryWrapper = new QueryWrapper<>(); |
262 | - queryWrapper.select("inventory_status ,SUM(qty) qty").eq("warehouse_code", "CS0001").groupBy("inventory_status"); | |
263 | + HuahengJwtUtil.setWarehouseCode(queryWrapper, InventoryDetail.class, request); | |
264 | + queryWrapper.select("inventory_status, SUM(qty) qty").groupBy("inventory_status"); | |
263 | 265 | List<InventoryDetail> inventoryDetails = inventoryDetailServiceImpl.list(queryWrapper); |
264 | 266 | |
265 | 267 | LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = Wrappers.lambdaQuery(); |
... | ... | @@ -282,9 +284,10 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
282 | 284 | } |
283 | 285 | |
284 | 286 | @Override |
285 | - public Result<String> inventoryOverview() { | |
287 | + public Result<String> inventoryOverview(HttpServletRequest request) { | |
286 | 288 | QueryWrapper<InventoryDetail> queryWrapper = new QueryWrapper<>(); |
287 | - queryWrapper.select("material_name, sum(qty) AS qty").eq("warehouse_code", "CS0001").groupBy("material_name"); | |
289 | + HuahengJwtUtil.setWarehouseCode(queryWrapper, InventoryDetail.class, request); | |
290 | + queryWrapper.select("material_name, sum(qty) AS qty").groupBy("material_name"); | |
288 | 291 | List<InventoryDetail> inventoryDetails = inventoryDetailServiceImpl.list(queryWrapper); |
289 | 292 | Option option = new Option(); |
290 | 293 | option.tooltip(Trigger.item).tooltip().formatter("{a} <br/>{b} : {c} ({d}%)"); |
... | ... | @@ -334,16 +337,15 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
334 | 337 | } |
335 | 338 | |
336 | 339 | @Override |
337 | - public Result getCommonData() { | |
340 | + public Result getCommonData(HttpServletRequest request) { | |
338 | 341 | // 昨天日期 |
339 | 342 | String today = new SimpleDateFormat("yyyy-MM-dd").format(System.currentTimeMillis() - 1000 * 60 * 60 * 24).toString(); |
340 | 343 | Map<String, Object> map = new HashMap<>(); |
341 | 344 | |
342 | - | |
343 | - | |
344 | 345 | // 今天入库量 |
345 | 346 | LambdaQueryWrapper<InventoryTransaction> inventoryTransactionLambdaQueryWrapper = Wrappers.lambdaQuery(); |
346 | - inventoryTransactionLambdaQueryWrapper.select(InventoryTransaction::getType,InventoryTransaction::getQty).gt(InventoryTransaction::getCreateTime, today); | |
347 | + HuahengJwtUtil.setWarehouseCode(inventoryTransactionLambdaQueryWrapper, InventoryTransaction.class, request); | |
348 | + inventoryTransactionLambdaQueryWrapper.select(InventoryTransaction::getType, InventoryTransaction::getQty).gt(InventoryTransaction::getCreateTime, today); | |
347 | 349 | List<InventoryTransaction> inventoryTransactions = inventoryTransactionServiceImpl.list(inventoryTransactionLambdaQueryWrapper); |
348 | 350 | BigDecimal receiptQty = BigDecimal.ZERO; |
349 | 351 | BigDecimal shipmentQty = BigDecimal.ZERO; |
... | ... | @@ -360,11 +362,9 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
360 | 362 | // 今日交易量 |
361 | 363 | map.put("bllCount", receiptQty.add(shipmentQty)); |
362 | 364 | |
363 | - | |
364 | - | |
365 | - | |
366 | 365 | // 库存总数 |
367 | 366 | LambdaQueryWrapper<InventoryHeader> inventoryHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); |
367 | + HuahengJwtUtil.setWarehouseCode(inventoryHeaderLambdaQueryWrapper, InventoryHeader.class, request); | |
368 | 368 | inventoryHeaderLambdaQueryWrapper.select(InventoryHeader::getTotalQty); |
369 | 369 | List<InventoryHeader> inventoryHeaders = inventoryHeaderServiceImpl.list(inventoryHeaderLambdaQueryWrapper); |
370 | 370 | BigDecimal inventoryQty = BigDecimal.ZERO; |
... | ... | @@ -373,14 +373,16 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
373 | 373 | } |
374 | 374 | map.put("inventoryTotal", inventoryQty); |
375 | 375 | |
376 | - // 库内品数 | |
376 | + // 库内良品数 | |
377 | 377 | LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); |
378 | - inventoryDetailLambdaQueryWrapper.select(InventoryDetail::getId).groupBy(InventoryDetail::getInventoryStatus); | |
378 | + HuahengJwtUtil.setWarehouseCode(inventoryDetailLambdaQueryWrapper, InventoryDetail.class, request); | |
379 | + inventoryDetailLambdaQueryWrapper.select(InventoryDetail::getInventoryStatus).groupBy(InventoryDetail::getInventoryStatus); | |
379 | 380 | List<InventoryDetail> inventoryDetails = inventoryDetailServiceImpl.list(inventoryDetailLambdaQueryWrapper); |
380 | 381 | map.put("materialCount", inventoryDetails.size()); |
381 | 382 | |
382 | 383 | // 待执行任务数 |
383 | 384 | LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); |
385 | + HuahengJwtUtil.setWarehouseCode(taskHeaderLambdaQueryWrapper, TaskHeader.class, request); | |
384 | 386 | taskHeaderLambdaQueryWrapper.ge(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_RELEASE).lt(TaskHeader::getStatus, |
385 | 387 | QuantityConstant.TASK_STATUS_COMPLETED); |
386 | 388 | List<TaskHeader> taskHeaders = taskHeaderService.list(taskHeaderLambdaQueryWrapper); |
... | ... | @@ -388,5 +390,4 @@ public class HomePageViewServiceImpl implements HomePageViewService { |
388 | 390 | |
389 | 391 | return Result.ok(map); |
390 | 392 | } |
391 | - | |
392 | 393 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/mapper/xml/InventoryDetailMapper.xml
... | ... | @@ -4,14 +4,13 @@ |
4 | 4 | |
5 | 5 | <delete id="deleteByMainId" parameterType="java.lang.String"> |
6 | 6 | DELETE |
7 | - FROM inventory_detail | |
8 | - WHERE inventory_header_id = #{mainId} | |
7 | + FROM inventory_detail | |
8 | + WHERE inventory_header_id = #{mainId} | |
9 | 9 | </delete> |
10 | 10 | |
11 | - <select id="selectByMainId" parameterType="java.lang.String" | |
12 | - resultType="org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail"> | |
11 | + <select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail"> | |
13 | 12 | SELECT * |
14 | - FROM inventory_detail | |
15 | - WHERE inventory_header_id = #{mainId} | |
13 | + FROM inventory_detail | |
14 | + WHERE inventory_header_id = #{mainId} | |
16 | 15 | </select> |
17 | 16 | </mapper> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/TableCleanTesk.java
... | ... | @@ -62,8 +62,9 @@ public class TableCleanTesk implements Job { |
62 | 62 | Field timeField = ReflectUtil.getField(Class.forName(className), javaTimefieldName); |
63 | 63 | if (timeField != null) { |
64 | 64 | QueryWrapper<?> queryWrapper = new QueryWrapper<>(); |
65 | - LocalDateTime timeValue = LocalDateUtils.minus(LocalDateTime.now(), tableCleanDto.getRetentionDays(), ChronoUnit.DAYS); | |
66 | - queryWrapper.lt(tableCleanDto.getTimeFieldName(), timeValue); | |
65 | + LocalDateTime localDateTimeValue = LocalDateUtils.minus(LocalDateTime.now(), tableCleanDto.getRetentionDays(), ChronoUnit.DAYS); | |
66 | +// queryWrapper.apply("{0} < {1}", tableCleanDto.getTimeFieldName(), LocalDateUtils.getStartTimeOfDayStr(localDateTimeValue)); | |
67 | + queryWrapper.lt(tableCleanDto.getTimeFieldName(), LocalDateUtils.getStartTimeOfDayStr(localDateTimeValue)); | |
67 | 68 | BaseMapper baseMapper = (BaseMapper)this.sqlSession.getMapper(mapperClass); |
68 | 69 | Integer deleteCount = baseMapper.delete(queryWrapper); |
69 | 70 | log.info("定时任务 TableCleanTesk 删除 {} {} 天前数据 {} 行", className, tableCleanDto.getRetentionDays(), deleteCount); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/HuahengJwtUtil.java
... | ... | @@ -23,6 +23,7 @@ import com.auth0.jwt.algorithms.Algorithm; |
23 | 23 | import com.auth0.jwt.exceptions.JWTDecodeException; |
24 | 24 | import com.auth0.jwt.interfaces.DecodedJWT; |
25 | 25 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
26 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
26 | 27 | |
27 | 28 | import cn.hutool.core.date.DatePattern; |
28 | 29 | import cn.hutool.core.date.DateUtil; |
... | ... | @@ -133,6 +134,18 @@ public class HuahengJwtUtil { |
133 | 134 | lambdaQueryWrapper.apply("warehouse_code = {0}", warehouseCode); |
134 | 135 | } |
135 | 136 | } |
137 | + | |
138 | + public static <T> void setWarehouseCode(QueryWrapper<T> queryWrapper, Class<T> clazz, HttpServletRequest request) { | |
139 | + List<String> roles = HuahengJwtUtil.getRolesByToken(request); | |
140 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(request); | |
141 | + if (roles.contains(USER_ROLE_INSPECTOR) && warehouseCode.equals(ALL_WAREHOUSE_CODE)) { | |
142 | + return; | |
143 | + } | |
144 | + Field warehouseCodeField = ReflectUtil.getField(clazz, "warehouseCode"); | |
145 | + if (warehouseCodeField != null) { | |
146 | + queryWrapper.eq("warehouse_code", warehouseCode); | |
147 | + } | |
148 | + } | |
136 | 149 | |
137 | 150 | /** |
138 | 151 | * 生成签名 |
... | ... |
huaheng-wms-core/src/main/resources/application-dev.yml
... | ... | @@ -51,6 +51,7 @@ spring: |
51 | 51 | scheduler: |
52 | 52 | instanceName: test |
53 | 53 | instanceId: AUTO |
54 | + # wrapJobExecutionInUserTransaction: false | |
54 | 55 | jobStore: |
55 | 56 | class: org.quartz.impl.jdbcjobstore.JobStoreTX |
56 | 57 | driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate |
... | ... | @@ -58,6 +59,8 @@ spring: |
58 | 59 | isClustered: true |
59 | 60 | misfireThreshold: 60000 |
60 | 61 | clusterCheckinInterval: 10000 |
62 | + # 使用sqlServer数据源时需放开此配置 | |
63 | + # selectWithLockSQL: SELECT* FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? | |
61 | 64 | threadPool: |
62 | 65 | class: org.quartz.simpl.SimpleThreadPool |
63 | 66 | threadCount: 10 |
... | ... | @@ -120,7 +123,7 @@ spring: |
120 | 123 | timeBetweenEvictionRunsMillis: 60000 |
121 | 124 | # 配置一个连接在池中最小生存的时间,单位是毫秒 |
122 | 125 | minEvictableIdleTimeMillis: 300000 |
123 | - validationQuery: SELECT 1 FROM DUAL | |
126 | + validationQuery: SELECT 1 | |
124 | 127 | testWhileIdle: true |
125 | 128 | testOnBorrow: false |
126 | 129 | testOnReturn: false |
... | ... | @@ -137,6 +140,11 @@ spring: |
137 | 140 | username: root |
138 | 141 | password: HHsoft123. |
139 | 142 | driver-class-name: net.sf.log4jdbc.DriverSpy |
143 | + # sqlserver 数据源配置 | |
144 | + # url: jdbc:sqlserver://172.16.29.88:1433;DatabaseName=wms4;encrypt=false;SelectMethod=cursor; | |
145 | + # username: sa | |
146 | + # password: 1qaz!QAZ | |
147 | + # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
140 | 148 | # 多数据源配置 |
141 | 149 | # multi-datasource1: |
142 | 150 | # url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai |
... | ... |
huaheng-wms-core/src/main/resources/application-prod.yml
... | ... | @@ -51,6 +51,7 @@ spring: |
51 | 51 | scheduler: |
52 | 52 | instanceName: prod |
53 | 53 | instanceId: AUTO |
54 | + # wrapJobExecutionInUserTransaction: false | |
54 | 55 | jobStore: |
55 | 56 | class: org.quartz.impl.jdbcjobstore.JobStoreTX |
56 | 57 | driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate |
... | ... | @@ -58,6 +59,8 @@ spring: |
58 | 59 | isClustered: true |
59 | 60 | misfireThreshold: 60000 |
60 | 61 | clusterCheckinInterval: 10000 |
62 | + # 使用sqlServer数据源时需放开此配置 | |
63 | + # selectWithLockSQL: SELECT* FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? | |
61 | 64 | threadPool: |
62 | 65 | class: org.quartz.simpl.SimpleThreadPool |
63 | 66 | threadCount: 10 |
... | ... | @@ -120,7 +123,7 @@ spring: |
120 | 123 | timeBetweenEvictionRunsMillis: 60000 |
121 | 124 | # 配置一个连接在池中最小生存的时间,单位是毫秒 |
122 | 125 | minEvictableIdleTimeMillis: 300000 |
123 | - validationQuery: SELECT 1 FROM DUAL | |
126 | + validationQuery: SELECT 1 | |
124 | 127 | testWhileIdle: true |
125 | 128 | testOnBorrow: false |
126 | 129 | testOnReturn: false |
... | ... | @@ -137,6 +140,11 @@ spring: |
137 | 140 | username: root |
138 | 141 | password: hhsoftware |
139 | 142 | driver-class-name: com.mysql.cj.jdbc.Driver |
143 | + # sqlserver 数据源配置 | |
144 | + # url: jdbc:sqlserver://172.16.29.88:1433;DatabaseName=wms4;encrypt=false;SelectMethod=cursor; | |
145 | + # username: sa | |
146 | + # password: 1qaz!QAZ | |
147 | + # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
140 | 148 | # 多数据源配置 |
141 | 149 | # multi-datasource1: |
142 | 150 | # url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai |
... | ... |
huaheng-wms-core/src/main/resources/application-test.yml
... | ... | @@ -51,6 +51,7 @@ spring: |
51 | 51 | scheduler: |
52 | 52 | instanceName: test |
53 | 53 | instanceId: AUTO |
54 | + # wrapJobExecutionInUserTransaction: false | |
54 | 55 | jobStore: |
55 | 56 | class: org.quartz.impl.jdbcjobstore.JobStoreTX |
56 | 57 | driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate |
... | ... | @@ -58,6 +59,8 @@ spring: |
58 | 59 | isClustered: true |
59 | 60 | misfireThreshold: 60000 |
60 | 61 | clusterCheckinInterval: 10000 |
62 | + # 使用sqlServer数据源时需放开此配置 | |
63 | + # selectWithLockSQL: SELECT* FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? | |
61 | 64 | threadPool: |
62 | 65 | class: org.quartz.simpl.SimpleThreadPool |
63 | 66 | threadCount: 10 |
... | ... | @@ -120,7 +123,7 @@ spring: |
120 | 123 | timeBetweenEvictionRunsMillis: 60000 |
121 | 124 | # 配置一个连接在池中最小生存的时间,单位是毫秒 |
122 | 125 | minEvictableIdleTimeMillis: 300000 |
123 | - validationQuery: SELECT 1 FROM DUAL | |
126 | + validationQuery: SELECT 1 | |
124 | 127 | testWhileIdle: true |
125 | 128 | testOnBorrow: false |
126 | 129 | testOnReturn: false |
... | ... | @@ -133,17 +136,23 @@ spring: |
133 | 136 | connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 |
134 | 137 | datasource: |
135 | 138 | master: |
139 | + # mysql数据源配置 | |
136 | 140 | url: jdbc:log4jdbc:mysql://172.16.29.45:3306/wms4?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true |
137 | 141 | username: root |
138 | 142 | password: hhsoftware |
139 | 143 | driver-class-name: net.sf.log4jdbc.DriverSpy |
144 | + # sqlserver 数据源配置 | |
145 | + # url: jdbc:sqlserver://172.16.29.88:1433;DatabaseName=wms4;encrypt=false;SelectMethod=cursor; | |
146 | + # username: sa | |
147 | + # password: 1qaz!QAZ | |
148 | + # driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
140 | 149 | # 多数据源配置 |
141 | 150 | # multi-datasource1: |
142 | 151 | # url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai |
143 | 152 | # username: root |
144 | 153 | # password: root |
145 | 154 | # driver-class-name: com.mysql.cj.jdbc.Driver |
146 | - # # 达梦数据库链接驱动 | |
155 | + # 达梦数据库链接驱动 | |
147 | 156 | # url: jdbc:dm://192.168.225.128:5236?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true |
148 | 157 | # username: WMS4 |
149 | 158 | # password: 123456 |
... | ... |