完成物资库存模块

This commit is contained in:
zykzhangyukang 2020-04-16 13:37:04 +08:00
parent 921df0f8e3
commit e42ff8384d
27 changed files with 1474 additions and 481 deletions

View file

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Administrator">
<words>
<w>categorys</w>
</words>
</dictionary>
</component>

View file

@ -1,5 +0,0 @@
{
"code": -1,
"msg": "Required String parameter 'username' is not present",
"data": null
}

View file

@ -1,5 +0,0 @@
{
"code": -1,
"msg": "Required String parameter 'username' is not present",
"data": null
}

View file

@ -1,5 +0,0 @@
{
"code": -1,
"msg": "Required String parameter 'username' is not present",
"data": null
}

View file

@ -1,5 +0,0 @@
{
"code": 500,
"msg": "Required String parameter 'username' is not present",
"data": null
}

View file

@ -1,5 +0,0 @@
{
"code": -1,
"msg": "用户名必填",
"data": null
}

View file

@ -1,4 +0,0 @@
{
"code": 4001,
"msg": "无权访问(Unauthorized):无权访问(Unauthorized):请求头中没有token"
}

View file

@ -1,4 +0,0 @@
{
"code": 4001,
"msg": "Token无效您无权访问该接口"
}

View file

@ -1,4 +0,0 @@
{
"code": 4001,
"msg": " token失效请重新登入"
}

View file

@ -0,0 +1,5 @@
{
"code": -1,
"msg": "Required Integer parameter 'pageSize' is not present",
"data": null
}

View file

@ -0,0 +1,281 @@
{
"code": 200,
"msg": "成功",
"data": {
"total": 17,
"rows": [
{
"id": 17,
"name": "N95口罩",
"model": "10个/包",
"unit": "包",
"remark": "救命的口罩",
"sort": 1,
"createTime": "2020-03-18",
"modifiedTime": "2020-04-14",
"imageUrl": "group1/M00/00/00/rBofMl5yGl2AR3rCAAArOxrzeKs522.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 23,
"threeCategoryId": 25,
"pnum": "3DFC8EA0-6"
},
{
"id": 25,
"name": "防毒面具",
"model": "舒适版",
"unit": "个",
"remark": "防毒气的",
"sort": 1,
"createTime": "2020-03-18",
"modifiedTime": "2020-03-18",
"imageUrl": "group1/M00/00/00/rBofMl5yFiSAe6h2AADJ0MIVEUw374.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 23,
"threeCategoryId": 39,
"pnum": "2C15F1B6-1"
},
{
"id": 19,
"name": "普通温度计",
"model": "10只/盒",
"unit": "盒",
"remark": "温度计",
"sort": 2,
"createTime": "2020-03-18",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56zoiAJQ2HAAAhQYzsgJk572.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 21,
"threeCategoryId": 38,
"pnum": "6976D3B4-A"
},
{
"id": 21,
"name": "维生素葡萄糖",
"model": "100ml",
"unit": "瓶",
"remark": "葡萄糖",
"sort": 2,
"createTime": "2020-03-18",
"modifiedTime": "2020-04-14",
"imageUrl": "group1/M00/00/00/rBofMl56zmeAHjr4AACIeMDiX_A970.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 44,
"pnum": "52A0F5B9-5"
},
{
"id": 22,
"name": "小型救护车",
"model": "1吨",
"unit": "俩",
"remark": "车车",
"sort": 2,
"createTime": "2020-03-18",
"modifiedTime": "2020-04-14",
"imageUrl": "group1/M00/00/00/rBofMl5yF2iAWR7iAABOJPxrrMQ785.jpg",
"categoryKeys": null,
"oneCategoryId": 33,
"twoCategoryId": 34,
"threeCategoryId": 35,
"pnum": "967CE098-3"
},
{
"id": 28,
"name": "霸王洗发水",
"model": "10ml",
"unit": "瓶",
"remark": "洗发水挺好的",
"sort": 7,
"createTime": "2020-03-20",
"modifiedTime": "2020-03-20",
"imageUrl": "group1/M00/00/00/rBofMl50e76AYzVtAAB6dwE5XLI650.jpg",
"categoryKeys": null,
"oneCategoryId": 24,
"twoCategoryId": 31,
"threeCategoryId": 52,
"pnum": "894b8218-36ee-4a0d-9ad1-d9c5e455"
},
{
"id": 29,
"name": "卫龙辣条",
"model": "大包",
"unit": "包",
"remark": "好吃",
"sort": 4,
"createTime": "2020-03-21",
"modifiedTime": "2020-03-21",
"imageUrl": "group1/M00/00/00/rBofMl52BQKAB9scAAA8bqb6l5k008.jpg",
"categoryKeys": null,
"oneCategoryId": 24,
"twoCategoryId": 30,
"threeCategoryId": 41,
"pnum": "0b9e9176-f996-4384-bb6c-209f55d0"
},
{
"id": 20,
"name": "生理盐水",
"model": "500ml",
"unit": "瓶",
"remark": "生理盐水",
"sort": 3,
"createTime": "2020-03-18",
"modifiedTime": "2020-03-18",
"imageUrl": "group1/M00/00/00/rBofMl5yCqmAZi_8AABSkMEsmEI099.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 44,
"pnum": "AB0E206E-A"
},
{
"id": 23,
"name": "东北大米",
"model": "1斤/袋",
"unit": "袋",
"remark": "老鼠爱大米",
"sort": 4,
"createTime": "2020-03-18",
"modifiedTime": "2020-03-18",
"imageUrl": "group1/M00/00/00/rBofMl5yDA-AQd0QAAAKYAyjupw156.png",
"categoryKeys": null,
"oneCategoryId": 24,
"twoCategoryId": 30,
"threeCategoryId": 41,
"pnum": "6AF405A1-C"
},
{
"id": 18,
"name": "普通医用口罩",
"model": "5个/包",
"unit": "包",
"remark": "医用口罩也不错哦",
"sort": 3,
"createTime": "2020-03-18",
"modifiedTime": "2020-03-18",
"imageUrl": "group1/M00/00/00/rBofMl5yCTGAC-nZAAA5bqFUaK8834.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 23,
"threeCategoryId": 25,
"pnum": "6EF5F2C0-9"
},
{
"id": 31,
"name": "碘伏",
"model": "500ml",
"unit": "瓶",
"remark": "碘伏",
"sort": 3,
"createTime": "2020-03-22",
"modifiedTime": "2020-03-22",
"imageUrl": "group1/M00/00/00/rBofMl523RqAa7kpAABX9NSDgIo799.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 57,
"pnum": "c98183c8-bc47-4505-abbb-1dc219b5"
},
{
"id": 30,
"name": "医用酒精",
"model": "100ml/75%",
"unit": "瓶",
"remark": "100ml/75%",
"sort": 3,
"createTime": "2020-03-22",
"modifiedTime": "2020-03-22",
"imageUrl": "group1/M00/00/00/rBofMl522Z6AN_RSAACJQ9cHSCk392.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 57,
"pnum": "24573d5b-0c9b-403b-9a88-c214702e"
},
{
"id": 34,
"name": "帅气男装",
"model": "175cm",
"unit": "件",
"remark": "帅气男装",
"sort": 2,
"createTime": "2020-03-25",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56yieAIrPAAAE3074vL7M795.jpg",
"categoryKeys": null,
"oneCategoryId": 24,
"twoCategoryId": 27,
"threeCategoryId": 40,
"pnum": "beb944c4-01ae-497b-bfdd-2132032f"
},
{
"id": 36,
"name": "金龙鱼油",
"model": "500ml",
"unit": "瓶",
"remark": "金龙鱼油",
"sort": 2,
"createTime": "2020-03-25",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56zJGAC4cQAABF43OLKH8842.jpg",
"categoryKeys": null,
"oneCategoryId": 24,
"twoCategoryId": 30,
"threeCategoryId": 62,
"pnum": "c49aecca-12ec-4263-834a-f5a01d46"
},
{
"id": 37,
"name": "脑白金",
"model": "600ml",
"unit": "包",
"remark": "脑白金",
"sort": 2,
"createTime": "2020-03-25",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56zOCATfJ_AABZdj80IoY642.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 44,
"pnum": "cf5a5f37-b299-4d96-bcb2-c4a46737"
},
{
"id": 40,
"name": "康师傅矿泉水",
"model": "10瓶/箱",
"unit": "箱",
"remark": "矿泉水",
"sort": 2,
"createTime": "2020-03-25",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56zbyANBJlAAB2gMoSEvw394.jpg",
"categoryKeys": null,
"oneCategoryId": 59,
"twoCategoryId": 60,
"threeCategoryId": 61,
"pnum": "0e17f606-9aaa-48a7-b4e9-ef18462e"
},
{
"id": 39,
"name": "感冒康胶囊",
"model": "10片/包",
"unit": "包",
"remark": "感冒康胶囊",
"sort": 3,
"createTime": "2020-03-25",
"modifiedTime": "2020-03-25",
"imageUrl": "group1/M00/00/00/rBofMl56zXKAf32OAADXvzUKR90347.jpg",
"categoryKeys": null,
"oneCategoryId": 20,
"twoCategoryId": 43,
"threeCategoryId": 53,
"pnum": "de16b9e6-bb49-4547-ab91-db7ae7b6"
}
]
}
}

View file

@ -0,0 +1,49 @@
{
"code": 200,
"msg": "成功",
"data": {
"total": 17,
"rows": [
{
"name": "N95口罩",
"model": "10个/包",
"unit": "包",
"remark": "救命的口罩",
"stock": 130,
"pnum": "3DFC8EA0-6"
},
{
"name": "防毒面具",
"model": "舒适版",
"unit": "个",
"remark": "防毒气的",
"stock": 258,
"pnum": "2C15F1B6-1"
},
{
"name": "普通温度计",
"model": "10只/盒",
"unit": "盒",
"remark": "温度计",
"stock": 526,
"pnum": "6976D3B4-A"
},
{
"name": "维生素葡萄糖",
"model": "100ml",
"unit": "瓶",
"remark": "葡萄糖",
"stock": 257,
"pnum": "52A0F5B9-5"
},
{
"name": "小型救护车",
"model": "1吨",
"unit": "俩",
"remark": "车车",
"stock": 126,
"pnum": "967CE098-3"
}
]
}
}

View file

@ -0,0 +1,54 @@
{
"code": 200,
"msg": "成功",
"data": {
"total": 17,
"rows": [
{
"name": "N95口罩",
"model": "10个/包",
"unit": "包",
"remark": "救命的口罩",
"stock": 130,
"percentage": 7,
"pnum": "3DFC8EA0-6"
},
{
"name": "防毒面具",
"model": "舒适版",
"unit": "个",
"remark": "防毒气的",
"stock": 258,
"percentage": 15,
"pnum": "2C15F1B6-1"
},
{
"name": "普通温度计",
"model": "10只/盒",
"unit": "盒",
"remark": "温度计",
"stock": 526,
"percentage": 30,
"pnum": "6976D3B4-A"
},
{
"name": "维生素葡萄糖",
"model": "100ml",
"unit": "瓶",
"remark": "葡萄糖",
"stock": 257,
"percentage": 15,
"pnum": "52A0F5B9-5"
},
{
"name": "小型救护车",
"model": "1吨",
"unit": "俩",
"remark": "车车",
"stock": 126,
"percentage": 7,
"pnum": "967CE098-3"
}
]
}
}

View file

@ -0,0 +1,54 @@
{
"code": 200,
"msg": "成功",
"data": {
"total": 17,
"rows": [
{
"name": "N95口罩",
"model": "10个/包",
"unit": "包",
"remark": "救命的口罩",
"stock": 130,
"percentage": null,
"pnum": "3DFC8EA0-6"
},
{
"name": "防毒面具",
"model": "舒适版",
"unit": "个",
"remark": "防毒气的",
"stock": 258,
"percentage": null,
"pnum": "2C15F1B6-1"
},
{
"name": "普通温度计",
"model": "10只/盒",
"unit": "盒",
"remark": "温度计",
"stock": 526,
"percentage": null,
"pnum": "6976D3B4-A"
},
{
"name": "维生素葡萄糖",
"model": "100ml",
"unit": "瓶",
"remark": "葡萄糖",
"stock": 257,
"percentage": null,
"pnum": "52A0F5B9-5"
},
{
"name": "小型救护车",
"model": "1吨",
"unit": "俩",
"remark": "车车",
"stock": 126,
"percentage": null,
"pnum": "967CE098-3"
}
]
}
}

View file

@ -0,0 +1,90 @@
{
"code": 200,
"msg": "成功",
"data": {
"total": 17,
"rows": [
{
"name": "N95口罩",
"model": "10个/包",
"unit": "包",
"remark": "救命的口罩",
"stock": 130,
"percentage": null,
"pnum": "3DFC8EA0-6"
},
{
"name": "防毒面具",
"model": "舒适版",
"unit": "个",
"remark": "防毒气的",
"stock": 258,
"percentage": null,
"pnum": "2C15F1B6-1"
},
{
"name": "普通温度计",
"model": "10只/盒",
"unit": "盒",
"remark": "温度计",
"stock": 526,
"percentage": null,
"pnum": "6976D3B4-A"
},
{
"name": "维生素葡萄糖",
"model": "100ml",
"unit": "瓶",
"remark": "葡萄糖",
"stock": 257,
"percentage": null,
"pnum": "52A0F5B9-5"
},
{
"name": "小型救护车",
"model": "1吨",
"unit": "俩",
"remark": "车车",
"stock": 126,
"percentage": null,
"pnum": "967CE098-3"
},
{
"name": "霸王洗发水",
"model": "10ml",
"unit": "瓶",
"remark": "洗发水挺好的",
"stock": 50,
"percentage": null,
"pnum": "894b8218-36ee-4a0d-9ad1-d9c5e455"
},
{
"name": "卫龙辣条",
"model": "大包",
"unit": "包",
"remark": "好吃",
"stock": 15,
"percentage": null,
"pnum": "0b9e9176-f996-4384-bb6c-209f55d0"
},
{
"name": "生理盐水",
"model": "500ml",
"unit": "瓶",
"remark": "生理盐水",
"stock": 4,
"percentage": null,
"pnum": "AB0E206E-A"
},
{
"name": "东北大米",
"model": "1斤/袋",
"unit": "袋",
"remark": "老鼠爱大米",
"stock": 10,
"percentage": null,
"pnum": "6AF405A1-C"
}
]
}
}

View file

@ -0,0 +1,4 @@
{
"code": 4001,
"msg": " token过期请重新登入"
}

View file

@ -1,3 +1,73 @@
GET http://localhost:8081/product/findProductStocks?pageSize=9
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMTE1NjYsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.axsuPWwv4YAEqTPfobtUZqm1ngnN6VVrIZ-NGGGqtm4
###
GET http://localhost:8081/product/findProductStocks?pageSize=9
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T115818.200.json
###
GET http://localhost:8081/product/findProductStocks?pageSize=9
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T094602.200.json
###
GET http://localhost:8081/product/findProductStocks?pageSize=5
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T094554.200.json
###
GET http://localhost:8081/product/findProductStocks?pageSize=5
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T094409.200.json
###
GET http://localhost:8081/product/findProductStocks?pageSize=5
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T094041.200.json
###
GET http://localhost:8081/product/findProductStocks?pageSize=5
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T090818.200.json
###
GET http://localhost:8081/product/findProductStocks?username=zhangyukang
Accept: */*
Cache-Control: no-cache
Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1ODcwMDQyNDIsInVzZXJuYW1lIjoiemhhbmd5dWthbmcifQ.1OJc5Y7LwYRLeayA_O7_ilLKXaLvptyzqCg8bs_MEAI
<> 2020-04-16T090800.200.json
###
POST http://localhost:8081/user/login?username=zhangyukang
Accept: */*
Cache-Control: no-cache
@ -362,68 +432,3 @@ Authorization: fdasfdasf
###
POS http://localhost:8081/user/add?password=123456
Accept: */*
Cache-Control: no-cache
Authorization: fdasfdasf
<> 2020-03-27T093035.401.json
###
POS http://localhost:8081/user/log?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092840.401.json
###
POST http://localhost:8081/user/log?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092618.401.json
###
POST http://localhost:8081/user/login?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092543.200.json
###
POST http://localhost:8081/user/login?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092322.200.json
###
POST http://localhost:8081/user/login?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092226.200.json
###
POST http://localhost:8081/user/login?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T092224.200.json
###
POST http://localhost:8081/user/login?password=123456
Accept: */*
Cache-Control: no-cache
<> 2020-03-27T091912.200.json
###

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
package com.coderman.api.biz.controller;
import com.coderman.api.biz.service.ProductService;
import com.coderman.api.biz.vo.ProductStockVO;
import com.coderman.api.biz.vo.ProductVO;
import com.coderman.api.system.bean.ResponseBean;
import com.coderman.api.system.vo.PageVO;
@ -11,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author zhangyukang
* @Date 2020/3/17 09:19
@ -36,6 +39,47 @@ public class ProductController {
@RequestParam(value = "pageSize") Integer pageSize,
@RequestParam(value = "categorys", required = false) String categorys,
ProductVO productVO) {
buildCategorySearch(categorys, productVO);
PageVO<ProductVO> productVOPageVO = productService.findProductList(pageNum, pageSize, productVO);
return ResponseBean.success(productVOPageVO);
}
/**
* 库存列表
*
* @return
*/
@ApiOperation(value = "库存列表", notes = "物资列表,根据物资名模糊查询")
@GetMapping("/findProductStocks")
public ResponseBean findProductStocks(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize") Integer pageSize,
@RequestParam(value = "categorys", required = false) String categorys,
ProductVO productVO) {
buildCategorySearch(categorys, productVO);
PageVO<ProductStockVO> productVOPageVO = productService.findProductStocks(pageNum, pageSize, productVO);
return ResponseBean.success(productVOPageVO);
}
/**
* 所有库存
*
* @return
*/
@ApiOperation(value = "所有库存", notes = "物资所有库存信息")
@GetMapping("/findAllStocks")
public ResponseBean findAllStocks() {
List<ProductStockVO> list = productService.findAllStocks();
return ResponseBean.success(list);
}
/**
* 封装物资查询条件
* @param categorys
* @param productVO
*/
private void buildCategorySearch(@RequestParam(value = "categorys", required = false) String categorys, ProductVO productVO) {
if (categorys != null && !"".equals(categorys)) {
String[] split = categorys.split(",");
switch (split.length) {
@ -53,8 +97,6 @@ public class ProductController {
break;
}
}
PageVO<ProductVO> productVOPageVO = productService.findProductList(pageNum, pageSize, productVO);
return ResponseBean.success(productVOPageVO);
}

View file

@ -2,13 +2,11 @@ package com.coderman.api.biz.converter;
import com.coderman.api.biz.mapper.ProductStockMapper;
import com.coderman.api.biz.pojo.Product;
import com.coderman.api.biz.pojo.ProductStock;
import com.coderman.api.biz.vo.ProductVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;
import java.util.ArrayList;
import java.util.List;
@ -18,30 +16,19 @@ import java.util.List;
* @Date 2020/3/17 09:22
* @Version 1.0
**/
@Component
public class ProductConverter {
@Autowired
private ProductStockMapper productStockMapper;
/**
* 转VOList
* @param products
* @return
*/
public List<ProductVO> converterToVOList(List<Product> products) {
public static List<ProductVO> converterToVOList(List<Product> products) {
List<ProductVO> productVOS=new ArrayList<>();
if(!CollectionUtils.isEmpty(products)){
for (Product product : products) {
ProductVO productVO = converterToProductVO(product);
//设置库存信息
Example o = new Example(ProductStock.class);
o.createCriteria().andEqualTo("pNum",product.getPNum());
List<ProductStock> productStocks = productStockMapper.selectByExample(o);
if(!CollectionUtils.isEmpty(productStocks)){
ProductStock productStock = productStocks.get(0);
productVO.setStock(productStock.getStock());
}
productVOS.add(productVO);
}
}
@ -53,7 +40,7 @@ public class ProductConverter {
* @param product
* @return
*/
public ProductVO converterToProductVO(Product product) {
public static ProductVO converterToProductVO(Product product) {
ProductVO productVO = new ProductVO();
BeanUtils.copyProperties(product,productVO);
return productVO;

View file

@ -1,12 +1,29 @@
package com.coderman.api.biz.mapper;
import com.coderman.api.biz.pojo.ProductStock;
import com.coderman.api.biz.vo.ProductStockVO;
import com.coderman.api.biz.vo.ProductVO;
import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/**
* @Author zhangyukang
* @Date 2020/3/21 19:38
* @Version 1.0
**/
public interface ProductStockMapper extends Mapper<ProductStock> {
/**
* 库存列表
* @param productVO
* @return
*/
List<ProductStockVO> selectProductStockList(ProductVO productVO);
/**
* 所有库存信息
* @return
*/
List<ProductStockVO> findAllStocks();
}

View file

@ -1,8 +1,11 @@
package com.coderman.api.biz.service;
import com.coderman.api.biz.vo.ProductStockVO;
import com.coderman.api.biz.vo.ProductVO;
import com.coderman.api.system.vo.PageVO;
import java.util.List;
/**
* @Author zhangyukang
* @Date 2020/3/16 17:18
@ -46,4 +49,20 @@ public interface ProductService {
* @param id
*/
void delete(Long id);
/**
* 库存列表
* @param pageNum
* @param pageSize
* @param productVO
* @return
*/
PageVO<ProductStockVO> findProductStocks(Integer pageNum, Integer pageSize, ProductVO productVO);
/**
* 所有库存信息
* @return
*/
List<ProductStockVO> findAllStocks();
}

View file

@ -2,8 +2,11 @@ package com.coderman.api.biz.service.imp;
import com.coderman.api.biz.converter.ProductConverter;
import com.coderman.api.biz.mapper.ProductMapper;
import com.coderman.api.biz.mapper.ProductStockMapper;
import com.coderman.api.biz.pojo.Product;
import com.coderman.api.biz.pojo.ProductStock;
import com.coderman.api.biz.service.ProductService;
import com.coderman.api.biz.vo.ProductStockVO;
import com.coderman.api.biz.vo.ProductVO;
import com.coderman.api.system.vo.PageVO;
import com.github.pagehelper.PageHelper;
@ -11,6 +14,7 @@ import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;
import javax.validation.constraints.NotNull;
@ -31,8 +35,11 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private ProductMapper productMapper;
@Autowired
private ProductConverter productConverter;
private ProductStockMapper productStockMapper;
/**
* 商品列表
@ -56,7 +63,7 @@ public class ProductServiceImpl implements ProductService {
.andEqualTo("twoCategoryId",productVO.getTwoCategoryId())
.andEqualTo("threeCategoryId",productVO.getThreeCategoryId());
products = productMapper.selectByExample(o);
List<ProductVO> categoryVOS=productConverter.converterToVOList(products);
List<ProductVO> categoryVOS= ProductConverter.converterToVOList(products);
PageInfo<Product> info = new PageInfo<>(products);
return new PageVO<>(info.getTotal(), categoryVOS);
}
@ -64,19 +71,19 @@ public class ProductServiceImpl implements ProductService {
o.createCriteria().andEqualTo("oneCategoryId",productVO.getOneCategoryId())
.andEqualTo("twoCategoryId",productVO.getTwoCategoryId());
products = productMapper.selectByExample(o);
List<ProductVO> categoryVOS=productConverter.converterToVOList(products);
List<ProductVO> categoryVOS=ProductConverter.converterToVOList(products);
PageInfo<Product> info = new PageInfo<>(products);
return new PageVO<>(info.getTotal(), categoryVOS);
}
if(productVO.getOneCategoryId()!=null){
o.createCriteria().andEqualTo("oneCategoryId",productVO.getOneCategoryId());
products = productMapper.selectByExample(o);
List<ProductVO> categoryVOS=productConverter.converterToVOList(products);
List<ProductVO> categoryVOS=ProductConverter.converterToVOList(products);
PageInfo<Product> info = new PageInfo<>(products);
return new PageVO<>(info.getTotal(), categoryVOS);
}
products = productMapper.selectByExample(o);
List<ProductVO> categoryVOS=productConverter.converterToVOList(products);
List<ProductVO> categoryVOS=ProductConverter.converterToVOList(products);
PageInfo<Product> info = new PageInfo<>(products);
return new PageVO<>(info.getTotal(), categoryVOS);
}
@ -111,8 +118,7 @@ public class ProductServiceImpl implements ProductService {
@Override
public ProductVO edit(Long id) {
Product product = productMapper.selectByPrimaryKey(id);
ProductVO productVO = productConverter.converterToProductVO(product);
return productVO;
return ProductConverter.converterToProductVO(product);
}
/**
@ -143,4 +149,28 @@ public class ProductServiceImpl implements ProductService {
productMapper.deleteByPrimaryKey(id);
}
/**
* 物资库存列表
* @param pageNum
* @param pageSize
* @param productVO
* @return
*/
@Override
public PageVO<ProductStockVO> findProductStocks(Integer pageNum, Integer pageSize, ProductVO productVO) {
PageHelper.startPage(pageNum, pageSize);
List<ProductStockVO> productStockVOList=productStockMapper.selectProductStockList(productVO);
PageInfo<ProductStockVO> info = new PageInfo<>(productStockVOList);
return new PageVO<>(info.getTotal(), productStockVOList);
}
/**
* 所有库存信息
* @return
*/
@Override
public List<ProductStockVO> findAllStocks() {
return productStockMapper.findAllStocks();
}
}

View file

@ -0,0 +1,24 @@
package com.coderman.api.biz.vo;
import lombok.Data;
/** 商品库存
* @Author zhangyukang
* @Date 2020/4/16 09:27
* @Version 1.0
**/
@Data
public class ProductStockVO {
private String name;
private String pNum;
private String model;
private String unit;
private String remark;
private Long stock;
}

View file

@ -52,6 +52,4 @@ public class ProductVO {
private Long threeCategoryId;
//商品库存
private Long stock=0L;
}

View file

@ -26,6 +26,6 @@ spring:
url-pattern: /druid/*
mybatis:
mapper-locations: classpath:mapper/*Mapper.xml
mapper-locations: classpath:mapper/*/*Mapper.xml
type-aliases-package: com.coderman.api.*.pojo

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.coderman.api.biz.mapper.ProductStockMapper">
<!--库存列表-->
<select id="selectProductStockList" parameterType="com.coderman.api.biz.vo.ProductVO"
resultType="com.coderman.api.biz.vo.ProductStockVO">
SELECT s.id,s.p_num,s.stock ,p.name,
p.model,p.unit
FROM biz_product_stock s
, biz_product p WHERE s.`p_num`=p.`p_num`
<if test="name!=null and name!=''">
and p.name like concat('%',#{name}, '%')
</if>
</select>
<!--所有库存信息-->
<select id="findAllStocks"
resultType="com.coderman.api.biz.vo.ProductStockVO">
SELECT s.id,s.p_num,s.stock ,p.name,
p.model,p.unit
FROM biz_product_stock s
, biz_product p WHERE s.`p_num`=p.`p_num`
</select>
</mapper>