|
|
|
@ -106,6 +106,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Integer applicationIn(Map<String, Object> map) { |
|
|
|
Boolean flagForApproval = ObjectFormatUtil.toBoolean(map.get("flagForApproval")); |
|
|
|
|
|
|
|
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); |
|
|
|
Depository depositoryRecordById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
Map<String, Object> temp = new HashMap<>(); |
|
|
|
@ -115,7 +117,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Integer Inventory = depositoryMapper.getToDayInventoryByDName(temp); |
|
|
|
//构造单号
|
|
|
|
String code = createCode(depositoryRecordById.getDname(), "InOrderNumber", "in", ""); |
|
|
|
Double quantity = Double.parseDouble((String) map.get("quantity")); |
|
|
|
double quantity = Double.parseDouble((String) map.get("quantity")); |
|
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
|
// 根据物料id查询物料
|
|
|
|
Material material = materialMapper.findMaterialById(mid); |
|
|
|
@ -145,6 +147,39 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
map.put("code", code); |
|
|
|
// 获取当前物料
|
|
|
|
|
|
|
|
// 获取当前入库物料id
|
|
|
|
Integer newMid = 0; |
|
|
|
if(!flagForApproval){ |
|
|
|
newMid = updateOrInsertInventory(map,materialByCondition,quantity,mid,depositoryId,producedDate); |
|
|
|
} |
|
|
|
|
|
|
|
// 将新入库的物料id记录下来
|
|
|
|
map.put("newInMid", newMid); |
|
|
|
|
|
|
|
// 如果包含realQuantity则代表是入库的拆单单位
|
|
|
|
if (map.containsKey("realQuantity")) { |
|
|
|
// 将入库数量修改为realQuantity
|
|
|
|
map.put("quantity", map.get("realQuantity")); |
|
|
|
} |
|
|
|
if (!map.containsKey("flagForGroup")) { |
|
|
|
// 如果不包含标志位.
|
|
|
|
map.put("flagForGroup", 1); |
|
|
|
} |
|
|
|
return depositoryRecordMapper.insertApplicationInRecord(map); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于入库申请时,更新物料库存计量 |
|
|
|
* @param map 入库数据 |
|
|
|
* @param materialByCondition 当前仓库是否存在该物料 |
|
|
|
* @param quantity 入库数量 |
|
|
|
* @param mid 入库物料id |
|
|
|
* @param depositoryId 入库位置 |
|
|
|
* @param producedDate 生产日期 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
Integer updateOrInsertInventory(Map<String,Object> map,List<Inventory> materialByCondition,Double quantity,Integer mid,Integer depositoryId,long producedDate){ |
|
|
|
// 获取当前入库物料id
|
|
|
|
Integer newMid = 0; |
|
|
|
if (materialByCondition.size() > 0) { // 如果当前存在
|
|
|
|
@ -154,7 +189,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
mt.setProducedDate(producedDate); |
|
|
|
materialMapper.updateInventory(mt); |
|
|
|
newMid = mt.getId(); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
Map<String, Object> insert = new HashMap<>(); |
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
insert.put("depositoryId", depositoryId); |
|
|
|
@ -165,19 +201,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
materialMapper.insertInventory(insert); |
|
|
|
newMid = ObjectFormatUtil.toInteger(insert.get("id")); |
|
|
|
} |
|
|
|
// 将新入库的物料id记录下来
|
|
|
|
map.put("newInMid", newMid); |
|
|
|
|
|
|
|
// 如果包含realQuantity则代表是入库的拆单单位
|
|
|
|
if (map.containsKey("realQuantity")) { |
|
|
|
// 将入库数量修改为realQuantity
|
|
|
|
map.put("quantity", map.get("realQuantity")); |
|
|
|
} |
|
|
|
if (!map.containsKey("flagForGroup")) { |
|
|
|
// 如果不包含标志位.
|
|
|
|
map.put("flagForGroup", 1); |
|
|
|
} |
|
|
|
return depositoryRecordMapper.insertApplicationInRecord(map); |
|
|
|
return newMid; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -620,6 +644,15 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if ("-1".equals(unit)) { |
|
|
|
map.put("unit", materialById.getUnit()); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取当前仓库是否需要审批
|
|
|
|
List<RoleAndDepository> depositoryListForIn = roleService.findRoleAndDepositoryByDepositoryIdForIn(ObjectFormatUtil.toInteger(map.get("depositoryId"))); |
|
|
|
boolean flagForApproval = false; // 默认不需要审批
|
|
|
|
if(depositoryListForIn.size() > 0){ |
|
|
|
flagForApproval = true; |
|
|
|
} |
|
|
|
map.put("flagForApproval",flagForApproval); |
|
|
|
|
|
|
|
if (placeById.getMax() - placeById.getQuantity() > quantity) { |
|
|
|
// 如果当前库位还能存放
|
|
|
|
// 入库
|
|
|
|
@ -627,6 +660,29 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
if (integer != 1) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
if(!flagForApproval){ |
|
|
|
// 如果不需要审批
|
|
|
|
Integer result = updateInventoryInfoForApproval(map, quantity, materialById, placeById); |
|
|
|
map.remove("applicationInId"); |
|
|
|
return result; |
|
|
|
} |
|
|
|
return integer; |
|
|
|
} else { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于入库后修改相关数据信息 |
|
|
|
* @param map 入库数据 |
|
|
|
* @param quantity 数量 |
|
|
|
* @param materialById 入库物料 |
|
|
|
* @param placeById 入库库位 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
Integer updateInventoryInfoForApproval(Map<String,Object> map,Integer quantity,Material materialById,Place placeById){ |
|
|
|
// 获取当前入库的物料id
|
|
|
|
Integer newInMid = ObjectFormatUtil.toInteger(map.get("newInMid")); |
|
|
|
// 获取当前入库记录id
|
|
|
|
@ -654,7 +710,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
materialAndProducedDateByMidAndProducedDate.setInventory(materialAndProducedDateByMidAndProducedDate.getInventory() + quantity); |
|
|
|
// 修改
|
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDateByMidAndProducedDate); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
insertProducedDate.put("quantity", quantity); |
|
|
|
insertProducedDate.put("inventory", quantity); |
|
|
|
insertProducedDate.put("expendnum", 0); |
|
|
|
@ -668,9 +725,10 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
|
param.put("mcode", materialById.getCode()); |
|
|
|
param.put("mname", materialById.getMname()); |
|
|
|
if (placeId == 0) { |
|
|
|
if (Integer.compare(placeById.getId(),0) == 0) { |
|
|
|
param.put("depositoryId", map.get("depositoryId")); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
param.put("depositoryId", placeById.getDid()); |
|
|
|
} |
|
|
|
List<Inventory> inventory = materialMapper.findInventory(param); |
|
|
|
@ -687,7 +745,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
insert.put("quantity", quantity); |
|
|
|
// 插入记录
|
|
|
|
placeMapper.addMaterialOnPlace(insert); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() + quantity); |
|
|
|
// 修改数量
|
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
@ -695,9 +754,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 修改当前库位数量
|
|
|
|
placeById.setQuantity(placeById.getQuantity() + quantity); |
|
|
|
return placeMapper.UpdatePlace(placeById); |
|
|
|
} else { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|