Commit ca887132bcb16140dfdb9ed3da1da5f1c925a27d
1 parent
3f321e83
1. 增加单据ID的搜索
2. 修复自动出库bug 3. apilog 修改成每次删除1000条
Showing
8 changed files
with
59 additions
and
49 deletions
ant-design-vue-jeecg/src/views/system/receipt/ReceiptHeaderList.vue
... | ... | @@ -4,6 +4,13 @@ |
4 | 4 | <div class="table-page-search-wrapper"> |
5 | 5 | <a-form layout="inline" @keyup.enter.native="searchQuery"> |
6 | 6 | <a-row :gutter="24"> |
7 | + | |
8 | + <a-col :xl="6" :lg="7" :md="8" :sm="24"> | |
9 | + <a-form-item label="单据ID"> | |
10 | + <a-input placeholder="请输入单据ID" v-model="queryParam.id"></a-input> | |
11 | + </a-form-item> | |
12 | + </a-col> | |
13 | + | |
7 | 14 | <a-col :xl="6" :lg="7" :md="8" :sm="24"> |
8 | 15 | <a-form-item label="入库单编码"> |
9 | 16 | <a-input placeholder="请输入入库单编码" v-model="queryParam.code"></a-input> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
... | ... | @@ -139,7 +139,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService |
139 | 139 | } |
140 | 140 | } |
141 | 141 | roadWays.removeAll(removeRoadWays); |
142 | - if (roadWays == null || roadWays.size() == 0) { | |
142 | + if (CollectionUtils.isEmpty(roadWays)) { | |
143 | 143 | throw new JeecgBootException("分配库位时, 可用巷道为空"); |
144 | 144 | } |
145 | 145 | Integer roadWay = locationAllocationService.getRoadWay(roadWays, materialCode, zoneCode, warehouseCode); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/apiLog/mapper/ApiLogMapper.java
1 | 1 | package org.jeecg.modules.wms.monitor.apiLog.mapper; |
2 | 2 | |
3 | -import java.util.List; | |
3 | +import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; | |
4 | 4 | |
5 | -import org.apache.ibatis.annotations.Param; | |
6 | 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
7 | -import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; | |
8 | 6 | |
9 | 7 | /** |
10 | 8 | * @Description: 接口日志 |
... | ... | @@ -14,4 +12,6 @@ import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; |
14 | 12 | */ |
15 | 13 | public interface ApiLogMapper extends BaseMapper<ApiLog> { |
16 | 14 | |
15 | + Integer deleteByCreateTime(String createTime); | |
16 | + | |
17 | 17 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/apiLog/mapper/xml/ApiLogMapper.xml
... | ... | @@ -2,4 +2,11 @@ |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 | <mapper namespace="org.jeecg.modules.wms.monitor.apiLog.mapper.ApiLogMapper"> |
4 | 4 | |
5 | + <delete id="deleteByCreateTime" parameterType="java.lang.String"> | |
6 | + DELETE | |
7 | + FROM api_log | |
8 | + WHERE create_time <![CDATA[<=]]> #{createTime}) | |
9 | + order by id asc limit 1000 | |
10 | + </delete> | |
11 | + | |
5 | 12 | </mapper> |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/apiLog/service/IApiLogService.java
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/apiLog/service/impl/ApiLogServiceImpl.java
... | ... | @@ -4,6 +4,8 @@ import java.util.Date; |
4 | 4 | import java.util.List; |
5 | 5 | import java.util.stream.Collectors; |
6 | 6 | |
7 | +import javax.annotation.Resource; | |
8 | + | |
7 | 9 | import org.jeecg.modules.wms.monitor.apiLog.entity.ApiLog; |
8 | 10 | import org.jeecg.modules.wms.monitor.apiLog.mapper.ApiLogMapper; |
9 | 11 | import org.jeecg.modules.wms.monitor.apiLog.service.IApiLogService; |
... | ... | @@ -26,6 +28,9 @@ import cn.hutool.core.date.DateUtil; |
26 | 28 | @Service |
27 | 29 | public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> implements IApiLogService { |
28 | 30 | |
31 | + @Resource | |
32 | + private ApiLogMapper apiLogMapper; | |
33 | + | |
29 | 34 | @Override |
30 | 35 | @Scheduled(fixedDelay = 1800 * 1000) // 计划任务:每次方法执行后1800秒执行 |
31 | 36 | // @SchedulerLock(name = "getApiNameList", lockAtLeastFor = "PT900S", lockAtMostFor = "PT3600S") // 计划任务锁:最短等待时间1800秒,最长等待时间3600秒 |
... | ... | @@ -37,4 +42,10 @@ public class ApiLogServiceImpl extends ServiceImpl<ApiLogMapper, ApiLog> impleme |
37 | 42 | return apiLogList.stream().map(t -> t.getApiName()).collect(Collectors.toList()); |
38 | 43 | } |
39 | 44 | |
45 | + @Override | |
46 | + public Integer deleteByCreateTime(String createTime) { | |
47 | + LambdaQueryWrapper<ApiLog> apiLogLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
48 | + apiLogLambdaQueryWrapper.lt(ApiLog::getCreateTime, createTime).orderByAsc(true, ApiLog::getId).last(" limit 1000"); | |
49 | + return apiLogMapper.delete(apiLogLambdaQueryWrapper); | |
50 | + } | |
40 | 51 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/TableCleanTask.java
1 | 1 | package org.jeecg.modules.wms.monitor.job; |
2 | 2 | |
3 | -import java.lang.reflect.Field; | |
4 | 3 | import java.lang.reflect.ParameterizedType; |
5 | 4 | import java.time.LocalDateTime; |
6 | 5 | import java.time.temporal.ChronoUnit; |
7 | -import java.util.ArrayList; | |
8 | 6 | import java.util.List; |
9 | 7 | |
10 | 8 | import org.apache.ibatis.session.SqlSession; |
11 | 9 | import org.jeecg.common.util.DateUtils; |
12 | -import org.jeecg.modules.system.mapper.SysLogMapper; | |
10 | +import org.jeecg.modules.wms.monitor.apiLog.service.IApiLogService; | |
13 | 11 | import org.jeecg.modules.wms.monitor.job.dto.TableCleanDto; |
14 | -import org.jeecg.modules.wms.monitor.operation.mapper.OperationLogMapper; | |
15 | 12 | import org.jeecg.utils.LocalDateUtils; |
16 | -import org.quartz.DisallowConcurrentExecution; | |
17 | -import org.quartz.Job; | |
18 | -import org.quartz.JobExecutionContext; | |
19 | -import org.quartz.JobExecutionException; | |
20 | -import org.quartz.PersistJobDataAfterExecution; | |
13 | +import org.quartz.*; | |
21 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
22 | 15 | |
23 | 16 | import com.alibaba.fastjson.JSON; |
24 | 17 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
25 | 18 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
26 | -import com.google.common.base.CaseFormat; | |
27 | 19 | |
28 | 20 | import cn.hutool.core.util.StrUtil; |
29 | -import dm.jdbc.util.ReflectUtil; | |
30 | 21 | import lombok.extern.slf4j.Slf4j; |
31 | 22 | |
32 | 23 | /** |
... | ... | @@ -44,56 +35,46 @@ public class TableCleanTask implements Job { |
44 | 35 | @Autowired |
45 | 36 | private SqlSession sqlSession; |
46 | 37 | |
38 | + @Autowired | |
39 | + private IApiLogService apiLogService; | |
40 | + | |
47 | 41 | public void setParameter(String parameter) { |
48 | 42 | this.parameter = parameter; |
49 | 43 | } |
50 | 44 | |
51 | 45 | @Override |
46 | + @SuppressWarnings({"rawtypes", "unchecked"}) | |
52 | 47 | public void execute(JobExecutionContext context) throws JobExecutionException { |
53 | 48 | log.info(StrUtil.format("定时任务 TableCleanTask 参数:{},执行时间:{}", this.parameter, DateUtils.getTimestamp())); |
54 | 49 | List<TableCleanDto> tableCleanList = JSON.parseArray(this.parameter, TableCleanDto.class); |
55 | 50 | if (tableCleanList != null && tableCleanList.size() > 0) { |
56 | 51 | for (TableCleanDto tableCleanDto : tableCleanList) { |
57 | 52 | try { |
58 | - Class mapperClass = Class.forName(tableCleanDto.getMapperName()); | |
59 | - ParameterizedType parameterizedType = (ParameterizedType)mapperClass.getGenericInterfaces()[0]; | |
60 | - String className = parameterizedType.getActualTypeArguments()[0].getTypeName(); | |
61 | - String javaTimefieldName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, tableCleanDto.getTimeFieldName()); | |
62 | - Field timeField = ReflectUtil.getField(Class.forName(className), javaTimefieldName); | |
63 | - if (timeField != null) { | |
64 | - QueryWrapper<?> queryWrapper = new QueryWrapper<>(); | |
53 | + if (tableCleanDto.getMapperName().equals("org.jeecg.modules.wms.monitor.apiLog.mapper.ApiLogMapper")) { | |
65 | 54 | 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)); | |
68 | - BaseMapper baseMapper = (BaseMapper)this.sqlSession.getMapper(mapperClass); | |
69 | - Integer deleteCount = baseMapper.delete(queryWrapper); | |
70 | - log.info("定时任务 TableCleanTask 删除 {} {} 天前数据 {} 行", className, tableCleanDto.getRetentionDays(), deleteCount); | |
55 | + Boolean isContinue = true; | |
56 | + while (isContinue) { | |
57 | + Integer deleteCount = apiLogService.deleteByCreateTime(LocalDateUtils.getStartTimeOfDayStr(localDateTimeValue)); | |
58 | + if (deleteCount.equals(0)) { | |
59 | + isContinue = false; | |
60 | + } | |
61 | + Thread.sleep(1000); | |
62 | + } | |
63 | + continue; | |
71 | 64 | } |
72 | - } catch (ClassNotFoundException e) { | |
65 | + Class<?> mapperClass = Class.forName(tableCleanDto.getMapperName()); | |
66 | + ParameterizedType parameterizedType = (ParameterizedType)mapperClass.getGenericInterfaces()[0]; | |
67 | + String className = parameterizedType.getActualTypeArguments()[0].getTypeName(); | |
68 | + QueryWrapper<?> queryWrapper = new QueryWrapper<>(); | |
69 | + LocalDateTime localDateTimeValue = LocalDateUtils.minus(LocalDateTime.now(), tableCleanDto.getRetentionDays(), ChronoUnit.DAYS); | |
70 | + queryWrapper.lt(tableCleanDto.getTimeFieldName(), LocalDateUtils.getStartTimeOfDayStr(localDateTimeValue)); | |
71 | + BaseMapper baseMapper = (BaseMapper<Object>)this.sqlSession.getMapper(mapperClass); | |
72 | + Integer deleteCount = baseMapper.delete(queryWrapper); | |
73 | + log.info("定时任务 TableCleanTask 删除 {} {} 天前数据 {} 行", className, tableCleanDto.getRetentionDays(), deleteCount); | |
74 | + } catch (ClassNotFoundException | InterruptedException e) { | |
73 | 75 | e.printStackTrace(); |
74 | 76 | } |
75 | 77 | } |
76 | 78 | } |
77 | 79 | } |
78 | - | |
79 | - /** | |
80 | - * 参数范例 | |
81 | - * @author TanYibin | |
82 | - * @createDate 2023年3月16日 | |
83 | - * @param args | |
84 | - */ | |
85 | - public static void main(String[] args) { | |
86 | - List<TableCleanDto> tableCleanList = new ArrayList<TableCleanDto>(); | |
87 | - TableCleanDto tableCleanDto1 = new TableCleanDto(); | |
88 | - tableCleanDto1.setMapperName(SysLogMapper.class.getName()); | |
89 | - tableCleanDto1.setTimeFieldName("create_time"); | |
90 | - tableCleanDto1.setRetentionDays(90); | |
91 | - TableCleanDto tableCleanDto2 = new TableCleanDto(); | |
92 | - tableCleanDto2.setMapperName(OperationLogMapper.class.getName()); | |
93 | - tableCleanDto2.setTimeFieldName("operation_time"); | |
94 | - tableCleanDto2.setRetentionDays(90); | |
95 | - tableCleanList.add(tableCleanDto1); | |
96 | - tableCleanList.add(tableCleanDto2); | |
97 | - System.out.println(JSON.toJSONString(tableCleanList)); | |
98 | - } | |
99 | 80 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/service/impl/ShipmentHeaderServiceImpl.java
... | ... | @@ -431,6 +431,9 @@ public class ShipmentHeaderServiceImpl extends ServiceImpl<ShipmentHeaderMapper, |
431 | 431 | if (shipmentContainerHeader == null) { |
432 | 432 | throw new JeecgBootException("自动出库, 没有找到出库表头:" + shipmentContainerId); |
433 | 433 | } |
434 | + if (shipmentContainerHeader.getStatus().intValue() == QuantityConstant.SHIPMENT_CONTAINER_FINISHED) { | |
435 | + continue; | |
436 | + } | |
434 | 437 | int taskType = shipmentContainerHeader.getTaskType(); |
435 | 438 | int type = QuantityConstant.PORT_TYPE_PICK; |
436 | 439 | if (taskType == QuantityConstant.TASK_TYPE_WHOLESHIPMENT) { |
... | ... |