Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
0cf1b293
Commit
0cf1b293
authored
Jul 24, 2021
by
季圣华
Browse files
优化商品的多属性
parent
8fb8aecf
Changes
7
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/docs/jsh_erp.sql
View file @
0cf1b293
...
...
@@ -429,11 +429,11 @@ CREATE TABLE `jsh_material_attribute` (
-- ----------------------------
-- Records of jsh_material_attribute
-- ----------------------------
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'1'
,
'
c
olor'
,
'颜色'
,
'红色|橙色|黄色|绿色|蓝色|紫色'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'2'
,
'
s
ize'
,
'尺寸'
,
'S|M|L|XL|XXL|XXXL'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'3'
,
'
brand'
,
'品牌'
,
'品牌1|品牌2
'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'4'
,
'other
1
'
,
'自定义
1
'
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'5'
,
'other
2
'
,
'自定义
2
'
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'1'
,
'
manyC
olor'
,
'颜色'
,
'红色|橙色|黄色|绿色|蓝色|紫色'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'2'
,
'
manyS
ize'
,
'尺寸'
,
'S|M|L|XL|XXL|XXXL'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'3'
,
'
other1'
,
'自定义1'
,
'小米|华为
'
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'4'
,
'other
2
'
,
'自定义
2
'
,
null
,
'63'
,
'0'
);
INSERT
INTO
`jsh_material_attribute`
VALUES
(
'5'
,
'other
3
'
,
'自定义
3
'
,
null
,
'63'
,
'0'
);
-- ----------------------------
-- Table structure for jsh_material_category
...
...
jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt
View file @
0cf1b293
...
...
@@ -1143,11 +1143,11 @@ CREATE TABLE `jsh_material_attribute` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='产品属性';
INSERT INTO `jsh_material_attribute` VALUES ('1', '
c
olor', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('2', '
s
ize', '尺寸', 'S|M|L|XL|XXL|XXXL', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('3', '
brand', '品牌', '品牌1|品牌2
', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('4', 'other
1
', '自定义
1
', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('5', 'other
2
', '自定义
2
', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('1', '
manyC
olor', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('2', '
manyS
ize', '尺寸', 'S|M|L|XL|XXL|XXXL', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('3', '
other1', '自定义1', '小米|华为
', '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('4', 'other
2
', '自定义
2
', null, '63', '0');
INSERT INTO `jsh_material_attribute` VALUES ('5', 'other
3
', '自定义
3
', null, '63', '0');
-- --------------------------------------------------------
-- 时间 2021年7月22日
...
...
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialAttributeController.java
0 → 100644
View file @
0cf1b293
package
com.jsh.erp.controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.MaterialAttribute
;
import
com.jsh.erp.service.materialAttribute.MaterialAttributeService
;
import
com.jsh.erp.utils.BaseResponseInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
/**
* @author ji sheng hua jshERP
*/
@RestController
@RequestMapping
(
value
=
"/materialAttribute"
)
public
class
MaterialAttributeController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MaterialAttributeController
.
class
);
@Resource
private
MaterialAttributeService
materialAttributeService
;
@GetMapping
(
"/getAll"
)
public
BaseResponseInfo
getAll
(
HttpServletRequest
request
)
throws
Exception
{
BaseResponseInfo
res
=
new
BaseResponseInfo
();
try
{
JSONObject
obj
=
materialAttributeService
.
getAll
();
res
.
code
=
200
;
res
.
data
=
obj
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
res
.
code
=
500
;
res
.
data
=
"获取数据失败"
;
}
return
res
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java
View file @
0cf1b293
...
...
@@ -47,6 +47,7 @@ public class MaterialExtendController {
item
.
put
(
"id"
,
md
.
getId
());
item
.
put
(
"barCode"
,
md
.
getBarCode
());
item
.
put
(
"commodityUnit"
,
md
.
getCommodityUnit
());
item
.
put
(
"sku"
,
md
.
getSku
());
item
.
put
(
"purchaseDecimal"
,
md
.
getPurchaseDecimal
());
item
.
put
(
"commodityDecimal"
,
md
.
getCommodityDecimal
());
item
.
put
(
"wholesaleDecimal"
,
md
.
getWholesaleDecimal
());
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/materialAttribute/MaterialAttributeService.java
View file @
0cf1b293
package
com.jsh.erp.service.materialAttribute
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.constants.BusinessConstants
;
import
com.jsh.erp.datasource.entities.MaterialAttribute
;
...
...
@@ -9,6 +10,7 @@ import com.jsh.erp.datasource.mappers.MaterialAttributeMapperEx;
import
com.jsh.erp.exception.BusinessRunTimeException
;
import
com.jsh.erp.exception.JshException
;
import
com.jsh.erp.service.log.LogService
;
import
com.jsh.erp.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
...
...
@@ -58,13 +60,13 @@ public class MaterialAttributeService {
public
List
<
MaterialAttribute
>
select
(
String
attributeField
,
int
offset
,
int
rows
)
throws
Exception
{
String
[]
arr
=
{
"
c
olor"
,
"
s
ize"
,
"brand"
,
"other1"
,
"other2"
};
String
[]
arr
=
{
"
manyC
olor"
,
"
manyS
ize"
,
"other1"
,
"other2"
,
"other3"
};
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"color"
,
"颜色"
);
map
.
put
(
"size"
,
"尺寸"
);
map
.
put
(
"brand"
,
"品牌"
);
map
.
put
(
"manyColor"
,
"多颜色"
);
map
.
put
(
"manySize"
,
"多尺寸"
);
map
.
put
(
"other1"
,
"自定义1"
);
map
.
put
(
"other2"
,
"自定义2"
);
map
.
put
(
"other3"
,
"自定义3"
);
List
<
MaterialAttribute
>
list
=
new
ArrayList
<>();
try
{
List
<
MaterialAttribute
>
maList
=
materialAttributeMapperEx
.
selectByConditionMaterialAttribute
(
attributeField
,
offset
,
rows
);
...
...
@@ -161,4 +163,59 @@ public class MaterialAttributeService {
}
return
list
==
null
?
0
:
list
.
size
();
}
public
JSONObject
getAll
()
{
JSONObject
obj
=
new
JSONObject
();
//属性名
obj
.
put
(
"manyColorName"
,
getNameByField
(
"manyColor"
));
obj
.
put
(
"manySizeName"
,
getNameByField
(
"manySize"
));
obj
.
put
(
"other1Name"
,
getNameByField
(
"other1"
));
obj
.
put
(
"other2Name"
,
getNameByField
(
"other2"
));
obj
.
put
(
"other3Name"
,
getNameByField
(
"other3"
));
//属性值
obj
.
put
(
"manyColorValue"
,
getValueArrByField
(
"manyColor"
));
obj
.
put
(
"manySizeValue"
,
getValueArrByField
(
"manySize"
));
obj
.
put
(
"other1Value"
,
getValueArrByField
(
"other1"
));
obj
.
put
(
"other2Value"
,
getValueArrByField
(
"other2"
));
obj
.
put
(
"other3Value"
,
getValueArrByField
(
"other3"
));
return
obj
;
}
public
MaterialAttribute
getInfoByField
(
String
field
)
{
MaterialAttributeExample
example
=
new
MaterialAttributeExample
();
example
.
createCriteria
().
andAttributeFieldEqualTo
(
field
).
andDeleteFlagNotEqualTo
(
BusinessConstants
.
DELETE_FLAG_DELETED
);
List
<
MaterialAttribute
>
list
=
materialAttributeMapper
.
selectByExample
(
example
);
if
(
list
!=
null
&&
list
.
size
()>
0
)
{
return
list
.
get
(
0
);
}
else
{
return
null
;
}
}
public
String
getNameByField
(
String
field
)
{
MaterialAttribute
ma
=
getInfoByField
(
field
);
if
(
ma
!=
null
)
{
return
ma
.
getAttributeName
();
}
else
{
return
null
;
}
}
public
JSONArray
getValueArrByField
(
String
field
)
{
JSONArray
valueArr
=
new
JSONArray
();
MaterialAttribute
ma
=
getInfoByField
(
field
);
if
(
ma
!=
null
)
{
String
value
=
ma
.
getAttributeValue
();
if
(
StringUtil
.
isNotEmpty
(
value
)){
String
[]
arr
=
value
.
split
(
"\\|"
);
for
(
String
v:
arr
)
{
JSONObject
item
=
new
JSONObject
();
item
.
put
(
"value"
,
v
);
item
.
put
(
"name"
,
v
);
valueArr
.
add
(
item
);
}
}
}
return
valueArr
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java
View file @
0cf1b293
...
...
@@ -131,6 +131,9 @@ public class MaterialExtendService {
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"commodityUnit"
)))
{
materialExtend
.
setCommodityUnit
(
tempInsertedJson
.
getString
(
"commodityUnit"
));
}
if
(
tempInsertedJson
.
get
(
"sku"
)!=
null
)
{
materialExtend
.
setSku
(
tempInsertedJson
.
getString
(
"sku"
));
}
if
(
StringUtils
.
isNotEmpty
(
tempInsertedJson
.
getString
(
"purchaseDecimal"
)))
{
materialExtend
.
setPurchaseDecimal
(
tempInsertedJson
.
getBigDecimal
(
"purchaseDecimal"
));
}
...
...
jshERP-boot/src/main/resources/mapper_xml/MaterialExtendMapperEx.xml
View file @
0cf1b293
...
...
@@ -6,7 +6,7 @@
</resultMap>
<select
id=
"getDetailList"
parameterType=
"com.jsh.erp.datasource.entities.MaterialExtendExample"
resultMap=
"ResultMapList"
>
select DISTINCT d.Id,d.bar_code,d.commodity_unit,d.commodity_decimal,d.purchase_decimal,d.wholesale_decimal,d.low_decimal
select DISTINCT d.Id,d.bar_code,d.commodity_unit,d.
sku,d.
commodity_decimal,d.purchase_decimal,d.wholesale_decimal,d.low_decimal
from jsh_material_extend d
where d.material_id = #{materialId}
and ifnull(d.delete_Flag,'0') !='1'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment