diff --git a/src/main/java/com/wms/controller/ExcelController.java b/src/main/java/com/wms/controller/ExcelController.java index 8ae11ff..a98df05 100644 --- a/src/main/java/com/wms/controller/ExcelController.java +++ b/src/main/java/com/wms/controller/ExcelController.java @@ -7,8 +7,7 @@ import com.wms.entity.app.ResponseEntity; import com.wms.entity.table.*; import com.wms.service.*; import com.wms.utils.HttpUtils; -import com.wms.utils.StringUtils; -import com.wms.utils.WmsUtils; + import com.wms.utils.excel.ExcelUtils; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @@ -19,6 +18,7 @@ import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -33,7 +33,7 @@ import java.util.*; @RequestMapping(value = "/wms/excel") public class ExcelController extends BaseController { private final StockService stockService;// 库存服务 - private final PartInfoService partInfoService;// 零件服务 + private final GoodsService goodsService;// 零件服务 private final HttpServletRequest servletRequest;// 请求服务 private final TaskRecordService taskRecordService;// 任务记录服务 @@ -50,13 +50,15 @@ public class ExcelController extends BaseController { logger.info("接收到导入零件信息请求,ip地址:{}", HttpUtils.getIpAddr(servletRequest)); ResponseEntity response = new ResponseEntity(); try { - List files = ExcelUtils.readMultipartFile(file, PartInfo.class); + List files = ExcelUtils.readMultipartFile(file, Goods.class); // 添加进物料表 - for (PartInfo pageInfo : files) { - if (partInfoService.selPartByPartNo(pageInfo.getMaterial()) != null) {// 当前零件号的数据已经存在过 - partInfoService.modifyPart(pageInfo); - } else {// 新零件 - partInfoService.addPart(pageInfo); + for (Goods goods : files) { + Goods query = new Goods(); + query.setGoodsName(goods.getGoodsName()); + if (!CollectionUtils.isEmpty(goodsService.selGoods(query))) { + goodsService.modifyGoods(goods); + }else { + goodsService.addGoods(goods); } } response.setCode(ResponseCode.OK.getCode()); @@ -103,8 +105,8 @@ public class ExcelController extends BaseController { @GetMapping("/downloadMaterialExcel") @ResponseBody public void downloadMaterialExcel(HttpServletResponse response) { - List Material = partInfoService.selParts(new PartInfo()); - ExcelUtils.export(response, "物料信息", Material, PartInfo.class); + List goodsList = goodsService.selGoods(new Goods()); + ExcelUtils.export(response, "物料信息", goodsList, Goods.class); } } \ No newline at end of file diff --git a/src/main/java/com/wms/controller/LocationController.java b/src/main/java/com/wms/controller/LocationController.java index a520ec1..6af4406 100644 --- a/src/main/java/com/wms/controller/LocationController.java +++ b/src/main/java/com/wms/controller/LocationController.java @@ -8,6 +8,7 @@ import com.wms.constants.enums.VehicleStatus; import com.wms.entity.app.LayerLocation; import com.wms.entity.app.ResponseEntity; import com.wms.entity.app.RowLocation; +import com.wms.entity.dto.locaiton.SelectArea; import com.wms.entity.page.PageDomain; import com.wms.entity.page.TableRequest; import com.wms.entity.page.TableResponse; @@ -212,7 +213,6 @@ public class LocationController extends BaseController { // 创建响应信息 ResponseEntity rsp = new ResponseEntity(); try { - // TODO 这里要更新料箱信息 if (StringUtils.isNotEmpty(location.getVehicleId())) {// 载具号不为空 // 判断是不是需要往载具表里面添加数据 if (vehicleService.selVehicleById(location.getVehicleId()) == null) { @@ -408,4 +408,51 @@ public class LocationController extends BaseController { rsp.setMessage("删除料箱成功"); return JSON.toJSONString(rsp); } + + + + /** + * 更新库位状态 + * + * @param selectArea 库位 + * @return 结果 + */ + @PostMapping("/updateArea") + @ResponseBody + @Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) + public String updateArea(@RequestBody SelectArea selectArea) { + // 创建响应信息 + ResponseEntity rsp = new ResponseEntity(); + try { + if ("reset".equals(selectArea.getChooseArea())){ + selectArea.setStartQueue(11); + selectArea.setEndQueue(22); + selectArea.setStartLine(11); + selectArea.setEndLine(48); + selectArea.setStartLayer(1); + selectArea.setEndLayer(4); + selectArea.setChooseArea("A"); + locationService.modifyArea(selectArea); + } + if (selectArea.isStartQueueLessThanEndQueue() || selectArea.isStartLineLessThanEndLine() || selectArea.isStartLayerLessThanEndLayer()) {// 载具号不为空 + // 判断是不是需要往载具表里面添加数据 + rsp.setCode(ResponseCode.ERROR.getCode()); + rsp.setMessage("参数填写错误"); + return JSON.toJSONString(rsp); + } + locationService.modifyArea(selectArea); + } catch (Exception e) { + // 回滚事务 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + logger.info("更新库位状态发生错误:{}", e.getMessage()); + // 返回其他异常 + rsp.setCode(ResponseCode.ERROR.getCode()); + rsp.setMessage(e.getMessage()); + return JSON.toJSONString(rsp); + } + // 返回成功 + rsp.setCode(ResponseCode.OK.getCode()); + rsp.setMessage("更新库位状态成功"); + return JSON.toJSONString(rsp); + } } \ No newline at end of file diff --git a/src/main/java/com/wms/entity/dto/locaiton/SelectArea.java b/src/main/java/com/wms/entity/dto/locaiton/SelectArea.java new file mode 100644 index 0000000..f0cbe50 --- /dev/null +++ b/src/main/java/com/wms/entity/dto/locaiton/SelectArea.java @@ -0,0 +1,55 @@ +package com.wms.entity.dto.locaiton; + +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @Classname SelectArea + * @Date 2025-02-26 0:02 + * @Created by luyifan + */ +@Data +public class SelectArea { + + @NotNull(message = "开始排不能为空") + @Min(value = 1, message = "开始排必须大于0") + private Integer startQueue; + + @NotNull(message = "结束排不能为空") + @Min(value = 1, message = "结束排必须大于0") + private Integer endQueue; + + @NotNull(message = "开始列不能为空") + @Min(value = 1, message = "开始列必须大于0") + private Integer startLine; + + @NotNull(message = "结束列不能为空") + @Min(value = 1, message = "结束列必须大于0") + private Integer endLine; + + @NotNull(message = "开始层不能为空") + @Min(value = 1, message = "开始层必须大于0") + private Integer startLayer; + + @NotNull(message = "结束层不能为空") + @Min(value = 1, message = "结束层必须大于0") + private Integer endLayer; + + @NotNull(message = "结束层不能为空") + private String chooseArea; + + public boolean isStartLineLessThanEndLine() { + return startLine >= endLine; + } + + public boolean isStartQueueLessThanEndQueue() { + return startQueue>= endQueue; + } + + public boolean isStartLayerLessThanEndLayer() { + return startQueue>= endQueue; + } +} + + diff --git a/src/main/java/com/wms/entity/table/Location.java b/src/main/java/com/wms/entity/table/Location.java index 0a92c57..c7ee8a8 100644 --- a/src/main/java/com/wms/entity/table/Location.java +++ b/src/main/java/com/wms/entity/table/Location.java @@ -77,6 +77,20 @@ public class Location extends BaseEntity { */ private String vehicleId; + + /** + * 是否为空托盘存放区域 0: 否, 1: 是 + */ + private Integer isEmptyArea; + + public Integer getIsEmptyArea() { + return isEmptyArea; + } + + public void setIsEmptyArea(Integer isEmptyArea) { + this.isEmptyArea = isEmptyArea; + } + public Location() { } diff --git a/src/main/java/com/wms/mapper/LocationMapper.java b/src/main/java/com/wms/mapper/LocationMapper.java index c73f5c6..a345158 100644 --- a/src/main/java/com/wms/mapper/LocationMapper.java +++ b/src/main/java/com/wms/mapper/LocationMapper.java @@ -1,5 +1,6 @@ package com.wms.mapper; +import com.wms.entity.dto.locaiton.SelectArea; import com.wms.entity.table.Location; import org.apache.ibatis.annotations.Mapper; @@ -41,4 +42,11 @@ public interface LocationMapper { * @return */ int modifyLocation(Location location); + + /** + * 修改区域 + * @param location + * @return + */ + int modifyArea(SelectArea selectArea); } diff --git a/src/main/java/com/wms/service/LocationService.java b/src/main/java/com/wms/service/LocationService.java index 5a436b0..a630563 100644 --- a/src/main/java/com/wms/service/LocationService.java +++ b/src/main/java/com/wms/service/LocationService.java @@ -1,5 +1,6 @@ package com.wms.service; +import com.wms.entity.dto.locaiton.SelectArea; import com.wms.entity.table.Location; import java.util.List; @@ -33,4 +34,11 @@ public interface LocationService { * @return 结果 */ int modifyLocation(Location location); + + /** + * 区域划分 + * @param location 选择的区域 + * @return 结果 + */ + int modifyArea(SelectArea selectArea); } diff --git a/src/main/java/com/wms/service/serviceImplements/LocationServiceImplements.java b/src/main/java/com/wms/service/serviceImplements/LocationServiceImplements.java index ecfabd4..11e045b 100644 --- a/src/main/java/com/wms/service/serviceImplements/LocationServiceImplements.java +++ b/src/main/java/com/wms/service/serviceImplements/LocationServiceImplements.java @@ -1,5 +1,6 @@ package com.wms.service.serviceImplements; +import com.wms.entity.dto.locaiton.SelectArea; import com.wms.entity.table.Location; import com.wms.mapper.LocationMapper; import com.wms.service.LocationService; @@ -36,4 +37,9 @@ public class LocationServiceImplements implements LocationService { public int modifyLocation(Location location) { return this.locationMapper.modifyLocation(location); } + + @Override + public int modifyArea(SelectArea selectArea) { + return this.locationMapper.modifyArea(selectArea); + } } diff --git a/src/main/resources/mapper/LocationMapper.xml b/src/main/resources/mapper/LocationMapper.xml index 5bf3148..2223db7 100644 --- a/src/main/resources/mapper/LocationMapper.xml +++ b/src/main/resources/mapper/LocationMapper.xml @@ -40,7 +40,7 @@ and vehicle_id = #{vehicleId} and ware_area = #{wareArea} - order by depth desc, line asc, layer asc + order by tunnel_id asc,depth desc, layer asc, line desc