|
|
@ -1,8 +1,7 @@ |
|
|
package com.dreamchaser.depository_manage.controller; |
|
|
package com.dreamchaser.depository_manage.controller; |
|
|
|
|
|
|
|
|
import com.dreamchaser.depository_manage.entity.Depository; |
|
|
import com.baomidou.mybatisplus.extension.api.R; |
|
|
import com.dreamchaser.depository_manage.entity.Material; |
|
|
import com.dreamchaser.depository_manage.entity.*; |
|
|
import com.dreamchaser.depository_manage.entity.Place; |
|
|
|
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
import com.dreamchaser.depository_manage.pojo.MaterialP; |
|
|
import com.dreamchaser.depository_manage.pojo.MaterialP; |
|
|
import com.dreamchaser.depository_manage.pojo.PlaceP; |
|
|
import com.dreamchaser.depository_manage.pojo.PlaceP; |
|
|
@ -10,11 +9,13 @@ import com.dreamchaser.depository_manage.pojo.RestResponse; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
import com.dreamchaser.depository_manage.service.PlaceService; |
|
|
import com.dreamchaser.depository_manage.service.PlaceService; |
|
|
|
|
|
import com.dreamchaser.depository_manage.service.RoleService; |
|
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
import com.dreamchaser.depository_manage.utils.ObjectFormatUtil; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
@ -32,6 +33,9 @@ public class PlaceController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
DepositoryService depositoryService; |
|
|
DepositoryService depositoryService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
RoleService roleService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据条件查询库位 |
|
|
* 根据条件查询库位 |
|
|
* |
|
|
* |
|
|
@ -46,12 +50,19 @@ public class PlaceController { |
|
|
Place place = placeByCondition.get(i); |
|
|
Place place = placeByCondition.get(i); |
|
|
PlaceP placeP = new PlaceP(place); |
|
|
PlaceP placeP = new PlaceP(place); |
|
|
Integer depositoryId = place.getDid(); |
|
|
Integer depositoryId = place.getDid(); |
|
|
Integer mid = place.getMid(); |
|
|
|
|
|
Depository depositoryById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
Depository depositoryById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
if(mid != null) { |
|
|
// 获取当前库位所有的物料信息
|
|
|
|
|
|
List<MaterialAndPlace> placeAndMaterialByPid = placeService.findPlaceAndMaterialByPid(place.getId()); |
|
|
|
|
|
if(placeAndMaterialByPid == null){ |
|
|
|
|
|
placeAndMaterialByPid = new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
StringBuilder mname = new StringBuilder(); |
|
|
|
|
|
for (int j = 0; j < placeAndMaterialByPid.size(); j++) { |
|
|
|
|
|
Integer mid = placeAndMaterialByPid.get(j).getMid(); |
|
|
Material materialById = materialService.findMaterialById(mid); |
|
|
Material materialById = materialService.findMaterialById(mid); |
|
|
placeP.setMname(materialById.getMname()); |
|
|
mname.append(materialById.getMname()+","); |
|
|
} |
|
|
} |
|
|
|
|
|
placeP.setMname(mname.toString()); |
|
|
placeP.setDepositoryName(depositoryById.getDname()); |
|
|
placeP.setDepositoryName(depositoryById.getDname()); |
|
|
placeP.setDepositoryCode(depositoryById.getCode()); |
|
|
placeP.setDepositoryCode(depositoryById.getCode()); |
|
|
placePList.add(placeP); |
|
|
placePList.add(placeP); |
|
|
@ -64,15 +75,17 @@ public class PlaceController { |
|
|
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; |
|
|
|
|
|
Integer total = 0; |
|
|
if ("one".equals(type)) { |
|
|
if ("one".equals(type)) { |
|
|
Integer place_x = ObjectFormatUtil.toInteger(map.get("place_x")); |
|
|
Integer place_x = ObjectFormatUtil.toInteger(map.get("place_x")); |
|
|
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 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); |
|
|
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); |
|
|
insert.put("code", code); |
|
|
insert.put("code", code); |
|
|
insert.put("did", map.get("depositoryId")); |
|
|
insert.put("did", map.get("depositoryId")); |
|
|
@ -87,14 +100,52 @@ public class PlaceController { |
|
|
insert.put("max", 0); |
|
|
insert.put("max", 0); |
|
|
} |
|
|
} |
|
|
insert.put("state",1); |
|
|
insert.put("state",1); |
|
|
|
|
|
insert.put("quantity",0); |
|
|
success += placeService.InsertPlace(insert); |
|
|
success += placeService.InsertPlace(insert); |
|
|
} else { |
|
|
} |
|
|
|
|
|
else if("list".equals(type)){ |
|
|
|
|
|
//获取起始、终止行
|
|
|
|
|
|
Integer place_start_x = ObjectFormatUtil.toInteger(map.get("place_start_x")); |
|
|
|
|
|
Integer place_end_x = ObjectFormatUtil.toInteger(map.get("place_end_x")); |
|
|
|
|
|
//获取起始、终止列
|
|
|
|
|
|
// Integer place_start_y = ObjectFormatUtil.toInteger(map.get("place_start_y"));
|
|
|
|
|
|
// Integer place_end_y = ObjectFormatUtil.toInteger(map.get("place_end_y"));
|
|
|
|
|
|
//获取起始、终止层
|
|
|
|
|
|
Integer place_start_z = ObjectFormatUtil.toInteger(map.get("place_start_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_z - place_start_z); |
|
|
|
|
|
String min = (String) map.get("min"); |
|
|
|
|
|
String max = (String) map.get("max"); |
|
|
|
|
|
for (int i = place_start_x; i < place_end_x; i++) { |
|
|
|
|
|
// for (int j = place_start_y; j < place_end_y; j++) {
|
|
|
|
|
|
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", k); |
|
|
|
|
|
insert.put("x",i); |
|
|
|
|
|
// insert.put("y",j);
|
|
|
|
|
|
insert.put("z",k); |
|
|
|
|
|
insert.put("code",code); |
|
|
|
|
|
insert.put("min",min); |
|
|
|
|
|
insert.put("max",max); |
|
|
|
|
|
insert.put("did", map.get("depositoryId")); |
|
|
|
|
|
insert.put("state",1); |
|
|
|
|
|
insert.put("quantity",0); |
|
|
|
|
|
success += placeService.InsertPlace(insert); |
|
|
|
|
|
} |
|
|
|
|
|
// }
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
throw new MyException("所需请求参数缺失!"); |
|
|
} |
|
|
} |
|
|
if ("one".equals(type)) { |
|
|
if ("one".equals(type)) { |
|
|
return CrudUtil.postHandle(success, 1); |
|
|
return CrudUtil.postHandle(success, 1); |
|
|
|
|
|
} else if("list".equals(type)){ |
|
|
|
|
|
return CrudUtil.postHandle(success,total); |
|
|
}else{ |
|
|
}else{ |
|
|
return new RestResponse(); |
|
|
throw new MyException("请求参数错误!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -128,13 +179,14 @@ public class PlaceController { |
|
|
} |
|
|
} |
|
|
Map<String, Object> update = new HashMap<>(); |
|
|
Map<String, Object> update = new HashMap<>(); |
|
|
Integer place_x = ObjectFormatUtil.toInteger(map.get("place_x")); |
|
|
Integer place_x = ObjectFormatUtil.toInteger(map.get("place_x")); |
|
|
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 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); |
|
|
update.put("x", place_x); |
|
|
update.put("x", place_x); |
|
|
update.put("y", place_y); |
|
|
// update.put("y", place_y);
|
|
|
update.put("z", place_z); |
|
|
update.put("z", place_z); |
|
|
update.put("code", code); |
|
|
update.put("code", code); |
|
|
update.put("did", map.get("depositoryId")); |
|
|
update.put("did", map.get("depositoryId")); |
|
|
@ -151,4 +203,19 @@ public class PlaceController { |
|
|
update.put("id",map.get("id")); |
|
|
update.put("id",map.get("id")); |
|
|
return CrudUtil.postHandle(placeService.UpdatePlace(update),1); |
|
|
return CrudUtil.postHandle(placeService.UpdatePlace(update),1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/findPlaceByMid") |
|
|
|
|
|
public RestResponse findPlaceByMid(@RequestBody Map<String,Object> map, HttpServletRequest request){ |
|
|
|
|
|
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|
|
|
|
|
List<Depository> depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); |
|
|
|
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
|
|
|
List<PlaceP> placeList = new ArrayList<>(); |
|
|
|
|
|
for (int i = 0; i < depositoryByAdminorg.size(); i++) { |
|
|
|
|
|
Depository depository = depositoryByAdminorg.get(i); |
|
|
|
|
|
List<PlaceP> placeByMidAndDid = placeService.findPlaceByMidAndDid(mid, depository.getId()); |
|
|
|
|
|
placeList.addAll(placeByMidAndDid); |
|
|
|
|
|
} |
|
|
|
|
|
return new RestResponse(placeList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|