|
|
|
@ -7,10 +7,7 @@ import com.dreamchaser.depository_manage.entity.*; |
|
|
|
import com.dreamchaser.depository_manage.exception.MyException; |
|
|
|
import com.dreamchaser.depository_manage.pojo.*; |
|
|
|
import com.dreamchaser.depository_manage.security.bean.UserToken; |
|
|
|
import com.dreamchaser.depository_manage.service.CompanyService; |
|
|
|
import com.dreamchaser.depository_manage.service.DepositoryRecordService; |
|
|
|
import com.dreamchaser.depository_manage.service.DepositoryService; |
|
|
|
import com.dreamchaser.depository_manage.service.MaterialService; |
|
|
|
import com.dreamchaser.depository_manage.service.*; |
|
|
|
import com.dreamchaser.depository_manage.utils.CrudUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.DateUtil; |
|
|
|
import com.dreamchaser.depository_manage.utils.HttpUtils; |
|
|
|
@ -20,6 +17,7 @@ import org.apache.http.protocol.HTTP; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.servlet.ModelAndView; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.io.IOException; |
|
|
|
@ -45,6 +43,11 @@ public class DepositoryRecordController { |
|
|
|
private CompanyService companyService; |
|
|
|
@Autowired |
|
|
|
private RedisTemplate<Object,Object> redisTemplate; |
|
|
|
@Autowired |
|
|
|
private RedisTemplate<String,String> redisTemplateForHash; |
|
|
|
@Autowired |
|
|
|
private PlaceService placeService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -64,13 +67,17 @@ public class DepositoryRecordController { |
|
|
|
List<ApplicationInRecordP> applicationInRecordPlist = depositoryRecordService.findApplicationInRecordPByCondition(map); |
|
|
|
Integer InCount = depositoryRecordService.findApplicationInRecordPCountByCondition(map); |
|
|
|
for (int i = 0; i < applicationInRecordPlist.size(); i++) { |
|
|
|
if(applicationInRecordPlist.get(i).getPrice() != null) { |
|
|
|
applicationInRecordPlist.get(i).setPrice(applicationInRecordPlist.get(i).getPrice() / 100); |
|
|
|
} |
|
|
|
} |
|
|
|
List<ApplicationOutRecordP> applicationOutRecordPlist = depositoryRecordService.findApplicationOutRecordPByCondition(map); |
|
|
|
Integer OutCount = depositoryRecordService.findApplicationOutRecordPCountByCondition(map); |
|
|
|
for (int i = 0; i < applicationOutRecordPlist.size(); i++) { |
|
|
|
if(applicationOutRecordPlist.get(i).getPrice() != null) { |
|
|
|
applicationOutRecordPlist.get(i).setPrice(applicationOutRecordPlist.get(i).getPrice() / 100); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,Object> result = new HashMap<>(); |
|
|
|
result.put("applicationIn",applicationInRecordPlist); |
|
|
|
result.put("InCount",InCount); |
|
|
|
@ -87,6 +94,77 @@ public class DepositoryRecordController { |
|
|
|
return new RestResponse(myTask |
|
|
|
,depositoryRecordService.findMyTaskOutCount(map),200); |
|
|
|
} |
|
|
|
|
|
|
|
// 查找当前用户所有的扫码出库订单
|
|
|
|
@GetMapping("/myTashForScanQrCode") |
|
|
|
public RestResponse findAllMinRecordByUser(@RequestParam Map<String,Object> map,HttpServletRequest request){ |
|
|
|
List<SimpleApplicationOutMinRecordP> result = new ArrayList<>(); |
|
|
|
// isDone 为0为未完成,1为已完成
|
|
|
|
String isDone = (String) (map.get("isDone")); |
|
|
|
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|
|
|
// 获取当前用户下的所有扫码出库订单
|
|
|
|
String key = "user:"+userToken.getId().toString(); |
|
|
|
String minRecord = (String) redisTemplateForHash.opsForHash().get(key, "minRecord"); |
|
|
|
if(minRecord == null){ |
|
|
|
return new RestResponse(result,result.size(),200); |
|
|
|
} |
|
|
|
// 获取子订单键值
|
|
|
|
String[] split = minRecord.replace("[","").replace("]","").split(","); |
|
|
|
String completeSplit= "";// 已完成
|
|
|
|
String ongoingSplit= ""; // 进行中
|
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
// 获取所有子订单状态
|
|
|
|
String state = (String) redisTemplateForHash.opsForHash().get(split[i],"state"); |
|
|
|
if("1".equals(state)){ |
|
|
|
// 如果当前订单未完成
|
|
|
|
ongoingSplit+= split[i]+","; |
|
|
|
}else if ("2".equals(state)){ |
|
|
|
// 如果当前订单已完成
|
|
|
|
completeSplit+= split[i]+","; |
|
|
|
} |
|
|
|
} |
|
|
|
// 用户管理仓库
|
|
|
|
Map<String,Object> userManageHouse = new HashMap<>(); |
|
|
|
if("1".equals(isDone)){ |
|
|
|
// 如果要获取已完成
|
|
|
|
split = completeSplit.split(","); |
|
|
|
}else{ |
|
|
|
// 如果获取未完成
|
|
|
|
split = ongoingSplit.split(","); |
|
|
|
} |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
// 获取子订单编码
|
|
|
|
String[] strings = split[i].split(":"); |
|
|
|
String minRecordId = ""; |
|
|
|
if(strings.length>1) { |
|
|
|
minRecordId = strings[1]; |
|
|
|
} |
|
|
|
if("".equals(minRecordId)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 获取数据库中子订单信息
|
|
|
|
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(ObjectFormatUtil.toInteger(minRecordId)); |
|
|
|
// 获取仓库信息
|
|
|
|
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(applicationOutMinById.getDepositoryId()); |
|
|
|
// 获取子订单对应主订单
|
|
|
|
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId()); |
|
|
|
// 创建展示对象
|
|
|
|
SimpleApplicationOutMinRecordP simpleApplicationOutMinRecordP = new SimpleApplicationOutMinRecordP(applicationOutMinById); |
|
|
|
simpleApplicationOutMinRecordP.setApplicantTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getApplicantTime()))); |
|
|
|
simpleApplicationOutMinRecordP.setApplyRemark(applicationOutRecordPById.getApplyRemark()); |
|
|
|
simpleApplicationOutMinRecordP.setDepositoryId(depositoryRecordById.getId()); |
|
|
|
simpleApplicationOutMinRecordP.setDepositoryName(depositoryRecordById.getDname()); |
|
|
|
simpleApplicationOutMinRecordP.setCode(applicationOutRecordPById.getCode()); |
|
|
|
List<Object> objectList = (List<Object>) userManageHouse.get(depositoryRecordById.getCode()); |
|
|
|
if(objectList == null){ |
|
|
|
objectList = new ArrayList<>(); |
|
|
|
} |
|
|
|
objectList.add(simpleApplicationOutMinRecordP); |
|
|
|
userManageHouse.put(depositoryRecordById.getCode(),objectList); |
|
|
|
} |
|
|
|
return new RestResponse(userManageHouse); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/depositoryRecord") |
|
|
|
public RestResponse insertDepositoryRecord(@RequestBody Map<String,Object> map, HttpServletRequest request){ |
|
|
|
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|
|
|
@ -221,7 +299,7 @@ public class DepositoryRecordController { |
|
|
|
insert.put("quantity", map.get("quantity" + temp)); |
|
|
|
insert.put("applyRemark", map.get("applyRemark" + temp)); |
|
|
|
insert.put("code", map.get("code")); |
|
|
|
insert.put("placeId", map.get("placeId" + temp)); |
|
|
|
insert.put("placeId", map.get("placeId")); |
|
|
|
// 获取主订单编号
|
|
|
|
insert.put("parentId", map.get("id")); |
|
|
|
// 插入子订单
|
|
|
|
@ -254,12 +332,107 @@ public class DepositoryRecordController { |
|
|
|
return new RestResponse(list,depositoryRecordService.findApplicationInRecordPCountByCondition(map),200); |
|
|
|
} |
|
|
|
|
|
|
|
// 当前仓库中该用户的子订单详情
|
|
|
|
@GetMapping("/ApplicationOutMinByDid") |
|
|
|
public RestResponse ApplicationOutMinByDid(@RequestParam Map<String,Object> map, HttpServletRequest request){ |
|
|
|
Integer depositoryId =ObjectFormatUtil.toInteger(map.get("depositoryId")); |
|
|
|
// 0未完成1已完成
|
|
|
|
Integer stateOnView =ObjectFormatUtil.toInteger(map.get("state")); |
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
// 获取当前仓库信息
|
|
|
|
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
|
// 获取当前用户要处理的记录信息
|
|
|
|
String minRecord = (String) redisTemplateForHash.opsForHash().get("user:"+userToken.getId(),"minRecord"); |
|
|
|
// 获取子订单键值
|
|
|
|
String[] split = minRecord.replace("[","").replace("]","").split(","); |
|
|
|
List<SimpleApplicationOutMinRecordP> applicationOutRecordMinList = new ArrayList<>(); |
|
|
|
for (int i = 0; i < split.length; i++) { |
|
|
|
//获取当前订单状态
|
|
|
|
String state = (String) redisTemplateForHash.opsForHash().get(split[i], "state"); |
|
|
|
if(Integer.compare(stateOnView,0) == 0 && !"1".equals(state)){ |
|
|
|
// 如果当前要查看的是未完成的并且当前订单不是未完成
|
|
|
|
continue; |
|
|
|
} |
|
|
|
if(Integer.compare(stateOnView,1) == 0 && !"2".equals(state)){ |
|
|
|
// 如果当前要查看的是已完成的并且当前订单不是已完成
|
|
|
|
continue; |
|
|
|
} |
|
|
|
if("1".equals(state)){ |
|
|
|
// 如果当前订单未完成
|
|
|
|
state = "进行中"; |
|
|
|
|
|
|
|
}else if("2".equals(state)){ |
|
|
|
// 如果当前订单已完成
|
|
|
|
state = "已完成"; |
|
|
|
} |
|
|
|
// 获取子订单编码
|
|
|
|
String minRecordId = split[i].split(":")[1]; |
|
|
|
// 获取数据库中子订单信息
|
|
|
|
ApplicationOutRecordMin applicationOutMinById = depositoryRecordService.findApplicationOutMinById(ObjectFormatUtil.toInteger(minRecordId)); |
|
|
|
// 如果该子订单仓库是当前仓库
|
|
|
|
if(Integer.compare(applicationOutMinById.getDepositoryId(),depositoryId) == 0){ |
|
|
|
// 获取子订单对应主订单
|
|
|
|
ApplicationOutRecordP applicationOutRecordPById = depositoryRecordService.findApplicationOutRecordPById(applicationOutMinById.getParentId()); |
|
|
|
// 获取申请人
|
|
|
|
UserByPort userByPort = PageController.FindUserById(applicationOutRecordPById.getApplicantId()); |
|
|
|
// 创建展示对象
|
|
|
|
SimpleApplicationOutMinRecordP simpleApplicationOutMinRecordP = new SimpleApplicationOutMinRecordP(applicationOutMinById); |
|
|
|
// 获取申请的物料信息
|
|
|
|
Material materialById = materialService.findMaterialById(applicationOutMinById.getMid()); |
|
|
|
// 获取当前出库库位
|
|
|
|
Place placeByDid = placeService.findPlaceById(applicationOutMinById.getPlaceId()); |
|
|
|
simpleApplicationOutMinRecordP.setApplicantTime(DateUtil.TimeStampToDateTime(Long.valueOf(applicationOutRecordPById.getApplicantTime()))); |
|
|
|
simpleApplicationOutMinRecordP.setApplyRemark(applicationOutRecordPById.getApplyRemark()); |
|
|
|
simpleApplicationOutMinRecordP.setDepositoryId(depositoryRecordById.getId()); |
|
|
|
simpleApplicationOutMinRecordP.setDepositoryName(depositoryRecordById.getDname()); |
|
|
|
simpleApplicationOutMinRecordP.setMname(materialById.getMname()); |
|
|
|
simpleApplicationOutMinRecordP.setMcode(materialById.getCode()); |
|
|
|
simpleApplicationOutMinRecordP.setApplicantName(userByPort.getName()); |
|
|
|
simpleApplicationOutMinRecordP.setCode(applicationOutRecordPById.getCode()); |
|
|
|
simpleApplicationOutMinRecordP.setPcode(placeByDid.getCode()); |
|
|
|
simpleApplicationOutMinRecordP.setPid(placeByDid.getId()); |
|
|
|
simpleApplicationOutMinRecordP.setState(state); |
|
|
|
|
|
|
|
applicationOutRecordMinList.add(simpleApplicationOutMinRecordP); |
|
|
|
} |
|
|
|
} |
|
|
|
return new RestResponse(applicationOutRecordMinList,applicationOutRecordMinList.size(),200); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 查看出库申请
|
|
|
|
@GetMapping("/applicationOutView") |
|
|
|
public RestResponse findApplicationOutRecordByCondition(@RequestParam Map<String,Object> map){ |
|
|
|
// 获取对应主订单
|
|
|
|
List<ApplicationOutRecordP> list = depositoryRecordService.findApplicationOutRecordPByCondition(map); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
list.get(i).setPrice(list.get(i).getPrice() / 100); |
|
|
|
ApplicationOutRecordP outRecordP = list.get(i); |
|
|
|
// 根据主订单获取所有子订单
|
|
|
|
List<ApplicationOutRecordMin> applicationOutMinByParentId = depositoryRecordService.findApplicationOutMinByParentId(outRecordP.getId()); |
|
|
|
StringBuilder mname = new StringBuilder(); |
|
|
|
StringBuilder mcode = new StringBuilder(); |
|
|
|
StringBuilder depositoryName = new StringBuilder(); |
|
|
|
Integer sumQuantity = 0; |
|
|
|
Double sumPrice = 0.0; |
|
|
|
for (int j = 0; j < applicationOutMinByParentId.size(); j++) { |
|
|
|
// 获取子订单信息
|
|
|
|
ApplicationOutRecordMin applicationOutRecordMin = applicationOutMinByParentId.get(j); |
|
|
|
// 获取出库物料信息
|
|
|
|
Material materialById = materialService.findMaterialById(applicationOutRecordMin.getMid()); |
|
|
|
// 获取出库物料仓库信息
|
|
|
|
Depository depository = depositoryService.findDepositoryRecordById(applicationOutRecordMin.getDepositoryId()); |
|
|
|
mname.append(materialById.getMname()).append(","); |
|
|
|
mcode.append(materialById.getCode()).append(","); |
|
|
|
depositoryName.append(depository.getDname()).append(","); |
|
|
|
sumQuantity += applicationOutRecordMin.getQuantity(); |
|
|
|
sumPrice += (materialById.getPrice() / 100); |
|
|
|
} |
|
|
|
list.get(i).setMcode(mcode.toString()); |
|
|
|
list.get(i).setMname(mname.toString()); |
|
|
|
list.get(i).setDepositoryName(depositoryName.toString()); |
|
|
|
list.get(i).setQuantity(sumQuantity); |
|
|
|
list.get(i).setPrice(sumPrice); |
|
|
|
|
|
|
|
} |
|
|
|
return new RestResponse(list,depositoryRecordService.findApplicationOutRecordPCountByCondition(map),200); |
|
|
|
} |
|
|
|
@ -289,18 +462,20 @@ public class DepositoryRecordController { |
|
|
|
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|
|
|
List<Integer> mids = (List<Integer>) map.get("mids"); |
|
|
|
List<Integer> depositoryIds = (List<Integer>) map.get("depositoryIds"); |
|
|
|
List<String> placeCodes = (List<String>) map.get("placeCodes"); |
|
|
|
List<Object> nowmids = redisTemplate.opsForList().range("mids"+userToken.getId(), 0, -1); |
|
|
|
List<Object> nowdepositoryIds = redisTemplate.opsForList().range("depositoryIds"+userToken.getId(), 0, -1); |
|
|
|
for (int i = 0; i < mids.size(); i++) { |
|
|
|
if(nowmids.contains(mids.get(i))){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
redisTemplate.opsForList().leftPush("mids"+userToken.getId(), mids.get(i)); |
|
|
|
redisTemplate.opsForList().leftPush("depositoryIds"+userToken.getId(), depositoryIds.get(i)); |
|
|
|
redisTemplate.opsForList().leftPush("placeCodes"+userToken.getId(), placeCodes.get(i)); |
|
|
|
|
|
|
|
} |
|
|
|
redisTemplate.expire("mids"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS); |
|
|
|
redisTemplate.expire("depositoryIds"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS); |
|
|
|
redisTemplate.expire("placeCodes"+userToken.getId(),24 * 60 * 60, TimeUnit.SECONDS); |
|
|
|
return CrudUtil.postHandle(1,1); |
|
|
|
} |
|
|
|
|
|
|
|
@ -420,14 +595,22 @@ public class DepositoryRecordController { |
|
|
|
} |
|
|
|
List<ApplicationModel> list = new ArrayList<>(); |
|
|
|
for (int i = start; i < end; i++) { |
|
|
|
// 获取物料编号
|
|
|
|
Integer mid =ObjectFormatUtil.toInteger(redisTemplate.opsForList().index("mids"+userToken.getId(),i)); |
|
|
|
// 获取仓库编号
|
|
|
|
Integer depositoryId =ObjectFormatUtil.toInteger(redisTemplate.opsForList().index("depositoryIds"+userToken.getId(),i)); |
|
|
|
// 获取库位编码
|
|
|
|
String placeCode =(String)(redisTemplate.opsForList().index("placeCodes"+userToken.getId(),i)); |
|
|
|
// 获取物料信息
|
|
|
|
Material materialById = materialService.findMaterialById(mid); |
|
|
|
// 获取仓库信息
|
|
|
|
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
|
|
|
|
|
ApplicationModel ap = new ApplicationModel(); |
|
|
|
ap.setDepositoryId(depositoryId); |
|
|
|
ap.setDepositoryName(depositoryRecordById.getDname()); |
|
|
|
ap.setMid(mid); |
|
|
|
ap.setPlaceCode(placeCode); |
|
|
|
ap.setVersion(materialById.getVersion()); |
|
|
|
ap.setMname(materialById.getMname()); |
|
|
|
ap.setCode(materialById.getCode()); |
|
|
|
@ -457,9 +640,19 @@ public class DepositoryRecordController { |
|
|
|
if("in".equals(type)){ |
|
|
|
success += depositoryRecordService.applicationIn(map); |
|
|
|
}else if("out".equals(type)){ |
|
|
|
UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken); |
|
|
|
map.put("departmenthead",departmentHeadByUser.getId()); |
|
|
|
success += depositoryRecordService.insertApplicationOutRecord(map,userToken); |
|
|
|
// 获取部门负责人
|
|
|
|
// UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
|
|
|
|
// map.put("departmenthead",departmentHeadByUser.getId());
|
|
|
|
Integer res = depositoryRecordService.insertApplicationOutRecord(map,userToken); // 插入主订单
|
|
|
|
if(res == 1){ // 如果插入成功
|
|
|
|
Object id = map.get("id"); // 获取主订单编号
|
|
|
|
if(id != null){ |
|
|
|
map.remove("id"); |
|
|
|
map.put("parentId",id); |
|
|
|
} |
|
|
|
success += depositoryRecordService.insertApplicationOutMin(map); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(success == 0){ |
|
|
|
return new RestResponse("",666,new StatusInfo("申请失败","超出最大存储容量")); |
|
|
|
@ -476,24 +669,53 @@ public class DepositoryRecordController { |
|
|
|
@PostMapping("/createMultiApplications") |
|
|
|
public RestResponse createMultiApplications(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|
|
|
UserByPort userToken= (UserByPort) request.getAttribute("userToken"); |
|
|
|
// 获取要处理的类型
|
|
|
|
String type = (String) map.get("type"); |
|
|
|
Integer success = 0; |
|
|
|
List<Integer> mids = (List<Integer>) map.get("mids"); |
|
|
|
List<Integer> depositoryIds = (List<Integer>) map.get("depositoryIds"); |
|
|
|
List<Object> quantitys = (List<Object>) map.get("quantitys"); |
|
|
|
List<String> placeCodes = (List<String>) map.get("placeCodes"); |
|
|
|
List<String> applyRemarks = (List<String>) map.get("applyRemarks"); |
|
|
|
List<Object> prices = (List<Object>) map.get("prices"); |
|
|
|
String errMsg = ""; |
|
|
|
Integer id = 0; |
|
|
|
if("in".equals(type)){ |
|
|
|
for (int i = 0; i < mids.size(); i++) { |
|
|
|
Integer mid = mids.get(i); |
|
|
|
// 获取库位
|
|
|
|
String placeCode = placeCodes.get(i); |
|
|
|
// 获取当前仓库编号
|
|
|
|
Integer depositoryId = depositoryIds.get(i); |
|
|
|
String price = prices.get(i).toString(); |
|
|
|
// 获取当前申请数量
|
|
|
|
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i)); |
|
|
|
String quantity = integer.toString(); |
|
|
|
// 获取每个库位编码
|
|
|
|
String[] s = placeCode.split(" "); |
|
|
|
// 先定义最终要使用的库位,默认是默认库位
|
|
|
|
Integer place = 0; |
|
|
|
if(s.length > 1){ |
|
|
|
// 获取当前仓库所有库位
|
|
|
|
List<Place> placeByDid = placeService.findPlaceByDid(depositoryId); |
|
|
|
// 遍历当前物料存储的库位
|
|
|
|
for (int j = 0; j < s.length; j++) { |
|
|
|
Place place1 = placeByDid.get(j); |
|
|
|
if(placeCode.equals(place1.getCode())){ |
|
|
|
// 如果当前物料存放在当前库位
|
|
|
|
if(place1.getMax() - place1.getQuantity() >= integer){ |
|
|
|
// 如果当前库位能够存放当前数量
|
|
|
|
place = place1.getId(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Integer mid = mids.get(i); |
|
|
|
String price = prices.get(i).toString(); |
|
|
|
String applyRemark = applyRemarks.get(i); |
|
|
|
Map<String,Object> inRecord = new HashMap<>(); |
|
|
|
inRecord.put("applicantId",userToken.getId()); |
|
|
|
inRecord.put("mid",mid); |
|
|
|
inRecord.put("placeId",place); |
|
|
|
inRecord.put("depositoryId",depositoryId); |
|
|
|
inRecord.put("quantity",quantity); |
|
|
|
inRecord.put("price",price); |
|
|
|
@ -501,27 +723,113 @@ public class DepositoryRecordController { |
|
|
|
success += depositoryRecordService.applicationIn(inRecord); |
|
|
|
} |
|
|
|
}else if("out".equals(type)){ |
|
|
|
Map<String,Object> mainRecord = new HashMap<>(); |
|
|
|
Integer sumQuantity = 0; |
|
|
|
for (int i = 0; i < quantitys.size(); i++) { |
|
|
|
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i)); |
|
|
|
sumQuantity += integer; |
|
|
|
} |
|
|
|
// 获取部门负责人
|
|
|
|
// UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken);
|
|
|
|
mainRecord.put("applicantId",userToken.getId()); |
|
|
|
mainRecord.put("applyRemark",""); |
|
|
|
mainRecord.put("quantity",sumQuantity.toString()); |
|
|
|
// mainRecord.put("departmenthead",departmentHeadByUser.getId());
|
|
|
|
// 插入主表
|
|
|
|
depositoryRecordService.insertApplicationOutRecord(mainRecord,userToken); |
|
|
|
id = ObjectFormatUtil.toInteger(mainRecord.get("id")); |
|
|
|
for (int i = 0; i < mids.size(); i++) { |
|
|
|
Integer mid = mids.get(i); |
|
|
|
Integer integer = ObjectFormatUtil.toInteger(quantitys.get(i)); |
|
|
|
// 获取当前仓库编号
|
|
|
|
Integer depositoryId = depositoryIds.get(i); |
|
|
|
String quantity = integer.toString(); |
|
|
|
// 获取库位
|
|
|
|
String placeCode = placeCodes.get(i); |
|
|
|
// 获取每个库位编码
|
|
|
|
String[] s = placeCode.split(" "); |
|
|
|
Integer place = 0; |
|
|
|
// 用于标志该库位是否可以出库
|
|
|
|
Boolean flag = false; |
|
|
|
if(s.length > 1){ |
|
|
|
// 获取当前仓库所有库位
|
|
|
|
List<Place> placeByDid = placeService.findPlaceByDid(depositoryId); |
|
|
|
// 遍历当前物料存储的库位
|
|
|
|
for (int j = 1; j < s.length; j++) { |
|
|
|
// 获取当前库位
|
|
|
|
for (int k = 0; k < placeByDid.size(); k++) { |
|
|
|
Place place1 = placeByDid.get(k); |
|
|
|
if(s[j].equals(place1.getCode())){ |
|
|
|
// 如果当前物料存放在当前库位
|
|
|
|
// 获取当前物料在当前库位中的数目
|
|
|
|
Integer quantityByMidAndPid = placeService.findQuantityByMidAndPid(mid, place1.getId()); |
|
|
|
if(quantityByMidAndPid > integer){ |
|
|
|
// 如果可以出库
|
|
|
|
place = place1.getId(); |
|
|
|
flag = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(Integer.compare(0,place) == 0){ |
|
|
|
// 如果当前库位是默认库位
|
|
|
|
Integer quantityByMidAndPid = placeService.findQuantityByMidAndPid(mid, 0); |
|
|
|
if(quantityByMidAndPid > integer){ |
|
|
|
// 如果默认库位中该物料数量可以出库
|
|
|
|
flag = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if(flag) { |
|
|
|
String applyRemark = applyRemarks.get(i); |
|
|
|
Map<String, Object> outRecord = new HashMap<>(); |
|
|
|
outRecord.put("quantity", quantity); |
|
|
|
outRecord.put("mid", mid); |
|
|
|
outRecord.put("applicantId",userToken.getId()); |
|
|
|
outRecord.put("applyRemark",applyRemark); |
|
|
|
UserByPort departmentHeadByUser = findDepartmentHeadByUser(userToken); |
|
|
|
outRecord.put("departmenthead",departmentHeadByUser.getId()); |
|
|
|
success += depositoryRecordService.insertApplicationOutRecord(outRecord,userToken); |
|
|
|
outRecord.put("parentId", mainRecord.get("id")); |
|
|
|
outRecord.put("code", mainRecord.get("code")); |
|
|
|
outRecord.put("placeId",place); |
|
|
|
success += depositoryRecordService.insertApplicationOutMin(outRecord); |
|
|
|
}else{ |
|
|
|
// 获取失败的物料信息
|
|
|
|
Material materialById = materialService.findMaterialById(mid); |
|
|
|
// 获取失败的仓库信息
|
|
|
|
Depository depositoryRecordById = depositoryService.findDepositoryRecordById(depositoryId); |
|
|
|
errMsg += materialById.getMname() + "在"+depositoryRecordById.getDname()+"出库数量为"+quantity +"失败,数量不足;"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(success == 0){ |
|
|
|
depositoryRecordService.deleteApplicationOutRecordById(1); |
|
|
|
return new RestResponse("",666,new StatusInfo("申请失败","超出最大存储容量")); |
|
|
|
} |
|
|
|
if(success < mids.size()){ |
|
|
|
// 如果申请成功数量小于申请数量
|
|
|
|
return new RestResponse(errMsg,1234,new StatusInfo("出库失败","数量不足")); |
|
|
|
} |
|
|
|
return CrudUtil.postHandle(success,mids.size()); |
|
|
|
} |
|
|
|
|
|
|
|
// 确认将物料出库
|
|
|
|
@PostMapping("/isCheckOut") |
|
|
|
public RestResponse isCheckOut(@RequestBody Map<String,Object> map,HttpServletRequest request){ |
|
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
|
Integer placeId =ObjectFormatUtil.toInteger(map.get("placeId")); |
|
|
|
if(placeId == null){ |
|
|
|
// 如果是仓库,则使用默认库位
|
|
|
|
map.put("placeId",0); |
|
|
|
} |
|
|
|
Integer integer = depositoryRecordService.completeApplicationOutMinRecord(map, userToken); |
|
|
|
if(integer == 1){ |
|
|
|
return new RestResponse("",200,new StatusInfo("出库成功","出库成功")); |
|
|
|
}else{ |
|
|
|
return new RestResponse("",500,new StatusInfo("出库失败","出库失败,请联系开发人员")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 获取当前登录用户的部门负责人 |
|
|
|
* @param user |
|
|
|
@ -556,4 +864,8 @@ public class DepositoryRecordController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|