Commit dc7fd2eef011044ef3bf7a03fffb4c13dd5a2758

Authored by 易文鹏
1 parent 1ca89a52

feat: 修复了容器管理增加托盘1个会失败的问题

src/main/java/com/huaheng/pc/config/container/service/ContainerServiceImpl.java
@@ -24,7 +24,7 @@ import java.util.Date; @@ -24,7 +24,7 @@ import java.util.Date;
24 import java.util.List; 24 import java.util.List;
25 25
26 @Service 26 @Service
27 -public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container> implements ContainerService{ 27 +public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container> implements ContainerService {
28 28
29 @Resource 29 @Resource
30 private ContainerTypeService containerTypeService; 30 private ContainerTypeService containerTypeService;
@@ -37,10 +37,9 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -37,10 +37,9 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
37 37
38 @Override 38 @Override
39 public AjaxResult<List<Container>> insertContainer(String type, Integer quantity) { 39 public AjaxResult<List<Container>> insertContainer(String type, Integer quantity) {
40 - List<Container> containerList = new ArrayList<>();  
41 - List<Container> containers =new ArrayList<>(); 40 + List<Container> containers = new ArrayList<>();
42 Integer number = getNumber(type); 41 Integer number = getNumber(type);
43 - for(int i=0; i<quantity; i++) { 42 + for (int i = 0; i < quantity; i++) {
44 number++; 43 number++;
45 Container container = new Container(); 44 Container container = new Container();
46 container.setContainerType(type); 45 container.setContainerType(type);
@@ -51,10 +50,10 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -51,10 +50,10 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
51 container.setLastUpdated(null); 50 container.setLastUpdated(null);
52 container.setLastUpdatedBy(null); 51 container.setLastUpdatedBy(null);
53 container.setEnable(true); 52 container.setEnable(true);
54 - //container.setCompanyCode(ShiroUtils.getCompanyCodeList().get(0));  
55 container.setWarehouseCode(ShiroUtils.getWarehouseCode()); 53 container.setWarehouseCode(ShiroUtils.getWarehouseCode());
56 containers.add(container); 54 containers.add(container);
57 - if( i>0 && (i%1000==0 || i == quantity-1)){ 55 +
  56 + if (i % 1000 == 0 || i == quantity - 1) {
58 containerMapper.addList(containers); 57 containerMapper.addList(containers);
59 containers = new ArrayList<>(); 58 containers = new ArrayList<>();
60 } 59 }
@@ -75,16 +74,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -75,16 +74,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
75 //如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1) 74 //如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1)
76 if (container != null && container.getCode() != null) { 75 if (container != null && container.getCode() != null) {
77 Integer number = Integer.valueOf(container.getCode().substring(container.getCode().length() - 5, container.getCode().length())); 76 Integer number = Integer.valueOf(container.getCode().substring(container.getCode().length() - 5, container.getCode().length()));
78 - return number; 77 + return number;
79 } else { 78 } else {
80 - return 0; 79 + return 0;
81 } 80 }
82 } 81 }
83 82
84 @Override 83 @Override
85 - public String importContainer(List<Container> containerList, Boolean updateSupport, String operName){ 84 + public String importContainer(List<Container> containerList, Boolean updateSupport, String operName) {
86 if (StringUtils.isNull(containerList) || containerList.size() == 0) { 85 if (StringUtils.isNull(containerList) || containerList.size() == 0) {
87 - throw new BusinessException("导入数据不能为空!"); 86 + throw new BusinessException("导入数据不能为空!");
88 } 87 }
89 int successNum = 0; 88 int successNum = 0;
90 int failureNum = 0; 89 int failureNum = 0;
@@ -127,15 +126,15 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -127,15 +126,15 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
127 126
128 /** 127 /**
129 * 已入空容器展示 128 * 已入空容器展示
130 - * */ 129 + */
131 @Override 130 @Override
132 public List<Location> getEmptyContainerInLocation(String zoneCode, String containerCode, String locationCode, String warehouseCode) { 131 public List<Location> getEmptyContainerInLocation(String zoneCode, String containerCode, String locationCode, String warehouseCode) {
133 - return containerMapper.getEmptyContainerInLocation(zoneCode, containerCode,locationCode,warehouseCode); 132 + return containerMapper.getEmptyContainerInLocation(zoneCode, containerCode, locationCode, warehouseCode);
134 } 133 }
135 134
136 /** 135 /**
137 * 修改容器库位和状态 136 * 修改容器库位和状态
138 - * */ 137 + */
139 @Override 138 @Override
140 public void updateLocationCodeAndStatus(String containerCode, String locationCode, String status) { 139 public void updateLocationCodeAndStatus(String containerCode, String locationCode, String status) {
141 if (StringUtils.isNotEmpty(containerCode) || StringUtils.isNotEmpty(locationCode)) { 140 if (StringUtils.isNotEmpty(containerCode) || StringUtils.isNotEmpty(locationCode)) {
@@ -154,15 +153,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -154,15 +153,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
154 public boolean updateStatus(String containerCode, String status, String warehouseCode) { 153 public boolean updateStatus(String containerCode, String status, String warehouseCode) {
155 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); 154 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
156 containerLambdaQueryWrapper.eq(Container::getCode, containerCode) 155 containerLambdaQueryWrapper.eq(Container::getCode, containerCode)
157 - .eq(Container::getWarehouseCode, warehouseCode); 156 + .eq(Container::getWarehouseCode, warehouseCode);
158 Container container = getOne(containerLambdaQueryWrapper); 157 Container container = getOne(containerLambdaQueryWrapper);
159 container.setStatus(status); 158 container.setStatus(status);
160 - boolean result = update(container, containerLambdaQueryWrapper); 159 + boolean result = update(container, containerLambdaQueryWrapper);
161 return result; 160 return result;
162 } 161 }
163 162
164 /** 163 /**
165 * 如果为临时容器,在取消组盘和出库任务完成时删除容器 164 * 如果为临时容器,在取消组盘和出库任务完成时删除容器
  165 + *
166 * @param containerType 容器类型 166 * @param containerType 容器类型
167 * @param containerCode 容器编码 167 * @param containerCode 容器编码
168 * @return 168 * @return
@@ -172,8 +172,8 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container @@ -172,8 +172,8 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
172 public void removeContainer(String containerType, String containerCode) { 172 public void removeContainer(String containerType, String containerCode) {
173 if ("LS".equals(containerType)) { 173 if ("LS".equals(containerType)) {
174 LambdaQueryWrapper<Container> lambdaQueryWrapper = Wrappers.lambdaQuery(); 174 LambdaQueryWrapper<Container> lambdaQueryWrapper = Wrappers.lambdaQuery();
175 - lambdaQueryWrapper.eq(Container::getCode,containerCode);  
176 - if (!this.remove(lambdaQueryWrapper)){ 175 + lambdaQueryWrapper.eq(Container::getCode, containerCode);
  176 + if (!this.remove(lambdaQueryWrapper)) {
177 throw new ServiceException("删除临时容器失败"); 177 throw new ServiceException("删除临时容器失败");
178 } 178 }
179 } 179 }
src/main/java/com/huaheng/pc/inventory/inventoryHeader/controller/InventoryHeaderController.java
@@ -112,8 +112,16 @@ public class InventoryHeaderController extends BaseController { @@ -112,8 +112,16 @@ public class InventoryHeaderController extends BaseController {
112 .in(InventoryHeader::getCompanyCode, ShiroUtils.getCompanyCodeList()) 112 .in(InventoryHeader::getCompanyCode, ShiroUtils.getCompanyCodeList())
113 .orderByDesc(InventoryHeader::getId); 113 .orderByDesc(InventoryHeader::getId);
114 114
115 - IPage<InventoryHeader> iPage = inventoryHeaderService.page(new Page<>(pageNum, pageSize), lambdaQueryWrapper);  
116 - return getMpDataTable(inventoryHeaderService.inventoryToDto(iPage.getRecords()), iPage.getTotal()); 115 +
  116 + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
  117 + //分页查询
  118 + Page<InventoryHeader> page = new Page<>(pageNum, pageSize);
  119 + IPage<InventoryHeader> iPage = inventoryHeaderService.page(page, lambdaQueryWrapper);
  120 + return getMpDataTable(inventoryHeaderService.inventoryToDto(iPage.getRecords()), iPage.getTotal());
  121 + } else {
  122 + List<InventoryHeader> list = inventoryHeaderService.list(lambdaQueryWrapper);
  123 + return getDataTable(inventoryHeaderService.inventoryToDto(list));
  124 + }
117 } 125 }
118 126
119 127