Commit be3afcf0 authored by licc's avatar licc

二维码实现2

parent d6ba22fa
......@@ -12,6 +12,8 @@
<result column="use_status" property="useStatus"/>
<result column="scan_number" property="scanNumber"/>
<result column="brand" property="brand"/>
<result column="specification" property="specification"/>
<result column="brand_name" property="brandName"/>
<result column="product_country" property="productCountry"/>
<result column="valid_time" property="validTime"/>
<result column="company_name" property="companyName"/>
......@@ -34,21 +36,21 @@
</sql>
<sql id="cols_exclude_id">
product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,product_country,
valid_time, company_name,company_address,company_url,tracking_number,logistics_url,record_number,
create_time,update_time
product_no,batch_number,sha_value,produce_time,scan_time,status,use_status,scan_number,brand,specification,
brand_name,product_country, valid_time, company_name,company_address,company_url,tracking_number,
logistics_url,record_number, create_time,update_time
</sql>
<sql id="vals">
#{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()
</sql>
<sql id="createsVal">
#{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.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
#{i.scanNumber},#{i.brand},#{i.specification},#{i.brandName},#{i.productCountry}, #{i.validTime},#{i.companyName},
#{i.companyAddress}, #{i.companyUrl},#{i.trackingNumber},#{i.logisticsUrl}, #{i.recordNumber},now(),now()
</sql>
<sql id="updateCondition">
......@@ -59,8 +61,10 @@
<if test="scanTime != null">scan_time = #{scanTime},</if>
<if test="status != null">status = #{status},</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="specification != null">specification = #{specification},</if>
<if test="brandName != null">brand_name = #{brandName},</if>
<if test="productCountry != null">product_country = #{productCountry},</if>
<if test="validTime != null">valid_time = #{validTime},</if>
<if test="companyName != null">company_name = #{companyName},</if>
......@@ -83,6 +87,8 @@
<if test="useStatus != null">and use_status = #{useStatus}</if>
<if test="scaNumber != null">and sca_number = #{scaNumber}</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="validTime != null">and valid_time = #{validTime}</if>
<if test="companyName != null">and company_name = #{companyName}</if>
......
......@@ -81,6 +81,18 @@ public class AntiFake implements Serializable {
@ApiModelProperty(value = "品牌", name = "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 {
private Integer number;
/**
* 产品编号
* 生产日期 yyyy-MM-dd
*/
@ApiModelProperty(value = "产品编号", name = "productNo")
private String productNo;
@ApiModelProperty(value = "生产日期 yyyy-MM-dd", name = "produceTime",required = true)
private String produceTime;
/**
* 防伪码
* 规格
*/
@ApiModelProperty(value = "防伪码", name = "shaValue")
private String shaValue;
@ApiModelProperty(value = "规格", name = "specification")
private String specification;
/**
* 生产日期 yyyy-MM-dd
* 品牌名
*/
@ApiModelProperty(value = "生产日期 yyyy-MM-dd", name = "produceTime",required = true)
private String produceTime;
@ApiModelProperty(value = "品牌名", name = "brandName")
private String brandName;
/**
* 原产国
......@@ -55,12 +55,6 @@ public class CreateCodeVo {
@ApiModelProperty(value = "货运单号", name = "trackingNumber")
private String trackingNumber;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty(value = "物流轨迹查询平台", name = "logisticsUrl")
private String logisticsUrl;
/**
* 海关进境货物备案编号
*/
......
......@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;
......@@ -25,7 +26,7 @@ public interface AntiFakeService {
* @param codeVo 二维码信息
* @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;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
......@@ -47,7 +48,7 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
private AntiFakeManger antiFakeManger;
@Override
public R<Boolean> createCode(CreateCodeVo codeVo) {
public R<Boolean> createCode(CreateCodeVo codeVo) throws ParseException {
log.info("AntiFakeServiceImpl[]createCode[]input.param.codeVo:" + codeVo);
if (null == codeVo || StringUtils.isBlank(codeVo.getProduceTime())) {
return R.error("入参不能为空!");
......@@ -99,6 +100,8 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
antiFake.setRecordNumber(codeVo.getRecordNumber());
antiFake.setTrackingNumber(codeVo.getTrackingNumber());
antiFake.setValidTime(codeVo.getValidTime());
antiFake.setSpecification(codeVo.getSpecification());
antiFake.setBrandName(codeVo.getBrandName());
list.add(antiFake);
}
......@@ -248,10 +251,4 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
schemeVo.setPageNo(pageNum);
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;
import cn.wisenergy.common.utils.DateUtil;
import org.apache.commons.lang.RandomStringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
......@@ -14,11 +16,14 @@ public class CodeUtils {
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 ruleNumber = getVerifyNumber(batchNumber, batchNo, produceTime, random);
return VALUE + produceTime + batchNumber + batchNo + random + ruleNumber;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
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;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
/**
* @author 86187
......@@ -32,7 +31,7 @@ public class AntiFakeController {
@ApiOperation(value = "创建二维码", notes = "创建二维码", httpMethod = "POST")
@ApiImplicitParam(name = "codeVo", value = "二维码信息", dataType = "CreateCodeVo")
@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);
}
......
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