Commit be3afcf0 authored by licc's avatar licc

二维码实现2

parent d6ba22fa
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<result column="use_status" property="useStatus"/> <result column="use_status" property="useStatus"/>
<result column="scan_number" property="scanNumber"/> <result column="scan_number" property="scanNumber"/>
<result column="brand" property="brand"/> <result column="brand" property="brand"/>
<result column="specification" property="specification"/>
<result column="brand_name" property="brandName"/>
<result column="product_country" property="productCountry"/> <result column="product_country" property="productCountry"/>
<result column="valid_time" property="validTime"/> <result column="valid_time" property="validTime"/>
<result column="company_name" property="companyName"/> <result column="company_name" property="companyName"/>
...@@ -34,21 +36,21 @@ ...@@ -34,21 +36,21 @@
</sql> </sql>
<sql id="cols_exclude_id"> <sql id="cols_exclude_id">
product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,product_country, product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,specification,
valid_time, company_name,company_address,company_url,tracking_number,logistics_url,record_number, brand_name,product_country, valid_time, company_name,company_address,company_url,tracking_number,
create_time,update_time logistics_url,record_number, create_time,update_time
</sql> </sql>
<sql id="vals"> <sql id="vals">
#{productNo},#{batchNumber},#{shaValue},#{produceTime},#{scanTime},#{status},#{useStatus},#{scanNumber},#{brand}, #{productNo},#{batchNumber},#{shaValue},#{produceTime},#{scanTime},#{status},#{useStatus},#{scanNumber},#{brand},
#{productCountry}, #{validTime},#{companyName},#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl}, #{specification},#{brandName},#{productCountry}, #{validTime},#{companyName},#{companyAddress},#{companyUrl},#{trackingNumber},#{logisticsUrl},
#{recordNumber},now(),now() #{recordNumber},now(),now()
</sql> </sql>
<sql id="createsVal"> <sql id="createsVal">
#{i.productNo},#{i.batchNumber},#{i.shaValue},#{i.produceTime},#{i.scanTime},#{i.status},#{i.useStatus}, #{i.productNo},#{i.batchNumber},#{i.shaValue},#{i.produceTime},#{i.scanTime},#{i.status},#{i.useStatus},
#{i.scanNumber},#{i.brand},#{i.productCountry}, #{i.validTime},#{i.companyName},#{i.companyAddress}, #{i.scanNumber},#{i.brand},#{i.specification},#{i.brandName},#{i.productCountry}, #{i.validTime},#{i.companyName},
#{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now() #{i.companyAddress}, #{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
</sql> </sql>
<sql id="updateCondition"> <sql id="updateCondition">
...@@ -59,8 +61,10 @@ ...@@ -59,8 +61,10 @@
<if test="scanTime != null">scan_time = #{scanTime},</if> <if test="scanTime != null">scan_time = #{scanTime},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="useStatus != null">use_status = #{useStatus},</if> <if test="useStatus != null">use_status = #{useStatus},</if>
<if test="scaNumber != null">sca_number = #{scaNumber},</if> <if test="scanNumber != null">scan_number = #{scanNumber},</if>
<if test="brand != null">brand = #{brand},</if> <if test="brand != null">brand = #{brand},</if>
<if test="specification != null">specification = #{specification},</if>
<if test="brandName != null">brand_name = #{brandName},</if>
<if test="productCountry != null">product_country = #{productCountry},</if> <if test="productCountry != null">product_country = #{productCountry},</if>
<if test="validTime != null">valid_time = #{validTime},</if> <if test="validTime != null">valid_time = #{validTime},</if>
<if test="companyName != null">company_name = #{companyName},</if> <if test="companyName != null">company_name = #{companyName},</if>
...@@ -83,6 +87,8 @@ ...@@ -83,6 +87,8 @@
<if test="useStatus != null">and use_status = #{useStatus}</if> <if test="useStatus != null">and use_status = #{useStatus}</if>
<if test="scaNumber != null">and sca_number = #{scaNumber}</if> <if test="scaNumber != null">and sca_number = #{scaNumber}</if>
<if test="brand != null">and brand = #{brand}</if> <if test="brand != null">and brand = #{brand}</if>
<if test="specification != null">and specification = #{specification}</if>
<if test="brandName != null">and brand_name = #{brandName}</if>
<if test="productCountry != null">and product_country = #{productCountry}</if> <if test="productCountry != null">and product_country = #{productCountry}</if>
<if test="validTime != null">and valid_time = #{validTime}</if> <if test="validTime != null">and valid_time = #{validTime}</if>
<if test="companyName != null">and company_name = #{companyName}</if> <if test="companyName != null">and company_name = #{companyName}</if>
......
...@@ -81,6 +81,18 @@ public class AntiFake implements Serializable { ...@@ -81,6 +81,18 @@ public class AntiFake implements Serializable {
@ApiModelProperty(value = "品牌", name = "brand") @ApiModelProperty(value = "品牌", name = "brand")
private String brand; private String brand;
/**
* 规格
*/
@ApiModelProperty(value = "规格", name = "specification")
private String specification;
/**
* 品牌名
*/
@ApiModelProperty(value = "品牌名", name = "brandName")
private String brandName;
/** /**
* 原产国 * 原产国
*/ */
......
...@@ -20,22 +20,22 @@ public class CreateCodeVo { ...@@ -20,22 +20,22 @@ public class CreateCodeVo {
private Integer number; private Integer number;
/** /**
* 产品编号 * 生产日期 yyyy-MM-dd
*/ */
@ApiModelProperty(value = "产品编号", name = "productNo") @ApiModelProperty(value = "生产日期 yyyy-MM-dd", name = "produceTime",required = true)
private String productNo; private String produceTime;
/** /**
* 防伪码 * 规格
*/ */
@ApiModelProperty(value = "防伪码", name = "shaValue") @ApiModelProperty(value = "规格", name = "specification")
private String shaValue; private String specification;
/** /**
* 生产日期 yyyy-MM-dd * 品牌名
*/ */
@ApiModelProperty(value = "生产日期 yyyy-MM-dd", name = "produceTime",required = true) @ApiModelProperty(value = "品牌名", name = "brandName")
private String produceTime; private String brandName;
/** /**
* 原产国 * 原产国
...@@ -55,12 +55,6 @@ public class CreateCodeVo { ...@@ -55,12 +55,6 @@ public class CreateCodeVo {
@ApiModelProperty(value = "货运单号", name = "trackingNumber") @ApiModelProperty(value = "货运单号", name = "trackingNumber")
private String trackingNumber; private String trackingNumber;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty(value = "物流轨迹查询平台", name = "logisticsUrl")
private String logisticsUrl;
/** /**
* 海关进境货物备案编号 * 海关进境货物备案编号
*/ */
......
...@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo; ...@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List; import java.util.List;
...@@ -25,7 +26,7 @@ public interface AntiFakeService { ...@@ -25,7 +26,7 @@ public interface AntiFakeService {
* @param codeVo 二维码信息 * @param codeVo 二维码信息
* @return true or false * @return true or false
*/ */
R<Boolean> createCode(CreateCodeVo codeVo); R<Boolean> createCode(CreateCodeVo codeVo) throws ParseException;
/** /**
......
...@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -47,7 +48,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i ...@@ -47,7 +48,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
private AntiFakeManger antiFakeManger; private AntiFakeManger antiFakeManger;
@Override @Override
public R<Boolean> createCode(CreateCodeVo codeVo) { public R<Boolean> createCode(CreateCodeVo codeVo) throws ParseException {
log.info("AntiFakeServiceImpl[]createCode[]input.param.codeVo:" + codeVo); log.info("AntiFakeServiceImpl[]createCode[]input.param.codeVo:" + codeVo);
if (null == codeVo || StringUtils.isBlank(codeVo.getProduceTime())) { if (null == codeVo || StringUtils.isBlank(codeVo.getProduceTime())) {
return R.error("入参不能为空!"); return R.error("入参不能为空!");
...@@ -99,6 +100,8 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i ...@@ -99,6 +100,8 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
antiFake.setRecordNumber(codeVo.getRecordNumber()); antiFake.setRecordNumber(codeVo.getRecordNumber());
antiFake.setTrackingNumber(codeVo.getTrackingNumber()); antiFake.setTrackingNumber(codeVo.getTrackingNumber());
antiFake.setValidTime(codeVo.getValidTime()); antiFake.setValidTime(codeVo.getValidTime());
antiFake.setSpecification(codeVo.getSpecification());
antiFake.setBrandName(codeVo.getBrandName());
list.add(antiFake); list.add(antiFake);
} }
...@@ -248,10 +251,4 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i ...@@ -248,10 +251,4 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
schemeVo.setPageNo(pageNum); schemeVo.setPageNo(pageNum);
schemeVo.setPageSize(pageSize); schemeVo.setPageSize(pageSize);
} }
public static void main(String[] args) {
String str = "nishidamori2021042210000001100000091vfpsyib7";
String result = DigestUtils.sha1Hex(str);
System.out.println(result);
}
} }
...@@ -3,6 +3,8 @@ package cn.wisenergy.service.util; ...@@ -3,6 +3,8 @@ package cn.wisenergy.service.util;
import cn.wisenergy.common.utils.DateUtil; import cn.wisenergy.common.utils.DateUtil;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
/** /**
...@@ -14,11 +16,14 @@ public class CodeUtils { ...@@ -14,11 +16,14 @@ public class CodeUtils {
private static final String VALUE = "nishidamori"; private static final String VALUE = "nishidamori";
public static String createProductNo(String batchNumber, String batchNo, String produceTime) { public static String createProductNo(String batchNumber, String batchNo, String produceTime) throws ParseException {
//产品编号 =固定值+生产时间+生产批次+编号+随机数+校验规则 //产品编号 =固定值+生产时间+生产批次+编号+随机数+校验规则
String random = getRandom(); String random = getRandom();
String ruleNumber = getVerifyNumber(batchNumber, batchNo, produceTime, random); SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
return VALUE + produceTime + batchNumber + batchNo + random + ruleNumber; Date date = format.parse(produceTime);
String time = format.format(date);
String ruleNumber = getVerifyNumber(batchNumber, batchNo, time, random);
return VALUE + time + batchNumber + batchNo + random + ruleNumber;
} }
/** /**
......
...@@ -13,10 +13,9 @@ import lombok.extern.slf4j.Slf4j; ...@@ -13,10 +13,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
/** /**
* @author 86187 * @author 86187
...@@ -32,7 +31,7 @@ public class AntiFakeController { ...@@ -32,7 +31,7 @@ public class AntiFakeController {
@ApiOperation(value = "创建二维码", notes = "创建二维码", httpMethod = "POST") @ApiOperation(value = "创建二维码", notes = "创建二维码", httpMethod = "POST")
@ApiImplicitParam(name = "codeVo", value = "二维码信息", dataType = "CreateCodeVo") @ApiImplicitParam(name = "codeVo", value = "二维码信息", dataType = "CreateCodeVo")
@PostMapping(value = "/admin/create/code") @PostMapping(value = "/admin/create/code")
public R<Boolean> create(@RequestBody CreateCodeVo codeVo) { public R<Boolean> create(@RequestBody CreateCodeVo codeVo) throws ParseException {
return antiFakeService.createCode(codeVo); return antiFakeService.createCode(codeVo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment