Commit beb38615 authored by licc's avatar licc

新增获取产品信息接口

parent d166f071
......@@ -4,6 +4,9 @@ import cn.wisenergy.model.app.LastMonthAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
/**
* @author 86187
*/
public interface LastAccountMapper extends BaseMapper<LastMonthAccount> {
/**
......
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author 86187
*/
@Data
@ApiModel("ProductDto")
public class ProductDto {
/**
* 品牌
*/
@ApiModelProperty(value = "品牌", name = "brand")
private String brand;
/**
* 规格
*/
@ApiModelProperty(value = "规格", name = "specification")
private String specification;
/**
* 品牌名
*/
@ApiModelProperty(value = "品牌名", name = "brandName")
private String brandName;
/**
* 原产国
*/
@ApiModelProperty(value = "原产国", name = "productCountry")
private String productCountry;
/**
* 有效时间
*/
@ApiModelProperty(value = "有效时间", name = "validTime")
private Date validTime;
/**
* 生产日期 yyyy-MM-dd
*/
@ApiModelProperty(value = "生产日期 yyyy-MM-dd", name = "produceTime")
private String produceTime;
/**
* 企业名称
*/
@ApiModelProperty(value = "企业名称", name = "companyName")
private String companyName;
/**
* 企业地址
*/
@ApiModelProperty(value = "企业地址", name = "companyAddress")
private String companyAddress;
/**
* 企业网址
*/
@ApiModelProperty(value = "企业网址", name = "companyUrl")
private String companyUrl;
/**
* 货运单号
*/
@ApiModelProperty(value = "货运单号", name = "trackingNumber")
private String trackingNumber;
/**
* 物流轨迹查询平台
*/
@ApiModelProperty(value = "物流轨迹查询平台", name = "logisticsUrl")
private String logisticsUrl;
/**
* 海关进境货物备案编号
*/
@ApiModelProperty(value = "海关进境货物备案编号", name = "recordNumber")
private String recordNumber;
}
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.*;
/**
* @author 86187
......
......@@ -2,8 +2,10 @@ package cn.wisenergy.service.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AntiFake;
import cn.wisenergy.model.app.ProductInfo;
import cn.wisenergy.model.dto.AntiFakeQuery;
import cn.wisenergy.model.dto.CreateCodeVo;
import cn.wisenergy.model.dto.ProductDto;
import com.github.pagehelper.PageInfo;
import org.springframework.web.multipart.MultipartFile;
......@@ -55,5 +57,11 @@ public interface AntiFakeService {
*/
R<Boolean> report(String batchNumber, HttpServletResponse response);
void exportReceivable(String str, HttpServletResponse response);
/**
* 获取产品信息
* @param shaValue 防伪码
* @return 产品信息
*/
R<ProductDto> getProductInfo(String shaValue);
}
......@@ -5,16 +5,16 @@ import cn.wisenergy.common.utils.DateUtil;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.common.utils.StringUtil;
import cn.wisenergy.mapper.AntiFakeMapper;
import cn.wisenergy.mapper.ProductMapper;
import cn.wisenergy.model.app.AntiFake;
import cn.wisenergy.model.app.ProductInfo;
import cn.wisenergy.model.dto.AntiFakeQuery;
import cn.wisenergy.model.dto.CreateCodeVo;
import cn.wisenergy.model.dto.ProductDto;
import cn.wisenergy.model.vo.ReportCodeVo;
import cn.wisenergy.service.Manager.AntiFakeManger;
import cn.wisenergy.service.app.AntiFakeService;
import cn.wisenergy.service.util.CodeUtils;
import cn.wisenergy.service.util.ExcelUtils;
import cn.wisenergy.service.util.QRCodeUtils;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
......@@ -45,6 +45,9 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
@Autowired
private AntiFakeManger antiFakeManger;
@Autowired
private ProductMapper productMapper;
@Override
public R<Boolean> createCode(CreateCodeVo codeVo) throws ParseException {
log.info("AntiFakeServiceImpl[]createCode[]input.param.codeVo:" + codeVo);
......@@ -233,33 +236,38 @@ public class AntiFakeServiceImpl extends ServiceImpl<AntiFakeMapper, AntiFake> i
}
@Override
public void exportReceivable(String str, HttpServletResponse response) {
if (StringUtils.isBlank(str)) {
return;
}
//把字符转化为数字
List<Long> array = StringUtil.strToLongArray(str);
if (CollectionUtils.isEmpty(array)) {
return;
public R<ProductDto> getProductInfo(String shaValue) {
log.info("AntiFakeServiceImpl[]getProductInfo[]input.param.shaValue:" + shaValue);
if (StringUtils.isBlank(shaValue)) {
return R.error("入参不能为空!");
}
//获取防伪码
List<AntiFake> result = antiFakeMapper.getProductNos(array);
if (CollectionUtils.isEmpty(result)) {
return;
//获取二维码信息
ProductDto productDto = new ProductDto();
AntiFake antiFake = antiFakeMapper.getByShaValue(shaValue);
if (null != antiFake && StringUtils.isNotEmpty(antiFake.getBatchNumber())) {
//获取产品信息
ProductInfo productInfo = productMapper.getByBatchNumber(antiFake.getBatchNumber());
if (null != productInfo) {
productDto.setBrand(productInfo.getBrand());
productDto.setBrandName(productInfo.getBrandName());
productDto.setCompanyAddress(productInfo.getCompanyAddress());
productDto.setCompanyName(productInfo.getCompanyName());
productDto.setCompanyUrl(productInfo.getCompanyUrl());
productDto.setLogisticsUrl(productInfo.getLogisticsUrl());
productDto.setProduceTime(antiFake.getProduceTime());
productDto.setProductCountry(productInfo.getProductCountry());
productDto.setRecordNumber(productInfo.getRecordNumber());
productDto.setSpecification(productInfo.getSpecification());
productDto.setTrackingNumber(productInfo.getTrackingNumber());
productDto.setValidTime(productInfo.getValidTime());
}
}
List<ReportCodeVo> resultBo = new ArrayList<>();
for (AntiFake anti : result) {
String url = REQUEST_URL + anti.getShaValue();
ReportCodeVo reportCodeVo = new ReportCodeVo();
reportCodeVo.setShaValue(url);
resultBo.add(reportCodeVo);
}
ExcelUtils.export(response, resultBo, "aadfgh", ReportCodeVo.class);
return R.ok(productDto);
}
/**
* 分页处理方法
*
......
......@@ -2,8 +2,10 @@ package cn.wisenergy.web.admin.controller.app;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.model.app.AntiFake;
import cn.wisenergy.model.app.ProductInfo;
import cn.wisenergy.model.dto.AntiFakeQuery;
import cn.wisenergy.model.dto.CreateCodeVo;
import cn.wisenergy.model.dto.ProductDto;
import cn.wisenergy.service.app.AntiFakeService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
......@@ -38,18 +40,18 @@ public class AntiFakeController {
@ApiOperation(value = "扫描防伪二维码", notes = "扫描防伪二维码", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "shaValue", value = "防伪码", dataType = "String",required = true),
@ApiImplicitParam(name = "securityCode", value = "安全码", dataType = "String",required = true)
@ApiImplicitParam(name = "shaValue", value = "防伪码", dataType = "String", required = true),
@ApiImplicitParam(name = "securityCode", value = "安全码", dataType = "String", required = true)
})
@ApiImplicitParam(name = "shaValue", value = "防伪码", dataType = "String")
@GetMapping("/admin/scanCode")
public R<String> scanCode(String shaValue,String securityCode) {
log.info("shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:" + shaValue,securityCode);
public R<String> scanCode(String shaValue, String securityCode) {
log.info("shop-mall[]AntiFakeController[]scanCode[]input.param.shaValue:" + shaValue, securityCode);
if (StringUtils.isBlank(shaValue)) {
return R.error("入参为空!");
}
return antiFakeService.scanCode(shaValue,securityCode);
return antiFakeService.scanCode(shaValue, securityCode);
}
......@@ -77,5 +79,16 @@ public class AntiFakeController {
return antiFakeService.report(batchNumber, response);
}
@ApiOperation(value = "获取产品信息", notes = "获取产品信息", httpMethod = "GET")
@ApiImplicitParam(name = "shaValue", value = "防伪码", dataType = "String", required = true)
@GetMapping("admin/productInfo")
public R<ProductDto> getProductInfo(String shaValue) {
log.info("shop-mall[]AntiFakeController[]getProductInfo[]input.param.shaValue:" + shaValue);
if (StringUtils.isBlank(shaValue)) {
return R.error("入参为空!");
}
return antiFakeService.getProductInfo(shaValue);
}
}
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