赵冬冬 4 роки тому
батько
коміт
00aecf2372

+ 51 - 0
forest-admin/admin-mbg/src/main/java/com/hwrj/cloud/admin/model/PmsBrand.java

@@ -2,6 +2,7 @@ package com.hwrj.cloud.admin.model;
 
 import io.swagger.annotations.ApiModelProperty;
 import java.io.Serializable;
+import java.util.Date;
 
 public class PmsBrand implements Serializable {
     private Long id;
@@ -11,11 +12,13 @@ public class PmsBrand implements Serializable {
     @ApiModelProperty(value = "首字母")
     private String firstLetter;
 
+    @ApiModelProperty(value = "排序")
     private Integer sort;
 
     @ApiModelProperty(value = "是否为品牌制造商:0->不是;1->是")
     private Integer factoryStatus;
 
+    @ApiModelProperty(value = "是否显示 0 不显示 1 显示")
     private Integer showStatus;
 
     @ApiModelProperty(value = "产品数量")
@@ -30,6 +33,18 @@ public class PmsBrand implements Serializable {
     @ApiModelProperty(value = "专区大图")
     private String bigPic;
 
+    @ApiModelProperty(value = "创建人")
+    private Long createId;
+
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    @ApiModelProperty(value = "更新人")
+    private Long updateId;
+
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
     @ApiModelProperty(value = "品牌故事")
     private String brandStory;
 
@@ -115,6 +130,38 @@ public class PmsBrand implements Serializable {
         this.bigPic = bigPic;
     }
 
+    public Long getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(Long createId) {
+        this.createId = createId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Long getUpdateId() {
+        return updateId;
+    }
+
+    public void setUpdateId(Long updateId) {
+        this.updateId = updateId;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
     public String getBrandStory() {
         return brandStory;
     }
@@ -139,6 +186,10 @@ public class PmsBrand implements Serializable {
         sb.append(", productCommentCount=").append(productCommentCount);
         sb.append(", logo=").append(logo);
         sb.append(", bigPic=").append(bigPic);
+        sb.append(", createId=").append(createId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateId=").append(updateId);
+        sb.append(", updateTime=").append(updateTime);
         sb.append(", brandStory=").append(brandStory);
         sb.append(", serialVersionUID=").append(serialVersionUID);
         sb.append("]");

+ 241 - 0
forest-admin/admin-mbg/src/main/java/com/hwrj/cloud/admin/model/PmsBrandExample.java

@@ -1,6 +1,7 @@
 package com.hwrj.cloud.admin.model;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 public class PmsBrandExample {
@@ -743,6 +744,246 @@ public class PmsBrandExample {
             addCriterion("big_pic not between", value1, value2, "bigPic");
             return (Criteria) this;
         }
+
+        public Criteria andCreateIdIsNull() {
+            addCriterion("create_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdIsNotNull() {
+            addCriterion("create_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdEqualTo(Long value) {
+            addCriterion("create_id =", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdNotEqualTo(Long value) {
+            addCriterion("create_id <>", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdGreaterThan(Long value) {
+            addCriterion("create_id >", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("create_id >=", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdLessThan(Long value) {
+            addCriterion("create_id <", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdLessThanOrEqualTo(Long value) {
+            addCriterion("create_id <=", value, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdIn(List<Long> values) {
+            addCriterion("create_id in", values, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdNotIn(List<Long> values) {
+            addCriterion("create_id not in", values, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdBetween(Long value1, Long value2) {
+            addCriterion("create_id between", value1, value2, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateIdNotBetween(Long value1, Long value2) {
+            addCriterion("create_id not between", value1, value2, "createId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdIsNull() {
+            addCriterion("update_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdIsNotNull() {
+            addCriterion("update_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdEqualTo(Long value) {
+            addCriterion("update_id =", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdNotEqualTo(Long value) {
+            addCriterion("update_id <>", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdGreaterThan(Long value) {
+            addCriterion("update_id >", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("update_id >=", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdLessThan(Long value) {
+            addCriterion("update_id <", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdLessThanOrEqualTo(Long value) {
+            addCriterion("update_id <=", value, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdIn(List<Long> values) {
+            addCriterion("update_id in", values, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdNotIn(List<Long> values) {
+            addCriterion("update_id not in", values, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdBetween(Long value1, Long value2) {
+            addCriterion("update_id between", value1, value2, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateIdNotBetween(Long value1, Long value2) {
+            addCriterion("update_id not between", value1, value2, "updateId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
     }
 
     public static class Criteria extends GeneratedCriteria {

+ 75 - 5
forest-admin/admin-mbg/src/main/resources/com/hwrj/cloud/admin/mapper/PmsBrandMapper.xml

@@ -12,6 +12,10 @@
     <result column="product_comment_count" jdbcType="INTEGER" property="productCommentCount" />
     <result column="logo" jdbcType="VARCHAR" property="logo" />
     <result column="big_pic" jdbcType="VARCHAR" property="bigPic" />
+    <result column="create_id" jdbcType="BIGINT" property="createId" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_id" jdbcType="BIGINT" property="updateId" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
   <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.hwrj.cloud.admin.model.PmsBrand">
     <result column="brand_story" jdbcType="LONGVARCHAR" property="brandStory" />
@@ -76,7 +80,7 @@
   </sql>
   <sql id="Base_Column_List">
     id, name, first_letter, sort, factory_status, show_status, product_count, product_comment_count, 
-    logo, big_pic
+    logo, big_pic, create_id, create_time, update_id, update_time
   </sql>
   <sql id="Blob_Column_List">
     brand_story
@@ -136,11 +140,13 @@
     insert into pms_brand (name, first_letter, sort, 
       factory_status, show_status, product_count, 
       product_comment_count, logo, big_pic, 
-      brand_story)
+      create_id, create_time, update_id, 
+      update_time, brand_story)
     values (#{name,jdbcType=VARCHAR}, #{firstLetter,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, 
       #{factoryStatus,jdbcType=INTEGER}, #{showStatus,jdbcType=INTEGER}, #{productCount,jdbcType=INTEGER}, 
       #{productCommentCount,jdbcType=INTEGER}, #{logo,jdbcType=VARCHAR}, #{bigPic,jdbcType=VARCHAR}, 
-      #{brandStory,jdbcType=LONGVARCHAR})
+      #{createId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateId,jdbcType=BIGINT}, 
+      #{updateTime,jdbcType=TIMESTAMP}, #{brandStory,jdbcType=LONGVARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.hwrj.cloud.admin.model.PmsBrand">
     <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@@ -175,6 +181,18 @@
       <if test="bigPic != null">
         big_pic,
       </if>
+      <if test="createId != null">
+        create_id,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateId != null">
+        update_id,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
       <if test="brandStory != null">
         brand_story,
       </if>
@@ -207,6 +225,18 @@
       <if test="bigPic != null">
         #{bigPic,jdbcType=VARCHAR},
       </if>
+      <if test="createId != null">
+        #{createId,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateId != null">
+        #{updateId,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="brandStory != null">
         #{brandStory,jdbcType=LONGVARCHAR},
       </if>
@@ -251,6 +281,18 @@
       <if test="record.bigPic != null">
         big_pic = #{record.bigPic,jdbcType=VARCHAR},
       </if>
+      <if test="record.createId != null">
+        create_id = #{record.createId,jdbcType=BIGINT},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateId != null">
+        update_id = #{record.updateId,jdbcType=BIGINT},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="record.brandStory != null">
         brand_story = #{record.brandStory,jdbcType=LONGVARCHAR},
       </if>
@@ -271,6 +313,10 @@
       product_comment_count = #{record.productCommentCount,jdbcType=INTEGER},
       logo = #{record.logo,jdbcType=VARCHAR},
       big_pic = #{record.bigPic,jdbcType=VARCHAR},
+      create_id = #{record.createId,jdbcType=BIGINT},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_id = #{record.updateId,jdbcType=BIGINT},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
       brand_story = #{record.brandStory,jdbcType=LONGVARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -287,7 +333,11 @@
       product_count = #{record.productCount,jdbcType=INTEGER},
       product_comment_count = #{record.productCommentCount,jdbcType=INTEGER},
       logo = #{record.logo,jdbcType=VARCHAR},
-      big_pic = #{record.bigPic,jdbcType=VARCHAR}
+      big_pic = #{record.bigPic,jdbcType=VARCHAR},
+      create_id = #{record.createId,jdbcType=BIGINT},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_id = #{record.updateId,jdbcType=BIGINT},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -322,6 +372,18 @@
       <if test="bigPic != null">
         big_pic = #{bigPic,jdbcType=VARCHAR},
       </if>
+      <if test="createId != null">
+        create_id = #{createId,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateId != null">
+        update_id = #{updateId,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
       <if test="brandStory != null">
         brand_story = #{brandStory,jdbcType=LONGVARCHAR},
       </if>
@@ -339,6 +401,10 @@
       product_comment_count = #{productCommentCount,jdbcType=INTEGER},
       logo = #{logo,jdbcType=VARCHAR},
       big_pic = #{bigPic,jdbcType=VARCHAR},
+      create_id = #{createId,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_id = #{updateId,jdbcType=BIGINT},
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
       brand_story = #{brandStory,jdbcType=LONGVARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -352,7 +418,11 @@
       product_count = #{productCount,jdbcType=INTEGER},
       product_comment_count = #{productCommentCount,jdbcType=INTEGER},
       logo = #{logo,jdbcType=VARCHAR},
-      big_pic = #{bigPic,jdbcType=VARCHAR}
+      big_pic = #{bigPic,jdbcType=VARCHAR},
+      create_id = #{createId,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_id = #{updateId,jdbcType=BIGINT},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>
 </mapper>

+ 6 - 0
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/controller/UmsAdminController.java

@@ -2,6 +2,7 @@ package com.hwrj.cloud.admin.controller;
 
 import cn.hutool.core.collection.CollUtil;
 import com.hwrj.cloud.admin.model.UmsResource;
+import com.hwrj.cloud.admin.util.CurrUserUtil;
 import com.hwrj.cloud.common.api.CommonPage;
 import com.hwrj.cloud.common.api.CommonResult;
 import com.hwrj.cloud.admin.dto.UmsAdminLoginParam;
@@ -118,11 +119,16 @@ public class UmsAdminController {
         }
         return CommonResult.success(data);
     }
+    @Autowired
+    private UmsAdminCacheService adminCacheService;
 
     @ApiOperation(value = "登出功能")
     @RequestMapping(value = "/logout", method = RequestMethod.POST)
     @ResponseBody
     public CommonResult logout() {
+        adminCacheService.delToken(CurrUserUtil.getUmsAdmin().getUsername());
+        adminCacheService.delAdmin((long) CurrUserUtil.getUserId());
+        adminCacheService.delResourceList((long) CurrUserUtil.getUserId());
         return CommonResult.success(null);
     }
 

+ 28 - 5
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/controller/UploadCompanyInfoAndProductController.java

@@ -16,6 +16,7 @@ import com.hwrj.cloud.admin.mapper.UmsMemberOriginMapper;
 import com.hwrj.cloud.admin.model.*;
 import com.hwrj.cloud.admin.service.UmsCompanyService;
 import com.hwrj.cloud.admin.service.UmsMemberOriginService;
+import com.hwrj.cloud.admin.util.ChineseCharToEn;
 import com.hwrj.cloud.admin.util.EasyExcelUtil;
 import com.hwrj.cloud.admin.util.OrderNo;
 import com.hwrj.cloud.admin.util.UploadFileUtil;
@@ -559,13 +560,35 @@ public class UploadCompanyInfoAndProductController {
                 }
             }
         }
+        List<PmsBrand> bandlist=new ArrayList<>();
+        log.info("开始插入品牌数据");
+        List<String> BandNames = listAll.stream().map(PmsProductParam::getBrandName).distinct().collect(Collectors.toList());
+        for (String bandName : BandNames) {
+            PmsBrand pmsBrand =new PmsBrand();
+            pmsBrand.setName(bandName);
+            pmsBrand.setFirstLetter(ChineseCharToEn.getAllFirstLetter(bandName));
+            pmsBrand.setShowStatus(1);
+            pmsBrand.setSort(1);
+            pmsBrand.setFactoryStatus(1);
+            pmsBrand.setProductCount(listAll.size());
+            pmsBrand.setCreateId((long) 1);
+            pmsBrand.setCreateTime(new Date());
+            bandlist.add(pmsBrand);
+        }
+        if(BandNames.size()>0){
+            productExcelDao.saveBrandData(bandlist);
+        }
         log.info("开始插入商品数据");
-        productExcelDao.saveData(listAll);
-        log.info(JSONObject.toJSONString(listAll));
-        log.info(JSONObject.toJSONString(listAll));
+        if(listAll.size()>0){
+            log.info(JSONObject.toJSONString(listAll));
+            productExcelDao.saveData(listAll);
+        }
         List<String> compNames = listAll.stream().map(PmsProductParam::getUmsCompanyInfo).distinct().collect(Collectors.toList());
-        //更新大小类
-        updateProductType(compNames);
+        if(compNames.size()>0){
+            //更新大小类以及品牌生产地
+            updateProductType(compNames);
+        }
+
     }
     //更新大小类
     public void updateProductType(List<String> compName){

+ 3 - 0
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/dao/PmsProductExcelDao.java

@@ -1,6 +1,7 @@
 package com.hwrj.cloud.admin.dao;
 
 import com.hwrj.cloud.admin.dto.param.*;
+import com.hwrj.cloud.admin.model.PmsBrand;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -9,6 +10,8 @@ import java.util.List;
 public interface PmsProductExcelDao {
     void saveData(@Param("list") List<PmsProductParam> list);
 
+    void saveBrandData(@Param("list") List<PmsBrand> list);
+
     List<BigDataListInfoVo> bigDataList(BigDataListParam bigDataListParam);
 
     BigDataListInfoVo bigDatainfo(@Param("id")Long id);

+ 97 - 0
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/util/ChineseCharToEn.java

@@ -0,0 +1,97 @@
+package com.hwrj.cloud.admin.util;
+
+import java.io.UnsupportedEncodingException;
+
+/**
+ * 取得给定汉字串的首字母串,即声母串
+ * Title: ChineseCharToEn
+ *
+ * @date 注:只支持GB2312字符集中的汉字
+ */
+public final class ChineseCharToEn {
+    private final static int[] li_SecPosValue = {1601, 1637, 1833, 2078, 2274,
+            2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635, 3722, 3730, 3858,
+            4027, 4086, 4390, 4558, 4684, 4925, 5249, 5590};
+    private final static String[] lc_FirstLetter = {"a", "b", "c", "d", "e",
+            "f", "g", "h", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
+            "t", "w", "x", "y", "z"};
+
+    /**
+     * 取得给定汉字串的首字母串,即声母串
+     *
+     * @param str 给定汉字串
+     * @return 声母串
+     */
+    public static String getAllFirstLetter(String str) {
+        if (str == null || str.trim().length() == 0) {
+            return "";
+        }
+
+        String _str = "";
+        for (int i = 0; i < str.length(); i++) {
+            _str = _str + getFirstLetter(str.substring(i, i + 1));
+        }
+
+        return _str.toUpperCase();
+    }
+
+    /**
+     * 取得给定汉字的首字母,即声母
+     *
+     * @param chinese 给定的汉字
+     * @return 给定汉字的声母
+     */
+    public static String getFirstLetter(String chinese) {
+        if (chinese == null || chinese.trim().length() == 0) {
+            return "";
+        }
+        chinese = conversionStr(chinese, "GB2312", "ISO8859-1");
+
+        if (chinese.length() > 1) // 判断是不是汉字
+        {
+            int li_SectorCode = (int) chinese.charAt(0); // 汉字区码
+            int li_PositionCode = (int) chinese.charAt(1); // 汉字位码
+            li_SectorCode = li_SectorCode - 160;
+            li_PositionCode = li_PositionCode - 160;
+            int li_SecPosCode = li_SectorCode * 100 + li_PositionCode; // 汉字区位码
+            if (li_SecPosCode > 1600 && li_SecPosCode < 5590) {
+                for (int i = 0; i < 23; i++) {
+                    if (li_SecPosCode >= li_SecPosValue[i]
+                            && li_SecPosCode < li_SecPosValue[i + 1]) {
+                        chinese = lc_FirstLetter[i];
+                        break;
+                    }
+                }
+            } else // 非汉字字符,如图形符号或ASCII码
+            {
+                chinese = conversionStr(chinese, "ISO8859-1", "GB2312");
+                chinese = chinese.substring(0, 1);
+            }
+        }
+
+        return chinese;
+    }
+
+    /**
+     * 字符串编码转换
+     *
+     * @param str           要转换编码的字符串
+     * @param charsetName   原来的编码
+     * @param toCharsetName 转换后的编码
+     * @return 经过编码转换后的字符串
+     */
+    private static String conversionStr(String str, String charsetName, String toCharsetName) {
+        String reDta = "";
+        try {
+            reDta = new String(str.getBytes(charsetName), toCharsetName);
+        } catch (UnsupportedEncodingException ex) {
+            System.out.println("字符串编码转换异常:" + ex.getMessage());
+        }
+        return reDta;
+    }
+
+    public static void main(String[] args) {
+        System.out.println("获取拼音首字母:" + getAllFirstLetter("大中国南昌中大china"));
+    }
+
+}

+ 163 - 125
forest-admin/admin-server/src/main/resources/dao/ProductExcelDao.xml

@@ -1,121 +1,155 @@
 <?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.hwrj.cloud.admin.dao.PmsProductExcelDao">
-    <insert id="saveData" useGeneratedKeys="true" keyProperty="id" parameterType="com.hwrj.cloud.admin.dto.param.PmsProductParam" >
-         INSERT INTO pms_product
-           (
-            brand_id,
-            product_big_category_name,
-            product_category_id,
-            feight_template_id,
-            product_attribute_category_id,
-            name,
-            pic,
-            product_sn,
-            delete_status,
-            publish_status,
-            new_status,
-            recommand_status,
-            verify_status,
-            sort,
-            sale,
-            price,
-            promotion_price,
-            gift_growth,
-            gift_point,
-            use_point_limit,
-            sub_title,
-            description,
-            original_price,
-            stock,
-            low_stock,
-            unit,
-            weight,
-            preview_status,
-            service_ids,
-            keywords,
-            note,
-            album_pics,
-            detail_title,
-            detail_desc,
-            detail_html,
-            detail_mobile_html,
-            promotion_start_time,
-            promotion_end_time,
-            promotion_per_limit,
-            promotion_type,
-            brand_name,
-            product_category_name,
-            comp_id,
-            comp_name,
-            trade_price,
-            spec,
-            date_of_manufacture,
-            place_of_production_id,
-            place_of_production,
-            instructions,
-            points_for_attention,
-            quality_guarantee_period,
-            create_id,
-            create_time)
+    <insert id="saveData" useGeneratedKeys="true" keyProperty="id"
+            parameterType="com.hwrj.cloud.admin.dto.param.PmsProductParam">
+        INSERT INTO pms_product
+        (
+        brand_id,
+        product_big_category_name,
+        product_category_id,
+        feight_template_id,
+        product_attribute_category_id,
+        name,
+        pic,
+        product_sn,
+        delete_status,
+        publish_status,
+        new_status,
+        recommand_status,
+        verify_status,
+        sort,
+        sale,
+        price,
+        promotion_price,
+        gift_growth,
+        gift_point,
+        use_point_limit,
+        sub_title,
+        description,
+        original_price,
+        stock,
+        low_stock,
+        unit,
+        weight,
+        preview_status,
+        service_ids,
+        keywords,
+        note,
+        album_pics,
+        detail_title,
+        detail_desc,
+        detail_html,
+        detail_mobile_html,
+        promotion_start_time,
+        promotion_end_time,
+        promotion_per_limit,
+        promotion_type,
+        brand_name,
+        product_category_name,
+        comp_id,
+        comp_name,
+        trade_price,
+        spec,
+        date_of_manufacture,
+        place_of_production_id,
+        place_of_production,
+        instructions,
+        points_for_attention,
+        quality_guarantee_period,
+        create_id,
+        create_time)
         VALUES
         <foreach collection="list" item="item" index="index" separator=",">
-         <trim prefix="(" suffix=")" suffixOverrides=",">
-             #{item.brandId},
-             #{item.productBigCategoryName},
-             #{item.productCategoryId},
-             #{item.feightTemplateId},
-             #{item.productAttributeCategoryId},
-             #{item.name},
-             #{item.pic},
-             #{item.productSn},
-             #{item.deleteStatus},
-             #{item.publishStatus},
-             #{item.newStatus},
-             #{item.recommandStatus},
-             #{item.verifyStatus},
-             #{item.sort},
-             #{item.sale},
-             #{item.price},
-             #{item.promotionPrice},
-             #{item.giftGrowth},
-             #{item.giftPoint},
-             #{item.usePointLimit},
-             #{item.subTitle},
-             #{item.description},
-             #{item.originalPrice},
-             #{item.stock},
-             #{item.lowStock},
-             #{item.unit},
-             #{item.weight},
-             #{item.previewStatus},
-             #{item.serviceIds},
-             #{item.keywords},
-             #{item.note},
-             #{item.albumPics},
-             #{item.detailTitle},
-             #{item.detailDesc},
-             #{item.detailHtml},
-             #{item.detailMobileHtml},
-             #{item.promotionStartTime},
-             #{item.promotionEndTime},
-             #{item.promotionPerLimit},
-             #{item.promotionType},
-             #{item.brandName},
-             #{item.productCategoryName},
-             #{item.umsCompanyInfoId},
-             #{item.umsCompanyInfo},
-             #{item.tradePrice},
-             #{item.spec},
-             #{item.dateOfManufacture},
-             #{item.placeOfProductionId},
-             #{item.placeOfProduction},
-             #{item.instructions},
-             #{item.pointsForAttention},
-             #{item.qualityGuaranteePeriod},
-             #{item.createUser},
-             #{item.createTime}
-         </trim>
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                #{item.brandId},
+                #{item.productBigCategoryName},
+                #{item.productCategoryId},
+                #{item.feightTemplateId},
+                #{item.productAttributeCategoryId},
+                #{item.name},
+                #{item.pic},
+                #{item.productSn},
+                #{item.deleteStatus},
+                #{item.publishStatus},
+                #{item.newStatus},
+                #{item.recommandStatus},
+                #{item.verifyStatus},
+                #{item.sort},
+                #{item.sale},
+                #{item.price},
+                #{item.promotionPrice},
+                #{item.giftGrowth},
+                #{item.giftPoint},
+                #{item.usePointLimit},
+                #{item.subTitle},
+                #{item.description},
+                #{item.originalPrice},
+                #{item.stock},
+                #{item.lowStock},
+                #{item.unit},
+                #{item.weight},
+                #{item.previewStatus},
+                #{item.serviceIds},
+                #{item.keywords},
+                #{item.note},
+                #{item.albumPics},
+                #{item.detailTitle},
+                #{item.detailDesc},
+                #{item.detailHtml},
+                #{item.detailMobileHtml},
+                #{item.promotionStartTime},
+                #{item.promotionEndTime},
+                #{item.promotionPerLimit},
+                #{item.promotionType},
+                #{item.brandName},
+                #{item.productCategoryName},
+                #{item.umsCompanyInfoId},
+                #{item.umsCompanyInfo},
+                #{item.tradePrice},
+                #{item.spec},
+                #{item.dateOfManufacture},
+                #{item.placeOfProductionId},
+                #{item.placeOfProduction},
+                #{item.instructions},
+                #{item.pointsForAttention},
+                #{item.qualityGuaranteePeriod},
+                #{item.createUser},
+                #{item.createTime}
+            </trim>
+        </foreach>
+    </insert>
+    <insert id="saveBrandData">
+        INSERT IGNORE INTO pms_brand (
+        name,
+        first_letter,
+        sort,
+        factory_status,
+        show_status,
+        product_count,
+        product_comment_count,
+        logo,
+        big_pic,
+        brand_story,
+        create_id,
+        create_time
+        )
+        VALUES
+        <foreach collection="list" item="item" index="index" separator=",">
+            <trim prefix="(" suffix=")" suffixOverrides=",">
+                #{item.name},
+                #{item.firstLetter},
+                #{item.sort},
+                #{item.factoryStatus},
+                #{item.showStatus},
+                #{item.productCount},
+                #{item.productCommentCount},
+                #{item.logo},
+                #{item.bigPic},
+                #{item.brandStory},
+                #{item.createId},
+                #{item.createTime}
+            </trim>
         </foreach>
     </insert>
 
@@ -135,12 +169,12 @@
         WHERE
         1 = 1
         AND a.delete_status = 0
-    <if test="typeId != null">
-        AND a.product_big_category_id = #{typeId}
-    </if>
-    <if test="search != null and search != ''">
-        AND concat(a.`name`, a.brand_name) LIKE concat(concat('%', #{search}, '%'))
-    </if>
+        <if test="typeId != null">
+            AND a.product_big_category_id = #{typeId}
+        </if>
+        <if test="search != null and search != ''">
+            AND concat(a.`name`, a.brand_name) LIKE concat(concat('%', #{search}, '%'))
+        </if>
     </select>
 
     <resultMap id="bigDatainfoMap" type="com.hwrj.cloud.admin.dto.param.BigDataListInfoVo">
@@ -224,12 +258,12 @@
     </select>
     <select id="plOfProSelect" resultType="com.hwrj.cloud.admin.dto.param.SelectVo">
         SELECT
-            a.id as lable,
-            a.origin_name as text
+        a.id as lable,
+        a.origin_name as text
         FROM
-            ums_member_origin a
+        ums_member_origin a
         WHERE
-            a.state = 0
+        a.state = 0
         <if test="compId != null and compId != ''">
             AND a.comp_id = #{compId}
         </if>
@@ -239,10 +273,14 @@
         UPDATE pms_product a
         LEFT JOIN pms_product_category b ON a.product_big_category_name = b.`name`
         LEFT JOIN pms_product_category c ON a.product_category_name = c.`name`
+        LEFT JOIN ums_member_origin e ON a.place_of_production = e.origin_name
+        LEFT JOIN pms_brand f ON a.brand_name = f.`name`
         SET a.product_big_category_id = b.id,
-         a.product_category_id = c.id
+        a.product_category_id = c.id,
+        a.place_of_production_id = e.id,
+        a.brand_id = f.id
         WHERE
-            b.parent_id = 0
+        b.parent_id = 0
         AND c.parent_id != 0
         AND a.comp_name in
         <foreach collection="list" item="compName" open="(" separator="," close=")">

+ 14 - 0
更新sql.sql

@@ -41,4 +41,18 @@ WHERE
 AND c.parent_id != 0
 AND a.create_time >= '2020-10-9 00:00:00';
 
+# 品牌表新增字段
+
+ALTER TABLE pms_brand ADD COLUMN `create_id` BIGINT (20) DEFAULT NULL COMMENT '创建人' AFTER `brand_story`;
+
+ALTER TABLE pms_brand ADD COLUMN `create_time` datetime DEFAULT NULL COMMENT '创建时间' AFTER `create_id`;
+
+ALTER TABLE pms_brand ADD COLUMN `update_id` BIGINT (20) DEFAULT NULL COMMENT '更新人' AFTER `create_time`;
+
+ALTER TABLE pms_brand ADD COLUMN `update_time` datetime DEFAULT NULL COMMENT '更新时间' AFTER `update_id`;
+
+
+# 品牌表新增唯一索引
+ALTER TABLE `pms_brand` ADD UNIQUE (`name`)
+