add:添加原材料库存变动

This commit is contained in:
zhangzhiqiang
2023-09-18 13:50:00 +08:00
parent 4f2e8b3e2f
commit 36723c513b
4 changed files with 64 additions and 21 deletions

View File

@@ -1,18 +1,27 @@
package org.nl.wms.storage_manage.rawmanage.controller.structIvt;
import cn.hutool.core.util.NumberUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiOperation;
import org.nl.common.anno.Log;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.device_manage.ios.service.structIvt.dto.StructIvtEmQuery;
import org.nl.wms.storage_manage.productmanage.util.ChangeIvtUtil;
import org.nl.wms.storage_manage.rawmanage.service.iostorInv.IStIvtIostorinvOutYlService;
import org.nl.wms.storage_manage.rawmanage.service.structIvt.IStIvtStructivtYlService;
import org.nl.wms.storage_manage.rawmanage.service.structIvt.dao.StIvtStructivtYl;
import org.nl.wms.storage_manage.rawmanage.service.structIvt.dto.StructIvtYLQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
/**
* <p>
* 仓位库存表 前端控制器
@@ -27,31 +36,29 @@ public class StIvtStructivtYlController {
@Autowired
private IStIvtStructivtYlService structivtYlService;
@Autowired
private IStIvtIostorinvOutYlService iostorinvOutYlService;
@GetMapping("/getRawIvt")
@Log("查询可用的原料库存")
//("查询可用的原料库存")
public ResponseEntity<Object> getRawIvt(StructIvtYLQuery query, PageQuery page) {
return new ResponseEntity<>(structivtYlService.getRawIvt(query, page), HttpStatus.OK);
}
@GetMapping("/getProductIvt")
@Log("查询可用的成品库存")
//("查询可用的成品库存")
public ResponseEntity<Object> getProductIvt(StructIvtYLQuery query, PageQuery page) {
return new ResponseEntity<>(structivtYlService.getProductIvt(query,page), HttpStatus.OK);
}
@PostMapping("/getStructIvt")
@Log("查询库存")
//("查询库存")
public ResponseEntity<Object> getStructIvt(StructIvtYLQuery query) {
return new ResponseEntity<>(structivtYlService.getStructIvt(query), HttpStatus.OK);
}
@PostMapping("/getSemiProductIvt")
@Log("查询可用的半成品库存")
//("查询可用的半成品库存")
public ResponseEntity<Object> getSemiProductIvt(StructIvtYLQuery query) {
return new ResponseEntity<>(structivtYlService.getSemiProductIvt(query), HttpStatus.OK);
}
@@ -59,21 +66,21 @@ public class StIvtStructivtYlController {
@GetMapping("/getSemiProductIvt2")
@Log("查询可用的半成品库存")
//("查询可用的半成品库存")
public ResponseEntity<Object> getSemiProductIvt2(StructIvtYLQuery query, PageQuery page) {
return new ResponseEntity<>(structivtYlService.getSemiProductIvt(query,page), HttpStatus.OK);
}
@GetMapping("/getAllRawIvt")
@Log("查询原料库存")
//("查询原料库存")
public ResponseEntity<Object> getAllRawIvt(StructIvtYLQuery query, PageQuery page) {
return new ResponseEntity<>(structivtYlService.getAllRawIvt(query, page), HttpStatus.OK);
}
@GetMapping("/update")
@PostMapping("/update")
@Log("更新原料库存")
//("查询原料库存")
public ResponseEntity<Object> update(@RequestBody JSONObject form) {
iostorinvOutYlService.updateIvt(form);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -63,4 +63,10 @@ public interface IStIvtIostorinvOutYlService extends IService<StIvtIostorinvYl>
*/
void confirm(JSONObject form);
/**
* 手动修改库存
* @param form
*/
void updateIvt(JSONObject form);
}

View File

@@ -299,4 +299,35 @@ public class StIvtIostorinvOutYlServiceImpl extends ServiceImpl<StIvtIostorinvOu
return stIvtIostorinvYl;
}
//aps_sale_type"I"canuse_qty660class_name"紫铜管件S"frozen_qty0instorage_time"2023-09-13 17:29:55"is_activetrueivt_level"1"ivt_qty660material_code"24010638S"material_id"1684134849134333952"material_name"三通\\T7/8墨西哥\\MSNA0201002"pcsn"2023-09-13"qty_unit_id"1"qty_unit_name"KG"quality_scode"01"sect_code"RCK001"sect_id"1528631043903590400"sect_name"原材料区"stockrecord_id"1701890944963579904"stor_id"1528627964823080960"stor_name"紫铜原材料仓库"struct_code"YCL001"struct_id"1528636861080276992"struct_name"原材料仓位"warehousing_qty0
@Override
@Transactional
public void updateIvt(JSONObject form) {
StIvtStructivtYl ivt = structivtYlService.getOne(new QueryWrapper<StIvtStructivtYl>()
.eq("material_id", form.getString("material_id"))
.eq("stor_id", form.getString("stor_id"))
.eq("canuse_qty", form.getBigDecimal("old_qty"))
);
if (ivt==null){
throw new BadRequestException("当前物料库存已变更,请重新操作");
}
double change_qty = NumberUtil.sub(form.getBigDecimal("ivt_qty"),form.getBigDecimal("old_qty")).doubleValue();
if (change_qty==0){
return;
}
ivt.setCanuse_qty(form.getBigDecimal("ivt_qty"));
ivt.setIvt_qty(ivt.getCanuse_qty());
structivtYlService.updateById(ivt);
// 插入库存变动记
JSONObject param = JSONObject.parseObject(JSON.toJSONString(ivt));
param.put("change_type", change_qty>0?ChangeIvtUtil.SUBWAREHOUSING_ADDIVT_QTY:ChangeIvtUtil.SUBFROZEN_SUBIVT_QTY);
param.put("change_qty",Math.abs(change_qty));
param.put("result_qty", form.getBigDecimal("ivt_qty"));
param.put("bill_code","");
param.put("inv_id","");
param.put("bill_type_scode","");
iStIvtStructivtflowYlService.insetIvtChange(param);
}
}

View File

@@ -114,12 +114,7 @@
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="可用数量">
<el-input v-model="ivtForm.canuse_qty" style="width: 200px;" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="冻结数量">
<el-form-item label="库存数数量">
<el-input v-model="ivtForm.ivt_qty" style="width: 200px;" />
</el-form-item>
</el-col>
@@ -127,7 +122,7 @@
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="closeView">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="updateIvt">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
@@ -218,12 +213,16 @@ export default {
updateMaterial(row){
this.dialogVisible = true
this.ivtForm = row
// ProductIvt.edit(row).then(res => {
// this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
// this.crud.toQuery()
// }).catch(err => {
// console.log(err.response.data.message)
// })
this.ivtForm.old_qty = row.canuse_qty
},
updateIvt(){
ProductIvt.edit(this.ivtForm).then(res => {
this.crud.notify('操作成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
this.closeView()
}).catch(err => {
})
}
}
}