feat(库位信息): 添加自定义区域划分

This commit is contained in:
陆一凡 2025-02-26 01:00:27 +08:00
parent 48461031e7
commit 8a9ac391cf
8 changed files with 163 additions and 14 deletions

View File

@ -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<PartInfo> files = ExcelUtils.readMultipartFile(file, PartInfo.class);
List<Goods> 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<PartInfo> Material = partInfoService.selParts(new PartInfo());
ExcelUtils.export(response, "物料信息", Material, PartInfo.class);
List<Goods> goodsList = goodsService.selGoods(new Goods());
ExcelUtils.export(response, "物料信息", goodsList, Goods.class);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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() {
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -40,7 +40,7 @@
<if test="vehicleId != null and vehicleId != ''"> and vehicle_id = #{vehicleId}</if>
<if test="wareArea != null and wareArea != ''"> and ware_area = #{wareArea}</if>
</where>
order by depth desc, line asc, layer asc
order by tunnel_id asc,depth desc, layer asc, line desc
</select>
<select id="selSmallDepthLocations" parameterType="Location" resultMap="LocationMap">
@ -69,7 +69,7 @@
<if test="wareArea != null"> and ware_area = #{wareArea}</if>
and is_lock = 0 and location_status = 0
</where>
order by depth desc, layer asc, line desc
order by tunnel_id asc,depth desc, layer asc, line desc
for update
</select>
<select id="selectAll" resultType="java.lang.Integer">
@ -119,4 +119,13 @@
</trim>
where location_id = #{locationId}
</update>
<update id="modifyArea" parameterType="com.wms.entity.dto.locaiton.SelectArea">
update tbl_app_location
<trim prefix="SET" suffixOverrides=",">
<if test="chooseArea != null || chooseArea!= ''">ware_area = #{chooseArea},</if>
</trim>
where queue &gt;= #{startQueue} and queue &lt;= #{endQueue} and line &gt;= #{startLine} and line &lt;= #{endLine} and layer &gt;= #{startLayer} and layer &lt;= #{endLayer}
</update>
</mapper>