diff --git a/jshERP-boot/docs/jsh_erp.sql b/jshERP-boot/docs/jsh_erp.sql index 66616035..175ff417 100644 --- a/jshERP-boot/docs/jsh_erp.sql +++ b/jshERP-boot/docs/jsh_erp.sql @@ -429,11 +429,11 @@ CREATE TABLE `jsh_material_attribute` ( -- ---------------------------- -- Records of jsh_material_attribute -- ---------------------------- -INSERT INTO `jsh_material_attribute` VALUES ('1', 'color', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0'); -INSERT INTO `jsh_material_attribute` VALUES ('2', 'size', '尺寸', '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', 'other1', '自定义1', null, '63', '0'); -INSERT INTO `jsh_material_attribute` VALUES ('5', 'other2', '自定义2', null, '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('1', 'manyColor', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('2', 'manySize', '尺寸', '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', 'other2', '自定义2', null, '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('5', 'other3', '自定义3', null, '63', '0'); -- ---------------------------- -- Table structure for jsh_material_category diff --git a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt index b3870604..1679ef83 100644 --- a/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt +++ b/jshERP-boot/docs/数据库更新记录-首次安装请勿使用.txt @@ -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', 'color', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0'); -INSERT INTO `jsh_material_attribute` VALUES ('2', 'size', '尺寸', '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', 'other1', '自定义1', null, '63', '0'); -INSERT INTO `jsh_material_attribute` VALUES ('5', 'other2', '自定义2', null, '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('1', 'manyColor', '颜色', '红色|橙色|黄色|绿色|蓝色|紫色', '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('2', 'manySize', '尺寸', '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', 'other2', '自定义2', null, '63', '0'); +INSERT INTO `jsh_material_attribute` VALUES ('5', 'other3', '自定义3', null, '63', '0'); -- -------------------------------------------------------- -- 时间 2021年7月22日 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialAttributeController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialAttributeController.java new file mode 100644 index 00000000..a36d2b05 --- /dev/null +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialAttributeController.java @@ -0,0 +1,43 @@ +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; + } +} diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java index 6c381955..496ca834 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java @@ -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()); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/materialAttribute/MaterialAttributeService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/materialAttribute/MaterialAttributeService.java index 4b9f93d7..253aa957 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/materialAttribute/MaterialAttributeService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/materialAttribute/MaterialAttributeService.java @@ -1,5 +1,6 @@ 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 select(String attributeField, int offset, int rows) throws Exception{ - String[] arr = {"color","size","brand","other1","other2"}; + String[] arr = {"manyColor","manySize","other1","other2","other3"}; Map 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 list = new ArrayList<>(); try{ List 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 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; + } } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java index 1559e4a1..4b5aa80c 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/materialExtend/MaterialExtendService.java @@ -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")); } diff --git a/jshERP-boot/src/main/resources/mapper_xml/MaterialExtendMapperEx.xml b/jshERP-boot/src/main/resources/mapper_xml/MaterialExtendMapperEx.xml index 76de1635..60d623df 100644 --- a/jshERP-boot/src/main/resources/mapper_xml/MaterialExtendMapperEx.xml +++ b/jshERP-boot/src/main/resources/mapper_xml/MaterialExtendMapperEx.xml @@ -6,7 +6,7 @@