|
@@ -18,14 +18,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.zkqy.common.annotation.Log;
|
|
|
import com.zkqy.common.core.controller.BaseController;
|
|
|
import com.zkqy.common.core.domain.AjaxResult;
|
|
@@ -44,8 +37,7 @@ import com.zkqy.common.core.page.TableDataInfo;
|
|
|
@RestController
|
|
|
@RequestMapping("/system/inventory")
|
|
|
@Api(value = "/system/inventory", description = "物料库存-接口")
|
|
|
-public class MaterialInventoryController extends BaseController
|
|
|
-{
|
|
|
+public class MaterialInventoryController extends BaseController {
|
|
|
@Autowired
|
|
|
private IMaterialInventoryService materialInventoryService;
|
|
|
@Autowired
|
|
@@ -55,56 +47,60 @@ public class MaterialInventoryController extends BaseController
|
|
|
@Autowired
|
|
|
private MaterielMapper materielMapper;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 扫码入库
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:inventory:add')")
|
|
|
@Log(title = "物料库存", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping("/inventory/insertMaterialInventory")
|
|
|
+ @RequestMapping(value = "/insertMaterialInventory", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "新增物料库存")
|
|
|
- public AjaxResult insertMaterialInventory(@RequestBody MaterialInventoryVo materialInventoryVo)
|
|
|
- {
|
|
|
+ public AjaxResult insertMaterialInventory(@RequestBody MaterialInventoryVo materialInventoryVo) {
|
|
|
+ String replace = materialInventoryVo.getQtCodeNumber().replace("/r", "");
|
|
|
+ materialInventoryVo.setQtCodeNumber(replace);
|
|
|
//1、禁止重复入库
|
|
|
InboundRecords inboundRecords = inboundRecordsMapper.selectInboundRecordsByQtCodeNumber(materialInventoryVo.getQtCodeNumber());
|
|
|
- if(inboundRecords==null){
|
|
|
- return AjaxResult.success("不可以重复扫码");
|
|
|
+ if (inboundRecords != null) {
|
|
|
+ return AjaxResult.success("不可以重复扫码入库");
|
|
|
}
|
|
|
//2、判断是第一次入库还是第二次入库这个同类商品(这是一个连表语句)
|
|
|
MaterialInventory materialInventory
|
|
|
= materialInventoryService.selectMaterialInventoryByMaterialCodeAndSpecifications(materialInventoryVo.getMaterialCode(), materialInventoryVo.getSpecifications());
|
|
|
- int count=0;
|
|
|
- if(materialInventory!=null){ //证明已经入库过相同的产品了---库存叠加操作
|
|
|
- String quantityOld = materialInventory.getQuantity();
|
|
|
- String quantity = materialInventoryVo.getQuantity();
|
|
|
- Integer newQuantity=Integer.parseInt(quantityOld)+Integer.parseInt(quantity);
|
|
|
- materialInventory.setQuantity(String.valueOf(newQuantity));
|
|
|
+ int count = 0;
|
|
|
+ if (materialInventory != null) { //证明已经入库过相同的产品了---库存叠加操作
|
|
|
+ Double quantityOld = materialInventory.getQuantity();
|
|
|
+ Double quantity = materialInventoryVo.getQuantity();
|
|
|
+ Double newQuantity =quantityOld+quantity;
|
|
|
+ materialInventory.setQuantity(newQuantity);
|
|
|
+ materialInventory.setUpdateTime(new Date());
|
|
|
+ materialInventory.setUpdateById(SecurityUtils.getUserId());
|
|
|
count = materialInventoryService.updateMaterialInventory(materialInventory);
|
|
|
- }else{ //第一次入库走插入操作) ()
|
|
|
- MaterialInventory materialInventoryObj=new MaterialInventory();
|
|
|
+ } else { //第一次入库走插入操作) ()
|
|
|
+ MaterialInventory materialInventoryObj = new MaterialInventory();
|
|
|
materialInventoryObj.setStockNumber(String.valueOf(new Date().getTime()));//库存编号
|
|
|
materialInventoryObj.setWarehouseEntryNumber(UUID.randomUUID().toString());//入库单编号
|
|
|
materialInventoryObj.setMaterialCode(materialInventoryVo.getMaterialCode());//物料编号
|
|
|
- materialInventoryObj.setQuantity(materialInventoryObj.getQuantity());//数量
|
|
|
+ materialInventoryObj.setQuantity(materialInventoryVo.getQuantity());//数量
|
|
|
+ materialInventoryObj.setCreateById(SecurityUtils.getUserId());
|
|
|
+ materialInventoryObj.setCreateTime(new Date());
|
|
|
count = materialInventoryService.insertMaterialInventory(materialInventoryObj);
|
|
|
}
|
|
|
- if(count>0){
|
|
|
- InboundRecords inboundRecords1=new InboundRecords();
|
|
|
+ if (count > 0) {
|
|
|
+ InboundRecords inboundRecords1 = new InboundRecords();
|
|
|
inboundRecords1.setInboundTime(new Date());//入库时间
|
|
|
//物料名称需要根据物料编码查询下
|
|
|
Materiel materiel = materielMapper.selectMaterielByMaterielCode(materialInventoryVo.getMaterialCode());
|
|
|
inboundRecords1.setInboundAterialsName(materiel.getMaterielName());//物料名称
|
|
|
inboundRecords1.setSpecifications(materialInventoryVo.getSpecifications());//规格代号
|
|
|
inboundRecords1.setInboundUnit(materialInventoryVo.getInboundUnit());//单位
|
|
|
- inboundRecords1.setInboundQuantity(materialInventoryVo.getQuantity());//入库数量
|
|
|
+ inboundRecords1.setInboundQuantity(materialInventoryVo.getQuantity().toString());//入库数量
|
|
|
inboundRecords1.setInboundLeader(SecurityUtils.getUsername());//仓管员
|
|
|
inboundRecords1.setCreateById(SecurityUtils.getUserId());//创建人
|
|
|
inboundRecords1.setCreateTime(new Date());//创建时间
|
|
|
+ inboundRecords1.setQtCodeNumber(materialInventoryVo.getQtCodeNumber());
|
|
|
inboundRecordsMapper.insertInboundRecords(inboundRecords1); //插入入库日志信息
|
|
|
- return AjaxResult.success("入库成功");
|
|
|
+ return AjaxResult.success("入库成功");
|
|
|
}
|
|
|
- return AjaxResult.success("入库失败");
|
|
|
+ return AjaxResult.error("入库失败");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -113,45 +109,45 @@ public class MaterialInventoryController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('system:inventory:add')")
|
|
|
@Log(title = "物料库存", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping("/inventory/deliveryFromStorage")
|
|
|
- @ApiOperation(value = "新增物料库存")
|
|
|
- public AjaxResult deliveryFromStorage(@RequestBody MaterialInventoryVo materialInventoryVo)
|
|
|
- {
|
|
|
+ @RequestMapping(value = "/deliveryFromStorage",method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "扫码出库")
|
|
|
+ public AjaxResult deliveryFromStorage(@RequestBody MaterialInventoryVo materialInventoryVo) {
|
|
|
//1、禁止重复入库
|
|
|
InboundRecords inboundRecords = inboundRecordsMapper.selectInboundRecordsByQtCodeNumber(materialInventoryVo.getQtCodeNumber());
|
|
|
- if(inboundRecords==null){
|
|
|
- return AjaxResult.success("此货品还没有入库,不能出库");
|
|
|
+ if (inboundRecords == null) {
|
|
|
+ return AjaxResult.error("此货品还没有入库,不能出库");
|
|
|
}
|
|
|
//2、是否重复入库
|
|
|
OutboundRecords outboundRecords = outboundRecordsMapper.selectOutboundRecordsByQtCodeNumber(materialInventoryVo.getQtCodeNumber());
|
|
|
- if(outboundRecords==null){
|
|
|
- return AjaxResult.success("此货品不能重复出库");
|
|
|
+ if (outboundRecords != null) {
|
|
|
+ return AjaxResult.success("此货品不能重复出库");
|
|
|
}
|
|
|
//3、根据物料编码跟规则查询库存信息
|
|
|
MaterialInventory materialInventory
|
|
|
= materialInventoryService.selectMaterialInventoryByMaterialCodeAndSpecifications(materialInventoryVo.getMaterialCode(), materialInventoryVo.getSpecifications());
|
|
|
//4、出库多少减去这个数量
|
|
|
- String quantityOld = materialInventory.getQuantity();
|
|
|
- String quantity = materialInventoryVo.getQuantity();
|
|
|
- Integer newQuantity=Integer.parseInt(quantityOld)-Integer.parseInt(quantity);
|
|
|
- materialInventory.setQuantity(String.valueOf(newQuantity));
|
|
|
+ Double quantityOld = materialInventory.getQuantity();
|
|
|
+ Double quantity = materialInventoryVo.getQuantity();
|
|
|
+ Double newQuantity =quantityOld-quantity;
|
|
|
+ materialInventory.setQuantity(newQuantity);
|
|
|
int count = materialInventoryService.updateMaterialInventory(materialInventory);
|
|
|
- if(count>0){
|
|
|
- OutboundRecords outboundRecords1=new OutboundRecords();
|
|
|
+ if (count > 0) {
|
|
|
+ OutboundRecords outboundRecords1 = new OutboundRecords();
|
|
|
outboundRecords1.setOutboundTime(new Date());//出库时间
|
|
|
//物料名称需要根据物料编码查询下
|
|
|
Materiel materiel = materielMapper.selectMaterielByMaterielCode(materialInventoryVo.getMaterialCode());
|
|
|
outboundRecords1.setOutboundAterialsName(materiel.getMaterielName());//物料名称
|
|
|
+ outboundRecords1.setOutboundNo(UUID.randomUUID().toString());//出库编号
|
|
|
outboundRecords1.setSpecifications(materialInventoryVo.getSpecifications());//规格代号
|
|
|
outboundRecords1.setOutboundUnit(materialInventoryVo.getInboundUnit());//单位
|
|
|
- outboundRecords1.setOutboundQuantity(materialInventoryVo.getQuantity());//出库数量
|
|
|
+ outboundRecords1.setOutboundQuantity(materialInventoryVo.getQuantity().toString());//出库数量
|
|
|
outboundRecords1.setOutboundLeader(SecurityUtils.getUsername());//仓管员
|
|
|
outboundRecords1.setCreateById(SecurityUtils.getUserId());//创建人
|
|
|
outboundRecords1.setCreateTime(new Date());//创建时间
|
|
|
outboundRecordsMapper.insertOutboundRecords(outboundRecords1); //插出库库日志信息
|
|
|
- return AjaxResult.success("出库成功");
|
|
|
+ return AjaxResult.success("出库成功");
|
|
|
}
|
|
|
- return AjaxResult.success("出库失败");
|
|
|
+ return AjaxResult.error("出库失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -161,8 +157,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@Log(title = "物料库存", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
@ApiOperation(value = "新增物料库存")
|
|
|
- public AjaxResult add(@RequestBody MaterialInventory materialInventory)
|
|
|
- {
|
|
|
+ public AjaxResult add(@RequestBody MaterialInventory materialInventory) {
|
|
|
return toAjax(materialInventoryService.insertMaterialInventory(materialInventory));
|
|
|
}
|
|
|
|
|
@@ -172,8 +167,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:inventory:list')")
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperation(value = "查询物料库存列表")
|
|
|
- public TableDataInfo list(MaterialInventory materialInventory)
|
|
|
- {
|
|
|
+ public TableDataInfo list(MaterialInventory materialInventory) {
|
|
|
startPage();
|
|
|
List<MaterialInventory> list = materialInventoryService.selectMaterialInventoryList(materialInventory);
|
|
|
return getDataTable(list);
|
|
@@ -186,8 +180,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@Log(title = "物料库存", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
|
@ApiOperation(value = "导出物料库存列表")
|
|
|
- public void export(HttpServletResponse response, MaterialInventory materialInventory)
|
|
|
- {
|
|
|
+ public void export(HttpServletResponse response, MaterialInventory materialInventory) {
|
|
|
List<MaterialInventory> list = materialInventoryService.selectMaterialInventoryList(materialInventory);
|
|
|
ExcelUtil<MaterialInventory> util = new ExcelUtil<MaterialInventory>(MaterialInventory.class);
|
|
|
util.exportExcel(response, list, "物料库存数据");
|
|
@@ -199,8 +192,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('system:inventory:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
|
@ApiOperation(value = "获取物料库存详细信息")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
- {
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
return success(materialInventoryService.selectMaterialInventoryById(id));
|
|
|
}
|
|
|
|
|
@@ -212,8 +204,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@Log(title = "物料库存", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
@ApiOperation(value = "修改物料库存")
|
|
|
- public AjaxResult edit(@RequestBody MaterialInventory materialInventory)
|
|
|
- {
|
|
|
+ public AjaxResult edit(@RequestBody MaterialInventory materialInventory) {
|
|
|
return toAjax(materialInventoryService.updateMaterialInventory(materialInventory));
|
|
|
}
|
|
|
|
|
@@ -224,8 +215,7 @@ public class MaterialInventoryController extends BaseController
|
|
|
@Log(title = "物料库存", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
@ApiOperation(value = "删除物料库存")
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
- {
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(materialInventoryService.deleteMaterialInventoryByIds(ids));
|
|
|
}
|
|
|
}
|