|
|
|
@ -704,74 +704,53 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public Integer insertApplicationInRecord(Map<String, Object> map, UserByPort userToken) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前提交数
|
|
|
|
List<String> params = (List<String>) map.get("params"); |
|
|
|
|
|
|
|
// 用于存储申请数
|
|
|
|
Integer result = 0; |
|
|
|
|
|
|
|
// 定义参数用与入库
|
|
|
|
Map<String,Object> insertForApplicationInRecord = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
insertForApplicationInRecord.put("applicantId", userToken.getId()); |
|
|
|
// 循环参数列表
|
|
|
|
for (String temp : params) { |
|
|
|
|
|
|
|
// 获取当前入库的组合数量
|
|
|
|
Integer quantityForGroup = ObjectFormatUtil.toInteger(map.get("quantity" + temp)); |
|
|
|
Map<String,Object> paramForMethod = new HashMap<>(); |
|
|
|
paramForMethod.put("quantity",map.get("quantity" + temp)); |
|
|
|
paramForMethod.put("gid",map.get("gid" + temp)); |
|
|
|
paramForMethod.put("placeId",map.get("placeId" + temp)); |
|
|
|
paramForMethod.put("depositoryId",map.get("depositoryId" + temp)); |
|
|
|
paramForMethod.put("applyRemark",map.get("applyRemark" + temp)); |
|
|
|
result += insertOrUpdateInventoryForGroupInfo(paramForMethod,userToken,true); |
|
|
|
|
|
|
|
// 获取要出库的组合
|
|
|
|
Integer gid = ObjectFormatUtil.toInteger(map.get("gid"+temp)); |
|
|
|
} |
|
|
|
result += insertOrUpdateInventoryForGroupInfo(map,userToken,false); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于处理组合入库时的库位 |
|
|
|
* @param map 入库数据 |
|
|
|
* @param userToken 入库人员 |
|
|
|
* @param flag 标志是否需要保存入库单号(true时不需要,false时需要) |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
Integer insertOrUpdateInventoryForGroupInfo(Map<String,Object> map,UserByPort userToken,boolean flag){ |
|
|
|
// 用于存储申请数
|
|
|
|
Integer result = 0; |
|
|
|
|
|
|
|
// 获取要出库组合的具体信息
|
|
|
|
List<GroupInfo> groupInfoByGid = groupMapper.findGroupInfoByGid(gid); |
|
|
|
|
|
|
|
// 获取入库的库位
|
|
|
|
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId" + temp)); |
|
|
|
// 获取入库的仓库
|
|
|
|
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId" + temp)); |
|
|
|
// 获取入库的仓库
|
|
|
|
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); |
|
|
|
|
|
|
|
insertForApplicationInRecord.put("depositoryId",depositoryId); |
|
|
|
insertForApplicationInRecord.put("placeId",placeId); |
|
|
|
insertForApplicationInRecord.put("applyRemark", map.get("applyRemark" + temp)); |
|
|
|
// 循环当前组合信息
|
|
|
|
for (GroupInfo groupInfo : |
|
|
|
groupInfoByGid) { |
|
|
|
// 获取当前组合记录中的单位
|
|
|
|
String unit = groupInfo.getUnit(); |
|
|
|
insertForApplicationInRecord.put("mid",groupInfo.getMid()); |
|
|
|
insertForApplicationInRecord.put("quantity",String.valueOf(groupInfo.getQuantity() * quantityForGroup)); |
|
|
|
insertForApplicationInRecord.put("code",groupInfo.getMcode()); |
|
|
|
if("-1".equals(unit)){ |
|
|
|
// 如果是基础单位
|
|
|
|
Material material = materialMapper.findMaterialById(groupInfo.getMid()); |
|
|
|
insertForApplicationInRecord.put("unit",material.getUnit()); |
|
|
|
insertForApplicationInRecord.put("price", String.valueOf(0)); |
|
|
|
result += depositoryRecordService.applicationInPlace(insertForApplicationInRecord,false); |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForApplicationInRecord.get("id"))); |
|
|
|
}else{ |
|
|
|
insertForApplicationInRecord.put("unit",unit); |
|
|
|
insertForApplicationInRecord.put("type","in"); |
|
|
|
insertForApplicationInRecord.put("price", String.valueOf(0)); |
|
|
|
result += splitUnitService.addSplitInventory(insertForApplicationInRecord); |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForApplicationInRecord.get("applicationInId"))); |
|
|
|
insertForApplicationInRecord.remove("applicationInId"); |
|
|
|
|
|
|
|
} |
|
|
|
// 定义参数用与入库
|
|
|
|
Map<String,Object> insertForApplicationInRecord = new HashMap<>(); |
|
|
|
|
|
|
|
} |
|
|
|
insertForApplicationInRecord.put("flagForGroup",2); |
|
|
|
insertForApplicationInRecord.put("quantity",quantityForGroup.toString()); |
|
|
|
insertForApplicationInRecord.put("mid",gid); |
|
|
|
insertForApplicationInRecord.put("unit",-1); |
|
|
|
Depository depository = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
insertForApplicationInRecord.put("code",depositoryRecordService.createCode(depository.getDname(), "InOrderNumber", "in", "")); |
|
|
|
insertForApplicationInRecord.put("applicant_time",System.currentTimeMillis()); |
|
|
|
depositoryRecordMapper.insertApplicationInRecord(insertForApplicationInRecord); |
|
|
|
insertForApplicationInRecord.remove("id"); |
|
|
|
|
|
|
|
} |
|
|
|
insertForApplicationInRecord.put("applicantId", userToken.getId()); |
|
|
|
|
|
|
|
// 获取当前入库的组合数量
|
|
|
|
Integer quantityForGroup = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
|
@ -784,8 +763,7 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
|
|
|
|
// 获取入库的库位
|
|
|
|
Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); |
|
|
|
// 获取入库的仓库
|
|
|
|
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); |
|
|
|
|
|
|
|
|
|
|
|
insertForApplicationInRecord.put("depositoryId",depositoryId); |
|
|
|
insertForApplicationInRecord.put("placeId",placeId); |
|
|
|
@ -823,9 +801,12 @@ public class GroupServiceImpl implements GroupService { |
|
|
|
insertForApplicationInRecord.put("code",depositoryRecordService.createCode(depository.getDname(), "InOrderNumber", "in", "")); |
|
|
|
insertForApplicationInRecord.put("applicant_time",System.currentTimeMillis()); |
|
|
|
depositoryRecordMapper.insertApplicationInRecord(insertForApplicationInRecord); |
|
|
|
if(!flag){ |
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(ObjectFormatUtil.toInteger(insertForApplicationInRecord.get("applicationInId"))); |
|
|
|
insertForApplicationInRecord.remove("applicationInId"); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用于插入子出库订单 |
|
|
|
* |
|
|
|
|