|
|
|
@ -58,6 +58,9 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
@Autowired |
|
|
|
private MaterialTypeMapper materialTypeMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SplitUnitMapper splitUnitMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 提交申请,插入一条仓库调度记录 |
|
|
|
@ -764,15 +767,22 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
|
|
|
|
// 获取要出库的数量
|
|
|
|
Integer trueOut = ObjectFormatUtil.toInteger(param.get("trueOut")); |
|
|
|
|
|
|
|
// 获取出库库位
|
|
|
|
Integer placeId = ObjectFormatUtil.toInteger(param.get("placeId")); |
|
|
|
|
|
|
|
// 获取出库申请时的单位
|
|
|
|
String unit = applicationOutMinById.getUnit(); |
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = null; |
|
|
|
if("-1".equals(unit)) { |
|
|
|
|
|
|
|
// 如果是按基础单位出库
|
|
|
|
|
|
|
|
if (istransfer == 1) {// 如果是库存转移
|
|
|
|
// 获取库存转移订单
|
|
|
|
TransferRecord transferRecordById = transferRecordMapper.findTransferRecordById(applicationOutMinById.getTransferId()); |
|
|
|
placeId = transferRecordById.getFromPlaceId();// 获取转出库位
|
|
|
|
} |
|
|
|
MaterialAndPlace placeAndMaterialByMidAndPid = null; |
|
|
|
|
|
|
|
if (placeId != 0) { // 如果不是默认库位
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("mid", inventory.getId()); |
|
|
|
@ -791,7 +801,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "当前位置未发现该物料")); |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
} else { // 如果是默认库位
|
|
|
|
} |
|
|
|
else { // 如果是默认库位
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("mid", inventory.getId()); |
|
|
|
params.put("pid", 0); |
|
|
|
@ -810,24 +821,23 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果物料数量可以出库并且库位数量充足
|
|
|
|
if (inventory.getQuantity() >= trueOut && flag) { |
|
|
|
// 当前出库金额
|
|
|
|
Double sum = inventory.getPrice() * trueOut; |
|
|
|
// 当前出库数量
|
|
|
|
Integer quantity = trueOut; |
|
|
|
|
|
|
|
inventory.setAmounts(inventory.getAmounts() - sum); |
|
|
|
inventory.setQuantity(inventory.getQuantity() - quantity); |
|
|
|
inventory.setNumberOfTemporary(inventory.getNumberOfTemporary() - quantity); |
|
|
|
// 修改物料信息
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
|
|
if (placeAndMaterialByMidAndPid != null) { //如果库位不为空
|
|
|
|
|
|
|
|
// 修改当前库位存放物料的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - quantity); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
} |
|
|
|
|
|
|
|
// 修改库位数量
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
@ -835,6 +845,348 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", trueOut.toString()); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
// 进行子订单的相关处理
|
|
|
|
updateApplicationMinOutInfo(id,applicationOutMinById,record,trueOut,userByPort,placeId,userAgent); |
|
|
|
|
|
|
|
// 更新入库批次中的物料数量
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
// 获取出库物料id
|
|
|
|
Integer mid = inventory.getId(); |
|
|
|
// 获取当前物料对应的生产日期
|
|
|
|
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(mid); |
|
|
|
if (materialAndProducedDateByMid.size() > 0) { |
|
|
|
// 获取距今生产日期远的(即生产日期最早的)
|
|
|
|
for (MaterialAndProducedDate materialAndProducedDate : |
|
|
|
materialAndProducedDateByMid) { |
|
|
|
if (materialAndProducedDate.getInventory() > quantity) { |
|
|
|
// 设置使用的数量
|
|
|
|
materialAndProducedDate.setExpendnum(materialAndProducedDate.getExpendnum() + quantity); |
|
|
|
// 设置剩余的数量
|
|
|
|
materialAndProducedDate.setInventory(materialAndProducedDate.getInventory() - quantity); |
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); |
|
|
|
// 跳出循环
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} |
|
|
|
else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
// 如果是拆单后的单位
|
|
|
|
|
|
|
|
// 获取拆单库存处理记录
|
|
|
|
SplitInventory splitInventory = splitUnitMapper.findSplitInventoryByIid(inventory.getId()); |
|
|
|
if(splitInventory != null) { |
|
|
|
// 如果拆单库存处理记录存在
|
|
|
|
|
|
|
|
if (splitInventory.getSaveQuantity() >= trueOut) { |
|
|
|
// 如果当前待处理树可以满足需求
|
|
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - trueOut); |
|
|
|
if (splitInventory.getOutQuantity() != null) { |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + trueOut); |
|
|
|
} else { |
|
|
|
splitInventory.setOutQuantity(trueOut); |
|
|
|
} |
|
|
|
|
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
// 进行子订单的相关处理
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
// 如果不能满足需求
|
|
|
|
|
|
|
|
// 获取对应的拆单记录
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoById(splitInventory.getSid()); |
|
|
|
|
|
|
|
// 获取剩余不足的数量
|
|
|
|
int surplus = trueOut - splitInventory.getSaveQuantity(); |
|
|
|
if (surplus < splitInfo.getQuantity()) { |
|
|
|
// 如果剩余不足的数量小于拆单单位对应的数量
|
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("mid", inventory.getId()); |
|
|
|
params.put("pid", placeId); |
|
|
|
|
|
|
|
// 获取当前物料在库位中的数量
|
|
|
|
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params); |
|
|
|
|
|
|
|
if (placeAndMaterialByMidAndPid != null) { |
|
|
|
// 如果当前库位存在该物料
|
|
|
|
if (placeAndMaterialByMidAndPid.getQuantity() < 1) { |
|
|
|
// 如果当前库存中的物料库存不足以出库
|
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
restResponse.setStatus(566); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "当前位置未发现该物料")); |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
// 如果物料数量可以出库并且库位数量充足
|
|
|
|
if (inventory.getQuantity() >= 1 && flag) { |
|
|
|
|
|
|
|
// 令库存-1
|
|
|
|
inventory.setQuantity(inventory.getQuantity() - 1); |
|
|
|
|
|
|
|
// 重新计算总额
|
|
|
|
inventory.setAmounts(inventory.getQuantity() * inventory.getPrice()); |
|
|
|
|
|
|
|
// 重新计算单价
|
|
|
|
BigDecimal decimal = new BigDecimal(inventory.getAmounts() / inventory.getQuantity()); |
|
|
|
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
inventory.setPrice(price); |
|
|
|
|
|
|
|
// 修改库存记录
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
|
|
|
|
|
|
// 修改当前库位存放物料的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - 1); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
// 修改库位数量
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
placeById.setQuantity(placeById.getQuantity() - 1); |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", "1"); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
|
|
|
|
// 设置剩余拆单库存处理数量
|
|
|
|
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - trueOut); |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + trueOut); |
|
|
|
splitUnitMapper.updateSplitInventory(splitInventory); |
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 如果大于
|
|
|
|
|
|
|
|
// 获取库存重要减少的数量
|
|
|
|
int surplus_redundant = surplus / splitInfo.getQuantity(); |
|
|
|
// 获取拆单库存处理中要处理数量
|
|
|
|
int saveQuantity = surplus - surplus_redundant * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
if (saveQuantity > splitInventory.getSaveQuantity()) { |
|
|
|
// 如果要处理的数量大于剩余数量
|
|
|
|
|
|
|
|
// 获取一个数量
|
|
|
|
surplus_redundant += 1; |
|
|
|
splitInventory.setSaveQuantity(splitInfo.getQuantity() + splitInventory.getSaveQuantity() - saveQuantity); |
|
|
|
} else { |
|
|
|
// 如果不大于
|
|
|
|
splitInventory.setSaveQuantity(splitInventory.getSaveQuantity() - saveQuantity); |
|
|
|
} |
|
|
|
splitInventory.setOutQuantity(splitInventory.getOutQuantity() + saveQuantity); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("mid", inventory.getId()); |
|
|
|
params.put("pid", placeId); |
|
|
|
|
|
|
|
// 获取当前物料在库位中的数量
|
|
|
|
placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(params); |
|
|
|
|
|
|
|
if (placeAndMaterialByMidAndPid != null) { |
|
|
|
// 如果当前库位存在该物料
|
|
|
|
if (placeAndMaterialByMidAndPid.getQuantity() < surplus_redundant) { |
|
|
|
// 如果当前库存中的物料库存不足以出库
|
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
restResponse.setStatus(566); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "当前位置未发现该物料")); |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
if (inventory.getQuantity() >= surplus_redundant && flag) { |
|
|
|
// 如果能够出库
|
|
|
|
|
|
|
|
// 令库存-1
|
|
|
|
inventory.setQuantity(inventory.getQuantity() - surplus_redundant); |
|
|
|
|
|
|
|
// 重新计算总额
|
|
|
|
inventory.setAmounts(inventory.getQuantity() * inventory.getPrice()); |
|
|
|
|
|
|
|
// 重新计算单价
|
|
|
|
BigDecimal decimal = new BigDecimal(inventory.getAmounts() / inventory.getQuantity()); |
|
|
|
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
inventory.setPrice(price); |
|
|
|
|
|
|
|
// 修改库存记录
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
|
|
|
|
|
|
// 修改当前库位存放物料的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - surplus_redundant); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
// 修改库位数量
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
placeById.setQuantity(placeById.getQuantity() - surplus_redundant); |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", String.valueOf(surplus_redundant)); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
// 如果拆单库存处理记录不存在
|
|
|
|
|
|
|
|
// 用于获取对应的拆单记录
|
|
|
|
Map<String,Object> paramForSplitInfo = new HashMap<>(); |
|
|
|
paramForSplitInfo.put("mid",inventory.getMid()); |
|
|
|
paramForSplitInfo.put("newUnit",record.getUnit()); |
|
|
|
// 获取对应拆单记录
|
|
|
|
SplitInfo splitInfo = splitUnitMapper.findSplitInfoByMidAndUnit(paramForSplitInfo); |
|
|
|
if(inventory.getQuantity() * splitInfo.getQuantity() > trueOut){ |
|
|
|
// 如果当前库存数量满足要求
|
|
|
|
|
|
|
|
// 获取当前出库的具体数目
|
|
|
|
int residue = trueOut / splitInfo.getQuantity(); |
|
|
|
// 获取剩余数目
|
|
|
|
int residue_realQuantity = trueOut - residue * splitInfo.getQuantity(); |
|
|
|
|
|
|
|
// 设置新总额
|
|
|
|
inventory.setAmounts(inventory.getAmounts() - (residue + 1) * inventory.getPrice()); |
|
|
|
|
|
|
|
// 设置新库存
|
|
|
|
inventory.setQuantity(inventory.getQuantity() - residue - 1); |
|
|
|
|
|
|
|
// 重新计算单价
|
|
|
|
BigDecimal decimal = BigDecimal.valueOf(inventory.getAmounts() / inventory.getQuantity()); |
|
|
|
Double price = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); |
|
|
|
inventory.setPrice(price); |
|
|
|
|
|
|
|
//更新库存
|
|
|
|
materialMapper.updateInventory(inventory); |
|
|
|
|
|
|
|
// 更新对应库位的库存
|
|
|
|
// 修改当前库位存放物料的数量
|
|
|
|
placeAndMaterialByMidAndPid.setQuantity(placeAndMaterialByMidAndPid.getQuantity() - residue - 1); |
|
|
|
placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); |
|
|
|
|
|
|
|
// 修改库位数量
|
|
|
|
Place placeById = placeMapper.findPlaceById(placeId); |
|
|
|
placeById.setQuantity(placeById.getQuantity() - residue - 1); |
|
|
|
placeMapper.UpdatePlace(placeById); |
|
|
|
|
|
|
|
// 添加拆单库存处理记录
|
|
|
|
Map<String,Object> insertSplitInventory = new HashMap<>(); |
|
|
|
insertSplitInventory.put("sid",splitInfo.getId()); |
|
|
|
insertSplitInventory.put("iid",inventory.getId()); |
|
|
|
insertSplitInventory.put("outQuantity",trueOut); |
|
|
|
insertSplitInventory.put("inQuantity",0); |
|
|
|
insertSplitInventory.put("saveQuantity",splitInfo.getQuantity() - residue_realQuantity); |
|
|
|
splitUnitMapper.addSplitInventory(insertSplitInventory); |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", String.valueOf(residue)); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
|
|
|
|
updateApplicationMinOutInfo(id, applicationOutMinById, record, trueOut, userByPort, placeId, userAgent); |
|
|
|
|
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 用于完成出库时的相关处理操作 |
|
|
|
* @param id 子订单id |
|
|
|
* @param applicationOutMinById 待处理的子订单 |
|
|
|
* @param record 子订单对应的主订单 |
|
|
|
* @param trueOut 实际出库数量 |
|
|
|
* @param userByPort 当前登录用户 |
|
|
|
* @param placeId 出库库位id |
|
|
|
* @param userAgent user-agent |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
void updateApplicationMinOutInfo(Integer id, ApplicationOutRecordMin applicationOutMinById, ApplicationOutRecordP record, Integer trueOut, UserByPort userByPort, Integer placeId, String userAgent){ |
|
|
|
String redisMinRecordKey = "minRecord:" + id; // 设置redis中子订单键值
|
|
|
|
// 修改redis中本子订单状态
|
|
|
|
// redisTemplate.opsForHash().put(redisMinRecordKey,"state","2");
|
|
|
|
@ -954,58 +1306,12 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// depositoryManagerByQyWx.append(depositoryManager.getWorkwechat()+",");
|
|
|
|
} |
|
|
|
depositoryManagerByQyWx.append("PangFuZhen,"); |
|
|
|
JSONObject jsonObject = qyWxOperationService.sendCcMessageToUsers(depositoryManagerByQyWx.toString(), record.getId(), userAgent); |
|
|
|
// JSONObject jsonObject = qyWxOperationService.sendCcMessageToUsers(depositoryManagerByQyWx.toString(), record.getId(), userAgent);
|
|
|
|
|
|
|
|
// 删除redis中本订单
|
|
|
|
redisTemplate.delete("record:" + record.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 如果是库存转移订单
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
if (record.getIstransfer() == 1) { |
|
|
|
map.put("quantity", trueOut.toString()); |
|
|
|
map.put("applicantId", record.getApplicantId()); |
|
|
|
map.put("minRecordId", applicationOutMinById.getId()); // 出库订单编号
|
|
|
|
transferMaterial(map); |
|
|
|
} |
|
|
|
restResponse.setStatus(200); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库成功", "出库成功")); |
|
|
|
|
|
|
|
|
|
|
|
// 更新入库批次中的物料数量
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
// 获取出库物料id
|
|
|
|
Integer mid = inventory.getId(); |
|
|
|
// 获取当前物料对应的生产日期
|
|
|
|
List<MaterialAndProducedDate> materialAndProducedDateByMid = materialMapper.findMaterialAndProducedDateByMid(mid); |
|
|
|
if (materialAndProducedDateByMid.size() > 0) { |
|
|
|
// 获取距今生产日期远的(即生产日期最早的)
|
|
|
|
for (MaterialAndProducedDate materialAndProducedDate : |
|
|
|
materialAndProducedDateByMid) { |
|
|
|
if (materialAndProducedDate.getInventory() > quantity) { |
|
|
|
// 设置使用的数量
|
|
|
|
materialAndProducedDate.setExpendnum(materialAndProducedDate.getExpendnum() + quantity); |
|
|
|
// 设置剩余的数量
|
|
|
|
materialAndProducedDate.setInventory(materialAndProducedDate.getInventory() - quantity); |
|
|
|
materialMapper.updateMaterialAndProducedDate(materialAndProducedDate); |
|
|
|
// 跳出循环
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} else { |
|
|
|
restResponse.setStatus(508); |
|
|
|
restResponse.setData(""); |
|
|
|
restResponse.setStatusInfo(new StatusInfo("出库失败", "出库失败,库存不足")); |
|
|
|
} |
|
|
|
return restResponse; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -1372,7 +1678,8 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
} else { |
|
|
|
} |
|
|
|
else { |
|
|
|
String result = ""; |
|
|
|
// 开启线程更改其他用户卡片模板样式
|
|
|
|
String simpleTime = DateUtil.getSimpleTime(new Date()); |
|
|
|
@ -1428,16 +1735,14 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
// 获取对应的物料编号
|
|
|
|
Integer mid = applicationOutRecordMin.getMid(); |
|
|
|
// 获取物料信息
|
|
|
|
Material materialById = materialMapper.findMaterialById(mid); |
|
|
|
Inventory inventory = materialMapper.findInventoryById(mid); |
|
|
|
// 获取该物料所处仓库的仓库管理员
|
|
|
|
List<Integer> userIdByDid = new ArrayList<>(); |
|
|
|
userIdByDid = roleService.findUserIdByDid(materialById.getDepositoryId()); |
|
|
|
userIdByDid = roleService.findUserIdByDid(inventory.getDepositoryId()); |
|
|
|
// 用于保存仓库管理员的企业微信openid
|
|
|
|
StringBuilder QyWxUid = new StringBuilder(); |
|
|
|
for (int j = 0; j < userIdByDid.size(); j++) { |
|
|
|
|
|
|
|
// 获取当前用户信息
|
|
|
|
UserByPort userByPort = LinkInterfaceUtil.FindUserById(userIdByDid.get(j), userToken); |
|
|
|
// 仓库管理员订单信息
|
|
|
|
Map<String, Object> userRecord = new HashMap<>(); |
|
|
|
// 用户当前子订单
|
|
|
|
@ -1469,7 +1774,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
}).start();*/ |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < depositoryIdList.size(); i++) { |
|
|
|
/* for (int i = 0; i < depositoryIdList.size(); i++) { |
|
|
|
Object o = minIdByDepository.get("depository" + depositoryIdList.get(i)); |
|
|
|
if (o != null) { |
|
|
|
List<Integer> minIdList = (List<Integer>) o; |
|
|
|
@ -1517,7 +1822,7 @@ public class DepositoryRecordServiceImpl implements DepositoryRecordService { |
|
|
|
s = "PangFuZhen,"; |
|
|
|
qyWxOperationService.sendMessageForOtherUserByCard(ObjectFormatUtil.toInteger(id), s, userAgent, 1); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
}).start();*/ |
|
|
|
|
|
|
|
// 将主订单插入到redis中
|
|
|
|
redisTemplate.opsForHash().put("record:" + record.getId(), "minRecord", minRecordByMain.toString()); |
|
|
|
|