Browse Source

修改托盘无法进行修改的bug

lwx_dev
erdanergou 2 years ago
parent
commit
0a2860fff5
  1. 26
      src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java

26
src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java

@ -109,7 +109,7 @@ public class PlaceController {
if (maxQuantity >= 999999999) { if (maxQuantity >= 999999999) {
insert.put("max", 999999999); insert.put("max", 999999999);
} else { } else {
insert.put("max",maxQuantity); insert.put("max", maxQuantity);
} }
} else { } else {
insert.put("max", 0); insert.put("max", 0);
@ -317,18 +317,28 @@ public class PlaceController {
@PostMapping("/tray_edit") @PostMapping("/tray_edit")
public RestResponse trayEdit(@RequestBody Map<String, Object> map) { public RestResponse trayEdit(@RequestBody Map<String, Object> map) {
if (!map.containsKey("id")) {
throw new MyException("缺少必要参数");
}
Integer id = ObjectFormatUtil.toInteger(map.get("id"));
if (map.containsKey("state")) { if (map.containsKey("state")) {
map.put("state", 1); map.put("state", 1);
} else { } else {
map.put("state", 2); map.put("state", 2);
} }
String code = (String) map.get("code"); String code = (String) map.get("code");
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("did")); Place placeById = placeService.findPlaceById(id);
Place placeByDidAndCode = placeService.findPlaceByDidAndCode(depositoryId, code);
if (placeByDidAndCode != null) {
return new RestResponse("", 12345, new StatusInfo("修改失败", "该编码已经存在"));
}
Map<String, Object> update = new HashMap<>(); Map<String, Object> update = new HashMap<>();
if (!code.equals(placeById.getCode())) {
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("did"));
Place placeByDidAndCode = placeService.findPlaceByDidAndCode(depositoryId, code);
if (placeByDidAndCode == null) {
update.put("code", code);
} else {
return new RestResponse("", 12345, new StatusInfo("修改失败", "该编码已经存在"));
}
}
String min = (String) map.get("min"); String min = (String) map.get("min");
String max = (String) map.get("max"); String max = (String) map.get("max");
if (!"".equals(min)) { if (!"".equals(min)) {
@ -346,8 +356,8 @@ public class PlaceController {
} else { } else {
update.put("max", 50000); update.put("max", 50000);
} }
update.put("code", code);
update.put("id", map.get("id")); update.put("id", id);
return CrudUtil.insertHandle(placeService.UpdatePlace(update), 1); return CrudUtil.insertHandle(placeService.UpdatePlace(update), 1);
} }

Loading…
Cancel
Save