Commit 93acf01f by wangtian

新增条咨询中心→物流→条形码生成功能

parent 7e3274e6
......@@ -272,6 +272,41 @@
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>code</groupId>
<artifactId>code</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/code.jar</systemPath>
</dependency>
<dependency>
<groupId>barcode4j-2.2.0-SNAPSHOT</groupId>
<artifactId>barcode4j-2.2.0-SNAPSHOT</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/barcode4j-2.2.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>barcode4j-light-2.2.0-SNAPSHOT</groupId>
<artifactId>barcode4j-light-2.2.0-SNAPSHOT</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/barcode4j-light-2.2.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>barcode4j-spi-2.2.0-SNAPSHOT</groupId>
<artifactId>barcode4j-spi-2.2.0-SNAPSHOT</artifactId>
<version>1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/barcode4j-spi-2.2.0-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
<build>
......
package io.office.modules.manage.controller;
import io.office.common.utils.R;
import io.office.modules.app.annotation.Login;
import io.office.modules.manage.entity.GS1CodeListEntity;
import io.office.modules.manage.service.BarcodeGenerationService;
import io.office.modules.manage.utils.CheckAICodeUtil;
import io.office.modules.manage.vo.request.CheckAIVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* ${条码生成}
*
* @author zyf
* @email
* @date 2021-12-09 15:26:10
*/
@RestController
@RequestMapping("/barcodegeneration")
public class BarcodeGenerationController {
@Autowired
private BarcodeGenerationService barcodeGenerationService;
/**
* 条码生成
* @param param 条码内容
* @return pictureUrl 获取条形码地址
*/
@Login
@PostMapping("/api/createQRcode")
public R createQRcode(@RequestBody Map<String,String> param) {
String url = this.barcodeGenerationService.createPicture(param.get("content"));
return R.ok().put("pictureUrl", url);
}
@Login
@ApiOperation(value = "SSCC方式获取GS1 AI标识符列表", response = GS1CodeListEntity.class)
@PostMapping("/api/getGS1CodeListSSCC")
public R getGS1CodeListSSCC() {
List<GS1CodeListEntity> ais = barcodeGenerationService.getGS1CodeListSSCC();
return R.ok().put("ais",ais);
}
@Login
@ApiOperation(value = "GRAI方式获取GS1 AI标识符", response = GS1CodeListEntity.class)
@PostMapping("/api/getGS1CodeListGRAI")
public R getGS1CodeListGRAI() {
GS1CodeListEntity ai = barcodeGenerationService.getGS1CodeListGRAI();
return R.ok().put("ai",ai);
}
@Login
@ApiOperation(value = "校验GS1 AI标识符")
@PostMapping("/api/checkGS1Code")
public R checkGS1Code(@ApiParam(required = true)@Valid @RequestBody CheckAIVo body) {
String result = CheckAICodeUtil.ckeckCode(body.getCode(),body.getContent());
return R.ok().put("result",result);
}
}
......@@ -5,6 +5,8 @@ import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.RedisKeys;
import io.office.modules.app.annotation.Login;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.sys.controller.AbstractController;
import io.swagger.models.auth.In;
......@@ -119,6 +121,7 @@ public class ProductController extends AbstractController {
* @param param:分页参数
* @return
*/
@Login
@RequestMapping("/api/findPage")
// @RequiresPermissions("manage:product:findPage")
public R findPage(@RequestBody Map<String,String> param){
......
......@@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import io.office.modules.app.annotation.Login;
import io.office.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,6 +39,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 查询
*/
@Login
@RequestMapping("/api/find")
public R find(){
Integer id=getUserId().intValue();
......@@ -50,6 +52,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 修改
*/
@Login
@RequestMapping("/api/update")
// @RequiresPermissions("manage:userfunctionbinding:update")
public R update(@RequestBody Integer[] functionids){
......@@ -63,6 +66,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 保存
*/
@Login
@RequestMapping("/api/save")
// @RequiresPermissions("manage:userfunctionbinding:save")
public R save(@RequestBody Integer[] functionids){
......@@ -78,6 +82,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 列表
*/
@Login
@RequestMapping("/api/list")
// @RequiresPermissions("manage:userfunctionbinding:list")
public R list(@RequestParam Map<String, Object> params){
......@@ -88,6 +93,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 信息
*/
@Login
@RequestMapping("/api/info/{id}")
// @RequiresPermissions("manage:userfunctionbinding:info")
public R info(@PathVariable("id") Integer id){
......@@ -98,6 +104,7 @@ public class UserFunctionBindingController extends AbstractController {
/**
* 删除
*/
@Login
@RequestMapping("/delete")
// @RequiresPermissions("manage:userfunctionbinding:delete")
public R delete(@RequestBody Integer[] ids){
......
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.office.modules.manage.entity.GS1CodeListEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface QRcodeDao extends BaseMapper<GS1CodeListEntity> {
List<GS1CodeListEntity> getGS1CodeList();
GS1CodeListEntity getGS1ByMark();
}
package io.office.modules.manage.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* Created by naihe on 2019/9/16.
*/
@Setter
@Getter
@ApiModel(value = "GS1CodeList")
public class GS1CodeListEntity {
@ApiModelProperty(value = "标识符ID")
public String id;
@ApiModelProperty(value = "AI标识符名称")
public String codeName;
@ApiModelProperty(value = "AI标识符编号")
public String codeValue;
/** 是否可变长度(0 不可变 1 可变) */
@ApiModelProperty(value = "是否可变长度(0 不可变 1 可变)")
private Integer isVariable; //
/** 最后一位是否是校验位(0 否 1是) */
@ApiModelProperty(value = "最后一位是否是校验位(0 否 1是)")
private Integer isCheck;
/** 最小长度 */
@ApiModelProperty(value = "最小长度")
private Integer minLength;
/** 最大长度 */
@ApiModelProperty(value = "用户允许输入的最大长度")
private Integer maxLength;
/** 是否是日期(0 否 1是) */
@ApiModelProperty(value = "是否是日期(0 否 1是)")
private Integer isDate;
/** 是否包含小数位(0 不包含 1 包含) */
@ApiModelProperty(value = "是否包含小数位(0 不包含 1 包含)")
private Integer isDecimal;
/** 是否全是数字(0 否 1 是) */
@ApiModelProperty(value = "是否全是数字(0 否 1 是)")
private Integer isNum;
/** 格式 */
@ApiModelProperty(value = "格式")
private String format;
/** 是否需要特殊符号 */
@ApiModelProperty(value = "是否需要特殊符号(0:否 1:是)")
private Integer isFnc1;
/** 数据名称 */
@ApiModelProperty(value = "数据名称")
private String dataName;
/** 输入提示 */
@ApiModelProperty(value = "输入提示")
private String prompt;
}
package io.office.modules.manage.service;
import io.office.modules.manage.entity.GS1CodeListEntity;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* ${comments}
*
* @author zyf
* @email
* @date 2021-12-09 15:26:10
*/
@Service
public interface BarcodeGenerationService {
String createPicture(String content);
List<GS1CodeListEntity> getGS1CodeListSSCC();
GS1CodeListEntity getGS1CodeListGRAI();
}
package io.office.modules.manage.service.impl;
import io.office.common.exception.RRException;
import io.office.modules.manage.dao.QRcodeDao;
import io.office.modules.manage.entity.GS1CodeListEntity;
import io.office.modules.manage.service.BarcodeGenerationService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("barcodegenerationservice")
public class BarcodeGenerationServiceImpl implements BarcodeGenerationService {
@Autowired
private QRcodeDao qRcodeDao;
private final Log logger = LogFactory.getLog(getClass());
public static final String prefix_host="http://localhost:9091/office/";
public static final String prefix_url= "barcodegeneration/api/gensvg?type=";
@Override
public String createPicture(String content) {
String url = "";
if (content.length() > 50) {
throw new RRException("最大50位!");
}
url = prefix_host+prefix_url+"ean128&msg="+content+"&fmt=png&hrsize=5pt&hrfont=song&qz=0.6cm&wf=1&mw=0.17mm&height=1cm";
return url;
}
@Override
public List<GS1CodeListEntity> getGS1CodeListSSCC() {
return this.qRcodeDao.getGS1CodeList();
}
@Override
public GS1CodeListEntity getGS1CodeListGRAI() {
return this.qRcodeDao.getGS1ByMark();
}
}
package io.office.modules.manage.utils;
import io.office.common.exception.RRException;
import org.apache.commons.lang3.ArrayUtils;
/**
* Created by naihe on 2019/10/21.
*/
public class CheckAICodeUtil {
public static String ckeckCode(String ai, String code){
String substring = ai.substring(0, 2);
Integer intCode = Integer.valueOf(substring);
if (intCode<10){
if (intCode == 0 ){
if (code.length() != 17)throw new RRException("AI 为00 的信息需要填充17位数字");
return antoFixCheckCode(code);
}else if(intCode == 1 ){
if (code.length() != 13)throw new RRException("AI 为01 的信息需要填充13位数字");
return antoFixCheckCode(code);
}else if (intCode == 2 ){
if (code.length() != 13)throw new RRException("AI 为02 的信息需要填充13位数字");
return antoFixCheckCode(code);
}
}
return code;
}
//00 01
//返回一位校验码
private static String antoFixCheckCode(String gtinNo){
//gtinNo = "0690123456789";
int sum = 0;
char[] charArray = gtinNo.toCharArray();
ArrayUtils.reverse(charArray);
for(int i =0 ; i < charArray.length ;i++){
char n = charArray[i];
int num = Integer.parseInt(n+"");
if(i%2 != 0){
sum+=num;
}else{
sum+=num*3;
}
}
int ss = (int) Math.ceil(sum/10)*10;
if(ss < sum){
ss+=10;
}
int checkCode = ss -sum;
return checkCode+"";
}
public static void main(String[] args) {
String s="0045848885699885554";
String s1="2121384585698";
System.out.println(antoFixCheckCode(s1));
}
}
package io.office.modules.manage.vo.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.NotBlank;
import java.io.Serializable;
/**
* Created by naihe on 2019/9/7.
*/
@Setter
@Getter
@ApiModel(value = "CheckAIIO")
public class CheckAIVo implements Serializable {
@NotBlank(message = "AI标识符不能为空!!!")
@ApiModelProperty(value = "AI标识符")
public String code;
@NotBlank(message = "输入的内容不能为空!!!")
@ApiModelProperty(value = "输入的内容")
public String content;
}
Manifest-Version: 1.0
Built-By: wangll
Build-Jdk: 1.8.0_111
Created-By: Maven Integration for Eclipse
#Generated by Maven Integration for Eclipse
#Tue Jun 16 15:30:10 CST 2020
version=2.2.0-SNAPSHOT
groupId=net.sf.barcode4j
m2e.projectName=barcode4j-light
m2e.projectLocation=D\:\\\u5F00\u53D1\u5DE5\u5177\\java64\\barcode4j-develop\\barcode4j-light
artifactId=barcode4j-light
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-parent</artifactId>
<version>2.2.0-SNAPSHOT</version>
</parent>
<artifactId>barcode4j-light</artifactId>
<packaging>jar</packaging>
<name>barcode4j-light</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>barcode4j-spi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- <dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
</dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
org.krysalis.barcode4j.impl.codabar.CodabarBean
org.krysalis.barcode4j.impl.code39.Code39Bean
org.krysalis.barcode4j.impl.code128.Code128Bean
org.krysalis.barcode4j.impl.code128.EAN128Bean
org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5Bean
org.krysalis.barcode4j.impl.int2of5.ITF14Bean
org.krysalis.barcode4j.impl.upcean.EAN13Bean
org.krysalis.barcode4j.impl.upcean.EAN8Bean
org.krysalis.barcode4j.impl.upcean.UPCABean
org.krysalis.barcode4j.impl.upcean.UPCEBean
org.krysalis.barcode4j.impl.postnet.POSTNETBean
org.krysalis.barcode4j.impl.fourstate.RoyalMailCBCBean
org.krysalis.barcode4j.impl.fourstate.USPSIntelligentMailBean
org.krysalis.barcode4j.impl.pdf417.PDF417Bean
org.krysalis.barcode4j.impl.datamatrix.DataMatrixBean
org.krysalis.barcode4j.impl.qr.QRCodeBean
00=n17+cd
01=n13+cd
02=n13+cd
10=an1-20
11=d6
13=d6
15=d6
17=d6
20=n2
21=an-20
22=an-29
23x=e
230=n1
231=n10
232=n19
240=an-30
241=an-30
250=an-30
251=an-30
252=n2
30=n-8
310x=n6
311x=n6
312x=n6
313x=n6
314x=n6
315x=n6
316x=n6
32xx=n6
330x=n6
331x=n6
332x=n6
333x=n6
334x=n6
335x=n6
336x=n6
337x=n6
34xx=n6
350x=n6
351x=n6
352x=n6
353x=n6
354x=n6
355x=n6
356x=n6
36xx=n6
37=n-8
390x=n-15
391x=n4-18
392x=n-15
393x=n4-18
400=an-30
401=an-30
402=n17
403=an-30
# 410=n12+cd
# 411=n12+cd
# 412=n12+cd
# 413=n12+cd
# 414=n12+cd
# 415=n12+cd
410=n13
411=n13
412=n13
413=n13
414=n13
415=n13
420=an-9
#???420=an-20
#############################
#421=an4-12
421=n3+an1-9
##############
422=n3
8001=n14
8002=an-20
#############################
#8003=an15-30
8003=n13+cd+an1-16
##############
8004=an-30
8005=n6
#############################
#8006=n18
8006=n13+cd+n2+n2
##############
8007=an-30
8008=n9-12
8018=n18
8020=an-25
#?Typo??8020=an25
8100=n6
8101=n10
8102=n2
9x=an-30
#############################
#91=n2+n9+n2-8+cd0
#420=n5
##############
7001=n13
7002=an-30
7003=n10
7004=n-4
7005=an12
7006=n6
7007=d6
7008=an-3
7009=an-10
7010=an-2
7020=an-20
7021=an-20
7022=an-20
7023=an-30
703s=an4-30
710=an-20
711=an-20
712=an-20
713=an-20
714=an-20
242=n1-6
243=an1-20
253=an14-30
254=an1-20
255=n14-25
1;H;2;E;3
2;B;10;A;0
3;J;12;C;8
4;F;5;G;11
5;I;9;D;1
6;A;1;F;12
7;C;5;B;8
8;E;4;J;11
9;G;3;I;10
10;D;9;H;6
11;F;11;B;4
12;I;5;C;12
13;J;10;A;2
14;H;1;G;7
15;D;6;E;9
16;A;3;I;6
17;G;4;C;7
18;B;1;J;9
19;H;10;F;2
20;E;0;D;8
21;G;2;A;4
22;I;11;B;0
23;J;8;D;12
24;C;6;H;7
25;F;1;E;10
26;B;12;G;9
27;H;3;I;0
28;F;8;J;7
29;E;6;C;10
30;D;4;A;5
31;I;4;F;7
32;H;11;B;9
33;G;0;J;6
34;A;6;E;8
35;C;1;D;2
36;F;9;I;12
37;E;11;G;1
38;J;5;H;4
39;D;3;B;2
40;A;7;C;0
41;B;3;E;1
42;G;10;D;5
43;I;7;J;4
44;C;11;F;6
45;A;8;H;12
46;E;2;I;1
47;F;10;D;0
48;J;3;A;9
49;G;5;C;4
50;H;8;B;7
51;F;0;E;5
52;C;3;A;10
53;G;12;J;2
54;D;11;B;6
55;I;8;H;9
56;F;4;A;11
57;B;5;C;2
58;J;1;E;12
59;I;3;G;6
60;H;0;D;7
61;E;7;H;5
62;A;12;B;11
63;C;9;J;0
64;G;8;F;3
65;D;10;I;2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.office.modules.manage.dao.QRcodeDao">
<select id="getGS1CodeList" resultType="io.office.modules.manage.entity.GS1CodeListEntity">
SELECT id, CONCAT(mark,'(',meaning,')') as codeName,mark codeValue, is_variable isVariable, min_length minLength, enable_max_length maxLength,
is_decimal isDecimal,is_check isCheck, is_num isNum, format, is_fnc1 isFnc1, data_name dataName ,is_date isDate, prompt
FROM gs1_standard
</select>
<select id="getGS1ByMark" resultType="io.office.modules.manage.entity.GS1CodeListEntity">
SELECT id, CONCAT(mark,'(',meaning,')') as codeName,mark codeValue, is_variable isVariable, min_length minLength, enable_max_length maxLength,
is_decimal isDecimal,is_check isCheck, is_num isNum, format, is_fnc1 isFnc1, data_name dataName ,is_date isDate, prompt
FROM gs1_standard where mark='8003'
</select>
</mapper>
\ No newline at end of file
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