|
|
|
@ -872,54 +872,6 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return placeMapper.UpdatePlace(placeById); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将刚入库的记录删除 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Integer deleteApplicaionInPlace(Map<String, Object> map) { |
|
|
|
String code = map.get("code").toString(); |
|
|
|
Integer quantity = ObjectFormatUtil.toInteger(map.get("quantity")); |
|
|
|
Integer mid = ObjectFormatUtil.toInteger(map.get("mid")); |
|
|
|
Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); |
|
|
|
// 获取材料基本信息
|
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
Object oldPrice1 = map.get("oldPrice"); |
|
|
|
Double oldPrice = 0.0; |
|
|
|
if (oldPrice1 != null) { |
|
|
|
oldPrice = Double.parseDouble(oldPrice1.toString()); |
|
|
|
} |
|
|
|
Double price = Double.parseDouble(map.get("price").toString()); |
|
|
|
Integer id = ObjectFormatUtil.toInteger(map.get("id")); |
|
|
|
String deleteType = map.get("delete").toString(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("code", materialById.getCode()); |
|
|
|
params.put("depositoryId", depositoryId); |
|
|
|
List<Material> materialByCondition = materialMapper.findMaterialByCondition(params); |
|
|
|
if (materialByCondition.size() < 1) { |
|
|
|
throw new MyException("出现未知错误,联系开发人员"); |
|
|
|
} |
|
|
|
if ("in".equals(deleteType)) { |
|
|
|
// 删除入库记录
|
|
|
|
depositoryRecordMapper.deleteApplicationInRecordById(id); |
|
|
|
// 将库存还原
|
|
|
|
Material material = materialByCondition.get(0); |
|
|
|
Map<String, Object> update = new HashMap<>(); |
|
|
|
update.put("quantity", material.getQuantity() - quantity * 100); |
|
|
|
update.put("price", oldPrice); |
|
|
|
update.put("amounts", material.getAmounts() - quantity * price); |
|
|
|
update.put("id", material.getId()); |
|
|
|
return materialMapper.updateMaterial(update); |
|
|
|
|
|
|
|
} else if ("out".equals(deleteType)) { |
|
|
|
return null; |
|
|
|
} else { |
|
|
|
throw new MyException("请求参数错误"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 插入一条出库子订单 |
|
|
|
|