fix:纸管库存扣减

This commit is contained in:
zhouz
2024-06-07 09:23:29 +08:00
parent 9cb97a4b59
commit cca9e80cda
2 changed files with 14 additions and 5 deletions

View File

@@ -72,9 +72,10 @@ public class SlitterController {
public ResponseEntity<Object> create6(@RequestBody JSONObject entity){
return new ResponseEntity<>(slitterService.mesGetFinishWeighingOfWasteFoil(entity), HttpStatus.CREATED);
}
@PostMapping("/test7")
@Log("1111")
public ResponseEntity<Object> create7(@RequestBody JSONObject entity){
@PostMapping("/calPaperNum")
@Log("扣除纸管库存")
@SaIgnore
public ResponseEntity<Object> calPaperNum(@RequestBody JSONObject entity){
return new ResponseEntity<>(slitterService.acsToReduceTube(entity), HttpStatus.CREATED);
}
}

View File

@@ -45,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -707,13 +708,20 @@ public class SlitterServiceImpl implements SlitterService {
throw new BadRequestException("设备:" + param.getString("device_code") + "排数不能为空");
}
BstIvtStockingivt device = stockingivtService.getPointByCode(param.getString("device_code"), false);
MdPbPapervehicle mdPbPapervehicle = papervehicleService.getOne(new LambdaQueryWrapper<MdPbPapervehicle>().eq(MdPbPapervehicle::getVehicle_code, device.getVehicle_code())
.eq(MdPbPapervehicle::getRow_num, param.getString("row_num")));
int qty = mdPbPapervehicle.getQty().intValue();
if (qty <= 0) {
throw new BadRequestException("当前物料数量为0!");
}
UpdateWrapper<MdPbPapervehicle> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("vehicle_code", device.getVehicle_code())
.eq("row_num", param.getString("row_num"))
.setSql("qty=qty-1");
papervehicleService.update(updateWrapper);
JSONObject res = new JSONObject();
res.put("code", HttpStatus.HTTP_OK);
res.put("status", HttpStatus.HTTP_OK);
res.put("message", "请求成功!");
return res;
}