Browse Source

修改仓储中心提交出库申请时由自己审批

lwx_dev
erdanergou 3 years ago
parent
commit
a325dee2cb
  1. 223
      src/main/java/com/dreamchaser/depository_manage/controller/PlaceController.java

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

@ -71,6 +71,7 @@ public class PlaceController {
/** /**
* 用于创建库位 * 用于创建库位
*
* @param map * @param map
* @return * @return
*/ */
@ -87,7 +88,7 @@ public class PlaceController {
String min = (String) map.get("min"); String min = (String) map.get("min");
String max = (String) map.get("max"); String max = (String) map.get("max");
// String code = String.format("%02d", place_x) + String.format("%02d", place_y) + String.format("%02d", place_z); // String code = String.format("%02d", place_x) + String.format("%02d", place_y) + String.format("%02d", place_z);
String code = String.format("%02d", place_x) + String.format("%02d", place_z); String code = String.format("%02d", place_x) + String.format("%02d", place_z);
insert.put("x", place_x); insert.put("x", place_x);
// insert.put("y", place_y); // insert.put("y", place_y);
insert.put("z", place_z); insert.put("z", place_z);
@ -107,12 +108,11 @@ public class PlaceController {
} else { } else {
insert.put("max", 0); insert.put("max", 0);
} }
insert.put("state",1); insert.put("state", 1);
insert.put("quantity",0); insert.put("quantity", 0);
insert.put("flagType",1); insert.put("flagType", 1);
success += placeService.InsertPlace(insert); success += placeService.InsertPlace(insert);
} } else if ("list".equals(type)) {
else if("list".equals(type)){
//获取起始、终止行 //获取起始、终止行
Integer place_start_x = ObjectFormatUtil.toInteger(map.get("place_start_x")); Integer place_start_x = ObjectFormatUtil.toInteger(map.get("place_start_x"));
Integer place_end_x = ObjectFormatUtil.toInteger(map.get("place_end_x")); Integer place_end_x = ObjectFormatUtil.toInteger(map.get("place_end_x"));
@ -124,50 +124,48 @@ public class PlaceController {
Integer place_end_z = ObjectFormatUtil.toInteger(map.get("place_end_z")); Integer place_end_z = ObjectFormatUtil.toInteger(map.get("place_end_z"));
// 计算所需库位数目 // 计算所需库位数目
// total = (place_end_x - place_start_x) * (place_end_y - place_start_y) * (place_end_z - place_start_z); // total = (place_end_x - place_start_x) * (place_end_y - place_start_y) * (place_end_z - place_start_z);
total = (place_end_x - place_start_x + 1) * (place_end_z - place_start_z + 1); total = (place_end_x - place_start_x + 1) * (place_end_z - place_start_z + 1);
String min = (String) map.get("min"); String min = (String) map.get("min");
String max = (String) map.get("max"); String max = (String) map.get("max");
Depository depository = depositoryService.findDepositoryById(ObjectFormatUtil.toInteger(map.get("depositoryId"))); Depository depository = depositoryService.findDepositoryById(ObjectFormatUtil.toInteger(map.get("depositoryId")));
String depositoryCode = depository.getCode(); String depositoryCode = depository.getCode();
for (int i = place_start_x; i <= place_end_x; i++) { for (int i = place_start_x; i <= place_end_x; i++) {
// for (int j = place_start_y; j < place_end_y; j++) { // for (int j = place_start_y; j < place_end_y; j++) {
for (int k = place_start_z; k <= place_end_z; k++) { for (int k = place_start_z; k <= place_end_z; k++) {
// String code = String.format("%02d", i) + String.format("%02d", j) + String.format("%02d", k); // String code = String.format("%02d", i) + String.format("%02d", j) + String.format("%02d", k);
String code = String.format("%02d", i) + String.format("%02d", k); String code = String.format("%02d", i) + String.format("%02d", k);
insert.put("x",i); insert.put("x", i);
// insert.put("y",j); // insert.put("y",j);
insert.put("z",k); insert.put("z", k);
insert.put("code",code); insert.put("code", code);
String kingdeeCode = depositoryCode.substring(depositoryCode.length() - 2) + code; String kingdeeCode = depositoryCode.substring(depositoryCode.length() - 2) + code;
insert.put("did", map.get("depositoryId")); insert.put("did", map.get("depositoryId"));
insert.put("kingdeecode", kingdeeCode); insert.put("kingdeecode", kingdeeCode);
insert.put("min",min); insert.put("min", min);
insert.put("max",max); insert.put("max", max);
insert.put("state",1); insert.put("state", 1);
insert.put("quantity",0); insert.put("quantity", 0);
insert.put("flagType",1); insert.put("flagType", 1);
success += placeService.InsertPlace(insert); success += placeService.InsertPlace(insert);
} }
// } // }
} }
} } else {
else{
throw new MyException("所需请求参数缺失!"); throw new MyException("所需请求参数缺失!");
} }
if ("one".equals(type)) { if ("one".equals(type)) {
return CrudUtil.insertHandle(success, 1); return CrudUtil.insertHandle(success, 1);
} else if("list".equals(type)){ } else if ("list".equals(type)) {
return CrudUtil.insertHandle(success,total); return CrudUtil.insertHandle(success, total);
}else{ } else {
throw new MyException("请求参数错误!"); throw new MyException("请求参数错误!");
} }
} }
@PostMapping("/addTray") @PostMapping("/addTray")
public RestResponse addTray(@RequestBody Map<String,Object> map){ public RestResponse addTray(@RequestBody Map<String, Object> map) {
String type = (String) map.get("type"); String type = (String) map.get("type");
Map<String, Object> insert = new HashMap<>(); Map<String, Object> insert = new HashMap<>();
Integer success = 0; Integer success = 0;
@ -180,7 +178,12 @@ public class PlaceController {
insert.put("min", 0); insert.put("min", 0);
} }
if (!"".equals(max)) { if (!"".equals(max)) {
insert.put("max", map.get("max")); Double maxQuantity = ObjectFormatUtil.toDouble(max);
if (maxQuantity >= 999999999) {
insert.put("max", 999999999);
} else {
insert.put("max", map.get("max"));
}
} else { } else {
insert.put("max", 0); insert.put("max", 0);
} }
@ -189,46 +192,48 @@ public class PlaceController {
// 获取当前仓库的托盘数量 // 获取当前仓库的托盘数量
Integer countForTray = placeService.findPlaceCoutnByTypeForFlag(2, ObjectFormatUtil.toInteger(depositoryId)); Integer countForTray = placeService.findPlaceCoutnByTypeForFlag(2, ObjectFormatUtil.toInteger(depositoryId));
if ("one".equals(type)) { if ("one".equals(type)) {
String code = "F"+String.format("%02d",countForTray+1); String code = "F" + String.format("%02d", countForTray + 1);
insert.put("code", code); insert.put("code", code);
insert.put("state",1); insert.put("state", 1);
insert.put("quantity",0); insert.put("quantity", 0);
insert.put("flagType",2); insert.put("flagType", 2);
success += placeService.InsertPlace(insert); success += placeService.InsertPlace(insert);
}else if("list".equals(type)){ } else if ("list".equals(type)) {
Integer num = ObjectFormatUtil.toInteger(map.get("num")); Integer num = ObjectFormatUtil.toInteger(map.get("num"));
insert.put("state",1); insert.put("state", 1);
insert.put("quantity",0); insert.put("quantity", 0);
insert.put("flagType",2); insert.put("flagType", 2);
total = num; total = num;
for (int i = 1; i <= num; i++) { for (int i = 1; i <= num; i++) {
String code = "F"+String.format("%02d",countForTray+i); String code = "F" + String.format("%02d", countForTray + i);
insert.put("code", code); insert.put("code", code);
success += placeService.InsertPlace(insert); success += placeService.InsertPlace(insert);
} }
} }
if ("one".equals(type)) { if ("one".equals(type)) {
return CrudUtil.insertHandle(success, 1); return CrudUtil.insertHandle(success, 1);
} else if("list".equals(type)){ } else if ("list".equals(type)) {
return CrudUtil.insertHandle(success,total); return CrudUtil.insertHandle(success, total);
}else{ } else {
throw new MyException("请求参数错误!"); throw new MyException("请求参数错误!");
} }
} }
/** /**
* 将库位状态改为删除 * 将库位状态改为删除
*
* @param map * @param map
* @return * @return
*/ */
@PostMapping("/deletePlace") @PostMapping("/deletePlace")
public RestResponse deletePlace(@RequestBody Map<String,Object> map){ public RestResponse deletePlace(@RequestBody Map<String, Object> map) {
if (map.containsKey("id")){ if (map.containsKey("id")) {
Integer id= ObjectFormatUtil.toInteger(map.get("id")); Integer id = ObjectFormatUtil.toInteger(map.get("id"));
return CrudUtil.deleteHandle(placeService.changeStateToDeletedById(id),1); return CrudUtil.deleteHandle(placeService.changeStateToDeletedById(id), 1);
}else if (map.containsKey("ids")){ } else if (map.containsKey("ids")) {
List<Integer> ids=(List<Integer>) map.get("ids"); List<Integer> ids = (List<Integer>) map.get("ids");
return CrudUtil.deleteHandle(placeService.changeStateToDeletedByIds(ids),ids.size()); return CrudUtil.deleteHandle(placeService.changeStateToDeletedByIds(ids), ids.size());
}else { } else {
throw new MyException("所需请求参数缺失!"); throw new MyException("所需请求参数缺失!");
} }
} }
@ -237,11 +242,11 @@ public class PlaceController {
* 修改库位信息 * 修改库位信息
*/ */
@PostMapping("/place_edit") @PostMapping("/place_edit")
public RestResponse placeEdit(@RequestBody Map<String,Object> map){ public RestResponse placeEdit(@RequestBody Map<String, Object> map) {
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);
} }
Object id = map.get("id"); Object id = map.get("id");
// 获取当前修改的库位 // 获取当前修改的库位
@ -251,22 +256,22 @@ public class PlaceController {
// Integer place_y = ObjectFormatUtil.toInteger(map.get("place_y")); // Integer place_y = ObjectFormatUtil.toInteger(map.get("place_y"));
Integer place_z = ObjectFormatUtil.toInteger(map.get("place_z")); Integer place_z = ObjectFormatUtil.toInteger(map.get("place_z"));
String newCode = ""; String newCode = "";
if(Integer.compare(placeById.getX(),place_x) != 0 || Integer.compare(placeById.getZ(),place_z) != 0){ if (Integer.compare(placeById.getX(), place_x) != 0 || Integer.compare(placeById.getZ(), place_z) != 0) {
// 如果更改了行层 // 如果更改了行层
// String code = String.format("%02d", place_x) + String.format("%02d", place_y) + String.format("%02d", place_z); // String code = String.format("%02d", place_x) + String.format("%02d", place_y) + String.format("%02d", place_z);
newCode = String.format("%02d", place_x) + String.format("%02d", place_z); newCode = String.format("%02d", place_x) + String.format("%02d", place_z);
}else{ } else {
newCode = (String)map.get("code"); newCode = (String) map.get("code");
} }
String oldCode = placeById.getCode(); String oldCode = placeById.getCode();
if(!newCode.equals(oldCode)){ if (!newCode.equals(oldCode)) {
// 如果编码发生改变 // 如果编码发生改变
// 获取当前修改后的库位编码是否存在 // 获取当前修改后的库位编码是否存在
Place placeByDidAndCode = placeService.findPlaceByDidAndCode(placeById.getDid(), newCode); Place placeByDidAndCode = placeService.findPlaceByDidAndCode(placeById.getDid(), newCode);
if(placeByDidAndCode != null){ if (placeByDidAndCode != null) {
// 如果存在 // 如果存在
return new RestResponse("",12345,new StatusInfo("修改失败","该编码或位置已经存在")); return new RestResponse("", 12345, new StatusInfo("修改失败", "该编码或位置已经存在"));
} }
} }
String min = (String) map.get("min"); String min = (String) map.get("min");
@ -275,7 +280,7 @@ public class PlaceController {
// update.put("y", place_y); // update.put("y", place_y);
update.put("z", place_z); update.put("z", place_z);
update.put("code", newCode); update.put("code", newCode);
update.put("kingdeecode",placeById.getKingdeecode().substring(0,2) + newCode); update.put("kingdeecode", placeById.getKingdeecode().substring(0, 2) + newCode);
update.put("oldCode", oldCode); update.put("oldCode", oldCode);
update.put("did", map.get("did")); update.put("did", map.get("did"));
if (!"".equals(min)) { if (!"".equals(min)) {
@ -284,26 +289,31 @@ public class PlaceController {
update.put("min", 0); update.put("min", 0);
} }
if (!"".equals(max)) { if (!"".equals(max)) {
update.put("max", map.get("max")); Double maxQuantity = ObjectFormatUtil.toDouble(max);
if (maxQuantity >= 999999999) {
update.put("max", 999999999);
} else {
update.put("max", map.get("max"));
}
} else { } else {
update.put("max", 500); update.put("max", 50000);
} }
update.put("id", id); update.put("id", id);
return CrudUtil.insertHandle(placeService.UpdatePlace(update),1); return CrudUtil.insertHandle(placeService.UpdatePlace(update), 1);
} }
@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("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")); Integer depositoryId = ObjectFormatUtil.toInteger(map.get("did"));
Place placeByDidAndCode = placeService.findPlaceByDidAndCode(depositoryId, code); Place placeByDidAndCode = placeService.findPlaceByDidAndCode(depositoryId, code);
if(placeByDidAndCode != null){ if (placeByDidAndCode != null) {
return new RestResponse("",12345,new StatusInfo("修改失败","该编码已经存在")); return new RestResponse("", 12345, new StatusInfo("修改失败", "该编码已经存在"));
} }
Map<String, Object> update = new HashMap<>(); Map<String, Object> update = new HashMap<>();
String min = (String) map.get("min"); String min = (String) map.get("min");
@ -314,30 +324,36 @@ public class PlaceController {
update.put("min", 0); update.put("min", 0);
} }
if (!"".equals(max)) { if (!"".equals(max)) {
update.put("max", map.get("max")); Double maxQuantity = ObjectFormatUtil.toDouble(max);
if (maxQuantity >= 999999999) {
update.put("max", 999999999);
} else {
update.put("max", map.get("max"));
}
} else { } else {
update.put("max", 500); update.put("max", 50000);
} }
update.put("code",code); update.put("code", code);
update.put("id", map.get("id")); update.put("id", map.get("id"));
return CrudUtil.insertHandle(placeService.UpdatePlace(update),1); } return CrudUtil.insertHandle(placeService.UpdatePlace(update), 1);
}
@PostMapping("/editPlaceState") @PostMapping("/editPlaceState")
public RestResponse editPlaceState(@RequestBody Map<String,Object> map) { public RestResponse editPlaceState(@RequestBody Map<String, Object> map) {
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);
} }
return CrudUtil.insertHandle(placeService.editPlaceState(map),1); return CrudUtil.insertHandle(placeService.editPlaceState(map), 1);
} }
// 根据物料编号获取库位 // 根据物料编号获取库位
@PostMapping("/findPlaceByMid") @PostMapping("/findPlaceByMid")
public RestResponse findPlaceByMid(@RequestBody Map<String,Object> map, HttpServletRequest request){ public RestResponse findPlaceByMid(@RequestBody Map<String, Object> map, HttpServletRequest request) {
String token = request.getHeader("user-token"); String token = request.getHeader("user-token");
if(token == null){ if (token == null) {
token = (String) request.getSession().getAttribute("userToken"); token = (String) request.getSession().getAttribute("userToken");
} }
UserByPort userToken = AuthenticationTokenPool.getUserToken(token); UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
@ -355,18 +371,18 @@ public class PlaceController {
depositoryIdList.add(depository.getId()); depositoryIdList.add(depository.getId());
} }
for (RoleAndDepository depository : depositoryAndRole) { for (RoleAndDepository depository : depositoryAndRole) {
if(!depositoryIdList.contains(depository.getDepositoryId())){ if (!depositoryIdList.contains(depository.getDepositoryId())) {
depositoryIdList.add(depository.getDepositoryId()); depositoryIdList.add(depository.getDepositoryId());
} }
} }
List<InventoryP> inventoryPList = new ArrayList<>(); List<InventoryP> inventoryPList = new ArrayList<>();
for (Integer depositoryId:depositoryIdList for (Integer depositoryId : depositoryIdList
) { ) {
param.put("depositoryId", depositoryId); param.put("depositoryId", depositoryId);
// 查找当前用户部门仓库中是否存在该物料 // 查找当前用户部门仓库中是否存在该物料
inventoryPList.addAll(materialService.findInventory(param)); inventoryPList.addAll(materialService.findInventory(param));
} }
for (Integer depositoryId:depositoryIdList){ for (Integer depositoryId : depositoryIdList) {
for (InventoryP inventory : inventoryPList) { for (InventoryP inventory : inventoryPList) {
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(inventory.getId(), depositoryId); List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(inventory.getId(), depositoryId);
for (PlaceP placeP : placeByMidAndDid) { for (PlaceP placeP : placeByMidAndDid) {
@ -380,18 +396,19 @@ public class PlaceController {
} }
return new RestResponse(placeList); return new RestResponse(placeList);
} }
// 根据物料编码以及仓库编号获取具体库位 // 根据物料编码以及仓库编号获取具体库位
@PostMapping("/findPlaceByMcodeAndDid") @PostMapping("/findPlaceByMcodeAndDid")
public RestResponse findPlaceByMcodeAndDid(@RequestBody Map<String,Object> map,HttpServletRequest request){ public RestResponse findPlaceByMcodeAndDid(@RequestBody Map<String, Object> map, HttpServletRequest request) {
List<InventoryP> inventory = materialService.findInventory(map); List<InventoryP> inventory = materialService.findInventory(map);
List<PlaceP> placeList = new ArrayList<>(); List<PlaceP> placeList = new ArrayList<>();
if(inventory.size() > 0){ // 如果有当前物料 if (inventory.size() > 0) { // 如果有当前物料
for (int i = 0; i < inventory.size(); i++) { for (int i = 0; i < inventory.size(); i++) {
InventoryP materialP = inventory.get(i); InventoryP materialP = inventory.get(i);
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(materialP.getId(), ObjectFormatUtil.toInteger(map.get("depositoryId"))); List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(materialP.getId(), ObjectFormatUtil.toInteger(map.get("depositoryId")));
for (int j = 0; j < placeByMidAndDid.size(); j++) { for (int j = 0; j < placeByMidAndDid.size(); j++) {
int index = placeList.indexOf(placeByMidAndDid.get(j)); int index = placeList.indexOf(placeByMidAndDid.get(j));
if(index == -1){ if (index == -1) {
placeList.add(placeByMidAndDid.get(j)); placeList.add(placeByMidAndDid.get(j));
} }
} }
@ -402,7 +419,7 @@ public class PlaceController {
// 构造仓库二维码 // 构造仓库二维码
@PostMapping("/createQrCode") @PostMapping("/createQrCode")
public RestResponse createQrCode(@RequestBody Map<String,Object> map) { public RestResponse createQrCode(@RequestBody Map<String, Object> map) {
Integer pid = ObjectFormatUtil.toInteger(map.get("pid")); Integer pid = ObjectFormatUtil.toInteger(map.get("pid"));
@ -411,7 +428,7 @@ public class PlaceController {
// 二维码保存信息 // 二维码保存信息
Place placeById = placeService.findPlaceById(pid); Place placeById = placeService.findPlaceById(pid);
Depository depositoryById = depositoryService.findDepositoryById(placeById.getDid()); Depository depositoryById = depositoryService.findDepositoryById(placeById.getDid());
return RestResponse.CreateBarCode(qrCode,depositoryById.getDname() + "-" + placeById.getCode()); return RestResponse.CreateBarCode(qrCode, depositoryById.getDname() + "-" + placeById.getCode());
} catch (IOException e) { } catch (IOException e) {
return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员")); return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员"));
} }
@ -420,39 +437,39 @@ public class PlaceController {
// 用于扫描入库位置 // 用于扫描入库位置
@PostMapping("/qywxApplicationInScanQrCode") @PostMapping("/qywxApplicationInScanQrCode")
public RestResponse qywxApplicationInScanQrCode(@RequestBody Map<String,Object> map,HttpServletRequest request){ public RestResponse qywxApplicationInScanQrCode(@RequestBody Map<String, Object> map, HttpServletRequest request) {
// 获取扫描的码值 // 获取扫描的码值
String qrCode = (String) map.get("qrCode"); String qrCode = (String) map.get("qrCode");
// 根据二维码获取对应位置信息 // 根据二维码获取对应位置信息
PidOrDidAndCode locationByQrCode = placeService.findLocationByQrCode(qrCode); PidOrDidAndCode locationByQrCode = placeService.findLocationByQrCode(qrCode);
Map<String,Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("flag",0); result.put("flag", 0);
if(locationByQrCode != null){ if (locationByQrCode != null) {
// 获取当前标志位(1为库位2为仓库) // 获取当前标志位(1为库位2为仓库)
Integer flag = locationByQrCode.getFlag(); Integer flag = locationByQrCode.getFlag();
if(Integer.compare(1,flag) == 0){ if (Integer.compare(1, flag) == 0) {
// 如果当前位置为库位 // 如果当前位置为库位
// 获取当前库位 // 获取当前库位
Place place = placeService.findPlaceById(Integer.parseInt(locationByQrCode.getPid().toString())); Place place = placeService.findPlaceById(Integer.parseInt(locationByQrCode.getPid().toString()));
PlaceP placeP = new PlaceP(place); PlaceP placeP = new PlaceP(place);
if(Integer.compare(0,placeP.getId()) == 0){ if (Integer.compare(0, placeP.getId()) == 0) {
// 如果是默认库位 // 如果是默认库位
placeP.setDepositoryName("默认库位-0000"); placeP.setDepositoryName("默认库位-0000");
}else { } else {
Depository depository = depositoryService.findDepositoryById(placeP.getDid()); Depository depository = depositoryService.findDepositoryById(placeP.getDid());
placeP.setDepositoryName(depository.getDname() + "-"+placeP.getCode()); placeP.setDepositoryName(depository.getDname() + "-" + placeP.getCode());
} }
result.put("flag",1); result.put("flag", 1);
result.put("place",placeP); result.put("place", placeP);
}else { } else {
// 如果当前位置为仓库 // 如果当前位置为仓库
// 获取当前仓库 // 获取当前仓库
Depository depository = depositoryService.findDepositoryById(Integer.parseInt(locationByQrCode.getDepositoryId().toString())); Depository depository = depositoryService.findDepositoryById(Integer.parseInt(locationByQrCode.getDepositoryId().toString()));
result.put("flag",2); result.put("flag", 2);
result.put("depository",depository); result.put("depository", depository);
} }
} }
return new RestResponse(result); return new RestResponse(result);

Loading…
Cancel
Save