Browse Source

商品信息新增,编辑接口修改

huang 1 tuần trước cách đây
mục cha
commit
1276761cd1

+ 8 - 0
pom.xml

@@ -128,6 +128,14 @@
 			<artifactId>pagehelper-spring-boot-starter</artifactId>
 			<artifactId>pagehelper-spring-boot-starter</artifactId>
 			<version>1.2.13</version>
 			<version>1.2.13</version>
 		</dependency>
 		</dependency>
+
+		<!--常用工具类 -->
+		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-lang3</artifactId>
+			<version>3.12.0</version>
+		</dependency>
+
 	</dependencies>
 	</dependencies>
 
 
 	<build>
 	<build>

+ 3 - 0
src/main/java/com/jsh/erp/constants/ExceptionConstants.java

@@ -353,6 +353,9 @@ public class ExceptionConstants {
     //EXCEL中有副条码在系统中已存在(除自身商品之外)
     //EXCEL中有副条码在系统中已存在(除自身商品之外)
     public static final int MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_CODE = 80000028;
     public static final int MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_CODE = 80000028;
     public static final String MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_MSG = "抱歉,EXCEL中有副条码在系统中已存在,具体副条码为:%s";
     public static final String MATERIAL_EXCEL_IMPORT_MANY_BARCODE_EXIST_MSG = "抱歉,EXCEL中有副条码在系统中已存在,具体副条码为:%s";
+    //基本单位为空
+    public static final int MATERIAL_Category_Name_EMPTY_CODE = 8000029;
+    public static final String MATERIAL_Category_Name_EMPTY_MSG = "第%s行类别为空";
 
 
     /**
     /**
      *  单据信息
      *  单据信息

+ 1 - 1
src/main/java/com/jsh/erp/controller/MaterialController.java

@@ -356,7 +356,7 @@ public class MaterialController extends BaseController {
                     item.put("model", material.getModel());
                     item.put("model", material.getModel());
                     item.put("color", material.getColor());
                     item.put("color", material.getColor());
                     item.put("brand", material.getBrand());
                     item.put("brand", material.getBrand());
-                    item.put("mfrs", material.getMfrs());
+                    //item.put("mfrs", material.getMfrs());
                     item.put("unit", material.getCommodityUnit() + ratioStr);
                     item.put("unit", material.getCommodityUnit() + ratioStr);
                     item.put("sku", material.getSku());
                     item.put("sku", material.getSku());
                     item.put("enableSerialNumber", material.getEnableSerialNumber());
                     item.put("enableSerialNumber", material.getEnableSerialNumber());

+ 8 - 0
src/main/java/com/jsh/erp/controller/MaterialExtendController.java

@@ -108,6 +108,14 @@ public class MaterialExtendController {
                     item.put("commodityDecimal", md.getCommodityDecimal());
                     item.put("commodityDecimal", md.getCommodityDecimal());
                     item.put("wholesaleDecimal", md.getWholesaleDecimal());
                     item.put("wholesaleDecimal", md.getWholesaleDecimal());
                     item.put("lowDecimal", md.getLowDecimal());
                     item.put("lowDecimal", md.getLowDecimal());
+                    item.put("productionDate",md.getProductionDate());
+                    item.put("expiryNum",md.getExpiryNum());
+                    item.put("supplierId",md.getSupplierId());
+                    item.put("barCode",md.getBarCode());
+                    item.put("batchNumber",md.getBrandName());
+                    item.put("inventory",md.getInventory());
+                    item.put("depotId",md.getDepotId());
+                    item.put("position",md.getPosition());
                     dataArray.add(item);
                     dataArray.add(item);
                 }
                 }
             }
             }

+ 43 - 0
src/main/java/com/jsh/erp/datasource/entities/DepotHead.java

@@ -1,73 +1,116 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
 
 
+/**
+ * 单据主表
+ */
+@Data
 public class DepotHead {
 public class DepotHead {
+
+    @ApiModelProperty("主键id")
     private Long id;
     private Long id;
 
 
+    @ApiModelProperty("类型(出库/入库)")
     private String type;
     private String type;
 
 
+    @ApiModelProperty("出入库分类")
     private String subType;
     private String subType;
 
 
+    @ApiModelProperty("初始票据号")
     private String defaultNumber;
     private String defaultNumber;
 
 
+    @ApiModelProperty("票据号")
     private String number;
     private String number;
 
 
+    @ApiModelProperty("创建时间")
     private Date createTime;
     private Date createTime;
 
 
+    @ApiModelProperty("出入库时间")
     private Date operTime;
     private Date operTime;
 
 
+    @ApiModelProperty("供应商id")
     private Long organId;
     private Long organId;
 
 
+    @ApiModelProperty("操作员")
     private Long creator;
     private Long creator;
 
 
+    @ApiModelProperty("账户id")
     private Long accountId;
     private Long accountId;
 
 
+    @ApiModelProperty("变动金额(收款/付款)")
     private BigDecimal changeAmount;
     private BigDecimal changeAmount;
 
 
+    @ApiModelProperty("找零金额")
     private BigDecimal backAmount;
     private BigDecimal backAmount;
 
 
+    @ApiModelProperty("合计金额")
     private BigDecimal totalPrice;
     private BigDecimal totalPrice;
 
 
+    @ApiModelProperty("付款类型(现金、记账等)")
     private String payType;
     private String payType;
 
 
+    @ApiModelProperty("单据类型")
     private String billType;
     private String billType;
 
 
+    @ApiModelProperty("备注")
     private String remark;
     private String remark;
 
 
+    @ApiModelProperty("附件名称")
     private String fileName;
     private String fileName;
 
 
+    @ApiModelProperty("销售员(可以多个)")
     private String salesMan;
     private String salesMan;
 
 
+    @ApiModelProperty("多账户ID列表")
     private String accountIdList;
     private String accountIdList;
 
 
+    @ApiModelProperty("多账户金额列表")
     private String accountMoneyList;
     private String accountMoneyList;
 
 
+    @ApiModelProperty("优惠率")
     private BigDecimal discount;
     private BigDecimal discount;
 
 
+    @ApiModelProperty("优惠金额")
     private BigDecimal discountMoney;
     private BigDecimal discountMoney;
 
 
+    @ApiModelProperty("优惠后金额")
     private BigDecimal discountLastMoney;
     private BigDecimal discountLastMoney;
 
 
+    @ApiModelProperty("销售或采购费用合计")
     private BigDecimal otherMoney;
     private BigDecimal otherMoney;
 
 
+    @ApiModelProperty("订金")
     private BigDecimal deposit;
     private BigDecimal deposit;
 
 
+    @ApiModelProperty("状态,0未审核、1已审核、2完成采购|销售、3部分采购|销售、9审核中")
     private String status;
     private String status;
 
 
+    @ApiModelProperty("采购状态,0未采购、2完成采购、3部分采购")
     private String purchaseStatus;
     private String purchaseStatus;
 
 
+    @ApiModelProperty("单据来源,0-pc,1-手机")
     private String source;
     private String source;
 
 
+    @ApiModelProperty("关联订单号")
     private String linkNumber;
     private String linkNumber;
 
 
+    @ApiModelProperty("关联请购单")
     private String linkApply;
     private String linkApply;
 
 
+    @ApiModelProperty("租户id")
     private Long tenantId;
     private Long tenantId;
 
 
+    @ApiModelProperty("删除标记,0未删除,1删除")
     private String deleteFlag;
     private String deleteFlag;
 
 
+    @ApiModelProperty("凭证图片")
+    private String voucherPicture;
+
     public Long getId() {
     public Long getId() {
         return id;
         return id;
     }
     }

+ 48 - 0
src/main/java/com/jsh/erp/datasource/entities/DepotItem.java

@@ -1,59 +1,107 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
 
 
+/**
+ * 单据子表
+ */
+@Data
 public class DepotItem {
 public class DepotItem {
+
+    @ApiModelProperty("主键id")
     private Long id;
     private Long id;
 
 
+    @ApiModelProperty("表头Id")
     private Long headerId;
     private Long headerId;
 
 
+    @ApiModelProperty("商品Id")
     private Long materialId;
     private Long materialId;
 
 
+    @ApiModelProperty("商品扩展id")
     private Long materialExtendId;
     private Long materialExtendId;
 
 
+    @ApiModelProperty("商品单位")
     private String materialUnit;
     private String materialUnit;
 
 
+    @ApiModelProperty("多属性")
     private String sku;
     private String sku;
 
 
+    @ApiModelProperty("数量")
     private BigDecimal operNumber;
     private BigDecimal operNumber;
 
 
+    @ApiModelProperty("基础数量,如kg、瓶")
     private BigDecimal basicNumber;
     private BigDecimal basicNumber;
 
 
+    @ApiModelProperty("单价")
     private BigDecimal unitPrice;
     private BigDecimal unitPrice;
 
 
+    @ApiModelProperty("采购单价")
     private BigDecimal purchaseUnitPrice;
     private BigDecimal purchaseUnitPrice;
 
 
+    @ApiModelProperty("含税单价")
     private BigDecimal taxUnitPrice;
     private BigDecimal taxUnitPrice;
 
 
+    @ApiModelProperty("金额")
     private BigDecimal allPrice;
     private BigDecimal allPrice;
 
 
+    @ApiModelProperty("备注")
     private String remark;
     private String remark;
 
 
+    @ApiModelProperty("仓库ID")
     private Long depotId;
     private Long depotId;
 
 
+    @ApiModelProperty("调拨时,对方仓库Id")
     private Long anotherDepotId;
     private Long anotherDepotId;
 
 
+    @ApiModelProperty("税率")
     private BigDecimal taxRate;
     private BigDecimal taxRate;
 
 
+    @ApiModelProperty("税额")
     private BigDecimal taxMoney;
     private BigDecimal taxMoney;
 
 
+    @ApiModelProperty("价税合计")
     private BigDecimal taxLastMoney;
     private BigDecimal taxLastMoney;
 
 
+    @ApiModelProperty("商品类型")
     private String materialType;
     private String materialType;
 
 
+    @ApiModelProperty("序列号列表")
     private String snList;
     private String snList;
 
 
+    @ApiModelProperty("批号")
     private String batchNumber;
     private String batchNumber;
 
 
+    @ApiModelProperty("有效日期")
     private Date expirationDate;
     private Date expirationDate;
 
 
+    @ApiModelProperty("关联明细id")
     private Long linkId;
     private Long linkId;
 
 
+    @ApiModelProperty("租户id")
     private Long tenantId;
     private Long tenantId;
 
 
+    @ApiModelProperty("删除标记,0未删除,1删除")
     private String deleteFlag;
     private String deleteFlag;
 
 
+    @ApiModelProperty("实际出入库数量")
+    private BigDecimal actualQuantityInStorage;
+
+    @ApiModelProperty("出入库差异")
+    private BigDecimal warehousingVariance;
+
+    @ApiModelProperty("出入库差异原因")
+    private String reasonOfDifference;
+
+    @ApiModelProperty("出入库用户")
+    private Long warehousingUser;
+
+    @ApiModelProperty("出入库时间")
+    private Date warehousingTime;
+
     public Long getId() {
     public Long getId() {
         return id;
         return id;
     }
     }

+ 40 - 132
src/main/java/com/jsh/erp/datasource/entities/Material.java

@@ -1,245 +1,153 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 
 
+/**
+ * 产品表(商品表)
+ */
+@Data
 public class Material {
 public class Material {
+
+    @ApiModelProperty("主键id")
     private Long id;
     private Long id;
 
 
+    @ApiModelProperty("产品类型id")
     private Long categoryId;
     private Long categoryId;
 
 
+    @ApiModelProperty("产品名称")
     private String name;
     private String name;
 
 
-    private String mfrs;
+//    @ApiModelProperty("制造商")
+//    private String mfrs;
 
 
+    @ApiModelProperty("型号")
     private String model;
     private String model;
 
 
+    @ApiModelProperty("规格")
     private String standard;
     private String standard;
 
 
+    @ApiModelProperty("品牌")
     private String brand;
     private String brand;
 
 
+    @ApiModelProperty("助记码")
     private String mnemonic;
     private String mnemonic;
 
 
+    @ApiModelProperty("颜色")
     private String color;
     private String color;
 
 
+    @ApiModelProperty("单位-单个")
     private String unit;
     private String unit;
 
 
+    @ApiModelProperty("备注")
     private String remark;
     private String remark;
 
 
+    @ApiModelProperty("图片名称")
     private String imgName;
     private String imgName;
 
 
+    @ApiModelProperty("计量单位Id")
     private Long unitId;
     private Long unitId;
 
 
-    private Integer expiryNum;
+//    @ApiModelProperty("保质期天数")
+//    private Integer expiryNum;
 
 
+    @ApiModelProperty("基础重量(kg)")
     private BigDecimal weight;
     private BigDecimal weight;
 
 
+    @ApiModelProperty("启用 0-禁用  1-启用")
     private Boolean enabled;
     private Boolean enabled;
 
 
+    @ApiModelProperty("自定义1")
     private String otherField1;
     private String otherField1;
 
 
+    @ApiModelProperty("自定义2")
     private String otherField2;
     private String otherField2;
 
 
+    @ApiModelProperty("自定义3")
     private String otherField3;
     private String otherField3;
 
 
+    @ApiModelProperty("是否开启序列号,0否,1是")
     private String enableSerialNumber;
     private String enableSerialNumber;
 
 
+    @ApiModelProperty("是否开启批号,0否,1是")
     private String enableBatchNumber;
     private String enableBatchNumber;
 
 
-    private String position;
+//    @ApiModelProperty("仓位货架")
+//    private String position;
 
 
+    @ApiModelProperty("租户id")
     private Long tenantId;
     private Long tenantId;
 
 
+    @ApiModelProperty("删除标记,0未删除,1删除")
     private String deleteFlag;
     private String deleteFlag;
 
 
-    public Long getId() {
-        return id;
-    }
+    @ApiModelProperty("系统sku")
+    private String systemSku;
 
 
-    public void setId(Long id) {
-        this.id = id;
-    }
+    @ApiModelProperty("无动销提醒周期")
+    private String movingPinReminderCycle;
 
 
-    public Long getCategoryId() {
-        return categoryId;
-    }
-
-    public void setCategoryId(Long categoryId) {
-        this.categoryId = categoryId;
-    }
-
-    public String getName() {
-        return name;
-    }
 
 
     public void setName(String name) {
     public void setName(String name) {
         this.name = name == null ? null : name.trim();
         this.name = name == null ? null : name.trim();
     }
     }
 
 
-    public String getMfrs() {
-        return mfrs;
-    }
-
-    public void setMfrs(String mfrs) {
-        this.mfrs = mfrs == null ? null : mfrs.trim();
-    }
-
-    public String getModel() {
-        return model;
-    }
-
     public void setModel(String model) {
     public void setModel(String model) {
         this.model = model == null ? null : model.trim();
         this.model = model == null ? null : model.trim();
     }
     }
 
 
-    public String getStandard() {
-        return standard;
-    }
-
     public void setStandard(String standard) {
     public void setStandard(String standard) {
         this.standard = standard == null ? null : standard.trim();
         this.standard = standard == null ? null : standard.trim();
     }
     }
 
 
-    public String getBrand() {
-        return brand;
-    }
-
     public void setBrand(String brand) {
     public void setBrand(String brand) {
         this.brand = brand == null ? null : brand.trim();
         this.brand = brand == null ? null : brand.trim();
     }
     }
 
 
-    public String getMnemonic() {
-        return mnemonic;
-    }
-
     public void setMnemonic(String mnemonic) {
     public void setMnemonic(String mnemonic) {
         this.mnemonic = mnemonic == null ? null : mnemonic.trim();
         this.mnemonic = mnemonic == null ? null : mnemonic.trim();
     }
     }
 
 
-    public String getColor() {
-        return color;
-    }
-
     public void setColor(String color) {
     public void setColor(String color) {
         this.color = color == null ? null : color.trim();
         this.color = color == null ? null : color.trim();
     }
     }
 
 
-    public String getUnit() {
-        return unit;
-    }
-
     public void setUnit(String unit) {
     public void setUnit(String unit) {
         this.unit = unit == null ? null : unit.trim();
         this.unit = unit == null ? null : unit.trim();
     }
     }
 
 
-    public String getRemark() {
-        return remark;
-    }
-
     public void setRemark(String remark) {
     public void setRemark(String remark) {
         this.remark = remark == null ? null : remark.trim();
         this.remark = remark == null ? null : remark.trim();
     }
     }
 
 
-    public String getImgName() {
-        return imgName;
-    }
-
     public void setImgName(String imgName) {
     public void setImgName(String imgName) {
         this.imgName = imgName == null ? null : imgName.trim();
         this.imgName = imgName == null ? null : imgName.trim();
     }
     }
 
 
-    public Long getUnitId() {
-        return unitId;
-    }
-
-    public void setUnitId(Long unitId) {
-        this.unitId = unitId;
-    }
-
-    public Integer getExpiryNum() {
-        return expiryNum;
-    }
-
-    public void setExpiryNum(Integer expiryNum) {
-        this.expiryNum = expiryNum;
-    }
-
-    public BigDecimal getWeight() {
-        return weight;
-    }
-
-    public void setWeight(BigDecimal weight) {
-        this.weight = weight;
-    }
-
-    public Boolean getEnabled() {
-        return enabled;
-    }
-
-    public void setEnabled(Boolean enabled) {
-        this.enabled = enabled;
-    }
-
-    public String getOtherField1() {
-        return otherField1;
-    }
-
     public void setOtherField1(String otherField1) {
     public void setOtherField1(String otherField1) {
         this.otherField1 = otherField1 == null ? null : otherField1.trim();
         this.otherField1 = otherField1 == null ? null : otherField1.trim();
     }
     }
 
 
-    public String getOtherField2() {
-        return otherField2;
-    }
-
     public void setOtherField2(String otherField2) {
     public void setOtherField2(String otherField2) {
         this.otherField2 = otherField2 == null ? null : otherField2.trim();
         this.otherField2 = otherField2 == null ? null : otherField2.trim();
     }
     }
 
 
-    public String getOtherField3() {
-        return otherField3;
-    }
-
     public void setOtherField3(String otherField3) {
     public void setOtherField3(String otherField3) {
         this.otherField3 = otherField3 == null ? null : otherField3.trim();
         this.otherField3 = otherField3 == null ? null : otherField3.trim();
     }
     }
 
 
-    public String getEnableSerialNumber() {
-        return enableSerialNumber;
-    }
-
     public void setEnableSerialNumber(String enableSerialNumber) {
     public void setEnableSerialNumber(String enableSerialNumber) {
         this.enableSerialNumber = enableSerialNumber == null ? null : enableSerialNumber.trim();
         this.enableSerialNumber = enableSerialNumber == null ? null : enableSerialNumber.trim();
     }
     }
 
 
-    public String getEnableBatchNumber() {
-        return enableBatchNumber;
-    }
-
     public void setEnableBatchNumber(String enableBatchNumber) {
     public void setEnableBatchNumber(String enableBatchNumber) {
         this.enableBatchNumber = enableBatchNumber == null ? null : enableBatchNumber.trim();
         this.enableBatchNumber = enableBatchNumber == null ? null : enableBatchNumber.trim();
     }
     }
 
 
-    public String getPosition() {
-        return position;
-    }
-
-    public void setPosition(String position) {
-        this.position = position == null ? null : position.trim();
-    }
-
-    public Long getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(Long tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDeleteFlag() {
-        return deleteFlag;
-    }
-
     public void setDeleteFlag(String deleteFlag) {
     public void setDeleteFlag(String deleteFlag) {
         this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim();
         this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim();
     }
     }
+
 }
 }

+ 42 - 97
src/main/java/com/jsh/erp/datasource/entities/MaterialExtend.java

@@ -1,165 +1,110 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
 
 
+/**
+ * 产品价格扩展
+ */
+@Data
 public class MaterialExtend {
 public class MaterialExtend {
+
+    @ApiModelProperty("主键id")
     private Long id;
     private Long id;
 
 
+    @ApiModelProperty("商品id")
     private Long materialId;
     private Long materialId;
 
 
-    private String barCode;
-
+    @ApiModelProperty("商品单位")
     private String commodityUnit;
     private String commodityUnit;
 
 
+    @ApiModelProperty("商品属性")
     private String sku;
     private String sku;
 
 
+    @ApiModelProperty("采购价格")
     private BigDecimal purchaseDecimal;
     private BigDecimal purchaseDecimal;
 
 
+    @ApiModelProperty("零售价格")
     private BigDecimal commodityDecimal;
     private BigDecimal commodityDecimal;
 
 
+    @ApiModelProperty("销售价格")
     private BigDecimal wholesaleDecimal;
     private BigDecimal wholesaleDecimal;
 
 
+    @ApiModelProperty("最低售价")
     private BigDecimal lowDecimal;
     private BigDecimal lowDecimal;
 
 
+    @ApiModelProperty("是否为默认单位,1是,0否")
     private String defaultFlag;
     private String defaultFlag;
 
 
+    @ApiModelProperty("创建日期")
     private Date createTime;
     private Date createTime;
 
 
+    @ApiModelProperty("创建人编码")
     private String createSerial;
     private String createSerial;
 
 
+    @ApiModelProperty("更新人编码")
     private String updateSerial;
     private String updateSerial;
 
 
+    @ApiModelProperty("更新时间戳")
     private Long updateTime;
     private Long updateTime;
 
 
+    @ApiModelProperty("租户id")
     private Long tenantId;
     private Long tenantId;
 
 
+    @ApiModelProperty("删除标记,0未删除,1删除")
     private String deleteFlag;
     private String deleteFlag;
 
 
-    public Long getId() {
-        return id;
-    }
+    @ApiModelProperty("生产日期")
+    private Date productionDate;
 
 
-    public void setId(Long id) {
-        this.id = id;
-    }
+    @ApiModelProperty("保质期天数")
+    private Integer expiryNum;
 
 
-    public Long getMaterialId() {
-        return materialId;
-    }
+    @ApiModelProperty("供应商id")
+    private Long supplierId;
 
 
-    public void setMaterialId(Long materialId) {
-        this.materialId = materialId;
-    }
+    @ApiModelProperty("商品条码")
+    private String barCode;
 
 
-    public String getBarCode() {
-        return barCode;
-    }
+    @ApiModelProperty("批次号")
+    private String batchNumber;
+
+    @ApiModelProperty("库存")
+    private BigDecimal inventory;
+
+    @ApiModelProperty("仓库id")
+    private Long depotId;
+
+    @ApiModelProperty("仓位货架")
+    private String position;
 
 
     public void setBarCode(String barCode) {
     public void setBarCode(String barCode) {
         this.barCode = barCode == null ? null : barCode.trim();
         this.barCode = barCode == null ? null : barCode.trim();
     }
     }
 
 
-    public String getCommodityUnit() {
-        return commodityUnit;
-    }
-
     public void setCommodityUnit(String commodityUnit) {
     public void setCommodityUnit(String commodityUnit) {
         this.commodityUnit = commodityUnit == null ? null : commodityUnit.trim();
         this.commodityUnit = commodityUnit == null ? null : commodityUnit.trim();
     }
     }
 
 
-    public String getSku() {
-        return sku;
-    }
-
     public void setSku(String sku) {
     public void setSku(String sku) {
         this.sku = sku == null ? null : sku.trim();
         this.sku = sku == null ? null : sku.trim();
     }
     }
 
 
-    public BigDecimal getPurchaseDecimal() {
-        return purchaseDecimal;
-    }
-
-    public void setPurchaseDecimal(BigDecimal purchaseDecimal) {
-        this.purchaseDecimal = purchaseDecimal;
-    }
-
-    public BigDecimal getCommodityDecimal() {
-        return commodityDecimal;
-    }
-
-    public void setCommodityDecimal(BigDecimal commodityDecimal) {
-        this.commodityDecimal = commodityDecimal;
-    }
-
-    public BigDecimal getWholesaleDecimal() {
-        return wholesaleDecimal;
-    }
-
-    public void setWholesaleDecimal(BigDecimal wholesaleDecimal) {
-        this.wholesaleDecimal = wholesaleDecimal;
-    }
-
-    public BigDecimal getLowDecimal() {
-        return lowDecimal;
-    }
-
-    public void setLowDecimal(BigDecimal lowDecimal) {
-        this.lowDecimal = lowDecimal;
-    }
-
-    public String getDefaultFlag() {
-        return defaultFlag;
-    }
-
     public void setDefaultFlag(String defaultFlag) {
     public void setDefaultFlag(String defaultFlag) {
         this.defaultFlag = defaultFlag == null ? null : defaultFlag.trim();
         this.defaultFlag = defaultFlag == null ? null : defaultFlag.trim();
     }
     }
 
 
-    public Date getCreateTime() {
-        return createTime;
-    }
-
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
-
-    public String getCreateSerial() {
-        return createSerial;
-    }
-
     public void setCreateSerial(String createSerial) {
     public void setCreateSerial(String createSerial) {
         this.createSerial = createSerial == null ? null : createSerial.trim();
         this.createSerial = createSerial == null ? null : createSerial.trim();
     }
     }
 
 
-    public String getUpdateSerial() {
-        return updateSerial;
-    }
-
     public void setUpdateSerial(String updateSerial) {
     public void setUpdateSerial(String updateSerial) {
         this.updateSerial = updateSerial == null ? null : updateSerial.trim();
         this.updateSerial = updateSerial == null ? null : updateSerial.trim();
     }
     }
 
 
-    public Long getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Long updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public Long getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(Long tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public String getDeleteFlag() {
-        return deleteFlag;
-    }
-
     public void setDeleteFlag(String deleteFlag) {
     public void setDeleteFlag(String deleteFlag) {
         this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim();
         this.deleteFlag = deleteFlag == null ? null : deleteFlag.trim();
     }
     }

+ 38 - 7
src/main/java/com/jsh/erp/datasource/entities/MaterialVo4Unit.java

@@ -1,9 +1,15 @@
 package com.jsh.erp.datasource.entities;
 package com.jsh.erp.datasource.entities;
 
 
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.util.Date;
 
 
+@Data
 public class MaterialVo4Unit extends Material{
 public class MaterialVo4Unit extends Material{
 
 
+    //
     private String unitName;
     private String unitName;
 
 
     private BigDecimal ratio;
     private BigDecimal ratio;
@@ -44,8 +50,33 @@ public class MaterialVo4Unit extends Material{
 
 
     private String sku;
     private String sku;
 
 
+//    private Long depotId;
+
+    @ApiModelProperty("生产日期")
+    private Date productionDate;
+
+    @ApiModelProperty("保质期天数")
+    private Integer expiryNum;
+
+    @ApiModelProperty("供应商id")
+    private Long supplierId;
+
+    @ApiModelProperty("商品条码")
+    private String barCode;
+
+    @ApiModelProperty("批次号")
+    private String batchNumber;
+
+    @ApiModelProperty("库存")
+    private BigDecimal inventory;
+
+    @ApiModelProperty("仓库id")
     private Long depotId;
     private Long depotId;
 
 
+    @ApiModelProperty("仓位货架")
+    private String position;
+
+
     /**
     /**
      * 换算为大单位的库存
      * 换算为大单位的库存
      */
      */
@@ -220,13 +251,13 @@ public class MaterialVo4Unit extends Material{
         this.sku = sku;
         this.sku = sku;
     }
     }
 
 
-    public Long getDepotId() {
-        return depotId;
-    }
-
-    public void setDepotId(Long depotId) {
-        this.depotId = depotId;
-    }
+//    public Long getDepotId() {
+//        return depotId;
+//    }
+//
+//    public void setDepotId(Long depotId) {
+//        this.depotId = depotId;
+//    }
 
 
     public String getBigUnitStock() {
     public String getBigUnitStock() {
         return bigUnitStock;
         return bigUnitStock;

+ 156 - 28
src/main/java/com/jsh/erp/service/MaterialExtendService.java

@@ -13,6 +13,8 @@ import com.jsh.erp.datasource.mappers.MaterialExtendMapperEx;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
 import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.exception.JshException;
+import com.jsh.erp.utils.DateUtils;
+import com.jsh.erp.utils.RandomHelper;
 import com.jsh.erp.utils.StringUtil;
 import com.jsh.erp.utils.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
@@ -50,6 +52,11 @@ public class MaterialExtendService {
         }
         }
         return result;
         return result;
     }
     }
+
+    /**
+     * 根据产品id查询产品价格拓展信息
+     * @param materialId 产品id
+     */
     public List<MaterialExtendVo4List> getDetailList(Long materialId) {
     public List<MaterialExtendVo4List> getDetailList(Long materialId) {
         List<MaterialExtendVo4List> list=null;
         List<MaterialExtendVo4List> list=null;
         try{
         try{
@@ -73,14 +80,26 @@ public class MaterialExtendService {
         return meList;
         return meList;
     }
     }
 
 
+    /**
+     * 保存产品拓展记录
+     * @param obj
+     * @param sortList
+     * @param materialId
+     * @param type
+     * @return
+     * @throws Exception
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public String saveDetials(JSONObject obj, String sortList, Long materialId, String type) throws Exception {
     public String saveDetials(JSONObject obj, String sortList, Long materialId, String type) throws Exception {
         HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
         HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
+        //获取商品拓展行参数集合
         JSONArray meArr = obj.getJSONArray("meList");
         JSONArray meArr = obj.getJSONArray("meList");
+        //添加商品拓展集合
         JSONArray insertedJson = new JSONArray();
         JSONArray insertedJson = new JSONArray();
         JSONArray updatedJson = new JSONArray();
         JSONArray updatedJson = new JSONArray();
         JSONArray deletedJson = obj.getJSONArray("meDeleteIdList");
         JSONArray deletedJson = obj.getJSONArray("meDeleteIdList");
         JSONArray sortJson = JSONArray.parseArray(sortList);
         JSONArray sortJson = JSONArray.parseArray(sortList);
+        //添加/修改行数据处理
         if (null != meArr) {
         if (null != meArr) {
             if("insert".equals(type)){
             if("insert".equals(type)){
                 for (int i = 0; i < meArr.size(); i++) {
                 for (int i = 0; i < meArr.size(); i++) {
@@ -92,6 +111,7 @@ public class MaterialExtendService {
                     JSONObject tempJson = meArr.getJSONObject(i);
                     JSONObject tempJson = meArr.getJSONObject(i);
                     String tempId = tempJson.getString("id");
                     String tempId = tempJson.getString("id");
                     if(tempId.length()>19){
                     if(tempId.length()>19){
+                        //id长度大于19,属于新增数据
                         insertedJson.add(tempJson);
                         insertedJson.add(tempJson);
                     } else {
                     } else {
                         updatedJson.add(tempJson);
                         updatedJson.add(tempJson);
@@ -99,6 +119,7 @@ public class MaterialExtendService {
                 }
                 }
             }
             }
         }
         }
+        //删除行数据处理
         if (null != deletedJson) {
         if (null != deletedJson) {
             StringBuffer bf=new StringBuffer();
             StringBuffer bf=new StringBuffer();
             for (int i = 0; i < deletedJson.size(); i++) {
             for (int i = 0; i < deletedJson.size(); i++) {
@@ -107,47 +128,93 @@ public class MaterialExtendService {
                     bf.append(",");
                     bf.append(",");
                 }
                 }
             }
             }
+            //删除拓展行
             this.batchDeleteMaterialExtendByIds(bf.toString(), request);
             this.batchDeleteMaterialExtendByIds(bf.toString(), request);
         }
         }
+
+        //添加拓展行
         if (null != insertedJson) {
         if (null != insertedJson) {
             for (int i = 0; i < insertedJson.size(); i++) {
             for (int i = 0; i < insertedJson.size(); i++) {
+                //商品拓展
                 MaterialExtend materialExtend = new MaterialExtend();
                 MaterialExtend materialExtend = new MaterialExtend();
                 JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
                 JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
+                //设置商品id
                 materialExtend.setMaterialId(materialId);
                 materialExtend.setMaterialId(materialId);
-                if (StringUtils.isNotEmpty(tempInsertedJson.getString("barCode"))) {
-                    int exist = checkIsBarCodeExist(0L, tempInsertedJson.getString("barCode"));
-                    if(exist>0) {
-                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_EXISTS_CODE,
-                                String.format(ExceptionConstants.MATERIAL_BARCODE_EXISTS_MSG,tempInsertedJson.getString("barCode")));
-                    } else {
-                        materialExtend.setBarCode(tempInsertedJson.getString("barCode"));
-                    }
-                }
+                //设置条形码
+//                if (StringUtils.isNotEmpty(tempInsertedJson.getString("barCode"))) {
+//                    int exist = checkIsBarCodeExist(0L, tempInsertedJson.getString("barCode"));
+//                    if(exist>0) {
+//                        throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_BARCODE_EXISTS_CODE,
+//                                String.format(ExceptionConstants.MATERIAL_BARCODE_EXISTS_MSG,tempInsertedJson.getString("barCode")));
+//                    } else {
+//                        materialExtend.setBarCode(tempInsertedJson.getString("barCode"));
+//                    }
+//                }
+                //设置商品单位
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("commodityUnit"))) {
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("commodityUnit"))) {
                     materialExtend.setCommodityUnit(tempInsertedJson.getString("commodityUnit"));
                     materialExtend.setCommodityUnit(tempInsertedJson.getString("commodityUnit"));
                 }
                 }
+                //设置商品属性
                 if (tempInsertedJson.get("sku")!=null) {
                 if (tempInsertedJson.get("sku")!=null) {
                     materialExtend.setSku(tempInsertedJson.getString("sku"));
                     materialExtend.setSku(tempInsertedJson.getString("sku"));
                 }
                 }
+                //设置采购价格
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("purchaseDecimal"))) {
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("purchaseDecimal"))) {
                     materialExtend.setPurchaseDecimal(tempInsertedJson.getBigDecimal("purchaseDecimal"));
                     materialExtend.setPurchaseDecimal(tempInsertedJson.getBigDecimal("purchaseDecimal"));
                 }
                 }
+                //设置零售价格
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("commodityDecimal"))) {
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("commodityDecimal"))) {
                     materialExtend.setCommodityDecimal(tempInsertedJson.getBigDecimal("commodityDecimal"));
                     materialExtend.setCommodityDecimal(tempInsertedJson.getBigDecimal("commodityDecimal"));
                 }
                 }
+                //设置销售价格
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("wholesaleDecimal"))) {
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("wholesaleDecimal"))) {
                     materialExtend.setWholesaleDecimal(tempInsertedJson.getBigDecimal("wholesaleDecimal"));
                     materialExtend.setWholesaleDecimal(tempInsertedJson.getBigDecimal("wholesaleDecimal"));
                 }
                 }
+                //设置最低售价
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("lowDecimal"))) {
                 if (StringUtils.isNotEmpty(tempInsertedJson.getString("lowDecimal"))) {
                     materialExtend.setLowDecimal(tempInsertedJson.getBigDecimal("lowDecimal"));
                     materialExtend.setLowDecimal(tempInsertedJson.getBigDecimal("lowDecimal"));
                 }
                 }
+                //设置生产日期
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("productionDate"))) {
+                    materialExtend.setProductionDate(tempInsertedJson.getDate("productionDate"));
+                }
+                //设置保质期天数
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("expiryNum"))) {
+                    materialExtend.setExpiryNum(tempInsertedJson.getInteger("expiryNum"));
+                }
+                //设置供应商id
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("supplierId"))) {
+                    materialExtend.setSupplierId(tempInsertedJson.getLong("supplierId"));
+                }
+                //设置商品条码
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("barCode"))) {
+                    materialExtend.setBarCode(tempInsertedJson.getString("barCode"));
+                }
+                //设置批次号
+                String batchNumber = DateUtils.dateTimeNow("yyyyMMdd") + RandomHelper.getRandomStr(6);
+                materialExtend.setBatchNumber(batchNumber);
+                //设置库存
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("inventory"))) {
+                    materialExtend.setInventory(tempInsertedJson.getBigDecimal("inventory"));
+                }
+                //设置仓库id
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("depotId"))) {
+                    materialExtend.setDepotId(tempInsertedJson.getLong("depotId"));
+                }
+                //设置仓位货架
+                if (StringUtils.isNotEmpty(tempInsertedJson.getString("position"))) {
+                    materialExtend.setPosition(tempInsertedJson.getString("position"));
+                }
+                //添加数据
                 this.insertMaterialExtend(materialExtend);
                 this.insertMaterialExtend(materialExtend);
             }
             }
         }
         }
+        //修改拓展行
         if (null != updatedJson) {
         if (null != updatedJson) {
             for (int i = 0; i < updatedJson.size(); i++) {
             for (int i = 0; i < updatedJson.size(); i++) {
                 JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
                 JSONObject tempUpdatedJson = JSONObject.parseObject(updatedJson.getString(i));
                 MaterialExtend materialExtend = new MaterialExtend();
                 MaterialExtend materialExtend = new MaterialExtend();
+                //设置id
                 materialExtend.setId(tempUpdatedJson.getLong("id"));
                 materialExtend.setId(tempUpdatedJson.getLong("id"));
                 if (StringUtils.isNotEmpty(tempUpdatedJson.getString("barCode"))) {
                 if (StringUtils.isNotEmpty(tempUpdatedJson.getString("barCode"))) {
                     int exist = checkIsBarCodeExist(tempUpdatedJson.getLong("id"), tempUpdatedJson.getString("barCode"));
                     int exist = checkIsBarCodeExist(tempUpdatedJson.getLong("id"), tempUpdatedJson.getString("barCode"));
@@ -158,24 +225,9 @@ public class MaterialExtendService {
                         materialExtend.setBarCode(tempUpdatedJson.getString("barCode"));
                         materialExtend.setBarCode(tempUpdatedJson.getString("barCode"));
                     }
                     }
                 }
                 }
-                if (StringUtils.isNotEmpty(tempUpdatedJson.getString("commodityUnit"))) {
-                    materialExtend.setCommodityUnit(tempUpdatedJson.getString("commodityUnit"));
-                }
-                if (tempUpdatedJson.get("sku")!=null) {
-                    materialExtend.setSku(tempUpdatedJson.getString("sku"));
-                }
-                if (StringUtils.isNotEmpty(tempUpdatedJson.getString("purchaseDecimal"))) {
-                    materialExtend.setPurchaseDecimal(tempUpdatedJson.getBigDecimal("purchaseDecimal"));
-                }
-                if (StringUtils.isNotEmpty(tempUpdatedJson.getString("commodityDecimal"))) {
-                    materialExtend.setCommodityDecimal(tempUpdatedJson.getBigDecimal("commodityDecimal"));
-                }
-                if (StringUtils.isNotEmpty(tempUpdatedJson.getString("wholesaleDecimal"))) {
-                    materialExtend.setWholesaleDecimal(tempUpdatedJson.getBigDecimal("wholesaleDecimal"));
-                }
-                if (StringUtils.isNotEmpty(tempUpdatedJson.getString("lowDecimal"))) {
-                    materialExtend.setLowDecimal(tempUpdatedJson.getBigDecimal("lowDecimal"));
-                }
+                //Json里的数据赋值到对象
+                this.setMaterialExtend(tempUpdatedJson,materialExtend);
+                //修改商品拓展
                 this.updateMaterialExtend(materialExtend);
                 this.updateMaterialExtend(materialExtend);
                 //如果金额为空,此处单独置空
                 //如果金额为空,此处单独置空
                 materialExtendMapperEx.specialUpdatePrice(materialExtend);
                 materialExtendMapperEx.specialUpdatePrice(materialExtend);
@@ -216,6 +268,10 @@ public class MaterialExtendService {
         return null;
         return null;
     }
     }
 
 
+    /**
+     * 添加商品拓展
+     * @param materialExtend 商品拓展
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int insertMaterialExtend(MaterialExtend materialExtend)throws Exception {
     public int insertMaterialExtend(MaterialExtend materialExtend)throws Exception {
         User user = userService.getCurrentUser();
         User user = userService.getCurrentUser();
@@ -224,7 +280,7 @@ public class MaterialExtendService {
         materialExtend.setUpdateTime(new Date().getTime());
         materialExtend.setUpdateTime(new Date().getTime());
         materialExtend.setCreateSerial(user.getLoginName());
         materialExtend.setCreateSerial(user.getLoginName());
         materialExtend.setUpdateSerial(user.getLoginName());
         materialExtend.setUpdateSerial(user.getLoginName());
-        int result =0;
+        int result = 0;
         try{
         try{
             result= materialExtendMapper.insertSelective(materialExtend);
             result= materialExtendMapper.insertSelective(materialExtend);
         }catch(Exception e){
         }catch(Exception e){
@@ -233,6 +289,10 @@ public class MaterialExtendService {
         return result;
         return result;
     }
     }
 
 
+    /**
+     * 修改商品拓展
+     * @param materialExtend 商品拓展
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int updateMaterialExtend(MaterialExtend materialExtend) throws Exception{
     public int updateMaterialExtend(MaterialExtend materialExtend) throws Exception{
         User user = userService.getCurrentUser();
         User user = userService.getCurrentUser();
@@ -283,6 +343,11 @@ public class MaterialExtendService {
         return result;
         return result;
     }
     }
 
 
+    /**
+     * 删除商品拓展行
+     * @param ids 拓展行id集合
+     * @param request
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int batchDeleteMaterialExtendByIds(String ids, HttpServletRequest request) throws Exception{
     public int batchDeleteMaterialExtendByIds(String ids, HttpServletRequest request) throws Exception{
         String [] idArray=ids.split(",");
         String [] idArray=ids.split(",");
@@ -403,4 +468,67 @@ public class MaterialExtendService {
         }
         }
         return 0;
         return 0;
     }
     }
+
+    /**
+     * 将Json对象的数据赋值到商品拓展对象中
+     * @param tempJson
+     * @param materialExtend
+     */
+    private void setMaterialExtend(JSONObject tempJson, MaterialExtend materialExtend){
+        //设置商品单位
+        if (StringUtils.isNotEmpty(tempJson.getString("commodityUnit"))) {
+            materialExtend.setCommodityUnit(tempJson.getString("commodityUnit"));
+        }
+        //设置商品属性
+        if (tempJson.get("sku")!=null) {
+            materialExtend.setSku(tempJson.getString("sku"));
+        }
+        //设置采购价格
+        if (StringUtils.isNotEmpty(tempJson.getString("purchaseDecimal"))) {
+            materialExtend.setPurchaseDecimal(tempJson.getBigDecimal("purchaseDecimal"));
+        }
+        //设置零售价格
+        if (StringUtils.isNotEmpty(tempJson.getString("commodityDecimal"))) {
+            materialExtend.setCommodityDecimal(tempJson.getBigDecimal("commodityDecimal"));
+        }
+        //设置销售价格
+        if (StringUtils.isNotEmpty(tempJson.getString("wholesaleDecimal"))) {
+            materialExtend.setWholesaleDecimal(tempJson.getBigDecimal("wholesaleDecimal"));
+        }
+        //设置最低售价
+        if (StringUtils.isNotEmpty(tempJson.getString("lowDecimal"))) {
+            materialExtend.setLowDecimal(tempJson.getBigDecimal("lowDecimal"));
+        }
+        //设置生产日期
+        if (StringUtils.isNotEmpty(tempJson.getString("productionDate"))) {
+            materialExtend.setProductionDate(tempJson.getDate("productionDate"));
+        }
+        //设置保质期天数
+        if (StringUtils.isNotEmpty(tempJson.getString("expiryNum"))) {
+            materialExtend.setExpiryNum(tempJson.getInteger("expiryNum"));
+        }
+        //设置供应商id
+        if (StringUtils.isNotEmpty(tempJson.getString("supplierId"))) {
+            materialExtend.setSupplierId(tempJson.getLong("supplierId"));
+        }
+        //设置商品条码
+        if (StringUtils.isNotEmpty(tempJson.getString("barCode"))) {
+            materialExtend.setBarCode(tempJson.getString("barCode"));
+        }
+        //设置批次号
+        String batchNumber = DateUtils.dateTimeNow("yyyyMMdd") + RandomHelper.getRandomStr(6);
+        materialExtend.setBatchNumber(batchNumber);
+        //设置库存
+        if (StringUtils.isNotEmpty(tempJson.getString("inventory"))) {
+            materialExtend.setInventory(tempJson.getBigDecimal("inventory"));
+        }
+        //设置仓库id
+        if (StringUtils.isNotEmpty(tempJson.getString("depotId"))) {
+            materialExtend.setDepotId(tempJson.getLong("depotId"));
+        }
+        //设置仓位货架
+        if (StringUtils.isNotEmpty(tempJson.getString("position"))) {
+            materialExtend.setPosition(tempJson.getString("position"));
+        }
+    }
 }
 }

+ 109 - 35
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.*;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.exception.JshException;
+import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.utils.*;
 import com.jsh.erp.utils.*;
 import jxl.Sheet;
 import jxl.Sheet;
 import jxl.Workbook;
 import jxl.Workbook;
@@ -108,6 +109,10 @@ public class MaterialService {
         return list;
         return list;
     }
     }
 
 
+
+    /**
+     * 查询商品管理-商品信息列表查询
+     */
     public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
     public List<MaterialVo4Unit> select(String materialParam, String standard, String model, String color, String brand, String mfrs,
                                         String materialOther, String weight, String expiryNum, String enableSerialNumber,
                                         String materialOther, String weight, String expiryNum, String enableSerialNumber,
                                         String enableBatchNumber, String position, String enabled, String remark, String categoryId,
                                         String enableBatchNumber, String position, String enabled, String remark, String categoryId,
@@ -147,14 +152,29 @@ public class MaterialService {
         return list;
         return list;
     }
     }
 
 
+    /**
+     * 新增商品信息
+     * @param obj
+     * @param request
+     * @return
+     * @throws Exception
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int insertMaterial(JSONObject obj, HttpServletRequest request)throws Exception {
     public int insertMaterial(JSONObject obj, HttpServletRequest request)throws Exception {
         Material m = JSONObject.parseObject(obj.toJSONString(), Material.class);
         Material m = JSONObject.parseObject(obj.toJSONString(), Material.class);
         m.setEnabled(true);
         m.setEnabled(true);
+        //获取类型编码
+        String serial_no = materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
+        String sku = serial_no + DateUtils.dateTimeNow();
+        //设置系统sku
+        m.setSystemSku(sku);
         try{
         try{
+            //添加商品
             materialMapperEx.insertSelectiveEx(m);
             materialMapperEx.insertSelectiveEx(m);
             Long mId = m.getId();
             Long mId = m.getId();
+            //添加商品拓展记录
             materialExtendService.saveDetials(obj, obj.getString("sortList"), mId, "insert");
             materialExtendService.saveDetials(obj, obj.getString("sortList"), mId, "insert");
+            //初始库存
             if(obj.get("stock")!=null) {
             if(obj.get("stock")!=null) {
                 JSONArray stockArr = obj.getJSONArray("stock");
                 JSONArray stockArr = obj.getJSONArray("stock");
                 for (int i = 0; i < stockArr.size(); i++) {
                 for (int i = 0; i < stockArr.size(); i++) {
@@ -171,7 +191,9 @@ public class MaterialService {
                         }
                         }
                         Long depotId = jsonObj.getLong("id");
                         Long depotId = jsonObj.getLong("id");
                         if(StringUtil.isNotEmpty(number) && Double.parseDouble(number)>0 || lowSafeStock!=null || highSafeStock!=null) {
                         if(StringUtil.isNotEmpty(number) && Double.parseDouble(number)>0 || lowSafeStock!=null || highSafeStock!=null) {
+                            //设置初始库
                             insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
                             insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
+                            //设置当前库
                             insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
                             insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
                         }
                         }
                     }
                     }
@@ -190,17 +212,24 @@ public class MaterialService {
         }
         }
     }
     }
 
 
+    /**
+     * 修改商品
+     * @param obj
+     * @param request
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
     public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
         Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
         Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
         try{
         try{
+            //修改商品属性
             materialMapper.updateByPrimaryKeySelective(material);
             materialMapper.updateByPrimaryKeySelective(material);
+            //
             if(material.getUnitId() == null) {
             if(material.getUnitId() == null) {
                 materialMapperEx.setUnitIdToNull(material.getId());
                 materialMapperEx.setUnitIdToNull(material.getId());
             }
             }
-            if(material.getExpiryNum() == null) {
-                materialMapperEx.setExpiryNumToNull(material.getId());
-            }
+//            if(material.getExpiryNum() == null) {
+//                materialMapperEx.setExpiryNumToNull(material.getId());
+//            }
             materialExtendService.saveDetials(obj, obj.getString("sortList"),material.getId(), "update");
             materialExtendService.saveDetials(obj, obj.getString("sortList"),material.getId(), "update");
             if(obj.get("stock")!=null) {
             if(obj.get("stock")!=null) {
                 JSONArray stockArr = obj.getJSONArray("stock");
                 JSONArray stockArr = obj.getJSONArray("stock");
@@ -364,6 +393,11 @@ public class MaterialService {
         return list;
         return list;
     }
     }
 
 
+    /**
+     * 根据商品类型id获取子类型id集合
+     * @param parentId 商品类型父id
+     * @return
+     */
     public List<Long> getListByParentId(Long parentId) {
     public List<Long> getListByParentId(Long parentId) {
         List<Long> idList = new ArrayList<Long>();
         List<Long> idList = new ArrayList<Long>();
         List<MaterialCategory> list = materialCategoryMapperEx.getListByParentId(parentId);
         List<MaterialCategory> list = materialCategoryMapperEx.getListByParentId(parentId);
@@ -460,9 +494,25 @@ public class MaterialService {
         return result;
         return result;
     }
     }
 
 
+    /**
+     * 导出商品信息
+     * @param categoryId
+     * @param materialParam
+     * @param color
+     * @param materialOther
+     * @param weight
+     * @param expiryNum
+     * @param enabled
+     * @param enableSerialNumber
+     * @param enableBatchNumber
+     * @param remark
+     * @param response
+     * @throws Exception
+     */
     public void exportExcel(String categoryId, String materialParam, String color, String materialOther, String weight,
     public void exportExcel(String categoryId, String materialParam, String color, String materialOther, String weight,
                                              String expiryNum, String enabled, String enableSerialNumber, String enableBatchNumber,
                                              String expiryNum, String enabled, String enableSerialNumber, String enableBatchNumber,
                                              String remark, HttpServletResponse response)throws Exception {
                                              String remark, HttpServletResponse response)throws Exception {
+        //查询类型子集合id
         List<Long> idList = new ArrayList<>();
         List<Long> idList = new ArrayList<>();
         if(StringUtil.isNotEmpty(categoryId)){
         if(StringUtil.isNotEmpty(categoryId)){
             idList = getListByParentId(Long.parseLong(categoryId));
             idList = getListByParentId(Long.parseLong(categoryId));
@@ -477,8 +527,8 @@ public class MaterialService {
             //遇到多个副条码的情况,只加第一个
             //遇到多个副条码的情况,只加第一个
             otherMaterialMap.putIfAbsent(me.getMaterialId(), me);
             otherMaterialMap.putIfAbsent(me.getMaterialId(), me);
         }
         }
-        String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),保质期(天),基本单位*,副单位,基本条码*,副条码,比例,多属性," +
-                "采购价,零售价,销售价,最低售价,状态*,序列号,批号,仓位货架,制造商,自定义1,自定义2,自定义3,备注";
+        String nameStr = "名称*,规格,型号,颜色,品牌,类别,基础重量(kg),基本单位*,副单位,基本条码*,副条码,比例,多属性," +
+                "采购价,零售价,销售价,最低售价,状态*,序列号,批号,自定义1,自定义2,自定义3,备注,系统sku,生产日期,保质期,供应商,商品条码,批次号,仓库名称,仓位货架";
         List<String> nameList = StringUtil.strToStringList(nameStr);
         List<String> nameList = StringUtil.strToStringList(nameStr);
         //仓库列表
         //仓库列表
         List<Depot> depotList = depotService.getAllList();
         List<Depot> depotList = depotService.getAllList();
@@ -508,28 +558,33 @@ public class MaterialService {
                 objs[4] = m.getBrand();
                 objs[4] = m.getBrand();
                 objs[5] = m.getCategoryName();
                 objs[5] = m.getCategoryName();
                 objs[6] = m.getWeight() == null ? "" : m.getWeight().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
                 objs[6] = m.getWeight() == null ? "" : m.getWeight().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
-                objs[7] = m.getExpiryNum() == null ? "" : m.getExpiryNum().toString();
-                objs[8] = m.getCommodityUnit();
-                objs[9] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getCommodityUnit();
-                objs[10] = m.getmBarCode();
-                objs[11] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getBarCode();
-                objs[12] = m.getRatio() == null ? "" : m.getRatio().toString();
-                objs[13] = m.getSku();
-                objs[14] = m.getPurchaseDecimal() == null ? "" : m.getPurchaseDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
-                objs[15] = m.getCommodityDecimal() == null ? "" : m.getCommodityDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
-                objs[16] = m.getWholesaleDecimal() == null ? "" : m.getWholesaleDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
-                objs[17] = m.getLowDecimal() == null ? "" : m.getLowDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
-                objs[18] = m.getEnabled() ? "1" : "0";
-                objs[19] = m.getEnableSerialNumber();
-                objs[20] = m.getEnableBatchNumber();
-                objs[21] = m.getPosition();
-                objs[22] = m.getMfrs();
-                objs[23] = m.getOtherField1();
-                objs[24] = m.getOtherField2();
-                objs[25] = m.getOtherField3();
-                objs[26] = m.getRemark();
+                objs[7] = m.getCommodityUnit();
+                objs[8] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getCommodityUnit();
+                objs[9] = m.getmBarCode();
+                objs[10] = otherMaterialMap.get(m.getId()) == null ? "" : otherMaterialMap.get(m.getId()).getBarCode();
+                objs[11] = m.getRatio() == null ? "" : m.getRatio().toString();
+                objs[12] = m.getSku();
+                objs[13] = m.getPurchaseDecimal() == null ? "" : m.getPurchaseDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
+                objs[14] = m.getCommodityDecimal() == null ? "" : m.getCommodityDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
+                objs[15] = m.getWholesaleDecimal() == null ? "" : m.getWholesaleDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
+                objs[16] = m.getLowDecimal() == null ? "" : m.getLowDecimal().setScale(3, BigDecimal.ROUND_HALF_UP).toString();
+                objs[17] = m.getEnabled() ? "1" : "0";
+                objs[18] = m.getEnableSerialNumber();
+                objs[19] = m.getEnableBatchNumber();
+                objs[20] = m.getOtherField1();
+                objs[21] = m.getOtherField2();
+                objs[22] = m.getOtherField3();
+                objs[23] = m.getRemark();
+                objs[24] = m.getSystemSku();
+                objs[25] = m.getProductionDate() == null ? "" : m.getProductionDate().toString();
+                objs[26] = m.getExpiryNum() == null ? "" : m.getExpiryNum().toString();
+                objs[27] = m.getSupplierId() == null ? "" : m.getSupplierId().toString();
+                objs[28] = m.getBarCode();
+                objs[29] = m.getBatchNumber();
+                objs[30] = m.getDepotId() == null ? "" : m.getDepotId().toString();
+                objs[31] = m.getPosition();
                 //仓库期初库存
                 //仓库期初库存
-                int i = 27;
+                int i = 32;
                 for(Depot depot: depotList) {
                 for(Depot depot: depotList) {
                     BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
                     BigDecimal number = misMap.get(m.getId() + "_" + depot.getId());
                     objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
                     objs[i] = number == null ? "0" : number.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
@@ -542,6 +597,13 @@ public class MaterialService {
         ExcelUtils.downloadExcel(file, file.getName(), response);
         ExcelUtils.downloadExcel(file, file.getName(), response);
     }
     }
 
 
+    /**
+     * 导入商品信息
+     * @param file
+     * @param request
+     * @return
+     * @throws Exception
+     */
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public BaseResponseInfo importExcel(MultipartFile file, HttpServletRequest request) throws Exception {
     public BaseResponseInfo importExcel(MultipartFile file, HttpServletRequest request) throws Exception {
         BaseResponseInfo info = new BaseResponseInfo();
         BaseResponseInfo info = new BaseResponseInfo();
@@ -605,6 +667,11 @@ public class MaterialService {
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
                     throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_UNIT_EMPTY_CODE,
                             String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
                             String.format(ExceptionConstants.MATERIAL_UNIT_EMPTY_MSG, i+1));
                 }
                 }
+                //列别为空
+                if(StringUtil.isEmpty(categoryName)) {
+                    throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_Category_Name_EMPTY_CODE,
+                            String.format(ExceptionConstants.MATERIAL_Category_Name_EMPTY_MSG, i+1));
+                }
                 MaterialWithInitStock m = new MaterialWithInitStock();
                 MaterialWithInitStock m = new MaterialWithInitStock();
                 m.setName(name);
                 m.setName(name);
                 m.setStandard(standard);
                 m.setStandard(standard);
@@ -614,6 +681,10 @@ public class MaterialService {
                 //通过名称生成助记码
                 //通过名称生成助记码
                 m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
                 m.setMnemonic(PinYinUtil.getFirstLettersLo(name));
                 Long categoryId = materialCategoryService.getCategoryIdByName(categoryName);
                 Long categoryId = materialCategoryService.getCategoryIdByName(categoryName);
+                //获取类型编码
+                String serial_no = categoryId == null ? null : materialCategoryService.getMaterialCategory(m.getCategoryId()).getSerialNo();
+                //设置系统sku
+                m.setSystemSku(serial_no + DateUtils.dateTimeNow());
                 if(null!=categoryId){
                 if(null!=categoryId){
                     m.setCategoryId(categoryId);
                     m.setCategoryId(categoryId);
                 }
                 }
@@ -631,7 +702,7 @@ public class MaterialService {
                         throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
                         throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_CODE,
                                 String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
                                 String.format(ExceptionConstants.MATERIAL_EXPIRY_NUM_NOT_INTEGER_MSG, i+1));
                     }
                     }
-                    m.setExpiryNum(Integer.parseInt(expiryNum));
+                    //m.setExpiryNum(Integer.parseInt(expiryNum));
                 }
                 }
                 String manyUnit = ExcelUtils.getContent(src, i, 9); //副单位
                 String manyUnit = ExcelUtils.getContent(src, i, 9); //副单位
                 String barCode = ExcelUtils.getContent(src, i, 10); //基础条码
                 String barCode = ExcelUtils.getContent(src, i, 10); //基础条码
@@ -651,8 +722,8 @@ public class MaterialService {
                 String otherField2 = ExcelUtils.getContent(src, i, 24); //自定义2
                 String otherField2 = ExcelUtils.getContent(src, i, 24); //自定义2
                 String otherField3 = ExcelUtils.getContent(src, i, 25); //自定义3
                 String otherField3 = ExcelUtils.getContent(src, i, 25); //自定义3
                 String remark = ExcelUtils.getContent(src, i, 26); //备注
                 String remark = ExcelUtils.getContent(src, i, 26); //备注
-                m.setPosition(StringUtil.isNotEmpty(position)?position:null);
-                m.setMfrs(StringUtil.isNotEmpty(mfrs)?mfrs:null);
+               // m.setPosition(StringUtil.isNotEmpty(position)?position:null);
+                //m.setMfrs(StringUtil.isNotEmpty(mfrs)?mfrs:null);
                 m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
                 m.setOtherField1(StringUtil.isNotEmpty(otherField1)?otherField1:null);
                 m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
                 m.setOtherField2(StringUtil.isNotEmpty(otherField2)?otherField2:null);
                 m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
                 m.setOtherField3(StringUtil.isNotEmpty(otherField3)?otherField3:null);
@@ -681,6 +752,7 @@ public class MaterialService {
                 batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
                 batchCheckExistMaterialListByParam(mList, name, standard, model, color, unit, sku);
                 //批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
                 //批量校验excel中有无重复条码(1-文档自身校验,2-和数据库里面的商品校验)
                 batchCheckExistBarCodeByParam(mList, barCode, manyBarCode);
                 batchCheckExistBarCodeByParam(mList, barCode, manyBarCode);
+                //设置商品拓展属性
                 JSONObject materialExObj = new JSONObject();
                 JSONObject materialExObj = new JSONObject();
                 JSONObject basicObj = new JSONObject();
                 JSONObject basicObj = new JSONObject();
                 basicObj.put("barCode", barCode);
                 basicObj.put("barCode", barCode);
@@ -747,11 +819,12 @@ public class MaterialService {
                 Long mId = 0L;
                 Long mId = 0L;
                 //判断该商品是否存在,如果不存在就新增,如果存在就更新
                 //判断该商品是否存在,如果不存在就新增,如果存在就更新
                 String basicBarCode = getBasicBarCode(m);
                 String basicBarCode = getBasicBarCode(m);
+                //根据条件返回产品列表
                 List<Material> materials = getMaterialListByParam(m.getName(),m.getStandard(),m.getModel(),m.getColor(),m.getUnit(),m.getUnitId(), basicBarCode);
                 List<Material> materials = getMaterialListByParam(m.getName(),m.getStandard(),m.getModel(),m.getColor(),m.getUnit(),m.getUnitId(), basicBarCode);
-                if(materials.size() == 0) {
+                if(materials.size() == 0) { //产品列表为0,新增商品
                     materialMapperEx.insertSelectiveEx(m);
                     materialMapperEx.insertSelectiveEx(m);
                     mId = m.getId();
                     mId = m.getId();
-                } else {
+                } else { //产品列表不为0,商品存在,修改商品属性
                     mId = materials.get(0).getId();
                     mId = materials.get(0).getId();
                     String materialJson = JSON.toJSONString(m);
                     String materialJson = JSON.toJSONString(m);
                     Material material = JSONObject.parseObject(materialJson, Material.class);
                     Material material = JSONObject.parseObject(materialJson, Material.class);
@@ -762,9 +835,9 @@ public class MaterialService {
                         materialMapperEx.setUnitIdToNull(material.getId());
                         materialMapperEx.setUnitIdToNull(material.getId());
                     }
                     }
                     //如果之前有保质期,则更新保质期
                     //如果之前有保质期,则更新保质期
-                    if(materials.get(0).getExpiryNum()!=null && material.getExpiryNum() == null) {
-                        materialMapperEx.setExpiryNumToNull(material.getId());
-                    }
+//                    if(materials.get(0).getExpiryNum()!=null && material.getExpiryNum() == null) {
+//                        materialMapperEx.setExpiryNumToNull(material.getId());
+//                    }
                 }
                 }
                 //给商品新增或更新条码与价格相关信息
                 //给商品新增或更新条码与价格相关信息
                 JSONObject materialExObj = m.getMaterialExObj();
                 JSONObject materialExObj = m.getMaterialExObj();
@@ -822,6 +895,7 @@ public class MaterialService {
                 batchDeleteCurrentStockByMaterialList(deleteCurrentStockMaterialIdList);
                 batchDeleteCurrentStockByMaterialList(deleteCurrentStockMaterialIdList);
                 materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList);
                 materialCurrentStockMapperEx.batchInsert(insertCurrentStockMaterialList);
             }
             }
+            //添加日志
             logService.insertLog("商品",
             logService.insertLog("商品",
                     new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
                     new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_IMPORT).append(mList.size()).append(BusinessConstants.LOG_DATA_UNIT).toString(),
                     ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
                     ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -980,7 +1054,6 @@ public class MaterialService {
             }
             }
         }
         }
     }
     }
-
     /**
     /**
      * 给商品新增或更新条码与价格相关信息
      * 给商品新增或更新条码与价格相关信息
      * @param materialExObj
      * @param materialExObj
@@ -992,6 +1065,7 @@ public class MaterialService {
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public void insertOrUpdateMaterialExtend(JSONObject materialExObj, String type, String defaultFlag, Long mId, User user) throws Exception {
     public void insertOrUpdateMaterialExtend(JSONObject materialExObj, String type, String defaultFlag, Long mId, User user) throws Exception {
         if(StringUtil.isExist(materialExObj.get(type))){
         if(StringUtil.isExist(materialExObj.get(type))){
+            //获取对应的商品拓展字符
             String basicStr = materialExObj.getString(type);
             String basicStr = materialExObj.getString(type);
             MaterialExtend materialExtend = JSONObject.parseObject(basicStr, MaterialExtend.class);
             MaterialExtend materialExtend = JSONObject.parseObject(basicStr, MaterialExtend.class);
             materialExtend.setMaterialId(mId);
             materialExtend.setMaterialId(mId);

+ 322 - 0
src/main/java/com/jsh/erp/utils/DateUtils.java

@@ -0,0 +1,322 @@
+package com.jsh.erp.utils;
+
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import java.lang.management.ManagementFactory;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * 时间工具类
+ * 
+ * @author ruoyi
+ */
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils
+{
+    public static String YYYY = "yyyy";
+
+    public static String YYYY_MM = "yyyy-MM";
+
+    public static String YYYY_MM_DD = "yyyy-MM-dd";
+
+    public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+
+    public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+
+    private static String[] parsePatterns = {
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+            "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
+            "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+
+    /**
+     * 获取当前Date型日期
+     * 
+     * @return Date() 当前日期
+     */
+    public static Date getNowDate()
+    {
+        return new Date();
+    }
+
+    /**
+     * 获取当前日期, 默认格式为yyyy-MM-dd
+     * 
+     * @return String
+     */
+    public static String getDate()
+    {
+        return dateTimeNow(YYYY_MM_DD);
+    }
+
+    public static final String getTime()
+    {
+        return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
+    }
+
+    public static final String dateTimeNow()
+    {
+        return dateTimeNow(YYYYMMDDHHMMSS);
+    }
+
+    public static final String dateTimeNow(final String format)
+    {
+        return parseDateToStr(format, new Date());
+    }
+
+    public static final String dateTime(final Date date)
+    {
+        return parseDateToStr(YYYY_MM_DD, date);
+    }
+
+    public static final String parseDateToStr(final String format, final Date date)
+    {
+        return new SimpleDateFormat(format).format(date);
+    }
+
+    public static final Date dateTime(final String format, final String ts)
+    {
+        try
+        {
+            return new SimpleDateFormat(format).parse(ts);
+        }
+        catch (ParseException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 日期路径 即年/月/日 如2018/08/08
+     */
+    public static final String datePath()
+    {
+        Date now = new Date();
+        return DateFormatUtils.format(now, "yyyy/MM/dd");
+    }
+
+    /**
+     * 日期路径 即年/月/日 如20180808
+     */
+    public static final String dateTime()
+    {
+        Date now = new Date();
+        return DateFormatUtils.format(now, "yyyyMMdd");
+    }
+
+    /**
+     * 日期型字符串转化为日期 格式
+     */
+    public static Date parseDate(Object str)
+    {
+        if (str == null)
+        {
+            return null;
+        }
+        try
+        {
+            return parseDate(str.toString(), parsePatterns);
+        }
+        catch (ParseException e)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * 获取服务器启动时间
+     */
+    public static Date getServerStartDate()
+    {
+        long time = ManagementFactory.getRuntimeMXBean().getStartTime();
+        return new Date(time);
+    }
+
+    /**
+     * 计算相差天数
+     */
+    public static int differentDaysByMillisecond(Date date1, Date date2)
+    {
+        return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
+    }
+
+    /**
+     * 计算时间差
+     *
+     * @param endDate 最后时间
+     * @param startTime 开始时间
+     * @return 时间差(天/小时/分钟)
+     */
+    public static String timeDistance(Date endDate, Date startTime)
+    {
+        long nd = 1000 * 24 * 60 * 60;
+        long nh = 1000 * 60 * 60;
+        long nm = 1000 * 60;
+        // long ns = 1000;
+        // 获得两个时间的毫秒时间差异
+        long diff = endDate.getTime() - startTime.getTime();
+        // 计算差多少天
+        long day = diff / nd;
+        // 计算差多少小时
+        long hour = diff % nd / nh;
+        // 计算差多少分钟
+        long min = diff % nd % nh / nm;
+        // 计算差多少秒//输出结果
+        // long sec = diff % nd % nh % nm / ns;
+        return day + "天" + hour + "小时" + min + "分钟";
+    }
+
+    /**
+     * 增加 LocalDateTime ==> Date
+     */
+    public static Date toDate(LocalDateTime temporalAccessor)
+    {
+        ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
+        return Date.from(zdt.toInstant());
+    }
+
+    /**
+     * 增加 LocalDate ==> Date
+     */
+    public static Date toDate(LocalDate temporalAccessor)
+    {
+        LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
+        ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
+        return Date.from(zdt.toInstant());
+    }
+
+    /**
+     * 增加 LocalDate ==> Date 获取最早时刻
+     * 
+     * @param temporalAccessor 日期
+     * @return 列如:2025-01-01T00:00
+     */
+    public static Date toDateMin(LocalDate temporalAccessor)
+    {
+        LocalDateTime localDateTime = temporalAccessor.atStartOfDay();
+        ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
+        return Date.from(zdt.toInstant());
+    }
+
+    /**
+     * 增加 LocalDate ==> Date 获取最晚时刻
+     * 
+     * @param temporalAccessor 日期
+     * @return 列如:2025-01-01T23:59:59
+     */
+    public static Date toDateMax(LocalDate temporalAccessor)
+    {
+        LocalDateTime localDateTime = temporalAccessor.atTime(LocalTime.MAX);
+        ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
+        return Date.from(zdt.toInstant());
+    }
+
+    /**
+     * 增加 Date ==> LocalDate
+     *
+     * @param date 日期
+     * @return
+     */
+    public static LocalDate toLocalDate(Date date)
+    {
+        if(!Optional.ofNullable(date).isPresent()){
+            return LocalDate.now();
+        }
+        return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+    }
+
+    /**
+     * 增加 LocalDate ==> String
+     *
+     * @param date 日期
+     * @param format 格式
+     * @return
+     */
+    public static String localDate2String(LocalDate date,final String format) {
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(format);
+        return date.format(fmt);
+    }
+
+
+    /**
+     * 当前日期前或者后多少天
+     * day 负数往历史日期,正数往未来
+     */
+    public static Date displacement(Integer day){
+        // 获取当前时间
+        Calendar calendar = Calendar.getInstance();
+        Date currentTime = new Date();
+        calendar.setTime(currentTime);
+        calendar.add(Calendar.DAY_OF_MONTH, day);
+        return calendar.getTime();
+    }
+
+    /**
+     * 根据当前的时间区间获取上一周期的时间区间
+     * @param beginTime 开始时间
+     * @param endTime 结束时间
+     * @return
+     */
+    public static String[] getFrontCycleDate(String beginTime, String endTime) {
+        //处理上一周期时间
+        LocalDate localDateBeginTime = LocalDate.parse(beginTime);
+        LocalDate localDateEndTime = LocalDate.parse(endTime);
+        //获取上一周期结束时间
+        LocalDate frontEndTime = localDateBeginTime.minusDays(1);
+        LocalDate frontBeginTime;
+        //根据筛选时间天数获取上一周期开始时间
+        int days = DateUtils.differentDaysByMillisecond(DateUtils.toDate(localDateBeginTime), DateUtils.toDate(localDateEndTime));
+        if (days == 0) {
+            frontBeginTime = localDateBeginTime.minusDays(1);
+        } else {
+            frontBeginTime = localDateBeginTime.minusDays(days + 1);
+        }
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        String beginTimeString = frontBeginTime.format(formatter);
+        String endTimeString = frontEndTime.format(formatter);
+        return new String[]{beginTimeString, endTimeString};
+    }
+
+
+    /**
+     * 获取两个日期之间的所有日期
+     *
+     * @param startDateStr 开始日期字符串,格式为yyyy-MM-dd
+     * @param endDateStr 结束日期字符串,格式为yyyy-MM-dd
+     * @return 日期列表
+     */
+    public static List<LocalDate> getDatesBetween(String startDateStr, String endDateStr) {
+        // 定义日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        // 将字符串日期转换为LocalDate
+        LocalDate startDate = LocalDate.parse(startDateStr, formatter);
+        LocalDate endDate = LocalDate.parse(endDateStr, formatter);
+
+        // 创建一个列表来存储日期
+        List<LocalDate> dates = new ArrayList<>();
+
+        // 使用while循环获取两个日期之间的所有日期
+        LocalDate currentDate = startDate;
+        while (!currentDate.isAfter(endDate)) {
+            dates.add(currentDate);
+            currentDate = currentDate.plusDays(1); // 将当前日期加一天
+        }
+
+        return dates;
+    }
+
+    public static List<LocalDate> getDatesBetween(LocalDate startDate, LocalDate endDate) {
+        // 创建一个列表来存储日期
+        List<LocalDate> dates = new ArrayList<>();
+        // 使用while循环获取两个日期之间的所有日期
+        LocalDate currentDate = startDate;
+        while (!currentDate.isAfter(endDate)) {
+            dates.add(currentDate);
+            currentDate = currentDate.plusDays(1); // 将当前日期加一天
+        }
+        return dates;
+    }
+}

+ 1589 - 0
src/main/java/com/jsh/erp/utils/StringHelper.java

@@ -0,0 +1,1589 @@
+package com.jsh.erp.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *   
+ * 
+ * @Title: StringHelper.java
+ * @Description:
+ * @author HJJ
+ * @version V1.0   字符串处理工具类。
+ */
+public final class StringHelper {
+
+	/**
+	 * 描述: 构造方法
+	 */
+	private StringHelper() {
+	}
+
+	/**
+	 * 空字符串
+	 */
+	public static final String EMPTY_STRING = "";
+
+	/**
+	 * 点
+	 */
+	public static final char DOT = '.';
+
+	/**
+	 * 下划线
+	 */
+	public static final char UNDERSCORE = '_';
+
+	/**
+	 * 逗点及空格
+	 */
+	public static final String COMMA_SPACE = ", ";
+
+	/**
+	 * 逗点
+	 */
+	public static final String COMMA = ",";
+
+	/**
+	 * 开始括号
+	 */
+	public static final String OPEN_PAREN = "(";
+
+	/**
+	 * 结束括号
+	 */
+	public static final String CLOSE_PAREN = ")";
+
+	/**
+	 * 单引号
+	 */
+	public static final char SINGLE_QUOTE = '\'';
+
+	/**
+	 * 回车
+	 */
+	public static final String CRLF = "\r\n";
+
+	/**
+	 * 常量 12
+	 */
+	public static final int FIANL_TWELVE = 12;
+
+	/**
+	 * 十六进制常量 0x80
+	 */
+	public static final int HEX_80 = 0x80;
+
+	/**
+	 * 十六进制常量 0xff
+	 */
+	public static final int HEX_FF = 0xff;
+
+	/**
+	 * 把字符数组,转化为一个字符
+	 *
+	 * @param seperator
+	 *            字符分隔符
+	 * @param strings
+	 *            数组对象
+	 * @return 字符串
+	 */
+	public static String join(String seperator, String[] strings) {
+		int length = strings.length;
+		if (length == 0) {
+			return EMPTY_STRING;
+		}
+		StringBuffer buf = new StringBuffer(length * strings[0].length()).append(strings[0]);
+		for (int i = 1; i < length; i++) {
+			buf.append(seperator).append(strings[i]);
+		}
+		return buf.toString();
+	}
+
+	/**
+	 * 把迭代对象转化为一个字符串
+	 *
+	 * @param seperator
+	 *            分隔符
+	 * @param objects
+	 *            迭代器对象
+	 * @return 字符串
+	 */
+	public static String join(String seperator, Iterator<?> objects) {
+		StringBuffer buf = new StringBuffer();
+		if (objects.hasNext()) {
+			buf.append(objects.next());
+		}
+		while (objects.hasNext()) {
+			buf.append(seperator).append(objects.next());
+		}
+		return buf.toString();
+	}
+
+	/**
+	 * 把两个字符串数组的元素用分隔符连接,生成新的数组,生成的数组以第一个字符串数组为参照,与其长度相同。
+	 *
+	 * @param x
+	 *            字符串数组
+	 * @param seperator
+	 *            分隔符
+	 * @param y
+	 *            字符串数组
+	 * @return 组合后的字符串数组
+	 */
+	public static String[] add(String[] x, String seperator, String[] y) {
+		String[] result = new String[x.length];
+		for (int i = 0; i < x.length; i++) {
+			result[i] = x[i] + seperator + y[i];
+		}
+		return result;
+	}
+
+	/**
+	 * 生成一个重复的字符串,如需要重复*10次,则生成:**********。
+	 *
+	 * @param string
+	 *            重复元素
+	 * @param times
+	 *            重复次数
+	 * @return 生成后的字符串
+	 */
+	public static String repeat(String string, int times) {
+		StringBuffer buf = new StringBuffer(string.length() * times);
+		for (int i = 0; i < times; i++) {
+			buf.append(string);
+		}
+		return buf.toString();
+	}
+
+	/**
+	 * 字符串替换处理,把旧的字符串替换为新的字符串,主要是通过字符串查找进行处理
+	 *
+	 * @param source
+	 *            需要进行替换的字符串
+	 * @param old
+	 *            需要进行替换的字符串
+	 * @param replace
+	 *            替换成的字符串
+	 * @return 替换处理后的字符串
+	 */
+	public static String replace(String source, String old, String replace) {
+		StringBuffer output = new StringBuffer();
+
+		int sourceLen = source.length();
+		int oldLen = old.length();
+
+		int posStart = 0;
+		int pos;
+
+		// 通过截取字符串的方式,替换字符串
+		while ((pos = source.indexOf(old, posStart)) >= 0) {
+			output.append(source.substring(posStart, pos));
+
+			output.append(replace);
+			posStart = pos + oldLen;
+		}
+
+		// 如果还有没有处理的字符串,则都添加到新字符串后面
+		if (posStart < sourceLen) {
+			output.append(source.substring(posStart));
+		}
+
+		return output.toString();
+	}
+
+	/**
+	 * 替换字符,如果指定进行全替换,必须设wholeWords=true,否则只替换最后出现的字符。
+	 *
+	 * @param template
+	 *            字符模板
+	 * @param placeholder
+	 *            需要替换的字符
+	 * @param replacement
+	 *            新的字符
+	 * @param wholeWords
+	 *            是否需要全替换,true为需要,false为不需要。如果不需要,则只替换最后出现的字符。
+	 * @return 替换后的新字符
+	 */
+	public static String replace(String template, String placeholder, String replacement, boolean wholeWords) {
+		int loc = template.indexOf(placeholder);
+		if (loc < 0) {
+			return template;
+		} else {
+			final boolean actuallyReplace = wholeWords || loc + placeholder.length() == template.length()
+					|| !Character.isJavaIdentifierPart(template.charAt(loc + placeholder.length()));
+			String actualReplacement = actuallyReplace ? replacement : placeholder;
+			return new StringBuffer(template.substring(0, loc)).append(actualReplacement).append(
+					replace(template.substring(loc + placeholder.length()), placeholder, replacement, wholeWords))
+					.toString();
+		}
+	}
+
+	/**
+	 * 替换字符,只替换第一次出现的字符串。
+	 *
+	 * @param template
+	 *            字符模板
+	 * @param placeholder
+	 *            需要替换的字符串
+	 * @param replacement
+	 *            新字符串
+	 * @return 替换后的字符串
+	 */
+	public static String replaceOnce(String template, String placeholder, String replacement) {
+		int loc = template.indexOf(placeholder);
+		if (loc < 0) {
+			return template;
+		} else {
+			return new StringBuffer(template.substring(0, loc)).append(replacement)
+					.append(template.substring(loc + placeholder.length())).toString();
+		}
+	}
+
+	/**
+	 * 把字符串,按指字的分隔符分隔为字符串数组
+	 *
+	 * @param seperators
+	 *            分隔符
+	 * @param list
+	 *            字符串
+	 * @return 字符串数组
+	 */
+	public static String[] split(String list, String seperators) {
+		return split(list, seperators, false);
+	}
+
+	/**
+	 * 把字符串,按指字的分隔符分隔为字符串数组
+	 *
+	 * @param seperators
+	 *            分隔符
+	 * @param list
+	 *            字符串
+	 * @param include
+	 *            是否需要把分隔符也返回
+	 * @return 字符串数组
+	 */
+	public static String[] split(String list, String seperators, boolean include) {
+		StringTokenizer tokens = new StringTokenizer(list, seperators, include);
+		String[] result = new String[tokens.countTokens()];
+		int i = 0;
+		while (tokens.hasMoreTokens()) {
+			result[i++] = tokens.nextToken();
+		}
+		return result;
+	}
+
+	/**
+	 * 提取字符串中,以.为分隔符后的所有字符,如string.exe,将返回exe。
+	 *
+	 * @param qualifiedName
+	 *            字符串
+	 * @return 提取后的字符串
+	 */
+	public static String unqualify(String qualifiedName) {
+		return unqualify(qualifiedName, ".");
+	}
+
+	/**
+	 * 提取字符串中,以指定分隔符后的所有字符,如string.exe,将返回exe。
+	 *
+	 * @param qualifiedName
+	 *            字符串
+	 * @param seperator
+	 *            分隔符
+	 * @return 提取后的字符串
+	 */
+	public static String unqualify(String qualifiedName, String seperator) {
+		return qualifiedName.substring(qualifiedName.lastIndexOf(seperator) + 1);
+	}
+
+	/**
+	 * 提取字符串中,以.为分隔符以前的字符,如string.exe,则返回string
+	 *
+	 * @param qualifiedName
+	 *            字符串
+	 * @return 提取后的字符串
+	 */
+	public static String qualifier(String qualifiedName) {
+		int loc = qualifiedName.lastIndexOf(".");
+		if (loc < 0) {
+			return EMPTY_STRING;
+		} else {
+			return qualifiedName.substring(0, loc);
+		}
+	}
+
+	/**
+	 * 向字符串数组中的所有元素添加上后缀
+	 *
+	 * @param columns
+	 *            字符串数组
+	 * @param suffix
+	 *            后缀
+	 * @return 添加后缀后的数组
+	 */
+	public static String[] suffix(String[] columns, String suffix) {
+		if (suffix == null) {
+			return columns;
+		}
+		String[] qualified = new String[columns.length];
+		for (int i = 0; i < columns.length; i++) {
+			qualified[i] = suffix(columns[i], suffix);
+		}
+		return qualified;
+	}
+
+	/**
+	 * 向字符串加上后缀
+	 *
+	 * @param name
+	 *            需要添加后缀的字符串
+	 * @param suffix
+	 *            后缀
+	 * @return 添加后缀的字符串
+	 */
+	public static String suffix(String name, String suffix) {
+		return (suffix == null) ? name : name + suffix;
+	}
+
+	/**
+	 * 向字符串数组中的所有元素,添加上前缀
+	 *
+	 * @param columns
+	 *            需要添加前缀的字符串数组
+	 * @param prefix
+	 *            prefix
+	 * @return
+	 */
+	public static String[] prefix(String[] columns, String prefix) {
+		if (prefix == null) {
+			return columns;
+		}
+		String[] qualified = new String[columns.length];
+		for (int i = 0; i < columns.length; i++) {
+			qualified[i] = prefix + columns[i];
+		}
+		return qualified;
+	}
+
+	/**
+	 * 向字符串添加上前缀
+	 *
+	 * @param name
+	 *            需要添加前缀的字符串
+	 * @param prefix
+	 *            前缀
+	 * @return 添加前缀后的字符串
+	 */
+	public static String prefix(String name, String prefix) {
+		return (prefix == null) ? name : prefix + name;
+	}
+
+	/**
+	 * 判断字符串是否为"true"、"t",如果是,返回true,否则返回false
+	 *
+	 * @param tfString
+	 *            需要进行判断真/假的字符串
+	 * @return true/false
+	 */
+	public static boolean booleanValue(String tfString) {
+		String trimmed = tfString.trim().toLowerCase();
+		return trimmed.equals("true") || trimmed.equals("t");
+	}
+
+	/**
+	 * 把对象数组转化为字符串
+	 *
+	 * @param array
+	 *            对象数组
+	 * @return 字符串
+	 */
+	public static String toString(Object[] array) {
+		int len = array.length;
+		if (len == 0) {
+			return StringHelper.EMPTY_STRING;
+		}
+		StringBuffer buf = new StringBuffer(len * FIANL_TWELVE);
+		for (int i = 0; i < len - 1; i++) {
+			buf.append(array[i]).append(StringHelper.COMMA_SPACE);
+		}
+		return buf.append(array[len - 1]).toString();
+	}
+
+	/**
+	 * 描述:把数组中的所有元素出现的字符串进行替换,把旧字符串替换为新字符数组的所有元素,只替换第一次出现的字符。
+	 * 
+	 * @param string
+	 *            需要替换的数组
+	 * @param placeholders
+	 *            需要替换的字符串
+	 * @param replacements
+	 *            新字符串数组
+	 * @return 替换后的字符串数组
+	 */
+	public static String[] multiply(String string, Iterator<?> placeholders, Iterator<?> replacements) {
+		String[] result = new String[] { string };
+		while (placeholders.hasNext()) {
+			result = multiply(result, (String) placeholders.next(), (String[]) replacements.next());
+		}
+		return result;
+	}
+
+	/**
+	 * 把数组中的所有元素出现的字符串进行替换,把旧字符串替换为新字符数组的所有元素,只替换第一次出现的字符。
+	 *
+	 * @param strings
+	 *            需要替换的数组
+	 * @param placeholder
+	 *            需要替换的字符串
+	 * @param replacements
+	 *            新字符串数组
+	 * @return 替换后的字符串数组
+	 */
+	private static String[] multiply(String[] strings, String placeholder, String[] replacements) {
+		String[] results = new String[replacements.length * strings.length];
+		int n = 0;
+		for (int i = 0; i < replacements.length; i++) {
+			for (int j = 0; j < strings.length; j++) {
+				results[n++] = replaceOnce(strings[j], placeholder, replacements[i]);
+			}
+		}
+		return results;
+	}
+
+	/**
+	 * 统计Char在字符串中出现在次数,如"s"在字符串"string"中出现的次数
+	 *
+	 * @param string
+	 *            字符串
+	 * @param character
+	 *            需要进行统计的char
+	 * @return 数量
+	 */
+	public static int count(String string, char character) {
+		int n = 0;
+		for (int i = 0; i < string.length(); i++) {
+			if (string.charAt(i) == character) {
+				n++;
+			}
+		}
+		return n;
+	}
+
+	/**
+	 * 描述:计算字符串中未引用的字符
+	 * 
+	 * @param string
+	 *            字符串
+	 * @param character
+	 *            字符
+	 * @return 未引用的字符数
+	 */
+	public static int countUnquoted(String string, char character) {
+		if (SINGLE_QUOTE == character) {
+			throw new IllegalArgumentException("Unquoted count of quotes is invalid");
+		}
+
+		int count = 0;
+		int stringLength = string == null ? 0 : string.length();
+		boolean inQuote = false;
+		for (int indx = 0; indx < stringLength; indx++) {
+			if (inQuote) {
+				if (SINGLE_QUOTE == string.charAt(indx)) {
+					inQuote = false;
+				}
+			} else if (SINGLE_QUOTE == string.charAt(indx)) {
+				inQuote = true;
+			} else if (string.charAt(indx) == character) {
+				count++;
+			}
+		}
+		return count;
+	}
+
+	/**
+	 * 
+	 * 描述:描述:判断字符串是否为空,如果为true则为空。与isEmpty不同,如果字符为" "也视为空字符
+	 * 
+	 * @param str
+	 *            字符串
+	 * @return
+	 */
+	public static boolean isBlank(String str) {
+		boolean b = true;// 20140507 modify by liwei 修复对" "为false的bug
+		if (str == null) {
+			b = true;
+		} else {
+			int strLen = str.length();
+			if (strLen == 0) {
+				b = true;
+			}
+
+			for (int i = 0; i < strLen; i++) {
+				if (!Character.isWhitespace(str.charAt(i))) {
+					b = false;
+					break;
+				}
+			}
+		}
+
+		return b;
+	}
+
+	/**
+	 * 
+	 * 描述:描述:判断字符串是否为空,如果为true则不为空。与isNotEmpty不同,如果字符为" "也视为空字符
+	 * 
+	 * @param str
+	 *            字符串
+	 * @return
+	 */
+	public static boolean isNotBlank(String str) {
+		int strLen = 0;
+		if (str != null)
+			strLen = str.length();
+		if (str == null || strLen == 0) {
+			return false;
+		}
+		for (int i = 0; i < strLen; i++) {
+			if (!Character.isWhitespace(str.charAt(i))) {
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * 判断字符串是否非空,如果为true则不为空
+	 *
+	 * @param string
+	 *            字符串
+	 * @return true/false
+	 */
+	public static boolean isNotEmpty(String string) {
+		return string != null && string.length() > 0;
+	}
+
+	/**
+	 * 判断字符串是否空,如果为true则为空
+	 *
+	 * @param str
+	 *            字符串
+	 * @return true/false
+	 */
+
+	public static boolean isEmpty(String str) {
+		if (str == null || str.trim().length() == 0) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * 向字符串添加上前缀,并以.作为分隔符
+	 *
+	 * @param name
+	 *            需要添加前缀的字符串
+	 * @param prefix
+	 *            前缀
+	 * @return 添加前缀后的字符串
+	 */
+	public static String qualify(String name, String prefix) {
+		if (name.startsWith("'")) {
+			return name;
+		}
+
+		return new StringBuffer(prefix.length() + name.length() + 1).append(prefix).append(DOT).append(name).toString();
+	}
+
+	/**
+	 * 向字符串数组中的所有字符添加上前缀,前以点作为分隔符
+	 *
+	 * @param names
+	 *            字符串数组
+	 * @param prefix
+	 *            前缀
+	 * @return 添加前缀后的字符串数组
+	 */
+	public static String[] qualify(String[] names, String prefix) {
+		if (prefix == null) {
+			return names;
+		}
+		int len = names.length;
+		String[] qualified = new String[len];
+		for (int i = 0; i < len; i++) {
+			qualified[i] = qualify(prefix, names[i]);
+		}
+		return qualified;
+	}
+
+	/**
+	 * 在字符串中,查找字符第一次出现的位置
+	 *
+	 * @param sqlString
+	 *            原字符串
+	 * @param string
+	 *            需要查找到字符串
+	 * @param startindex
+	 *            开始位置
+	 * @return 第一个出现的位置
+	 */
+	public static int firstIndexOfChar(String sqlString, String string, int startindex) {
+		int matchAt = -1;
+		for (int i = 0; i < string.length(); i++) {
+			int curMatch = sqlString.indexOf(string.charAt(i), startindex);
+			if (curMatch >= 0) {
+				if (matchAt == -1) {
+					matchAt = curMatch;
+				} else {
+					matchAt = Math.min(matchAt, curMatch);
+				}
+			}
+		}
+		return matchAt;
+	}
+
+	/**
+	 * 从字符串中提取指字长度的字符。区分中英文。<br>
+	 * 如果需要加省略号,则将在指定长度上少取3个字符宽度,末尾加上"......"。
+	 *
+	 * @param string
+	 *            字符串
+	 * @param length
+	 *            要取的字符长度,此为中文长度,英文仅当作半个字符。
+	 * @param appendSuspensionPoints
+	 *            是否需要加省略号
+	 * @return 提取后的字符串
+	 */
+	public static String truncate(String string, int length, boolean appendSuspensionPoints) {
+		if (isEmpty(string) || length < 0) {
+			return string;
+		}
+
+		if (length == 0) {
+			return "";
+		}
+
+		int strLength = string.length(); // 字符串字符个数
+		int byteLength = byteLength(string); // 字符串字节长度
+		length *= 2; // 换成字节长度
+
+		// 判断是否需要加省略号
+		boolean needSus = false;
+		if (appendSuspensionPoints && byteLength >= length) {
+			needSus = true;
+
+			// 如果需要加省略号,则要少取2个字节用来加省略号
+			length -= 2;
+		}
+
+		StringBuffer result = new StringBuffer();
+		int count = 0;
+		for (int i = 0; i < strLength; i++) {
+			if (count >= length) { // 取完了
+				break;
+			}
+
+			char c = string.charAt(i);
+
+			if (isLetter(c)) { // Ascill字符
+				result.append(c);
+				count += 1;
+			} else { // 非Ascill字符
+				if (count == length - 1) { // 如果只要取1个字节了,而后面1个是汉字,就放空格
+					result.append(" ");
+					count += 1;
+				} else {
+					result.append(c);
+					count += 2;
+				}
+			}
+		}
+
+		if (needSus) {
+			result.append("...");
+		}
+
+		return result.toString();
+	}
+
+	/**
+	 * 描述:判断一个字符是Ascill字符还是其它字符(如汉,日,韩文字符)
+	 * 
+	 * @param c
+	 *            需要判断的字符
+	 * @return
+	 */
+	public static boolean isLetter(char c) {
+		int k = HEX_80;
+		return c / k == 0 ? true : false;
+	}
+
+	/**
+	 * 得到一个字符串的长度,显示的长度,一个汉字或日韩文长度为2,英文字符长度为1
+	 *
+	 * @param s
+	 *            ,需要得到长度的字符串
+	 * @return int, 得到的字符串长度
+	 */
+	public static int byteLength(String s) {
+		char[] c = s.toCharArray();
+		int len = 0;
+		for (int i = 0; i < c.length; i++) {
+			if (isLetter(c[i])) {
+				len++;
+			} else {
+				len += 2;
+			}
+		}
+		return len;
+	}
+
+	/**
+	 * 从字符串中提取指字长度的字符
+	 *
+	 * @param string
+	 *            字符串
+	 * @param length
+	 *            字符长度
+	 * @return 提取后的字符串
+	 */
+	public static String truncate(String string, int length) {
+		if (isEmpty(string)) {
+			return string;
+		}
+
+		if (string.length() <= length) {
+			return string;
+		} else {
+			return string.substring(0, length);
+		}
+	}
+
+	/**
+	 * 去丢字符的左侧空格
+	 *
+	 * @param value
+	 *            字符串
+	 * @return 去丢左侧空格后的字符串
+	 */
+	public static String leftTrim(String value) {
+		String result = value;
+		if (result == null) {
+			return result;
+		}
+		char ch[] = result.toCharArray();
+		int index = -1;
+		for (int i = 0; i < ch.length; i++) {
+			if (!Character.isWhitespace(ch[i])) {
+				break;
+			}
+			index = i;
+		}
+
+		if (index != -1) {
+			result = result.substring(index + 1);
+		}
+		return result;
+	}
+
+	/**
+	 * 去丢字符的右侧空格
+	 *
+	 * @param value
+	 *            字符串
+	 * @return 去右侧空格后的字符串
+	 */
+	public static String rightTrim(String value) {
+		String result = value;
+		if (result == null) {
+			return result;
+		}
+		char ch[] = result.toCharArray();
+		int endIndex = -1;
+		for (int i = ch.length - 1; i > -1; i--) {
+			if (!Character.isWhitespace(ch[i])) {
+				break;
+			}
+			endIndex = i;
+		}
+
+		if (endIndex != -1) {
+			result = result.substring(0, endIndex);
+		}
+		return result;
+	}
+
+	/**
+	 * 把null字符串转化为""
+	 *
+	 * @param source
+	 *            空字符串
+	 * @return 转化后的字符串
+	 */
+	public static String n2s(String source) {
+		return source != null ? source : "";
+	}
+
+	/**
+	 * 如果字符串为空,则返回默认字符串
+	 *
+	 * @param source
+	 *            源字符串
+	 * @param defaultStr
+	 *            默认字符串
+	 * @return 转换后的字符串
+	 */
+	public static String n2s(String source, String defaultStr) {
+		return source != null ? source : defaultStr;
+	}
+
+	/**
+	 * 将字符串格式化成 HTML 以SCRIPT变量 主要是替换单,双引号,以将内容格式化输出,适合于 HTML 中的显示输出
+	 *
+	 * @param str
+	 *            要格式化的字符串
+	 * @return 格式化后的字符串
+	 */
+	public static String toScript(String str) {
+		if (str == null) {
+			return null;
+		}
+
+		String html = new String(str);
+
+		html = replace(html, "\"", "\\\"");
+		html = replace(html, "\r\n", "\n");
+		html = replace(html, "\n", "\\n");
+		html = replace(html, "\t", "    ");
+		html = replace(html, "\'", "\\\'");
+
+		html = replace(html, "  ", " &nbsp;");
+
+		html = replace(html, "</script>", "<\\/script>");
+		html = replace(html, "</SCRIPT>", "<\\/SCRIPT>");
+
+		return html;
+	}
+
+	/**
+	 * 同于String#trim(),但是检测null,如果原字符串为null,则仍然返回null
+	 *
+	 * @param s
+	 *            s
+	 * @return
+	 */
+	public static String trim(String s) {
+		return s == null ? s : s.trim();
+	}
+
+	/**
+	 * 对字符串进行空格处理,如果字符串为null呀是空字符串, 则返回默认的数字。
+	 *
+	 * @param source
+	 *            需要进行处理的字符串
+	 * @param defaultValue
+	 *            缺省值
+	 * @return 字符串的数字值
+	 */
+	public static int strTrim(String source, int defaultValue) {
+		if (isEmpty(source)) {
+			return defaultValue;
+		}
+		try {
+			source = source.trim();
+			int value = (new Integer(source)).intValue();
+			return value;
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			System.err.println("数字转换出错,请检查数据来源。返回默认值");
+			return defaultValue;
+		}
+	}
+
+	/**
+	 * 对字符串进行过滤处理,如果字符串是null或为空字符串, 返回默认值。
+	 *
+	 * @param source
+	 *            需要进行处理的字符串
+	 * @param defaultValue
+	 *            缺省值
+	 * @return 过滤后的字符串
+	 */
+	public static String strTrim(String source, String defaultValue) {
+		if (StringHelper.isEmpty(source)) {
+			return defaultValue;
+		}
+		try {
+			source = source.trim();
+			return source;
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			System.err.println("字符串去空格失败,返回默认值");
+			return defaultValue;
+		}
+	}
+
+	/**
+	 * 描述:为了防止跨站脚本攻击,转换<>这种尖括号。
+	 * 
+	 * @param source
+	 * @return
+	 */
+	public static String encodeURL(String source) {
+		if (source == null) {
+			return null;
+		}
+		String html = new String(source);
+		html = replace(html, "<", "&lt;");
+		html = replace(html, ">", "&gt;");
+		html = replace(html, "\"", "&quot;");
+		html = replace(html, " ", "&nbsp;");
+		html = replace(html, "\'", "&acute;");
+		html = replace(html, "\\", "&#092;");
+		html = replace(html, "&", "&amp;");
+		html = replace(html, "\r", "");
+		html = replace(html, "\n", "");
+		html = replace(html, "(", "&#40;");
+		html = replace(html, ")", "&#41;");
+		html = replace(html, "[", "&#91;");
+		html = replace(html, "]", "&#93;");
+		html = replace(html, ";", "&#59;");
+		html = replace(html, "/", "&#47;");
+
+		return html;
+	}
+
+	/**
+	 * 把字符串中一些特定的字符转换成html字符,如&、<、>、"号等
+	 *
+	 * @param source
+	 *            需要进行处理的字符串
+	 * @return 处理后的字符串
+	 */
+	public static String encodeHtml(String source) {
+		if (source == null) {
+			return null;
+		}
+
+		String html = new String(source);
+
+		html = replace(html, "&", "&amp;");
+		html = replace(html, "<", "&lt;");
+		html = replace(html, ">", "&gt;");
+		html = replace(html, "\"", "&quot;");
+		html = replace(html, " ", "&nbsp;");
+		html = replace(html, "\'", "&acute;");
+		return html;
+	}
+
+	/**
+	 * 把一些html的字符串还原
+	 *
+	 * @param source
+	 *            需要进行处理的字符串
+	 * @return 处理后的字符串
+	 */
+	public static String decodeHtml(String source) {
+		if (source == null) {
+			return null;
+		}
+
+		String html = new String(source);
+
+		html = replace(html, "&amp;", "&");
+		html = replace(html, "&lt;", "<");
+		html = replace(html, "&gt;", ">");
+		html = replace(html, "&quot;", "\"");
+		html = replace(html, " ", "&nbsp;");
+
+		html = replace(html, "\r\n", "\n");
+		html = replace(html, "\n", "<br>\n");
+		html = replace(html, "\t", "    ");
+		html = replace(html, "  ", " &nbsp;");
+
+		return html;
+	}
+
+	/**
+	 * 判断字符串是否为布尔值,如true/false等
+	 *
+	 * @param source
+	 *            需要进行判断的字符串
+	 * @return 返回字符串的布尔值
+	 */
+	public static boolean isBoolean(String source) {
+		if (source.equalsIgnoreCase("true") || source.equalsIgnoreCase("false")) {
+			return true;
+		}
+		return false;
+	}
+
+	/**
+	 * 去除字符串中的最后字符
+	 *
+	 * @param str
+	 *            原字符串
+	 * @param strMove
+	 *            要去除字符 比如","
+	 * @return 去除后的字符串
+	 */
+	public static String lastCharTrim(String str, String strMove) {
+		if (isEmpty(str)) {
+			return "";
+		}
+
+		String newStr = "";
+		if (str.lastIndexOf(strMove) != -1 && str.lastIndexOf(strMove) == str.length() - 1) {
+			newStr = str.substring(0, str.lastIndexOf(strMove));
+		}
+		return newStr;
+	}
+
+	/**
+	 * 清除字符串里的html代码
+	 *
+	 * @param html
+	 *            需要进行处理的字符串
+	 * @return 清除html后的代码
+	 */
+	public static String clearHtml(String html) {
+		if (isEmpty(html)) {
+			return "";
+		}
+
+		String patternStr = "(<[^>]*>)";
+		Pattern pattern = Pattern.compile(patternStr, Pattern.CASE_INSENSITIVE);
+		Matcher matcher = null;
+		StringBuffer bf = new StringBuffer();
+		try {
+			matcher = pattern.matcher(html);
+			boolean first = true;
+			int start = 0;
+			int end = 0;
+			while (matcher.find()) {
+				start = matcher.start(1);
+				if (first) {
+					bf.append(html.substring(0, start));
+					first = false;
+				} else {
+					bf.append(html.substring(end, start));
+				}
+
+				end = matcher.end(1);
+			}
+			if (end < html.length()) {
+				bf.append(html.substring(end));
+			}
+			html = bf.toString();
+			return html;
+		} catch (Exception ex) {
+			ex.printStackTrace();
+			System.err.println("清除html标签失败");
+		} finally {
+			pattern = null;
+			matcher = null;
+		}
+		return html;
+	}
+
+	/**
+	 * 把文件格式转换为html格式
+	 *
+	 * @param content
+	 *            转换的内容
+	 * @return
+	 */
+	public static String textFmtToHtmlFmt(String content) {
+		content = StringHelper.replace(content, " ", "&nbsp;");
+		content = StringHelper.replace(content, "\r\n", "<br>");
+		content = StringHelper.replace(content, "\n", "<br>");
+
+		return content;
+	}
+
+	/**
+	 * 
+	 * 描述:大写英文字母转换成小写
+	 * 
+	 * @param strIn
+	 *            字符串参数
+	 * @return
+	 */
+	public static String toLowerStr(String strIn) {
+		String strOut = new String(); // 输出的字串
+		int len = strIn.length(); // 参数的长度
+		int i = 0; // 计数器
+		char ch; // 存放参数的字符
+
+		while (i < len) {
+			ch = strIn.charAt(i);
+
+			if (ch >= 'A' && ch <= 'Z') {
+				ch = (char) (ch - 'A' + 'a');
+			}
+
+			strOut += ch;
+			i++;
+		}
+		return strOut;
+	}
+
+	/**
+	 * 
+	 * 描述:小写英文字母转换成大写
+	 * 
+	 * @param strIn
+	 *            字符串参数
+	 * @return
+	 */
+	public static String toUpperStr(String strIn) {
+		String strOut = new String(); // 输出的字串
+		int len = strIn.length(); // 参数的长度
+		int i = 0; // 计数器
+		char ch; // 存放参数的字符
+
+		while (i < len) {
+			ch = strIn.charAt(i);
+
+			if (ch >= 'a' && ch <= 'z') {
+				ch = (char) (ch - 'a' + 'A');
+			}
+
+			strOut += ch;
+			i++;
+		}
+		return strOut;
+	}
+
+	/**
+	 * 货币缩写,提供亿和万两个单位,并精确到小数点2位 切换到新的算法:对数算法
+	 * 
+	 * @param original
+	 * @return
+	 */
+	public static String currencyShortFor(String original) {
+		if (StringHelper.isBlank(original)) {
+			return "";
+		} else {
+			String shortFor = "";
+			double shortForValue = 0;
+			DecimalFormat df = new DecimalFormat("#.00");
+
+			try {
+				double account = Double.parseDouble(original);
+				if (account / 100000000 > 1) {
+					shortForValue = account / 100000000;
+					shortFor = df.format(shortForValue) + "亿";
+				} else if (account / 10000 > 1) {
+					shortForValue = account / 10000;
+					shortFor = df.format(shortForValue) + "万";
+				} else {
+					shortFor = original;
+				}
+			} catch (NumberFormatException e) {
+				e.printStackTrace();
+				System.err.println("字符串[" + original + "]转换成数字出错");
+			}
+
+			return shortFor;
+		}
+	}
+
+	/**
+	 * 将日期格式由yyyyMMdd装换为yyyy-MM-dd
+	 * 
+	 * @param date
+	 *            Date string whose format is yyyyMMdd.
+	 * @return
+	 */
+	public static String formatDate(String date) {
+		if (isBlank(date) || date.length() < 8) {
+			return "";
+		}
+		StringBuffer dateBuf = new StringBuffer();
+		dateBuf.append(date.substring(0, 4));
+		dateBuf.append("-");
+		dateBuf.append(date.substring(4, 6));
+		dateBuf.append("-");
+		dateBuf.append(date.substring(6, 8));
+		return dateBuf.toString();
+	}
+
+	/**
+	 * 判断是否为整数
+	 * 
+	 * @param str
+	 *            传入的字符串
+	 * @return 是整数返回true,否则返回false
+	 */
+	public static boolean isInteger(String str) {
+		Pattern pattern = Pattern.compile("^\\d+(\\.0)?$", Pattern.CASE_INSENSITIVE);
+		return pattern.matcher(str).matches();
+
+	}
+
+	/**
+	 * 用于=中英文混排标题中限定字符串长度。保证显示长度最多只相差一个全角字符。
+	 * 
+	 * @param string
+	 *            需要截取的字符串
+	 * @param byteCount
+	 *            字节数(度量标准为中文为两个字节,ASCII字符为一个字节,这样子,刚好匹配ASCII为半角字符,而中文为全角字符,
+	 *            保证在网页上中英文混合的句子长度一致)
+	 * @return
+	 * @throws UnsupportedEncodingException
+	 */
+	public static String substring(String string, int byteCount) throws UnsupportedEncodingException {
+		if (isBlank(string)) {
+			return string;
+		}
+		byte[] bytes = string.getBytes("Unicode");// 使用UCS-2编码.
+		int viewBytes = 0; // 表示当前的字节数(英文为单字节,中文为双字节的表示方法)
+		int ucs2Bytes = 2; // 要截取的字节数,从第3个字节开始,前两位为位序。(UCS-2的表示方法)
+		// UCS-2每个字符使用两个字节来编码。
+		// ASCII n+=1,i+=2
+		// 中文 n+=2,i+=2
+		for (; ucs2Bytes < bytes.length && viewBytes < byteCount; ucs2Bytes++) {
+			// 奇数位置,如3、5、7等,为UCS2编码中两个字节的第二个字节
+			if (ucs2Bytes % 2 == 1) {
+				viewBytes++; // 低字节,无论中英文,都算一个字节。
+			} else {
+				// 当UCS2编码的第一个字节不等于0时,该UCS2字符为汉字,一个汉字算两个字节
+				// 高位时,仅中文的高位算一字节。
+				if (bytes[ucs2Bytes] != 0) {
+					viewBytes++;
+				}
+			}
+		}
+		// 截一半的汉字要保留
+		if (ucs2Bytes % 2 == 1) {
+			ucs2Bytes = ucs2Bytes + 1;
+		}
+		String result = new String(bytes, 0, ucs2Bytes, "Unicode");// 将字节流转换为java默认编码UTF-8的字符串
+		if (bytes.length > ucs2Bytes) {
+			result += "...";
+		}
+		return result;
+	}
+
+	/**
+	 * 描述:根据长度截断字串
+	 * 
+	 * @param str
+	 *            字串
+	 * @param length
+	 *            截取长度
+	 * @return
+	 */
+	public static String[] splite(String str, int length) {
+		if (StringHelper.isEmpty(str)) {
+			return null;
+		}
+		String[] strArr = new String[(str.length() + length - 1) / length];
+		for (int i = 0; i < strArr.length; i++) {
+			if (str.length() > i * length + length - 1) {
+				strArr[i] = str.substring(i * length, i * length + length - 1);
+			} else {
+				strArr[i] = str.substring(i * length);
+			}
+		}
+		return strArr;
+	}
+
+	/**
+	 * 描述:把某一个字符变成大写
+	 * 
+	 * @param str
+	 *            str 字串
+	 * @param index
+	 *            第几个字符
+	 * @return
+	 */
+	public static String toUpOneChar(String str, int index) {
+		return toUpOrLowOneChar(str, index, 1);
+	}
+
+	/**
+	 * 描述:把某一个字符变成小写 作者:李建 时间:Dec 17, 2010 9:42:32 PM
+	 * 
+	 * @param str
+	 *            str 字串
+	 * @param index
+	 *            第几个字符
+	 * @return
+	 */
+	public static String toLowOneChar(String str, int index) {
+		return toUpOrLowOneChar(str, index, 0);
+	}
+
+	/**
+	 * 描述:把某一个字符变成大写或小写 作者:李建 时间:Dec 17, 2010 9:39:32 PM
+	 * 
+	 * @param str
+	 *            字串
+	 * @param index
+	 *            第几个字符
+	 * @param upOrLow
+	 *            大小写 1:大写;0小写
+	 * @return
+	 */
+	public static String toUpOrLowOneChar(String str, int index, int upOrLow) {
+		if (StringHelper.isNotEmpty(str) && index > -1 && index < str.length()) {
+			char[] chars = str.toCharArray();
+			if (upOrLow == 1) {
+				chars[index] = Character.toUpperCase(chars[index]);
+			} else {
+				chars[index] = Character.toLowerCase(chars[index]);
+			}
+			return new String(chars);
+		}
+		return str;
+	}
+
+	/**
+	 * 将字符串用分隔符断裂成字符串列表
+	 * 
+	 * @param value
+	 *            原字符串
+	 * @param separator
+	 *            分隔字符
+	 * @return 结果列表
+	 */
+	public static List<String> split2List(String value, String separator) {
+		List<String> ls = new ArrayList<String>();
+		int i = 0, j = 0;
+		while ((i = value.indexOf(separator, i)) != -1) {
+			ls.add(value.substring(j, i));
+			++i;
+			j = i;
+		}
+		ls.add(value.substring(j));
+		return ls;
+	}
+
+	/**
+	 * 将数组用分隔符连接成新字符串(split的逆方法)
+	 * 
+	 * @param strs
+	 *            字符串数组
+	 * @param sep
+	 *            分隔符
+	 * @return 结果字符串
+	 */
+	public static String join(String[] strs, String sep) {
+		StringBuilder res = new StringBuilder();
+		for (int i = 0; i < strs.length; i++) {
+			res.append(strs[i] + sep);
+		}
+		return res.substring(0, res.length() - sep.length());
+	}
+
+	/**
+	 * 获得一个UUID
+	 * 
+	 * @return String UUID
+	 */
+	public static String getUUID() {
+		String str = UUID.randomUUID().toString();// 标准的UUID格式为:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx(8-4-4-4-12)
+		// 去掉"-"符号,不用replaceAll的原因与split一样,replaceAll支持正则表达式,频繁使用时效率不够高(当然偶尔用一下影响也不会特别严重)
+		return join(split(str, "-"), "");
+	}
+
+	/**
+	 * <pre>
+	 * 例: String strVal="This is a dog"; String
+	 * strResult=CTools.replace(strVal,"dog","cat"); 结果: strResult equals
+	 * "This is cat"
+	 *
+	 * @param strSrc
+	 *            要进行替换操作的字符串
+	 * @param strOld
+	 *            要查找的字符串
+	 * @param strNew
+	 *            要替换的字符串
+	 * @return 替换后的字符串
+	 * 
+	 *         <pre>
+	 */
+	public static final String replaceAllStr(String strSrc, String strOld, String strNew) {
+		if (strSrc == null || strOld == null || strNew == null)
+			return "";
+
+		int i = 0;
+
+		if (strOld.equals(strNew)) // 避免新旧字符一样产生死循环
+			return strSrc;
+
+		if ((i = strSrc.indexOf(strOld, i)) >= 0) {
+			char[] arr_cSrc = strSrc.toCharArray();
+			char[] arr_cNew = strNew.toCharArray();
+
+			int intOldLen = strOld.length();
+			StringBuffer buf = new StringBuffer(arr_cSrc.length);
+			buf.append(arr_cSrc, 0, i).append(arr_cNew);
+
+			i += intOldLen;
+			int j = i;
+
+			while ((i = strSrc.indexOf(strOld, i)) > 0) {
+				buf.append(arr_cSrc, j, i - j).append(arr_cNew);
+				i += intOldLen;
+				j = i;
+			}
+
+			buf.append(arr_cSrc, j, arr_cSrc.length - j);
+
+			return buf.toString();
+		}
+
+		return strSrc;
+	}
+
+	/**
+	 * 用于将字符串中的特殊字符转换成Web页中可以安全显示的字符串 可对表单数据据进行处理对一些页面特殊字符进行处理如'
+	 * <','>','"',''','&'
+	 * 
+	 * @param strSrc
+	 *            要进行替换操作的字符串
+	 * @return 替换特殊字符后的字符串
+	 * @since 1.0
+	 */
+
+	public static String htmlEncode(String strSrc) {
+		if (strSrc == null)
+			return "";
+
+		char[] arr_cSrc = strSrc.toCharArray();
+		StringBuffer buf = new StringBuffer(arr_cSrc.length);
+		char ch;
+
+		for (int i = 0; i < arr_cSrc.length; i++) {
+			ch = arr_cSrc[i];
+
+			if (ch == '<')
+				buf.append("&lt;");
+			else if (ch == '>')
+				buf.append("&gt;");
+			else if (ch == '"')
+				buf.append("&quot;");
+			else if (ch == '\'')
+				buf.append("&#039;");
+			else if (ch == '&')
+				buf.append("&amp;");
+			else
+				buf.append(ch);
+		}
+
+		return buf.toString();
+	}
+
+	/**
+	 * 用于将字符串中的特殊字符转换成Web页中可以安全显示的字符串 可对表单数据据进行处理对一些页面特殊字符进行处理如'
+	 * <','>','"',''','&'
+	 * 
+	 * @param strSrc
+	 *            要进行替换操作的字符串
+	 * @param quotes
+	 *            为0时单引号和双引号都替换,为1时不替换单引号,为2时不替换双引号,为3时单引号和双引号都不替换
+	 * @return 替换特殊字符后的字符串
+	 * @since 1.0
+	 */
+	public static String htmlEncode(String strSrc, int quotes) {
+
+		if (strSrc == null)
+			return "";
+		if (quotes == 0) {
+			return htmlEncode(strSrc);
+		}
+
+		char[] arr_cSrc = strSrc.toCharArray();
+		StringBuffer buf = new StringBuffer(arr_cSrc.length);
+		char ch;
+
+		for (int i = 0; i < arr_cSrc.length; i++) {
+			ch = arr_cSrc[i];
+			if (ch == '<')
+				buf.append("&lt;");
+			else if (ch == '>')
+				buf.append("&gt;");
+			else if (ch == '"' && quotes == 1)
+				buf.append("&quot;");
+			else if (ch == '\'' && quotes == 2)
+				buf.append("&#039;");
+			else if (ch == '&')
+				buf.append("&amp;");
+			else
+				buf.append(ch);
+		}
+
+		return buf.toString();
+	}
+
+	/**
+	 * 和htmlEncode正好相反
+	 * 
+	 * @param strSrc
+	 *            要进行转换的字符串
+	 * @return 转换后的字符串
+	 * @since 1.0
+	 */
+	public static String htmlDecode(String strSrc) {
+		if (strSrc == null)
+			return "";
+		strSrc = strSrc.replaceAll("&lt;", "<");
+		strSrc = strSrc.replaceAll("&gt;", ">");
+		strSrc = strSrc.replaceAll("&quot;", "\"");
+		strSrc = strSrc.replaceAll("&#039;", "'");
+		strSrc = strSrc.replaceAll("&amp;", "&");
+		return strSrc;
+	}
+
+	/**
+	 * 实际处理 return toChineseNoReplace(null2Blank(str));
+	 * 
+	 * @param str
+	 *            要进行处理的字符串
+	 * @return 转换后的字符串
+	 */
+	public static String toChineseAndHtmlEncode(String str, int quotes) {
+		try {
+			if (str == null) {
+				return "";
+			} else {
+				str = str.trim();
+				str = new String(str.getBytes("ISO8859_1"), "GBK");
+				String htmlEncode = htmlEncode(str, quotes);
+				return htmlEncode;
+			}
+		} catch (Exception exp) {
+			return "";
+		}
+	}
+
+	/**
+	 * 把null值和""值转换成&nbsp; 主要应用于页面表格格的显示
+	 * 
+	 * @param str
+	 *            要进行处理的字符串
+	 * @return 转换后的字符串
+	 */
+	public static String str4Table(String str) {
+		if (str == null)
+			return "&nbsp;";
+		else if (str.equals(""))
+			return "&nbsp;";
+		else
+			return str;
+	}
+
+}

+ 2 - 0
src/main/resources/mapper_xml/DepotHeadMapper.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.DepotHeadMapper">
 <mapper namespace="com.jsh.erp.datasource.mappers.DepotHeadMapper">
+
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.DepotHead">
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.DepotHead">
     <id column="id" jdbcType="BIGINT" property="id" />
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="type" jdbcType="VARCHAR" property="type" />
     <result column="type" jdbcType="VARCHAR" property="type" />
@@ -34,6 +35,7 @@
     <result column="link_apply" jdbcType="VARCHAR" property="linkApply" />
     <result column="link_apply" jdbcType="VARCHAR" property="linkApply" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
+    <result column="voucher_picture" jdbcType="VARCHAR" property="voucherPicture" />
   </resultMap>
   </resultMap>
   <sql id="Example_Where_Clause">
   <sql id="Example_Where_Clause">
     <where>
     <where>

+ 8 - 0
src/main/resources/mapper_xml/DepotItemMapper.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.DepotItemMapper">
 <mapper namespace="com.jsh.erp.datasource.mappers.DepotItemMapper">
+
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.DepotItem">
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.DepotItem">
     <id column="id" jdbcType="BIGINT" property="id" />
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="header_id" jdbcType="BIGINT" property="headerId" />
     <result column="header_id" jdbcType="BIGINT" property="headerId" />
@@ -27,6 +28,13 @@
     <result column="link_id" jdbcType="BIGINT" property="linkId" />
     <result column="link_id" jdbcType="BIGINT" property="linkId" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
+
+    <result column="actual_quantity_in_storage" jdbcType="DECIMAL" property="actualQuantityInStorage" />
+    <result column="warehousing_variance" jdbcType="DECIMAL" property="warehousingVariance" />
+    <result column="reason_of_difference" jdbcType="VARCHAR" property="reasonOfDifference" />
+    <result column="warehousing_user" jdbcType="VARCHAR" property="warehousingUser" />
+    <result column="warehousing_time" jdbcType="DATE" property="warehousingTime" />
+
   </resultMap>
   </resultMap>
   <sql id="Example_Where_Clause">
   <sql id="Example_Where_Clause">
     <where>
     <where>

+ 79 - 10
src/main/resources/mapper_xml/MaterialExtendMapper.xml

@@ -4,7 +4,6 @@
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.MaterialExtend">
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.MaterialExtend">
     <id column="id" jdbcType="BIGINT" property="id" />
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="material_id" jdbcType="BIGINT" property="materialId" />
     <result column="material_id" jdbcType="BIGINT" property="materialId" />
-    <result column="bar_code" jdbcType="VARCHAR" property="barCode" />
     <result column="commodity_unit" jdbcType="VARCHAR" property="commodityUnit" />
     <result column="commodity_unit" jdbcType="VARCHAR" property="commodityUnit" />
     <result column="sku" jdbcType="VARCHAR" property="sku" />
     <result column="sku" jdbcType="VARCHAR" property="sku" />
     <result column="purchase_decimal" jdbcType="DECIMAL" property="purchaseDecimal" />
     <result column="purchase_decimal" jdbcType="DECIMAL" property="purchaseDecimal" />
@@ -18,6 +17,14 @@
     <result column="update_time" jdbcType="BIGINT" property="updateTime" />
     <result column="update_time" jdbcType="BIGINT" property="updateTime" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="delete_Flag" jdbcType="VARCHAR" property="deleteFlag" />
     <result column="delete_Flag" jdbcType="VARCHAR" property="deleteFlag" />
+    <result column="production_date" jdbcType="DATE" property="productionDate" />
+    <result column="expiry_num" jdbcType="INTEGER" property="expiryNum" />
+    <result column="supplier_id" jdbcType="BIGINT" property="supplierId" />
+    <result column="bar_code" jdbcType="VARCHAR" property="barCode" />
+    <result column="batch_number" jdbcType="VARCHAR" property="batchNumber" />
+    <result column="inventory" jdbcType="BIGINT" property="inventory" />
+    <result column="depot_id" jdbcType="BIGINT" property="depotId" />
+    <result column="position" jdbcType="VARCHAR" property="position" />
   </resultMap>
   </resultMap>
   <sql id="Example_Where_Clause">
   <sql id="Example_Where_Clause">
     <where>
     <where>
@@ -126,6 +133,7 @@
       #{updateSerial,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT}, 
       #{updateSerial,jdbcType=VARCHAR}, #{updateTime,jdbcType=BIGINT}, #{tenantId,jdbcType=BIGINT}, 
       #{deleteFlag,jdbcType=VARCHAR})
       #{deleteFlag,jdbcType=VARCHAR})
   </insert>
   </insert>
+
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialExtend">
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.MaterialExtend">
     insert into jsh_material_extend
     insert into jsh_material_extend
     <trim prefix="(" suffix=")" suffixOverrides=",">
     <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -135,9 +143,6 @@
       <if test="materialId != null">
       <if test="materialId != null">
         material_id,
         material_id,
       </if>
       </if>
-      <if test="barCode != null">
-        bar_code,
-      </if>
       <if test="commodityUnit != null">
       <if test="commodityUnit != null">
         commodity_unit,
         commodity_unit,
       </if>
       </if>
@@ -177,6 +182,30 @@
       <if test="deleteFlag != null">
       <if test="deleteFlag != null">
         delete_Flag,
         delete_Flag,
       </if>
       </if>
+      <if test="productionDate != null">
+        production_date,
+      </if>
+      <if test="expiryNum != null">
+        expiry_num,
+      </if>
+      <if test="supplierId != null">
+        supplier_id,
+      </if>
+      <if test="barCode != null">
+        bar_code,
+      </if>
+      <if test="batchNumber != null">
+        batch_number,
+      </if>
+      <if test="inventory != null">
+        inventory,
+      </if>
+      <if test="depotId != null">
+        depot_id,
+      </if>
+      <if test="position != null">
+        position,
+      </if>
     </trim>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
       <if test="id != null">
@@ -185,9 +214,6 @@
       <if test="materialId != null">
       <if test="materialId != null">
         #{materialId,jdbcType=BIGINT},
         #{materialId,jdbcType=BIGINT},
       </if>
       </if>
-      <if test="barCode != null">
-        #{barCode,jdbcType=VARCHAR},
-      </if>
       <if test="commodityUnit != null">
       <if test="commodityUnit != null">
         #{commodityUnit,jdbcType=VARCHAR},
         #{commodityUnit,jdbcType=VARCHAR},
       </if>
       </if>
@@ -227,8 +253,33 @@
       <if test="deleteFlag != null">
       <if test="deleteFlag != null">
         #{deleteFlag,jdbcType=VARCHAR},
         #{deleteFlag,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="productionDate != null">
+        #{productionDate,jdbcType=DATE},
+      </if>
+      <if test="expiryNum != null">
+        #{expiryNum,jdbcType=INTEGER},
+      </if>
+      <if test="supplierId != null">
+        #{supplierId,jdbcType=BIGINT},
+      </if>
+      <if test="barCode != null">
+        #{barCode,jdbcType=VARCHAR},
+      </if>
+      <if test="batchNumber != null">
+        #{batchNumber,jdbcType=VARCHAR},
+      </if>
+      <if test="inventory != null">
+        #{inventory,jdbcType=DECIMAL},
+      </if>
+      <if test="depotId != null">
+        #{depotId,jdbcType=BIGINT},
+      </if>
+      <if test="position != null">
+        #{position,jdbcType=VARCHAR},
+      </if>
     </trim>
     </trim>
   </insert>
   </insert>
+
   <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExtendExample" resultType="java.lang.Long">
   <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExtendExample" resultType="java.lang.Long">
     select count(*) from jsh_material_extend
     select count(*) from jsh_material_extend
     <if test="_parameter != null">
     <if test="_parameter != null">
@@ -319,9 +370,6 @@
       <if test="materialId != null">
       <if test="materialId != null">
         material_id = #{materialId,jdbcType=BIGINT},
         material_id = #{materialId,jdbcType=BIGINT},
       </if>
       </if>
-      <if test="barCode != null">
-        bar_code = #{barCode,jdbcType=VARCHAR},
-      </if>
       <if test="commodityUnit != null">
       <if test="commodityUnit != null">
         commodity_unit = #{commodityUnit,jdbcType=VARCHAR},
         commodity_unit = #{commodityUnit,jdbcType=VARCHAR},
       </if>
       </if>
@@ -361,6 +409,27 @@
       <if test="deleteFlag != null">
       <if test="deleteFlag != null">
         delete_Flag = #{deleteFlag,jdbcType=VARCHAR},
         delete_Flag = #{deleteFlag,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="productionDate != null">
+        production_date = #{productionDate,jdbcType=DATE},
+      </if>
+      <if test="expiryNum != null">
+        expiry_num = #{expiryNum,jdbcType=INTEGER},
+      </if>
+      <if test="supplierId != null">
+        supplier_id = #{supplierId,jdbcType=BIGINT},
+      </if>
+      <if test="barCode != null">
+        bar_code = #{barCode,jdbcType=VARCHAR},
+      </if>
+      <if test="inventory != null">
+        inventory = #{inventory,jdbcType=DECIMAL},
+      </if>
+      <if test="depotId != null">
+        depot_id = #{depotId,jdbcType=BIGINT},
+      </if>
+      <if test="position != null">
+        position = #{position,jdbcType=VARCHAR},
+      </if>
     </set>
     </set>
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>
   </update>

+ 2 - 2
src/main/resources/mapper_xml/MaterialExtendMapperEx.xml

@@ -6,8 +6,8 @@
     </resultMap>
     </resultMap>
 
 
     <select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.MaterialExtendExample" resultMap="ResultMapList">
     <select id="getDetailList" parameterType="com.jsh.erp.datasource.entities.MaterialExtendExample" resultMap="ResultMapList">
-        select distinct d.id,d.bar_code,d.commodity_unit,d.sku,d.commodity_decimal,d.purchase_decimal,d.wholesale_decimal,
-                        d.low_decimal,d.default_flag
+        select distinct d.id,d.commodity_unit,d.sku,d.commodity_decimal,d.purchase_decimal,d.wholesale_decimal,
+                        d.low_decimal,d.default_flag,d.production_date,d.expiry_num,d.supplier_id,d.bar_code,d.batch_number,d.inventory,d.depot_id,d.position
         from jsh_material_extend d
         from jsh_material_extend d
         where d.material_id = #{materialId}
         where d.material_id = #{materialId}
         and ifnull(d.delete_flag,'0') !='1'
         and ifnull(d.delete_flag,'0') !='1'

+ 25 - 12
src/main/resources/mapper_xml/MaterialMapper.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.MaterialMapper">
 <mapper namespace="com.jsh.erp.datasource.mappers.MaterialMapper">
+
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.Material">
   <resultMap id="BaseResultMap" type="com.jsh.erp.datasource.entities.Material">
     <id column="id" jdbcType="BIGINT" property="id" />
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="category_id" jdbcType="BIGINT" property="categoryId" />
     <result column="category_id" jdbcType="BIGINT" property="categoryId" />
@@ -27,6 +28,7 @@
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
     <result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
   </resultMap>
   </resultMap>
+
   <sql id="Example_Where_Clause">
   <sql id="Example_Where_Clause">
     <where>
     <where>
       <foreach collection="oredCriteria" item="criteria" separator="or">
       <foreach collection="oredCriteria" item="criteria" separator="or">
@@ -56,6 +58,7 @@
       </foreach>
       </foreach>
     </where>
     </where>
   </sql>
   </sql>
+
   <sql id="Update_By_Example_Where_Clause">
   <sql id="Update_By_Example_Where_Clause">
     <where>
     <where>
       <foreach collection="example.oredCriteria" item="criteria" separator="or">
       <foreach collection="example.oredCriteria" item="criteria" separator="or">
@@ -85,11 +88,13 @@
       </foreach>
       </foreach>
     </where>
     </where>
   </sql>
   </sql>
+
   <sql id="Base_Column_List">
   <sql id="Base_Column_List">
-    id, category_id, name, mfrs, model, standard, brand, mnemonic, color, unit, remark, 
-    img_name, unit_id, expiry_num, weight, enabled, other_field1, other_field2, other_field3, 
-    enable_serial_number, enable_batch_number, position, tenant_id, delete_flag
+    id, category_id, name, model, standard, brand, mnemonic, color, unit, remark,
+    img_name, unit_id, weight, enabled, other_field1, other_field2, other_field3,
+    enable_serial_number, enable_batch_number, tenant_id, delete_flag
   </sql>
   </sql>
+
   <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
   <select id="selectByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="BaseResultMap">
     select
     select
     <if test="distinct">
     <if test="distinct">
@@ -104,22 +109,26 @@
       order by ${orderByClause}
       order by ${orderByClause}
     </if>
     </if>
   </select>
   </select>
+
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select 
     select 
     <include refid="Base_Column_List" />
     <include refid="Base_Column_List" />
     from jsh_material
     from jsh_material
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </select>
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from jsh_material
     delete from jsh_material
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </delete>
   </delete>
+
   <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample">
   <delete id="deleteByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample">
     delete from jsh_material
     delete from jsh_material
     <if test="_parameter != null">
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
       <include refid="Example_Where_Clause" />
     </if>
     </if>
   </delete>
   </delete>
+
   <insert id="insert" parameterType="com.jsh.erp.datasource.entities.Material">
   <insert id="insert" parameterType="com.jsh.erp.datasource.entities.Material">
     insert into jsh_material (id, category_id, name, 
     insert into jsh_material (id, category_id, name, 
       mfrs, model, standard, 
       mfrs, model, standard, 
@@ -140,6 +149,7 @@
       #{position,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
       #{position,jdbcType=VARCHAR}, #{tenantId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=VARCHAR}
       )
       )
   </insert>
   </insert>
+
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Material">
   <insert id="insertSelective" parameterType="com.jsh.erp.datasource.entities.Material">
     insert into jsh_material
     insert into jsh_material
     <trim prefix="(" suffix=")" suffixOverrides=",">
     <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -291,12 +301,14 @@
       </if>
       </if>
     </trim>
     </trim>
   </insert>
   </insert>
+
   <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="java.lang.Long">
   <select id="countByExample" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="java.lang.Long">
     select count(*) from jsh_material
     select count(*) from jsh_material
     <if test="_parameter != null">
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
       <include refid="Example_Where_Clause" />
     </if>
     </if>
   </select>
   </select>
+
   <update id="updateByExampleSelective" parameterType="map">
   <update id="updateByExampleSelective" parameterType="map">
     update jsh_material
     update jsh_material
     <set>
     <set>
@@ -377,6 +389,7 @@
       <include refid="Update_By_Example_Where_Clause" />
       <include refid="Update_By_Example_Where_Clause" />
     </if>
     </if>
   </update>
   </update>
+
   <update id="updateByExample" parameterType="map">
   <update id="updateByExample" parameterType="map">
     update jsh_material
     update jsh_material
     set id = #{record.id,jdbcType=BIGINT},
     set id = #{record.id,jdbcType=BIGINT},
@@ -407,6 +420,7 @@
       <include refid="Update_By_Example_Where_Clause" />
       <include refid="Update_By_Example_Where_Clause" />
     </if>
     </if>
   </update>
   </update>
+
   <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.Material">
   <update id="updateByPrimaryKeySelective" parameterType="com.jsh.erp.datasource.entities.Material">
     update jsh_material
     update jsh_material
     <set>
     <set>
@@ -416,9 +430,6 @@
       <if test="name != null">
       <if test="name != null">
         name = #{name,jdbcType=VARCHAR},
         name = #{name,jdbcType=VARCHAR},
       </if>
       </if>
-      <if test="mfrs != null">
-        mfrs = #{mfrs,jdbcType=VARCHAR},
-      </if>
       <if test="model != null">
       <if test="model != null">
         model = #{model,jdbcType=VARCHAR},
         model = #{model,jdbcType=VARCHAR},
       </if>
       </if>
@@ -446,9 +457,6 @@
       <if test="unitId != null">
       <if test="unitId != null">
         unit_id = #{unitId,jdbcType=BIGINT},
         unit_id = #{unitId,jdbcType=BIGINT},
       </if>
       </if>
-      <if test="expiryNum != null">
-        expiry_num = #{expiryNum,jdbcType=INTEGER},
-      </if>
       <if test="weight != null">
       <if test="weight != null">
         weight = #{weight,jdbcType=DECIMAL},
         weight = #{weight,jdbcType=DECIMAL},
       </if>
       </if>
@@ -470,18 +478,22 @@
       <if test="enableBatchNumber != null">
       <if test="enableBatchNumber != null">
         enable_batch_number = #{enableBatchNumber,jdbcType=VARCHAR},
         enable_batch_number = #{enableBatchNumber,jdbcType=VARCHAR},
       </if>
       </if>
-      <if test="position != null">
-        position = #{position,jdbcType=VARCHAR},
-      </if>
       <if test="tenantId != null">
       <if test="tenantId != null">
         tenant_id = #{tenantId,jdbcType=BIGINT},
         tenant_id = #{tenantId,jdbcType=BIGINT},
       </if>
       </if>
       <if test="deleteFlag != null">
       <if test="deleteFlag != null">
         delete_flag = #{deleteFlag,jdbcType=VARCHAR},
         delete_flag = #{deleteFlag,jdbcType=VARCHAR},
       </if>
       </if>
+      <if test="deleteFlag != null">
+        delete_flag = #{deleteFlag,jdbcType=VARCHAR},
+      </if>
+      <if test="movingPinReminderCycle != null">
+        moving_pin_reminder_cycle = #{movingPinReminderCycle,jdbcType=VARCHAR},
+      </if>
     </set>
     </set>
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>
   </update>
+
   <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.Material">
   <update id="updateByPrimaryKey" parameterType="com.jsh.erp.datasource.entities.Material">
     update jsh_material
     update jsh_material
     set category_id = #{categoryId,jdbcType=BIGINT},
     set category_id = #{categoryId,jdbcType=BIGINT},
@@ -509,4 +521,5 @@
       delete_flag = #{deleteFlag,jdbcType=VARCHAR}
       delete_flag = #{deleteFlag,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
     where id = #{id,jdbcType=BIGINT}
   </update>
   </update>
+
 </mapper>
 </mapper>

+ 14 - 19
src/main/resources/mapper_xml/MaterialMapperEx.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?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">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.jsh.erp.datasource.mappers.MaterialMapperEx">
 <mapper namespace="com.jsh.erp.datasource.mappers.MaterialMapperEx">
+
     <resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapList" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
     <resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapList" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
         <result column="unitName" jdbcType="VARCHAR" property="unitName" />
         <result column="unitName" jdbcType="VARCHAR" property="unitName" />
         <result column="ratio" jdbcType="DECIMAL" property="ratio" />
         <result column="ratio" jdbcType="DECIMAL" property="ratio" />
@@ -125,9 +126,6 @@
             <if test="name != null">
             <if test="name != null">
                 name,
                 name,
             </if>
             </if>
-            <if test="mfrs != null">
-                mfrs,
-            </if>
             <if test="model != null">
             <if test="model != null">
                 model,
                 model,
             </if>
             </if>
@@ -155,9 +153,6 @@
             <if test="unitId != null">
             <if test="unitId != null">
                 unit_id,
                 unit_id,
             </if>
             </if>
-            <if test="expiryNum != null">
-                expiry_num,
-            </if>
             <if test="weight != null">
             <if test="weight != null">
                 weight,
                 weight,
             </if>
             </if>
@@ -179,15 +174,18 @@
             <if test="enableBatchNumber != null">
             <if test="enableBatchNumber != null">
                 enable_batch_number,
                 enable_batch_number,
             </if>
             </if>
-            <if test="position != null">
-                position,
-            </if>
             <if test="tenantId != null">
             <if test="tenantId != null">
                 tenant_id,
                 tenant_id,
             </if>
             </if>
             <if test="deleteFlag != null">
             <if test="deleteFlag != null">
                 delete_flag,
                 delete_flag,
             </if>
             </if>
+            <if test="systemSku != null">
+                system_sku,
+            </if>
+            <if test="movingPinReminderCycle != null">
+                moving_pin_reminder_cycle,
+            </if>
         </trim>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">
             <if test="id != null">
@@ -199,9 +197,6 @@
             <if test="name != null">
             <if test="name != null">
                 #{name,jdbcType=VARCHAR},
                 #{name,jdbcType=VARCHAR},
             </if>
             </if>
-            <if test="mfrs != null">
-                #{mfrs,jdbcType=VARCHAR},
-            </if>
             <if test="model != null">
             <if test="model != null">
                 #{model,jdbcType=VARCHAR},
                 #{model,jdbcType=VARCHAR},
             </if>
             </if>
@@ -229,9 +224,6 @@
             <if test="unitId != null">
             <if test="unitId != null">
                 #{unitId,jdbcType=BIGINT},
                 #{unitId,jdbcType=BIGINT},
             </if>
             </if>
-            <if test="expiryNum != null">
-                #{expiryNum,jdbcType=INTEGER},
-            </if>
             <if test="weight != null">
             <if test="weight != null">
                 #{weight,jdbcType=DECIMAL},
                 #{weight,jdbcType=DECIMAL},
             </if>
             </if>
@@ -253,15 +245,18 @@
             <if test="enableBatchNumber != null">
             <if test="enableBatchNumber != null">
                 #{enableBatchNumber,jdbcType=VARCHAR},
                 #{enableBatchNumber,jdbcType=VARCHAR},
             </if>
             </if>
-            <if test="position != null">
-                #{position,jdbcType=VARCHAR},
-            </if>
             <if test="tenantId != null">
             <if test="tenantId != null">
                 #{tenantId,jdbcType=BIGINT},
                 #{tenantId,jdbcType=BIGINT},
             </if>
             </if>
             <if test="deleteFlag != null">
             <if test="deleteFlag != null">
                 #{deleteFlag,jdbcType=VARCHAR},
                 #{deleteFlag,jdbcType=VARCHAR},
             </if>
             </if>
+            <if test="systemSku != null">
+                #{systemSku,jdbcType=VARCHAR},
+            </if>
+            <if test="movingPinReminderCycle != null">
+                #{movingPinReminderCycle,jdbcType=VARCHAR},
+            </if>
         </trim>
         </trim>
     </insert>
     </insert>
 
 
@@ -392,7 +387,7 @@
 
 
     <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
     <select id="exportExcel" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
         select m.*,u.name unitName, u.ratio, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,
         select m.*,u.name unitName, u.ratio, mc.name categoryName,me.bar_code,me.commodity_unit,me.purchase_decimal, me.commodity_decimal,
-        me.wholesale_decimal, me.low_decimal, me.sku
+        me.wholesale_decimal, me.low_decimal, me.sku, me.production_date, me.expiry_num, me.supplier_id, me.bar_code, me.batch_number, me.depot_id, me.position
         from jsh_material m
         from jsh_material m
         left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
         left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
         left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
         left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'