Commit 32c1ebc6bf828669a9a71500d56329fe7fb58cec
1 parent
e81595a6
feat:增加新接口,完成增加空库位查询需求,接口测试已完成,数据确认无误。ps:尚未去除预留库位
Showing
7 changed files
with
119 additions
and
2 deletions
src/main/java/com/huaheng/pc/config/location/controller/LocationController.java
... | ... | @@ -361,4 +361,12 @@ public class LocationController extends BaseController { |
361 | 361 | { |
362 | 362 | print.jasperPrint(ids, prefix);// 不用返回json打印 |
363 | 363 | } |
364 | + | |
365 | + | |
366 | + @Log(title = "监控-库位空闲监控-库位管理", operating = "查看库位空闲结果", action = BusinessType.GRANT) | |
367 | + @PostMapping("/getIdleLocation") | |
368 | + @ResponseBody | |
369 | + public AjaxResult<?> getIdleLocation() { | |
370 | + return AjaxResult.success(locationService.getIdleLocation()); | |
371 | + } | |
364 | 372 | } |
... | ... |
src/main/java/com/huaheng/pc/config/location/domain/bo/LocationIdleBO.java
0 → 100644
1 | +package com.huaheng.pc.config.location.domain.bo; | |
2 | + | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | +import lombok.Builder; | |
5 | +import lombok.Data; | |
6 | + | |
7 | +import java.io.Serializable; | |
8 | + | |
9 | +/** | |
10 | + * @author puff | |
11 | + * @date 2023-06-21 | |
12 | + */ | |
13 | +@Data | |
14 | +@Builder | |
15 | +public class LocationIdleBO implements Serializable { | |
16 | + | |
17 | + @ApiModelProperty(value = "层级") | |
18 | + private String ilayer; | |
19 | + @ApiModelProperty(value = "巷道") | |
20 | + private String roadway; | |
21 | + @ApiModelProperty(value = "行数") | |
22 | + private Integer irow; | |
23 | + @ApiModelProperty(value = "空闲数") | |
24 | + private Integer idleCount; | |
25 | +} | |
... | ... |
src/main/java/com/huaheng/pc/config/location/domain/vo/LocationIdleVO.java
0 → 100644
1 | +package com.huaheng.pc.config.location.domain.vo; | |
2 | + | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | +import lombok.Builder; | |
5 | +import lombok.Data; | |
6 | + | |
7 | +import java.io.Serializable; | |
8 | + | |
9 | +/** | |
10 | + * @author puff | |
11 | + * @date 2023-06-21 | |
12 | + */ | |
13 | +@Data | |
14 | +public class LocationIdleVO implements Serializable { | |
15 | + | |
16 | + @ApiModelProperty(value = "巷道") | |
17 | + private String roadway; | |
18 | + @ApiModelProperty(value = "行数") | |
19 | + private Integer irow; | |
20 | + @ApiModelProperty(value = "空闲数") | |
21 | + private Integer idleCount; | |
22 | +} | |
... | ... |
src/main/java/com/huaheng/pc/config/location/mapper/LocationMapper.java
... | ... | @@ -2,6 +2,7 @@ package com.huaheng.pc.config.location.mapper; |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | 4 | import com.huaheng.pc.config.location.domain.Location; |
5 | +import com.huaheng.pc.config.location.domain.bo.LocationIdleBO; | |
5 | 6 | import org.apache.ibatis.annotations.Param; |
6 | 7 | |
7 | 8 | import java.util.LinkedHashMap; |
... | ... | @@ -33,4 +34,6 @@ public interface LocationMapper extends BaseMapper<Location> { |
33 | 34 | int getLastRowOfZone(@Param("warehouseCode") String warehouseCode, @Param("locationType") String locationType); |
34 | 35 | |
35 | 36 | int updateStatusNew(@Param("code") String code, @Param("warehouseCode") String warehouseCode,@Param("status") String status, @Param("oldStatus") String oldStatus); |
37 | + | |
38 | + List<LocationIdleBO> getIdleLocation(); | |
36 | 39 | } |
... | ... |
src/main/java/com/huaheng/pc/config/location/service/LocationService.java
... | ... | @@ -4,6 +4,7 @@ import com.huaheng.framework.web.domain.AjaxResult; |
4 | 4 | import com.huaheng.pc.config.location.domain.Location; |
5 | 5 | import com.baomidou.mybatisplus.extension.service.IService; |
6 | 6 | import com.huaheng.pc.config.location.domain.LocationInfo; |
7 | +import com.huaheng.pc.config.location.domain.vo.LocationIdleVO; | |
7 | 8 | |
8 | 9 | import java.util.LinkedHashMap; |
9 | 10 | import java.util.List; |
... | ... | @@ -118,4 +119,11 @@ public interface LocationService extends IService<Location>{ |
118 | 119 | void upstatus(String code); |
119 | 120 | |
120 | 121 | int updateStatusNew(String locationCode, String warehouseCode, String status, String oldStatus); |
122 | + | |
123 | + /** | |
124 | + * 查询空闲库位数量 | |
125 | + * @return | |
126 | + */ | |
127 | + List<LocationIdleVO> getIdleLocation(); | |
128 | + | |
121 | 129 | } |
... | ... |
src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
... | ... | @@ -12,17 +12,21 @@ import com.huaheng.common.utils.security.ShiroUtils; |
12 | 12 | import com.huaheng.framework.web.domain.AjaxResult; |
13 | 13 | import com.huaheng.pc.config.location.domain.Location; |
14 | 14 | import com.huaheng.pc.config.location.domain.LocationInfo; |
15 | +import com.huaheng.pc.config.location.domain.bo.LocationIdleBO; | |
16 | +import com.huaheng.pc.config.location.domain.vo.LocationIdleVO; | |
15 | 17 | import com.huaheng.pc.config.location.mapper.LocationMapper; |
16 | 18 | import com.huaheng.pc.config.locationType.domain.LocationType; |
17 | 19 | import com.huaheng.pc.config.locationType.service.LocationTypeService; |
18 | 20 | import com.huaheng.pc.config.zone.domain.Zone; |
19 | 21 | import com.huaheng.pc.config.zone.service.ZoneService; |
20 | 22 | import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; |
23 | +import io.swagger.models.auth.In; | |
21 | 24 | import org.springframework.stereotype.Service; |
22 | 25 | |
23 | 26 | import javax.annotation.Resource; |
24 | 27 | import java.text.MessageFormat; |
25 | 28 | import java.util.*; |
29 | +import java.util.stream.Collectors; | |
26 | 30 | |
27 | 31 | @Service("LocationService") |
28 | 32 | public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> implements LocationService { |
... | ... | @@ -361,7 +365,7 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
361 | 365 | } |
362 | 366 | |
363 | 367 | @Override |
364 | - public void updateContainerCodeAndStatus(String locationCode, String containerCode, | |
368 | + public void updateContainerCodeAndStatus(String locationCode, String containerCode, | |
365 | 369 | String status, String warehouseCode) { |
366 | 370 | if (StringUtils.isNotEmpty(locationCode) || StringUtils.isNotEmpty(containerCode)) { |
367 | 371 | LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate(); |
... | ... | @@ -371,7 +375,10 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
371 | 375 | .eq(Location::getCode, locationCode); |
372 | 376 | this.update(updateWrapper); |
373 | 377 | } |
374 | - } public LocationInfo getAllLocation(String type) { | |
378 | + } | |
379 | + | |
380 | + @Override | |
381 | + public LocationInfo getAllLocation(String type) { | |
375 | 382 | if (StringUtils.isNotEmpty(type)) { |
376 | 383 | Location location = locationMapper.getAllLocation(ShiroUtils.getWarehouseCode(), type); |
377 | 384 | LocationInfo locationInfo = new LocationInfo(); |
... | ... | @@ -667,4 +674,26 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
667 | 674 | } |
668 | 675 | return 0; |
669 | 676 | } |
677 | + | |
678 | + @Override | |
679 | + public List<LocationIdleVO> getIdleLocation() { | |
680 | + List<LocationIdleBO> idleBOList = locationMapper.getIdleLocation(); | |
681 | + return idleBOList.stream() | |
682 | + .collect(Collectors.groupingBy(LocationIdleBO::getRoadway)) // 以巷道分组 | |
683 | + .entrySet().stream() | |
684 | + .flatMap(entry -> entry.getValue().stream() | |
685 | + .collect(Collectors.groupingBy(LocationIdleBO::getIrow)) // 获取当前巷道分组下的行级别数据 | |
686 | + .entrySet().stream() | |
687 | + .map(rowEntry -> { | |
688 | + Integer idleCount = rowEntry.getValue().stream() | |
689 | + .mapToInt(LocationIdleBO::getIdleCount) | |
690 | + .sum(); // 计算空闲库位数量 | |
691 | + LocationIdleVO idleInfo = new LocationIdleVO(); | |
692 | + idleInfo.setRoadway(entry.getKey()); | |
693 | + idleInfo.setIrow(rowEntry.getKey()); | |
694 | + idleInfo.setIdleCount(idleCount); | |
695 | + return idleInfo; | |
696 | + })) | |
697 | + .collect(Collectors.toList()); | |
698 | + } | |
670 | 699 | } |
... | ... |
src/main/resources/mybatis/config/LocationMapper.xml
... | ... | @@ -32,6 +32,14 @@ |
32 | 32 | <result column="systemCreated" jdbcType="INTEGER" property="systemCreated" /> |
33 | 33 | <result column="deleted" jdbcType="BIT" property="deleted" /> |
34 | 34 | </resultMap> |
35 | + | |
36 | + <resultMap id="BaseResultLocationIdleBOMap" type="com.huaheng.pc.config.location.domain.bo.LocationIdleBO"> | |
37 | + <result column="ilayer" jdbcType="VARCHAR" property="ilayer" /> | |
38 | + <result column="roadway" jdbcType="VARCHAR" property="roadway" /> | |
39 | + <result column="irow" jdbcType="INTEGER" property="irow" /> | |
40 | + <result column="count" jdbcType="INTEGER" property="idleCount" /> | |
41 | + </resultMap> | |
42 | + | |
35 | 43 | <sql id="Base_Column_List"> |
36 | 44 | <!--@mbg.generated--> |
37 | 45 | id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer, |
... | ... | @@ -47,6 +55,20 @@ |
47 | 55 | select code from location where #{locatingRule} |
48 | 56 | </select> |
49 | 57 | |
58 | + <select id="getIdleLocation" resultMap="BaseResultLocationIdleBOMap"> | |
59 | + select ilayer ,roadway, irow, COUNT(*) AS idleCount | |
60 | + FROM location | |
61 | + WHERE area = '1' -- 区域 | |
62 | + AND warehouseCode = 'CS0001' -- 仓库 | |
63 | + AND roadway IN ('1', '2', '3', '4') -- 巷道 | |
64 | + AND status = 'empty' -- 状态:锁定、禁用,空闲 | |
65 | + AND high IN (0, 1) -- 0 是低库位,1 是高库位 | |
66 | + AND locationType IN ('L') -- 货位类型 | |
67 | + AND containerCode = '' -- 容器编码 | |
68 | + GROUP BY ilayer, irow | |
69 | + ORDER BY ilayer, irow; | |
70 | + </select> | |
71 | + | |
50 | 72 | <insert id="addList" parameterType="com.huaheng.pc.config.location.domain.Location" keyProperty="id" useGeneratedKeys="true" > |
51 | 73 | INSERT INTO location( |
52 | 74 | code, |
... | ... |