install commit! refs:#40417

This commit is contained in:
chengzhaofeng 2024-10-15 15:39:59 +08:00
commit 1ddc07fed3
72 changed files with 5535 additions and 0 deletions

37
.gitignore vendored Normal file
View File

@ -0,0 +1,37 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
.idea
*.iws
*.iml
*.ipr
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
.vscode/
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Others
*.log
logs/
*.log.gz
*.xml.versionsBackup

28
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,28 @@
## GitLab CI/CD Config File
## https://ewiki.semi-tech.com/STC/CICD/index.md
## https://docs.gitlab.com/ee/ci/index.html
## https://docs.gitlab.com/ee/ci/yaml/index.html
---
variables:
## `BOT_ALIAS` and `TEMPLATE_ALIAS` can be set here, or defined in your Group/Project > Settings > CI/CD > Variables
## !!!: Project variables > Group variables > Instance(GitLab) variables > .yml job variables > .yml global variables
## CI/CD variable precedence: https://docs.gitlab.com/ee/ci/variables/index.html#cicd-variable-precedence
BOT_ALIAS: "iep_cicd_notify_robot"
TEMPLATE_ALIAS: "sonar"
VERBOSE: "false"
JAVA_VERSION: "8"
default:
tags:
## public runners
- public
include:
## https://gitlab.semi-tech.com/stc/cicd/cicd-config
- project: stc/cicd/cicd-config
ref: master
file: java.yml

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# nlv-print
#### 介绍
打印模块
#### 软件架构
+ print-api
+ print-db
+ print-core
+ print-app

138
db/createTable.sql Normal file
View File

@ -0,0 +1,138 @@
CREATE TABLE `print_fields_custom_logic` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'FieldCustomLogicBO:SITE,FIELD_NUMBER',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工厂',
`FIELD_NUMBER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段编号',
`FUNCTION_NAME` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '方法名',
PRIMARY KEY (`HANDLE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='字段与方法绑定';
CREATE TABLE `print_label_category` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'LabelCategoryBO:SITE,LABEL_CATEGORY_ID',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '站点',
`LABEL_CATEGORY_ID` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签类别编号',
`LABEL_CATEGORY_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签类别名称',
`MODIFY_DATE_TIME` datetime DEFAULT NULL COMMENT '更新时间',
`MODIFY_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '更新人员',
PRIMARY KEY (`HANDLE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='标签类别维护表';
CREATE TABLE `print_label_field_allocation` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'LabelFieldAllocationBO:SITE,LABEL_NUMBER,LABEL_TYPE',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工厂',
`LABEL_NUMBER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签编号',
`LABEL_DESCRIPTION` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签编号描述',
`LABEL_TYPE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签类型',
`MODIFY_DATE_TIME` datetime DEFAULT NULL COMMENT '更新时间',
`MODIFY_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '更新人员',
PRIMARY KEY (`HANDLE`),
KEY `SITE_LABEL_NUMBER` (`SITE`,`LABEL_NUMBER`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='标签字段分配主表';
CREATE TABLE `print_label_field_allocation_detail` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'LabelFieldAllocationDetailBO:SITE,LABEL_NUMBER,LABEL_TYPE,LABEL_FIELD',
`Z_LABEL_FIELD_ALLOCATION_BO` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签字段分配HANDLE',
`SEQ` int DEFAULT NULL,
`LABEL_FIELD` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '标签字段',
`FIELD_NUMBER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段编号',
`MODIFY_DATE_TIME` datetime DEFAULT NULL COMMENT '更新时间',
`MODIFY_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '更新人员',
PRIMARY KEY (`HANDLE`),
KEY `Z_LABEL_FIELD_ALLOCATION_BO` (`Z_LABEL_FIELD_ALLOCATION_BO`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='标签字段分配明细表';
CREATE TABLE `print_printer` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'UUID',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '站点',
`PRINTER_ID` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '打印机编号',
`OPERATION_TYPE` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工序类型',
`PRINT_SCENARIO` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '打印场景',
`LOCATION_DESC` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '位置说明',
`RESOURCE` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '关联资源',
`IP_ADDRESS` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'IP地址',
`MODIFY_DATE_TIME` datetime DEFAULT NULL COMMENT '更新时间',
`MODIFY_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '更新人员',
PRIMARY KEY (`HANDLE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='打印机注册表';
CREATE TABLE `print_label_template` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'PrintLabelTemplateBO:SITE,TEMPLATE_CODE',
`SITE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '站点',
`TEMPLATE_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模板编码',
`TEMPLATE_NAME` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模板名称',
`TEMPLATE_CATEGORY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '模板类别',
`EXTERNAL_RULES` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '是否外部规则',
`CUSTOMER_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '客户编码',
`STATUS` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '状态',
`CREATED_DATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`CREATED_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建人',
PRIMARY KEY (`HANDLE`),
KEY `SITE_TEMPLATE_CODE` (`SITE`,`TEMPLATE_CODE`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='打印标签模板维护';
CREATE TABLE `print_record` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '主键',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '站点',
`SHOP_ORDER` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工单编号',
`BARCODE_NUMBER` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '打印条码序列号',
`BARCODE_TYPE` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '条码类型:工序打印,条码补打印等',
`PRINT_TIMES` int DEFAULT NULL COMMENT '打印次数',
`COPIES` int DEFAULT '0' COMMENT '打印副本数(总计)',
`LAST_PRINT_TIME` datetime NOT NULL COMMENT '打印时间',
`PRINT_TMPL` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '打印模板',
`PRINT_CONTENT` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '打印内容',
`BASEDATA_CONTENT` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin COMMENT '打印基本参考数据',
`PRINTER_NAME` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '打印机名称',
`OPERATION_TYPE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工序类型',
`PRINT_SCENARIO` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '打印场景',
`CREATED_USER` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建人ID',
`MODIFIED_USER` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '修改人ID',
`CREATED_DATE_TIME` datetime NOT NULL COMMENT '创建时间',
`MODIFIED_DATE_TIME` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`HANDLE`),
KEY `SITE_BARCODE_NUMBER` (`SITE`,`BARCODE_NUMBER`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='打印记录表';
CREATE TABLE `print_rule` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'PrintRuleBO:SITE,CUSTOMER_CODE,OPERATION',
`SITE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '站点',
`CUSTOMER_CODE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '客户编码',
`OPERATION` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '对应工序',
`STATUS` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则状态',
`RULE1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式1',
`PRINT_NUMBER1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式1打印次数',
`RULE2` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式2',
`PRINT_NUMBER2` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式2打印次数',
`RULE3` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式3',
`PRINT_NUMBER3` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '规则公式3打印次数',
`CREATED_DATE_TIME` timestamp NULL DEFAULT NULL COMMENT '创建时间',
`CREATED_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '创建人',
PRIMARY KEY (`HANDLE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='客户打印规则维护';
CREATE TABLE `print_field` (
`HANDLE` varchar(412) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'SystemLabelBO:SITE,FIELD_NUMBER',
`SITE` varchar(6) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '工厂',
`FIELD_NUMBER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段编号',
`FIELD_DESCRIPTION` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '字段描述',
`TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '类型',
`GET_VALUE_CONTEXT` varchar(5001) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '例:SQL语句,自定义格式内容等',
`MODIFY_DATE_TIME` datetime DEFAULT NULL COMMENT '更新时间',
`MODIFY_USER` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '更新人员',
PRIMARY KEY (`HANDLE`),
KEY `SITE_FIELD_NUMBER` (`SITE`,`FIELD_NUMBER`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='系统字段定义表';

43
pom.xml Normal file
View File

@ -0,0 +1,43 @@
<?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>com.foreverwin</groupId>
<artifactId>mom</artifactId>
<version>4.5.0</version>
</parent>
<artifactId>nlv-print</artifactId>
<packaging>pom</packaging>
<!--项目子模块-->
<modules>
<module>print-api</module>
<module>print-db</module>
<module>print-core</module>
<module>print-app</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mes-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>print-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>print-db</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

47
print-api/pom.xml Normal file
View File

@ -0,0 +1,47 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.foreverwin</groupId>
<artifactId>nlv-print</artifactId>
<version>4.5.0</version>
</parent>
<artifactId>print-api</artifactId>
<dependencies>
<!--core 工具类-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-core</artifactId>
</dependency>
<!--mybatis plus extension,包含了mybatis plus core-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</dependency>
<!--feign 工具类-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-feign</artifactId>
</dependency>
<!-- excel 导入导出 -->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-excel</artifactId>
</dependency>
<!-- mom通用工具包 -->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mes-common</artifactId>
</dependency>
<!-- mes接口 -->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mes-api</artifactId>
<version>4.5.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,72 @@
package com.foreverwin.nlv.print.dto;
public class LabelFieldSpecificLogicDTO {
private String site;
private String shopOrder;
private String labelType;
private String item;
private String bomtItem;
private String version;
private int size;
public LabelFieldSpecificLogicDTO() {
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public String getSite() {
return site;
}
public void setSite(String site) {
this.site = site;
}
public String getShopOrder() {
return shopOrder;
}
public void setShopOrder(String shopOrder) {
this.shopOrder = shopOrder;
}
public String getLabelType() {
return labelType;
}
public void setLabelType(String labelType) {
this.labelType = labelType;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public String getBomtItem() {
return bomtItem;
}
public void setBomtItem(String bomtItem) {
this.bomtItem = bomtItem;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

View File

@ -0,0 +1,52 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 字段与方法绑定
*
* @author aaron
* @date 2022-11-18 13:22:18
*/
@Data
@TableName("print_fields_custom_logic")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "字段与方法绑定")
public class FieldsCustomLogic extends Model<FieldsCustomLogic> {
private static final long serialVersionUID = 1L;
/**
* FieldCustomLogicBO:SITE,FIELD_NUMBER
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="FieldCustomLogicBO:SITE,FIELD_NUMBER")
private String handle;
/**
* 工厂
*/
@ApiModelProperty(value="工厂")
private String site;
/**
* 字段编号
*/
@ApiModelProperty(value="字段编号")
private String fieldNumber;
/**
* 方法名
*/
@ApiModelProperty(value="方法名")
private String functionName;
}

View File

@ -0,0 +1,75 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 标签类别维护表
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
@Data
@TableName("print_label_category")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "标签类别维护表")
public class LabelCategory extends Model<LabelCategory> {
private static final long serialVersionUID = 1L;
public static final String KW_Z_LABELCATEGORY_BO = "ZLabelcategoryBO";
/**
* 主键
*/
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value = "站点")
private String site;
/**
* 标签类别编号
*/
@ApiModelProperty(value = "标签类别编号")
private String labelCategoryId;
/**
* 标签类别名称
*/
@ApiModelProperty(value = "标签类别名称")
private String labelCategoryName;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String modifyUser;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private LocalDateTime modifyDateTime;
public LabelCategory() {}
public LabelCategory(String site, String labelCategoryId) {
this.site = site;
this.labelCategoryId = labelCategoryId;
this.handle = HandleBoProcessor.genHandle(KW_Z_LABELCATEGORY_BO, site, labelCategoryId);
}
public static String genHandle(String site, String labelCategoryId) {
return HandleBoProcessor.genHandle(KW_Z_LABELCATEGORY_BO, site, labelCategoryId);
}
}

View File

@ -0,0 +1,84 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.util.List;
/**
* 打印模板变量关系维护主表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Data
@TableName("print_label_field_allocation")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "打印模板变量关系维护主表")
public class LabelFieldAllocation extends Model<LabelFieldAllocation> {
private static final long serialVersionUID = 1L;
public static final String KW_Z_LABEL_FIELD_ALLOCATION_BO = "LabelFieldAllocationBO";
/**
* 主键
*/
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value = "站点")
private String site;
/**
* 模板编号
*/
@ApiModelProperty(value = "模板编号")
private String labelNumber;
/**
* 模板类型
*/
@ApiModelProperty(value = "模板类型")
private String labelType;
/**
* 模板名称
*/
@ApiModelProperty(value = "模板名称")
private String labelDescription;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String modifyUser;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private LocalDateTime modifyDateTime;
@TableField(exist = false)
private List<LabelFieldAllocationDetail> labelFieldAllocationDetailList;
public LabelFieldAllocation() {}
public LabelFieldAllocation(String site, String labelNumber) {
this.site = site;
this.labelNumber = labelNumber;
this.handle = HandleBoProcessor.genHandle(KW_Z_LABEL_FIELD_ALLOCATION_BO, site, labelNumber);
}
public static String genHandle(String site, String labelNumber) {
return HandleBoProcessor.genHandle(KW_Z_LABEL_FIELD_ALLOCATION_BO, site, labelNumber);
}
}

View File

@ -0,0 +1,90 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 打印模板变量关系维护明细表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Data
@TableName("print_label_field_allocation_detail")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "打印模板变量关系维护明细表")
public class LabelFieldAllocationDetail extends Model<LabelFieldAllocationDetail> {
private static final long serialVersionUID = 1L;
public static final String KW_Z_LABEL_FIELD_ALLOCATION_DETAIL_BO = "LabelFieldAllocationDetailBO";
/**
* 主键
*/
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "主键")
private String handle;
/**
* 序号
*/
@ApiModelProperty(value = "序号")
private BigDecimal seq;
/**
* 主表关联BO
*/
@ApiModelProperty(value = "主表关联BO")
private String zLabelFieldAllocationBo;
/**
* 模板字段名
*/
@ApiModelProperty(value = "模板字段名")
private String labelField;
/**
* 字段编号
*/
@ApiModelProperty(value = "字段编号")
private String fieldNumber;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建人")
private String modifyUser;
/**
* 修改时间
*/
@ApiModelProperty(value = "创建时间")
private LocalDateTime modifyDateTime;
/**
* 字段描述
*/
@TableField(exist = false)
private String fieldDescription;
public LabelFieldAllocationDetail() {}
public LabelFieldAllocationDetail(String zLabelFieldAllocationBo, String labelField) {
this.zLabelFieldAllocationBo = zLabelFieldAllocationBo;
this.labelField = labelField;
this.handle = HandleBoProcessor.genHandle(KW_Z_LABEL_FIELD_ALLOCATION_DETAIL_BO, zLabelFieldAllocationBo , labelField);
}
public static String genHandle(String zLabelFieldAllocationBo, String labelField) {
return HandleBoProcessor.genHandle(KW_Z_LABEL_FIELD_ALLOCATION_DETAIL_BO, zLabelFieldAllocationBo , labelField);
}
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2018-2025, mom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the foreverwin.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: mom
*/
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 打印标签模板维护
*
* @author MIHUYO
* @date 2022-10-24 17:13:11
*/
@Data
@TableName("print_label_template")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "打印标签模板维护")
public class PrintLabelTemplate extends Model<PrintLabelTemplate> {
private static final long serialVersionUID = 1L;
public static final String KW_Z_PRINT_LABEL_TEMPLATE_BO = "ZPrintLabelTemplateBO";
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value="站点")
private String site;
/**
* 模板编码
*/
@ApiModelProperty(value="模板编码")
private String templateCode;
/**
* 模板名称
*/
@ApiModelProperty(value="模板名称")
private String templateName;
/**
* 模板类别
*/
@ApiModelProperty(value="模板类别")
private String templateCategory;
/**
* 是否外部规则
*/
@ApiModelProperty(value="是否外部规则")
private String externalRules;
/**
* 客户编码
*/
@ApiModelProperty(value="客户编码")
private String customerCode;
/**
* 状态
*/
@ApiModelProperty(value="状态")
private String status;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
private LocalDateTime createdDateTime;
/**
* 创建人
*/
@ApiModelProperty("创建人")
private String createdUser;
public PrintLabelTemplate() {
}
public PrintLabelTemplate(String site, String templateCode) {
this.site = site;
this.templateCode = templateCode;
this.handle = HandleBoProcessor.genHandle(KW_Z_PRINT_LABEL_TEMPLATE_BO, site, templateCode);
}
public static String genHandle(String site, String templateCode) {
return HandleBoProcessor.genHandle(KW_Z_PRINT_LABEL_TEMPLATE_BO, site, templateCode);
}
}

View File

@ -0,0 +1,138 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 打印记录表
*
* @author aaron
* @date 2022-10-29 13:40:49
*/
@Data
@TableName("print_record")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "打印记录表")
public class PrintRecord extends Model<PrintRecord> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value="站点")
private String site;
/**
* 工单编号
*/
@ApiModelProperty(value="工单编号")
private String shopOrder;
/**
* 打印条码序列号
*/
@ApiModelProperty(value="打印条码序列号")
private String barcodeNumber;
/**
* 条码类型:工序打印,条码补打印等
*/
@ApiModelProperty(value="条码类型:工序打印,条码补打印等")
private String barcodeType;
/**
* 打印次数
*/
@ApiModelProperty(value="打印次数")
private Integer printTimes;
/**
* 打印副本数(总计)
*/
@ApiModelProperty(value="打印副本数(总计)")
private Integer copies;
/**
* 打印时间
*/
@ApiModelProperty(value="打印时间")
private LocalDateTime lastPrintTime;
/**
* 打印模板
*/
@ApiModelProperty(value="打印模板")
private String printTmpl;
/**
* 打印内容
*/
@ApiModelProperty(value="打印内容")
private String printContent;
/**
* 打印基本参考数据
*/
@ApiModelProperty(value="打印基本参考数据")
private String basedataContent;
/**
* 打印机名称
*/
@ApiModelProperty(value="打印机名称")
private String printerName;
/**
* 工序类型
*/
@ApiModelProperty(value="工序类型")
private String operationType;
/**
* 打印场景
*/
@ApiModelProperty(value="打印场景")
private String printScenario;
/**
* 创建人ID
*/
@ApiModelProperty(value="创建人ID")
private String createdUser;
/**
* 修改人ID
*/
@ApiModelProperty(value="修改人ID")
private String modifiedUser;
/**
* 创建时间
*/
@ApiModelProperty(value="创建时间")
private LocalDateTime createdDateTime;
/**
* 修改时间
*/
@ApiModelProperty(value="修改时间")
private LocalDateTime modifiedDateTime;
}

View File

@ -0,0 +1,86 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("print_rule")
public class PrintRule extends Model<PrintRule> {
private static final long serialVersionUID = 1L;
/**
* PrintRuleBO:SITE,CUSTOMER_CODE
*/
@TableId(value = "HANDLE", type = IdType.INPUT)
private String handle;
/**
* 站点
*/
@TableField("SITE")
private String site;
/**
* 客户编码
*/
@TableField("CUSTOMER_CODE")
private String customerCode;
/**
* 对应工序
*/
@TableField("OPERATION")
private String operation;
/**
* 规则状态
*/
@TableField("STATUS")
private String status;
/**
* 规则公式1
*/
@TableField("RULE1")
private String rule1;
/**
* 规则公式1打印次数
*/
@TableField("PRINT_NUMBER1")
private String printNumber1;
/**
* 规则公式2
*/
@TableField("RULE2")
private String rule2;
/**
* 规则公式2打印次数
*/
@TableField("PRINT_NUMBER2")
private String printNumber2;
/**
* 规则公式3
*/
@TableField("RULE3")
private String rule3;
/**
* 规则公式3打印次数
*/
@TableField("PRINT_NUMBER3")
private String printNumber3;
/**
* 创建时间
*/
@TableField("CREATED_DATE_TIME")
private LocalDateTime createdDateTime;
/**
* 创建人
*/
@TableField("CREATED_USER")
private String createdUser;
}

View File

@ -0,0 +1,124 @@
/*
* Copyright (c) 2018-2025, mom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the foreverwin.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: mom
*/
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 打印机注册
*
* @author MIHUYO
* @date 2022-10-27 10:51:42
*/
@Data
@TableName("print_printer")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "打印机注册")
public class Printer extends Model<Printer> {
private static final long serialVersionUID = 1L;
public static final String KW_Z_PRINTER_BO = "ZPrinterBO";
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value="主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value="站点")
private String site;
/**
* 打印机编号
*/
@ApiModelProperty(value="打印机编号")
private String printerId;
/**
* 工序类型
*/
@ApiModelProperty(value="工序类型")
private String operationType;
/**
* 打印场景
*/
@ApiModelProperty(value="打印场景")
private String printScenario;
/**
* 位置说明
*/
@ApiModelProperty(value="位置说明")
private String locationDesc;
/**
* 关联资源
*/
@ApiModelProperty(value="关联资源")
private String resource;
/**
* IP地址
*/
@ApiModelProperty(value="IP地址")
private String ipAddress;
/**
* 创建人
*/
@ApiModelProperty(value="创建人")
private String modifyUser;
/**
* 创建时间
*/
@ApiModelProperty(value="创建时间")
private LocalDateTime modifyDateTime;
public Printer() {}
public Printer(String site, String printerId) {
this.site = site;
this.printerId = printerId;
this.handle = HandleBoProcessor.genHandle(KW_Z_PRINTER_BO, site, printerId);
}
public static String genHandle(String site, String printerId) {
return HandleBoProcessor.genHandle(KW_Z_PRINTER_BO, site, printerId);
}
}

View File

@ -0,0 +1,82 @@
package com.foreverwin.nlv.print.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 系统字段定义
*
* @author MIHUYO
* @date 2022-10-28 09:17:15
*/
@Data
@TableName("print_field")
@ApiModel(value = "打印字段定义")
public class SystemField {
private static final long serialVersionUID = 1L;
public static final String KW_Z_SYSTEM_FIELD_BO = "ZSystemFieldBO";
/**
* 主键
*/
@TableId(type = IdType.INPUT)
@ApiModelProperty(value = "主键")
private String handle;
/**
* 站点
*/
@ApiModelProperty(value = "站点")
private String site;
/**
* 字段编号
*/
@ApiModelProperty(value = "字段编号")
private String fieldNumber;
/**
* 字段描述
*/
@ApiModelProperty(value = "字段描述")
private String fieldDescription;
/**
* 类型
*/
@ApiModelProperty(value = "类型")
private String type;
/**
* 取值逻辑:SQL语句,自定义格式内容等
*/
@ApiModelProperty(value = "取值逻辑:SQL语句,自定义格式内容等")
private String getValueContext;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String modifyUser;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private LocalDateTime modifyDateTime;
public SystemField() {}
public SystemField(String site, String fieldNumber) {
this.site = site;
this.fieldNumber = fieldNumber;
this.handle = HandleBoProcessor.genHandle(KW_Z_SYSTEM_FIELD_BO, site, fieldNumber);
}
public static String genHandle(String site, String fieldNumber) {
return HandleBoProcessor.genHandle(KW_Z_SYSTEM_FIELD_BO, site, fieldNumber);
}
}

View File

@ -0,0 +1,70 @@
package com.foreverwin.nlv.print.util;
import cn.hutool.core.util.StrUtil;
import java.util.*;
import java.util.function.BiFunction;
/**
* @program: horizon.biz
* @description:
* @author: syngna
* @create: 2021-08-20 16:58
*/
public class ArrayUtil {
/**
* 把map的key转换成驼峰命名(递归)
*
* @param map
* @return
*/
public static void transferKeyToUnderline(Map<String, Object> map, Map<String, Object> resultMap, Set<String> ignoreKeys) {
Set<Map.Entry<String, Object>> entries = map.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String key = entry.getKey();
Object value = entry.getValue();
if (ignoreKeys.contains(key)) {
resultMap.put(key, value);
continue;
}
String newKey = key;
if(StrUtil.isUpperCase(key) || key.contains("_")) {
newKey = StrUtil.toCamelCase(key.toLowerCase());
}
if ((value instanceof List)) {
List newList = buildValueList(
(List) value, ignoreKeys,
(m, keys) -> {
Map subResultMap = new HashMap();
transferKeyToUnderline(m, subResultMap, ignoreKeys);
return subResultMap;
});
resultMap.put(newKey, newList);
} else if (value instanceof Map) {
Map<String, Object> subResultMap = new HashMap<>();
transferKeyToUnderline((Map) value, subResultMap, ignoreKeys);
resultMap.put(newKey, subResultMap);
} else {
resultMap.put(newKey, value);
}
}
}
public static List buildValueList(List valList, Set<String> ignoreKeys, BiFunction<Map, Set, Map> transferFunc) {
if (valList == null || valList.size() == 0) {
return valList;
}
Object first = valList.get(0);
if (!(first instanceof List) && !(first instanceof Map)) {
return valList;
}
List newList = new ArrayList();
for (Object val : valList) {
Map<String, Object> subResultMap = transferFunc.apply((Map) val, ignoreKeys);
newList.add(subResultMap);
}
return newList;
}
}

View File

@ -0,0 +1,760 @@
package com.foreverwin.nlv.print.util;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.util.*;
public class DateUtil
{
public static final String[] YEARS = {"2017年", "2018年", "2019年", "2020年", "2021年", "2022年", "2023年", "2024年", "2025年", "2026年", "2027年"};
public static final String[] YEARS_SHORT = {"2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027"};
public static final String[] MONTHS = {"01月", "02月", "03月", "04月", "05月", "06月", "07月", "08月", "09月", "10月", "11月", "12月"};
public static final String[] MONTHS_SHORT = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
public static final String[] DAYS = {"0天", "1天", "2天", "3天", "4天", "5天", "6天", "7天", "8天", "9天", "10天",
"11天", "12天", "13天", "14天", "15天", "16天", "17天", "18天", "19天", "20天",
"21天", "22天", "23天", "24天", "25天", "26天", "27天", "28天", "29天", "30天", "31天"};
public static final short DATE_TYPE_MILLISECOND = 0;
public static final short DATE_TYPE_SECOND = 1;
public static final short DATE_TYPE_MINUTE = 2;
public static final short DATE_TYPE_HOUR = 3;
public static final short DATE_TYPE_DAY = 4;
private static final String[] WEEK_DAYS = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final SimpleDateFormat FORMATTER_SERIAL = new SimpleDateFormat("yyyyMMddHHmmss");
private static final SimpleDateFormat FORMATTER_SHORT = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat FORMATTER_SHORT_GMT = new SimpleDateFormat("yyyy-MM-dd");
private static final SimpleDateFormat FORMATTER_SHORT_SLASH = new SimpleDateFormat("yyyy/MM/dd");
private static final SimpleDateFormat FORMATTER_SHORT_SERIAL = new SimpleDateFormat("yyyyMMdd");
private static final SimpleDateFormat FORMATTER_MIDDLE = new SimpleDateFormat("yyyy-MM-dd HH:mm");
private static final SimpleDateFormat FORMATTER_LONG = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
private static final SimpleDateFormat FORMATTER_NUMBER = new SimpleDateFormat("yyMMddHHmmss");
private static final SimpleDateFormat FORMATTER_YEAR = new SimpleDateFormat("yyyy");
private static final SimpleDateFormat FORMATTER_MONTH = new SimpleDateFormat("MM");
private static final SimpleDateFormat FORMATTER_DAY = new SimpleDateFormat("dd");
private static final SimpleDateFormat FORMATTER_YEAR_MONTH = new SimpleDateFormat("yyyy-MM");
private static final SimpleDateFormat FORMATTER_YEAR_MONTH_SERIAL = new SimpleDateFormat("yyyyMM");
public static Date toDate(LocalDate localDate) {
if (localDate == null) return null;
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static Date toDate(LocalDateTime localDateTime)
{
if (localDateTime == null) return null;
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
//Date -> LocalDate
public static LocalDate toLocalDate(Date date)
{
if (date == null) return null;
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
}
//Date -> LocalDateTime
public static LocalDateTime toLocalDateTime(Date date)
{
if (date == null) return null;
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
public static Date parseDate(String str)
{
str = StringUtil.toString(str);
if (!str.equals(""))
{
try
{
return FORMATTER.parse(str);
}
catch (Exception ex)
{
ex.printStackTrace();
return parseDateShort(str);
}
}
return null;
}
public static Date parseDateShort(String str)
{
str = StringUtil.toString(str);
if (!str.equals(""))
{
try
{
return FORMATTER_SHORT.parse(str);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
return null;
}
public static Date parseDateLong(String str)
{
str = StringUtil.toString(str);
if (!str.equals(""))
{
try
{
return FORMATTER_LONG.parse(str);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
return null;
}
public static Date parseDateYearMonth(String str)
{
str = StringUtil.toString(str);
if (!str.equals(""))
{
try
{
return FORMATTER_YEAR_MONTH.parse(str);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
return null;
}
public static String formatDate(Date date)
{
if (date != null)
{
return FORMATTER.format(date);
}
return "";
}
public static String formatDate(Date date, String fmt) {
SimpleDateFormat format = new SimpleDateFormat(fmt);
return format.format(date);
}
/***
* 把日期转换成字符串
*
* @param time
* @return
*/
public static String convertToStr(Date time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(time);
}
/* *//*
* 截取日期的年月日
* *//*
public static int interceptTime(String time) throws ParseException {
String dateStr = time;
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateStr );
Calendar ca = Calendar.getInstance();
ca.setTime(date);
int month = ca.get(Calendar.MONTH)+1;//第几个月
int year = ca.get(Calendar.YEAR);//年份数值
int monthday=ca.get(Calendar.DAY_OF_MONTH);//一个月中的第几天
int interceprT=year+month+monthday ;
return interceprT;
}*/
/**
* 在某一指定的日期基础上进行日期的偏差设置,参数意义同getNowDate
*
* @param date
* @param deviation
* @return
*/
public final static Date setDate(Date date, int... deviation) {
Calendar cal = Calendar.getInstance(Locale.US);
cal.setTime(date);
if (deviation.length < 1) {
return cal.getTime();
}
final int[] filed = {Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND};
for (int i = 0; i < deviation.length; i++) {
cal.add(filed[i], deviation[i]);
}
return cal.getTime();
}
/**
* 使用简单化的方式来解析日期时间格式.
*
* @param dateStr
* @return
*/
public final static Date parseSimpleDateTime(String dateStr) {
return parseSimpleDT("yyyy-MM-dd HH:mm:ss", dateStr);
}
/**
* 使用指定的模式来解析字符串日期时间.
*
* @param pattern
* @param dateStr
* @return
*/
public final static Date parseSimpleDT(String pattern, String dateStr) {
try {
return new SimpleDateFormat(pattern, Locale.US).parse(dateStr);
} catch (ParseException ex) {
return null;
}
}
public static String formatDateSerial(Date date)
{
if (date != null)
{
return FORMATTER_SERIAL.format(date);
}
return "";
}
public static String formatDateShort(Date date)
{
if (date != null)
{
return FORMATTER_SHORT.format(date);
}
return "";
}
public static String formatDateShortSlash(Date date)
{
if (date != null)
{
return FORMATTER_SHORT_SLASH.format(date);
}
return "";
}
public static String formatDateShortSerial(Date date)
{
if (date != null)
{
return FORMATTER_SHORT_SERIAL.format(date);
}
return "";
}
public static String formatDateMiddle(Date date)
{
if (date != null)
{
return FORMATTER_MIDDLE.format(date);
}
return "";
}
public static String formatDateLong(Date date)
{
if (date != null)
{
return FORMATTER_LONG.format(date);
}
return "";
}
public static String formatDateNumber(Date date)
{
if (date != null)
{
return FORMATTER_NUMBER.format(date);
}
return "";
}
public static String formatDateYear(Date date)
{
if (date != null)
{
return FORMATTER_YEAR.format(date);
}
return "";
}
public static String formatDateMonth(Date date)
{
if (date != null)
{
return FORMATTER_MONTH.format(date);
}
return "";
}
public static String formatDateDay(Date date)
{
if (date != null)
{
return FORMATTER_DAY.format(date);
}
return "";
}
public static String formatDateYearMonth(Date date)
{
if (date != null)
{
return FORMATTER_YEAR_MONTH.format(date);
}
return "";
}
public static String formatDateYearMonthSerial(Date date)
{
if (date != null)
{
return FORMATTER_YEAR_MONTH_SERIAL.format(date);
}
return "";
}
public static String formatGMTShort()
{
Calendar calendar = Calendar.getInstance(new SimpleTimeZone(0, "GMT"));
FORMATTER_SHORT_GMT.setCalendar(calendar);
return FORMATTER_SHORT_GMT.format(new Date());
}
public static String formatGMTShort(Date date)
{
Calendar calendar = Calendar.getInstance(new SimpleTimeZone(0, "GMT"));
FORMATTER_SHORT_GMT.setCalendar(calendar);
return FORMATTER_SHORT_GMT.format(date);
}
public static String formatTime(long seconds)
{
String result = "00:00";
if (seconds > 0)
{
long minute = seconds / 60;
if (minute < 60)
{
long second = seconds % 60;
result = formatterTime(minute) + ":" + formatterTime(second);
}
else
{
long hour = minute / 60;
if (hour <= 99)
{
minute = minute % 60;
long second = seconds - hour * 3600 - minute * 60;
result = formatterTime(hour) + ":" + formatterTime(minute) + ":" + formatterTime(second);
}
else
{
result = "99:59:59";
}
}
}
return result;
}
private static String formatterTime(long time)
{
String result = null;
if ((time >= 0) && (time < 10))
{
result = "0" + Long.toString(time);
}
else
{
result = time + "";
}
return result;
}
public static boolean largeThan(Date date)
{
return date.compareTo(new Date()) > 0;
}
public static boolean largeThan(Date date1, Date date2)
{
return date1.compareTo(date2) > 0;
}
public static boolean largeEqual(Date date)
{
return date.compareTo(new Date()) >= 0;
}
public static boolean largeEqual(Date date1, Date date2)
{
return date1.compareTo(date2) >= 0;
}
public static boolean lessThan(Date date)
{
return date.compareTo(new Date()) < 0;
}
public static boolean lessThan(Date date1, Date date2)
{
return date1.compareTo(date2) < 0;
}
public static boolean lessEqual(Date date)
{
return date.compareTo(new Date()) <= 0;
}
public static boolean lessEqual(Date date1, Date date2)
{
return date1.compareTo(date2) <= 0;
}
public static Date getCurrentDate()
{
return new Date();
}
public static Date getBeginDateByDay()
{
return getBeginDateByDay(new Date());
}
public static Date getBeginDateByDay(Date date)
{
if (date != null)
{
String _date = formatDateShort(date);
String beginDate = _date.substring(0, 10) + " 00:00:00";
return parseDate(beginDate);
}
return null;
}
public static Date getBeginDateByWeek()
{
Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 2;
calendar.add(Calendar.DATE, - dayOfWeek);
return getBeginDateByDay(calendar.getTime());
}
public static Date getBeginDateByMonth()
{
return getBeginDateByMonth(null, 0);
}
public static Date getBeginDateByMonth(Date date)
{
return getBeginDateByMonth(date, 0);
}
public static Date getBeginDateByMonth(int count)
{
return getBeginDateByMonth(null, count);
}
public static Date getBeginDateByMonth(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
if (date != null)
{
calendar.setTime(date);
}
calendar.add(Calendar.MONTH, count);
calendar.set(Calendar.DAY_OF_MONTH, 1);
return getBeginDateByDay(calendar.getTime());
}
public static Date getEndDateByDay()
{
return getEndDateByDay(new Date());
}
public static Date getEndDateByDay(Date date)
{
if (date != null)
{
String _date = formatDateShort(date);
String endDate = _date.substring(0, 10) + " 23:59:59";
return parseDate(endDate);
}
return null;
}
public static Date getEndDateByWeek()
{
Calendar calendar = Calendar.getInstance();
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 2;
calendar.add(Calendar.DATE, -dayOfWeek);
calendar.add(Calendar.DATE, 6);
return getEndDateByDay(calendar.getTime());
}
public static Date getEndDateByMonth()
{
return getEndDateByMonth(null, 0);
}
public static Date getEndDateByMonth(Date date)
{
return getEndDateByMonth(date, 0);
}
public static Date getEndDateByMonth(int count)
{
return getEndDateByMonth(null, count);
}
public static Date getEndDateByMonth(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
if (date != null)
{
calendar.setTime(date);
}
calendar.add(Calendar.MONTH, count);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
return getEndDateByDay(calendar.getTime());
}
public static Date getDateByDay(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, count);
return calendar.getTime();
}
public static Date getDateByWeek(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.WEEK_OF_YEAR, count);
return calendar.getTime();
}
public static Date getDateByMonth(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, count);
return calendar.getTime();
}
public static Date getDateByYear(Date date, int count)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.YEAR, count);
return calendar.getTime();
}
public static long getTimeInMillis(String str)
{
return getTimeInMillis(parseDate(str));
}
public static long getTimeInMillis(Date date)
{
if (date != null)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.getTimeInMillis();
}
return 0;
}
public static long getTimestamp()
{
return System.currentTimeMillis() / 1000;
}
public static long getIntervalTime(Date beginDate, Date endDate)
{
return getIntervalTime(beginDate, endDate, DATE_TYPE_MILLISECOND);
}
public static long getIntervalTime(Date beginDate, short dateType)
{
return getIntervalTime(beginDate, new Date(), dateType);
}
public static long getIntervalTime(Date beginDate, Date endDate, short dateType)
{
long times = endDate.getTime() - beginDate.getTime();
if (dateType == DATE_TYPE_SECOND)
{
return times / 1000;
}
if (dateType == DATE_TYPE_MINUTE)
{
return times / 1000 / 60;
}
else if (dateType == DATE_TYPE_HOUR)
{
return times / 1000 / 60 / 60;
}
else if (dateType == DATE_TYPE_DAY)
{
return times / 1000 / 60 / 60 / 24;
}
else
{
return times;
}
}
public static List<Date> getIntervalDates(Date beginDate, Date endDate)
{
List<Date> dates = new ArrayList<Date>();
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTime(beginDate);
Calendar endCalendar = Calendar.getInstance();
endCalendar.setTime(endDate);
while (startCalendar.before(endCalendar) || startCalendar.equals(endCalendar))
{
dates.add(startCalendar.getTime());
startCalendar.add(Calendar.DAY_OF_YEAR, 1);
}
return dates;
}
public static String getWeekDay(Date date)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int index = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if (index < 0)
{
index = 0;
}
return WEEK_DAYS[index];
}
public static long getMonthDayCount(Date date)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
}
public static String parseDiff(Date begin, Date end)
{
long diff = end.getTime() - begin.getTime();//这样得到的差值是毫秒级别
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff-days*(1000 * 60 * 60 * 24))/(1000* 60 * 60);
long minutes = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60))/(1000* 60);
long seconds = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60)-minutes*(1000*60))/1000;
return days+"天"+hours+"小时"+minutes+"分"+seconds+"秒";
}
/***
* 判断两日期是否同一天
* @param d1
* @param d2
* @return
*/
public static boolean sameDate(Date d1, Date d2) {
LocalDate localDate1 = ZonedDateTime.ofInstant(d1.toInstant(), ZoneId.systemDefault()).toLocalDate();
LocalDate localDate2 = ZonedDateTime.ofInstant(d2.toInstant(), ZoneId.systemDefault()).toLocalDate();
return localDate1.isEqual(localDate2);
}
/**
* 判断两日期是否同一周
*
* @param date1
* @param date2
* @return
*/
public static boolean sameWeek(Date date1, Date date2) {
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
//subYear==0,说明是同一年
if (subYear == 0) {
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) {
return true;
}
} else if (subYear == 1 && cal2.get(Calendar.MONTH) == 11) {
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
return true;
} else if (subYear == -1 && cal1.get(Calendar.MONTH) == 11) {
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR))
return true;
}
return false;
}
/**
* 判断两日期是否同一月
*
* @param date1
* @param date2
* @return
*/
public static boolean sameMonth(Date date1, Date date2) {
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
int year1 = cal1.get(Calendar.YEAR);
int year2 = cal2.get(Calendar.YEAR);
int month1 = cal1.get(Calendar.MONTH);
int month2 = cal2.get(Calendar.MONTH);
String m1 = "" + year1 + month1;
String m2 = "" + year2 + month2;
return m1.equals(m2);
}
/**
* 判断两日期是否同一年
*
* @param date1
* @param date2
* @return
*/
public static boolean sameYear(Date date1, Date date2) {
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR);
}
public static Timestamp getGmtTime() {
SimpleDateFormat gmtDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:sss.SSS");
gmtDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return Timestamp.valueOf(gmtDateFormat.format(new Date()));
}
}

View File

@ -0,0 +1,70 @@
package com.foreverwin.nlv.print.util;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Cell;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ExcelCellWidthStyleStrategy extends AbstractColumnWidthStyleStrategy {
// 可以根据这里的最大宽度,按自己需要进行调整,搭配单元格样式实现类中的,自动换行,效果更好
private static final int MAX_COLUMN_WIDTH = 50;
private Map<Integer, Map<Integer, Integer>> CACHE = new HashMap(8);
@Override
protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell,
Head head, Integer relativeRowIndex, Boolean isHead) {
boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList);
if (needSetWidth) {
Map<Integer, Integer> maxColumnWidthMap = (Map)CACHE.get(writeSheetHolder.getSheetNo());
if (maxColumnWidthMap == null) {
maxColumnWidthMap = new HashMap(16);
CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap);
}
Integer columnWidth = this.dataLength(cellDataList, cell, isHead);
if (columnWidth >= 0) {
if (columnWidth > MAX_COLUMN_WIDTH) {
columnWidth = MAX_COLUMN_WIDTH;
}
Integer maxColumnWidth = (Integer)((Map)maxColumnWidthMap).get(cell.getColumnIndex());
if (maxColumnWidth == null || columnWidth > maxColumnWidth) {
((Map)maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth);
writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256);
}
}
}
}
private Integer dataLength(List<WriteCellData<?>> cellDataList, Cell cell, Boolean isHead) {
if (isHead) {
return cell.getStringCellValue().getBytes().length;
} else {
WriteCellData cellData = (WriteCellData)cellDataList.get(0);
CellDataTypeEnum type = cellData.getType();
if (type == null) {
return -1;
} else {
switch(type) {
case STRING:
return cellData.getStringValue().getBytes().length;
case BOOLEAN:
return cellData.getBooleanValue().toString().getBytes().length;
case NUMBER:
return cellData.getNumberValue().toString().getBytes().length;
default:
return -1;
}
}
}
}
}

View File

@ -0,0 +1,16 @@
package com.foreverwin.nlv.print.util;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class FrontPage<T> extends Page {
private String searchText;
public FrontPage() {
}
}

View File

@ -0,0 +1,527 @@
package com.foreverwin.nlv.print.util;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil
{
public static final String SPLITOR_COMMON = "_#,#_";
public static final String NUMBER_CHARS = "0123456789";
public static final String UPPER_ALPHA_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String UPPER_ALPHA_NUMBER_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static final String ALPHA_NUMBER_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String[] CHINESE_MONEY_NUMBERS = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
private static final String[] CHINESE_MONEY_INTEGER = {"元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "万", "拾", "佰", "仟"};
private static final String[] CHINESE_MONEY_DECIMAL = {"角", "分", "厘"};
private static char[] QUID_ALPHA_NUMBER = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z' };
private static char[] QUID_ALPHA = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z' };
public static String createQUID()
{
return createAlphaNumericText(32);
}
public static String createAlphaNumericText(int length)
{
Random random = new Random();
StringBuilder str_builer = new StringBuilder();
char c = '\000';
c = QUID_ALPHA[random.nextInt(QUID_ALPHA.length)];
str_builer.append(c);
for (int i = 0; i < length - 1; i++)
{
c = QUID_ALPHA_NUMBER[random.nextInt(QUID_ALPHA_NUMBER.length)];
str_builer.append(c);
}
return str_builer.toString();
}
public static String append(String str, String appender, int position)
{
if (toString(str).equals(""))
{
return appender;
}
else if (toString(appender).equals(""))
{
return str;
}
else if (position <= 0)
{
return appender + str;
}
else if (position > str.length())
{
return str + appender;
}
String substr1 = str.substring(0, position);
String substr2 = str.substring(position, str.length());
return substr1 + appender + substr2;
}
public static int indexOf(String str, String substr)
{
if (!toString(str).equals(""))
{
return str.indexOf(substr);
}
return -1;
}
public static int lastIndexOf(String str, String substr)
{
if (!toString(str).equals(""))
{
return str.lastIndexOf(substr);
}
return -1;
}
public static boolean isEmpty(String str)
{
if (toString(str).equals(""))
{
return true;
}
return false;
}
public static boolean notEmpty(String str)
{
return !isEmpty(str);
}
public static String random(int length)
{
return random(length, ALPHA_NUMBER_CHARS);
}
public static String random(int length, String seed)
{
if (length < 1)
{
return "";
}
Random random = new Random();
char[] chars = new char[length];
char[] letters = seed.toCharArray();
for (int i = 0; i < chars.length; i++)
{
chars[i] = letters[random.nextInt(seed.length())];
}
return new String(chars);
}
public static String space(String str, char spacer, int slotter)
{
if (!toString(str).equals(""))
{
if (str.length() >= slotter)
{
return str;
}
else
{
String result = str;
slotter = slotter - str.length();
for (int i = 0; i < slotter; i++)
{
result = spacer + result;
}
return result;
}
}
return "";
}
public static Map<String, String> convertMap(Map<String, String> map)
{
if (map == null) return map;
Map<String, String> result = new HashMap<>();
Set<String> keys = map.keySet();
for (String key : keys) {
result.put(map.get(key), key);
}
return result;
}
public static Map<Integer, String> split(String str)
{
Map<Integer, String> strs = new HashMap<Integer, String>();
if (!toString(str).equals(""))
{
String[] _strs = str.split(SPLITOR_COMMON);
for (int i = 0; i < _strs.length; i++)
{
strs.put(i, _strs[i]);
}
}
return strs;
}
public static String[] split(String str, String splitter)
{
if (!toString(str).equals(""))
{
return str.split(splitter);
}
return new String[0];
}
public static int splitLength(String str, String splitter)
{
return split(str, splitter).length;
}
public static String substring(String str, int limit)
{
if (!toString(str).equals(""))
{
if (str.length() <= limit)
{
return str;
}
else
{
return str.substring(0, limit) + "...";
}
}
return "";
}
public static String hide(String str, int headLength, int tailLength)
{
if (!toString(str).equals(""))
{
if ((str.length() < headLength) || (str.length() < tailLength))
{
headLength = 1;
tailLength = 1;
}
String head = str.substring(0, headLength);
String tail = str.substring(str.length() - tailLength, str.length());
return head + "***" + tail;
}
return "";
}
public static String filterHtml(String html)
{
Pattern scriptPattern = Pattern.compile("<[//s]*?script[^>]*?>[//s//S]*?<[//s]*?///[//s]*?script[//s]*?>", 2);
Matcher scriptMatcher = scriptPattern.matcher(html);
html = scriptMatcher.replaceAll("");
Pattern cssPattern = Pattern.compile("<[//s]*?style[^>]*?>[//s//S]*?<[//s]*?///[//s]*?style[//s]*?>", 2);
Matcher cssMatcher = cssPattern.matcher(html);
html = cssMatcher.replaceAll("");
Pattern htmlPattern1 = Pattern.compile("<[^>]+>", 2);
Matcher htmlMatcher1 = htmlPattern1.matcher(html);
html = htmlMatcher1.replaceAll("");
Pattern htmlPattern2 = Pattern.compile("<[^>]+", 2);
Matcher htmlMatcher2 = htmlPattern2.matcher(html);
html = htmlMatcher2.replaceAll("");
return html;
}
public static String wrapHtml(String str)
{
String result = "";
if (!toString(str).equals(""))
{
for (int i = 0; i < str.length(); i++)
{
char _char = str.charAt(i);
result += _char + "<br/>";
}
}
return result;
}
public static String toString(Object obj)
{
if (obj != null)
{
return obj.toString().trim();
}
return "";
}
public static String toUpperCase(Object obj)
{
return toString(obj).toUpperCase();
}
public static String toLowerCase(Object obj)
{
return toString(obj).toLowerCase();
}
public static Set<String> toSet(String str)
{
return toSet(str, ",");
}
public static Set<String> toSet(String str, String split)
{
Set<String> strings = new LinkedHashSet<String>();
if (isEmpty(str)) return strings;
String[] elements = str.split(",");
for (String element : elements)
{
String string = toString(element);
if (!string.equals(""))
{
strings.add(string);
}
}
return strings;
}
public static List<String> toList(String str)
{
List<String> list = new ArrayList<String>();
String[] elements = str.split(",");
for (String element : elements)
{
String string = toString(element);
list.add(string);
}
return list;
}
public static String toChineseMoney(String str)
{
String integerStr;
String decimalStr;
str = toString(str);
str = str.replaceAll(",", "");
if (str.indexOf(".") > 0)
{
integerStr = str.substring(0, str.indexOf("."));
decimalStr = str.substring(str.indexOf(".") + 1);
}
else if (str.indexOf(".") == 0)
{
integerStr = "";
decimalStr = str.substring(1);
}
else
{
integerStr = str;
decimalStr = "";
}
if (!integerStr.equals(""))
{
integerStr = Long.toString(Long.parseLong(integerStr));
if (integerStr.equals("0"))
{
integerStr = "";
}
}
if (integerStr.length() > CHINESE_MONEY_INTEGER.length)
{
return str;
}
int[] integers = new int[integerStr.length()];
for (int i = 0; i < integerStr.length(); i++)
{
integers[i] = Integer.parseInt(integerStr.substring(i, i + 1));
}
boolean isMust5 = false;
int length = integerStr.length();
if (length > 4)
{
String subInteger = "";
if (length > 8)
{
subInteger = integerStr.substring(length - 8, length - 4);
}
else
{
subInteger = integerStr.substring(0, length - 4);
}
if (Integer.parseInt(subInteger) > 0)
{
isMust5 = true;
}
}
int[] decimals = new int[decimalStr.length()];
for (int i = 0; i < decimalStr.length(); i++)
{
decimals[i] = Integer.parseInt(decimalStr.substring(i, i + 1));
}
StringBuffer chineseInteger = new StringBuffer("");
length = integers.length;
for (int i = 0; i < length; i++)
{
String key = "";
if (integers[i] == 0)
{
if ((length - i) == 13)
{
key = CHINESE_MONEY_INTEGER[4];
}
else if ((length - i) == 9)
{
key = CHINESE_MONEY_INTEGER[8];
}
else if ((length - i) == 5 && isMust5)
{
key = CHINESE_MONEY_INTEGER[4];
}
else if ((length - i) == 1)
{
key = CHINESE_MONEY_INTEGER[0];
}
if ((length - i) > 1 && integers[i + 1] != 0)
{
key += CHINESE_MONEY_NUMBERS[0];
}
}
chineseInteger.append(integers[i] == 0 ? key : (CHINESE_MONEY_NUMBERS[integers[i]] + CHINESE_MONEY_INTEGER[length - i - 1]));
}
StringBuffer chineseDecimal = new StringBuffer("");
for (int i = 0; i < decimals.length; i++)
{
if (i == 3)
{
break;
}
chineseDecimal.append((decimals[i] == 0) ? "" : (CHINESE_MONEY_NUMBERS[decimals[i]] + CHINESE_MONEY_DECIMAL[i]));
}
return chineseInteger.toString() + chineseDecimal.toString();
}
public static boolean toBoolean(Object value)
{
try {
if (value == null) return false;
return toBoolean(value.toString());
}
catch (Exception localException)
{
}
return false;
}
public static boolean toBoolean(String str)
{
try {
if (str == null) return false;
if (str.equalsIgnoreCase("TRUE")) return true;
if (str.equalsIgnoreCase("Y")) return true;
if (str.equalsIgnoreCase("YES")) return true;
if (Integer.parseInt(str) > 0) return true;
}
catch (Exception localException)
{
}
return false;
}
public static String removeSuffix(String str)
{
int position = str.lastIndexOf(".");
if (position > -1)
{
str = str.substring(0, position);
}
return str;
}
public static void main(String[] args)
{
System.out.println(StringUtil.createQUID());
String component = "10021";
int itemLength = component.length();
if (itemLength < 18) {
for (int i = 0; i < 18 - itemLength; i++) {
component = "0" + component;
}
}
System.out.println(String.format("%12s", "100032").replace(" ","0"));
}
/**
* 版本号比较
* @param v1
* @param v2
* @return 0代表相等,1代表左边大,-1代表右边大
* compareVersion("1.0.358_20180820090554","1.0.358_20180820090553")=1
*/
public static int compareVersion(String v1, String v2) {
if (v1.equals(v2)) {
return 0;
}
String[] version1Array = v1.split("[._]");
String[] version2Array = v2.split("[._]");
int index = 0;
int minLen = Math.min(version1Array.length, version2Array.length);
long diff = 0;
while (index < minLen && (diff = Long.parseLong(version1Array[index]) - Long.parseLong(version2Array[index])) == 0) {
index++;
}
if (diff == 0) {
for (int i = index; i < version1Array.length; i++) {
if (Long.parseLong(version1Array[i]) > 0) {
return 1;
}
}
for (int i = index; i < version2Array.length; i++) {
if (Long.parseLong(version2Array[i]) > 0) {
return -1;
}
}
return 0;
} else {
return diff > 0 ? 1 : -1;
}
}
}

View File

@ -0,0 +1,2 @@
# 配置 feignclient 的全类名路径, 避免包名不规范无法扫描问题
com.foreverwin.mom.common.feign.MomFeignAutoConfiguration=

13
print-app/Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM moxm/java:1.8-full
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN mkdir -p /nlv-print
WORKDIR /nlv-print
EXPOSE 6066
ADD ./target/nlv-print.jar ./
CMD java -Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom -jar nlv-print.jar

39
print-app/pom.xml Normal file
View File

@ -0,0 +1,39 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.foreverwin</groupId>
<artifactId>nlv-print</artifactId>
<version>4.5.0</version>
</parent>
<artifactId>print-app</artifactId>
<dependencies>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>print-api</artifactId>
</dependency>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>print-core</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies>
<build>
<finalName>nlv-print</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,29 @@
package com.foreverwin.nlv.print;
import com.foreverwin.mom.common.feign.annotation.EnableMomFeignClients;
import com.foreverwin.mom.common.security.annotation.EnableMomResourceServer;
import com.foreverwin.mom.common.swagger.annotation.EnableMomSwagger2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableAsync;
@EnableMomSwagger2
@EnableMomFeignClients(basePackages = {"com.foreverwin.mom", "com.foreverwin.iep", "com.foreverwin.nlv"})
@EnableDiscoveryClient
@EnableMomResourceServer
@SpringBootApplication(scanBasePackages = {"com.foreverwin.mom", "com.foreverwin.iep", "com.foreverwin.nlv"})
// 需配置不然扫不到mes-db的mapper
@MapperScan({"com.foreverwin.iep.**.mapper", "com.foreverwin.nlv.**.mapper"})
@EnableAsync
public class Application {
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
// 启用循环引用
springApplication.setAllowCircularReferences(Boolean.TRUE);
springApplication.run(args);
}
}

View File

@ -0,0 +1,28 @@
server:
port: 6075
spring:
application:
name: nlv-print
version: @project.version@
cloud:
nacos:
discovery:
server-addr: ${NACOS_HOST:mom-register}:${NACOS_PORT:8848}
namespace: ${NACOS_NAMESPACE:}
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${NACOS_NAMESPACE:}
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
config:
import:
- optional:nacos:application-@profiles.active@.yml
- optional:nacos:${spring.application.name}-@profiles.active@.yml
jackson:
serialization:
# 懒加载前台序列化报错问题
FAIL_ON_EMPTY_BEANS: false
seata:
data-source-proxy-mode: XA

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
小技巧: 在根pom里面设置统一存放路径,统一管理方便维护
<properties>
<log-path>/Users/mom</log-path>
</properties>
1. 其他模块加日志输出,直接copy本文件放在resources 目录即可
2. 注意修改 <property name="${log-path}/log.path" value=""/> 的value模块
-->
<configuration debug="false" scan="false">
<springProperty name="logPath" source="spring.application.name" defaultValue="${project.artifactId}"/>
<property name="log.path" value="logs/${logPath}"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM, aux}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
</appender>
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<logger name="org.activiti.engine.impl.db" level="DEBUG">
<appender-ref ref="debug"/>
</logger>
<!--nacos 心跳 INFO 屏蔽-->
<logger name="com.alibaba.nacos" level="OFF">
<appender-ref ref="error"/>
</logger>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
</root>
</configuration>

140
print-core/pom.xml Normal file
View File

@ -0,0 +1,140 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.foreverwin</groupId>
<artifactId>nlv-print</artifactId>
<version>4.5.0</version>
</parent>
<artifactId>print-core</artifactId>
<dependencies>
<!--必备: undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!--必备: spring boot web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--必备: 注册中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--必备: 配置中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!--必备: 操作数据源相关-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-data</artifactId>
</dependency>
<!--必备:mom安全模块-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-security</artifactId>
</dependency>
<!--必备:xss 过滤模块-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-xss</artifactId>
</dependency>
<!--必备: sentinel 依赖-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-sentinel</artifactId>
</dependency>
<!--必备: feign 依赖-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-feign</artifactId>
</dependency>
<!--必备: 依赖api模块-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>print-api</artifactId>
</dependency>
<!--必备: log 依赖-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-log</artifactId>
</dependency>
<!--选配: mybatis 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<!--选配: druid 连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!--选配: mysql 数据库驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- ojdbc8 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<!--选配: swagger文档-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-swagger</artifactId>
</dependency>
<!--测试: spring boot test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mes-common</artifactId>
</dependency>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>print-db</artifactId>
</dependency>
<!--分布式事务-->
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mom-common-seata</artifactId>
</dependency>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mes-db</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>mes-api</artifactId>
<version>4.5.0</version>
</dependency>
<!--mssql-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<!-- postgre -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- ftp服务器 -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,63 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.nlv.print.entity.PrintRule;
import com.foreverwin.nlv.print.service.CustomerPrintRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 客户打印规则维护
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
@RestController
@RequestMapping("/printRule")
public class CustomerPrintRuleController {
@Autowired
public CustomerPrintRuleService customerPrintRuleService;
/**
* 查询所有数据
*
*/
@ResponseBody
@PostMapping("/search")
public R getPrintRuleList(PrintRule printRule){
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printRule);
return R.ok(customerPrintRuleService.list(queryWrapper));
}
/**
* 保存
* @param printRuleList 传递的实体
*/
@ResponseBody
@PostMapping("/save")
public R doSave(@RequestBody List<PrintRule> printRuleList) {
customerPrintRuleService.doSave(printRuleList);
return R.ok("");
}
/**
* 删除
* @param printRuleList 传递的实体
*/
@ResponseBody
@PostMapping("/delete")
public R doDelete(@RequestBody List<PrintRule> printRuleList) {
customerPrintRuleService.doDelete(printRuleList);
return R.ok("");
}
/**
* 获取模板
* @param site 传递的实体
*/
@ResponseBody
@GetMapping("/getLabelCategoryList/{site}")
public R getLabelCategoryList(@PathVariable("site") String site){
return R.ok(customerPrintRuleService.getLabelCategoryList(site));
}
}

View File

@ -0,0 +1,128 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.nlv.print.util.FrontPage;
import com.foreverwin.nlv.print.entity.LabelCategory;
import com.foreverwin.nlv.print.service.LabelCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 打印标签类别维护表
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
@RestController
@AllArgsConstructor
@RequestMapping("/label-category" )
@Api(value = "label-category", tags = "标签类别维护表管理")
public class LabelCategoryController {
private final LabelCategoryService labelCategoryService;
/**
* 分页查询
* @param page 分页对象
* @param labelCategory 标签类别维护表
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page" )
public R getLabelCategoryPage(FrontPage page, LabelCategory labelCategory) {
labelCategory.setSite(TenantContextHolder.getTenantId());
QueryWrapper<LabelCategory> queryWrapper = new QueryWrapper<>(labelCategory);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(LabelCategory::getLabelCategoryId, page.getSearchText())
.or().like(LabelCategory::getLabelCategoryName, page.getSearchText())
);
}
return R.ok(labelCategoryService.page(page, queryWrapper));
}
/**
* 通过id查询标签类别维护表
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}" )
public R getById(@PathVariable("handle" ) String handle) {
return R.ok(labelCategoryService.getById(handle));
}
/**
* 通过code查询标签类别维护表
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code" )
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(labelCategoryService.getByCode(site, code));
}
/**
* 通过code删除标签类别维护表
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code" )
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(labelCategoryService.deleteByCode(site, code));
}
/**
* 新增标签类别维护表
* @param labelCategory 标签类别维护表
* @return R
*/
@ApiOperation(value = "新增标签类别维护表", notes = "新增标签类别维护表")
@SysLog("新增标签类别维护表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('mes_label_category_save')" )
public R save(@RequestBody LabelCategory labelCategory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(labelCategoryService.save(site, user, labelCategory));
}
/**
* 修改标签类别维护表
* @param labelCategory 标签类别维护表
* @return R
*/
@ApiOperation(value = "修改标签类别维护表", notes = "修改标签类别维护表")
@SysLog("修改标签类别维护表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('mes_label_category_save')" )
public R updateById(@RequestBody LabelCategory labelCategory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(labelCategoryService.updateById(site, user, labelCategory));
}
/**
* 通过id删除标签类别维护表
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除标签类别维护表", notes = "通过id删除标签类别维护表")
@SysLog("通过id删除标签类别维护表" )
@DeleteMapping("/{handle}" )
@PreAuthorize("@pms.hasPermission('mes_label_category_del')" )
public R removeById(@PathVariable String handle) {
return R.ok(labelCategoryService.removeById(handle));
}
}

View File

@ -0,0 +1,129 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.nlv.print.util.FrontPage;
import com.foreverwin.nlv.print.entity.LabelFieldAllocation;
import com.foreverwin.nlv.print.service.LabelFieldAllocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 打印模板变量关系维护主表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@RestController
@AllArgsConstructor
@RequestMapping("/label-field-allocation" )
@Api(value = "label-field-allocation", tags = "打印模板变量关系维护主表管理")
public class LabelFieldAllocationController {
private final LabelFieldAllocationService labelFieldAllocationService;
/**
* 分页查询
* @param page 分页对象
* @param labelFieldAllocation 打印模板变量关系维护主表
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page" )
public R getLabelFieldAllocationPage(FrontPage page, LabelFieldAllocation labelFieldAllocation) {
labelFieldAllocation.setSite(TenantContextHolder.getTenantId());
QueryWrapper<LabelFieldAllocation> queryWrapper = new QueryWrapper<>(labelFieldAllocation);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(LabelFieldAllocation::getLabelNumber, page.getSearchText())
.or().like(LabelFieldAllocation::getLabelType, page.getSearchText())
.or().like(LabelFieldAllocation::getLabelDescription, page.getSearchText())
);
}
return R.ok(labelFieldAllocationService.page(page, queryWrapper));
}
/**
* 通过id查询打印模板变量关系维护主表
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}" )
public R getById(@PathVariable("handle" ) String handle) {
return R.ok(labelFieldAllocationService.getById(handle));
}
/**
* 通过code查询打印模板变量关系维护主表
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code" )
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(labelFieldAllocationService.getByCode(site, code));
}
/**
* 通过code删除打印模板变量关系维护主表
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code" )
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(labelFieldAllocationService.deleteByCode(site, code));
}
/**
* 新增打印模板变量关系维护主表
* @param labelFieldAllocation 打印模板变量关系维护主表
* @return R
*/
@ApiOperation(value = "新增打印模板变量关系维护主表", notes = "新增打印模板变量关系维护主表")
@SysLog("新增打印模板变量关系维护主表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('mes_label_field_save')" )
public R save(@RequestBody LabelFieldAllocation labelFieldAllocation) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(labelFieldAllocationService.save(site, user, labelFieldAllocation));
}
/**
* 修改打印模板变量关系维护主表
* @param labelFieldAllocation 打印模板变量关系维护主表
* @return R
*/
@ApiOperation(value = "修改打印模板变量关系维护主表", notes = "修改打印模板变量关系维护主表")
@SysLog("修改打印模板变量关系维护主表" )
@PutMapping
@PreAuthorize("@pms.hasPermission('mes_label_field_save')" )
public R updateById(@RequestBody LabelFieldAllocation labelFieldAllocation) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(labelFieldAllocationService.updateById(site, user, labelFieldAllocation));
}
/**
* 通过id删除打印模板变量关系维护主表
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除打印模板变量关系维护主表", notes = "通过id删除打印模板变量关系维护主表")
@SysLog("通过id删除打印模板变量关系维护主表" )
@DeleteMapping("/{handle}" )
@PreAuthorize("@pms.hasPermission('mes_label_field_del')" )
public R removeById(@PathVariable String handle) {
return R.ok(labelFieldAllocationService.removeById(handle));
}
}

View File

@ -0,0 +1,136 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.excel.annotation.ResponseExcel;
import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.nlv.print.entity.PrintLabelTemplate;
import com.foreverwin.nlv.print.service.PrintLabelTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 打印标签模板维护
*
* @author MIHUYO
* @date 2022-10-24 17:13:11
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/printlabeltemplate" )
@Api(value = "printlabeltemplate", tags = "打印标签模板维护管理")
public class PrintLabelTemplateController {
private final PrintLabelTemplateService printLabelTemplateService;
/**
* 分页查询
* @param page 分页对象
* @param printLabelTemplate 打印标签模板维护
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page" )
public R getPrintLabelTemplatePage(Page page, PrintLabelTemplate printLabelTemplate) {
IPage result = printLabelTemplateService.page(page, Wrappers.<PrintLabelTemplate>lambdaQuery()
.eq(PrintLabelTemplate::getSite, TenantContextHolder.getTenantId())
.like(StringUtils.isNotBlank(printLabelTemplate.getTemplateCode()), PrintLabelTemplate::getTemplateCode, printLabelTemplate.getTemplateCode())
.like(StringUtils.isNotBlank(printLabelTemplate.getTemplateName()), PrintLabelTemplate::getTemplateName, printLabelTemplate.getTemplateName())
.like(StringUtils.isNotBlank(printLabelTemplate.getCustomerCode()), PrintLabelTemplate::getCustomerCode, printLabelTemplate.getCustomerCode())
.eq(StringUtils.isNotBlank(printLabelTemplate.getTemplateCategory()), PrintLabelTemplate::getTemplateCategory, printLabelTemplate.getTemplateCategory()));
return R.ok(result);
}
/**
* 通过id查询打印标签模板维护
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}" )
public R getById(@PathVariable("handle" ) String handle) {
return R.ok(printLabelTemplateService.getFullById(handle));
}
/**
* 新增打印标签模板维护
* @param printLabelTemplate 打印标签模板维护
* @return R
*/
@ApiOperation(value = "新增打印标签模板维护", notes = "新增打印标签模板维护")
@SysLog("新增打印标签模板维护" )
@PostMapping
@PreAuthorize("@pms.hasPermission('mes_printlabeltemplate_add')" )
public R save(@RequestBody PrintLabelTemplate printLabelTemplate) {
String site = TenantContextHolder.getTenantStrId();
String user = SecurityUtils.getUserName();
return R.ok(printLabelTemplateService.validateAndSave(site, user, printLabelTemplate));
}
/**
* 修改打印标签模板维护
* @param printLabelTemplate 打印标签模板维护
* @return R
*/
@ApiOperation(value = "修改打印标签模板维护", notes = "修改打印标签模板维护")
@SysLog("修改打印标签模板维护" )
@PutMapping
@PreAuthorize("@pms.hasPermission('mes_printlabeltemplate_edit')" )
public R updateById(@RequestBody PrintLabelTemplate printLabelTemplate) {
String site = TenantContextHolder.getTenantStrId();
String user = SecurityUtils.getUserName();
return R.ok(printLabelTemplateService.validateAndUpdate(site, user, printLabelTemplate));
}
/**
* 通过id删除打印标签模板维护
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除打印标签模板维护", notes = "通过id删除打印标签模板维护")
@SysLog("通过id删除打印标签模板维护" )
@DeleteMapping("/{handle}" )
@PreAuthorize("@pms.hasPermission('mes_printlabeltemplate_del')" )
public R removeById(@PathVariable String handle) {
return R.ok(printLabelTemplateService.removeById(handle));
}
/**
* 导出excel 表格
* @param printLabelTemplate 查询条件
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('mes_printlabeltemplate_export')" )
public List<PrintLabelTemplate> export(PrintLabelTemplate printLabelTemplate) {
return printLabelTemplateService.list(Wrappers.query(printLabelTemplate));
}
/**
* 文件上传
* @param file 传递的实体
*/
@ResponseBody
@PostMapping("/upload")
public R doUpload(@RequestParam("file") MultipartFile file) throws Exception{
String templateCode = file.getOriginalFilename();
String site = TenantContextHolder.getTenantStrId();
printLabelTemplateService.doUpload(site, templateCode, file);
return R.ok("");
}
}

View File

@ -0,0 +1,131 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.nlv.print.util.FrontPage;
import com.foreverwin.nlv.print.entity.Printer;
import com.foreverwin.nlv.print.service.PrinterService;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 打印机注册
*
* @author MIHUYO
* @date 2022-10-27 10:51:42
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/printer" )
@Api(value = "printer", tags = "打印机注册管理")
public class PrinterController {
private final PrinterService printerService;
/**
* 分页查询
* @param page 分页对象
* @param printer 打印机注册
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page" )
public R getPrinterRegesterPage(FrontPage page, Printer printer) {
printer.setSite(TenantContextHolder.getTenantId());
QueryWrapper<Printer> queryWrapper = new QueryWrapper<>(printer);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(Printer::getPrinterId, page.getSearchText())
.or().like(Printer::getOperationType, page.getSearchText())
.or().like(Printer::getPrintScenario, page.getSearchText())
.or().like(Printer::getLocationDesc, page.getSearchText())
.or().like(Printer::getResource, page.getSearchText())
.or().like(Printer::getIpAddress, page.getSearchText())
);
}
return R.ok(printerService.page(page, queryWrapper));
}
/**
* 通过id查询打印机注册
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}" )
public R getById(@PathVariable("handle" ) String handle) {
return R.ok(printerService.getById(handle));
}
/**
* 通过code查询库位维护
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code" )
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(printerService.getByCode(site, code));
}
/**
* 通过code删除库位维护
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code" )
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(printerService.deleteByCode(site, code));
}
/**
* 新增打印机注册
* @param printer 打印机注册
* @return R
*/
@ApiOperation(value = "新增打印机注册", notes = "新增打印机注册")
@SysLog("新增打印机注册" )
@PostMapping
@PreAuthorize("@pms.hasPermission('print_printer_add')" )
public R save(@RequestBody Printer printer) {
String site = TenantContextHolder.getTenantId();
return R.ok(printerService.save(site, printer));
}
/**
* 修改打印机注册
* @param printer 打印机注册
* @return R
*/
@ApiOperation(value = "修改打印机注册", notes = "修改打印机注册")
@SysLog("修改打印机注册" )
@PutMapping
@PreAuthorize("@pms.hasPermission('print_printer_edit')" )
public R updateById(@RequestBody Printer printer) {
String site = TenantContextHolder.getTenantId();
return R.ok(printerService.updateById(site, printer));
}
/**
* 通过id删除打印机注册
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除打印机注册", notes = "通过id删除打印机注册")
@SysLog("通过id删除打印机注册" )
@DeleteMapping("/{handle}" )
@PreAuthorize("@pms.hasPermission('print_printer_del')" )
public R removeById(@PathVariable String handle) {
return R.ok(printerService.removeById(handle));
}
}

View File

@ -0,0 +1,130 @@
package com.foreverwin.nlv.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.nlv.print.util.FrontPage;
import com.foreverwin.nlv.print.entity.SystemField;
import com.foreverwin.nlv.print.service.SystemFieldService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* 系统字段定义
*
* @author MIHUYO
* @date 2022-10-28 09:17:15
*/
@RestController
@AllArgsConstructor
@RequestMapping("/system-field" )
@Api(value = "system-field", tags = "系统字段定义管理")
public class SystemFieldController {
private final SystemFieldService systemFieldService;
/**
* 分页查询
* @param page 分页对象
* @param systemField 系统字段定义
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page" )
public R getSystemFieldPage(FrontPage page, SystemField systemField) {
systemField.setSite(TenantContextHolder.getTenantId());
QueryWrapper<SystemField> queryWrapper = new QueryWrapper<>(systemField);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(SystemField::getFieldNumber, page.getSearchText())
.or().like(SystemField::getFieldDescription, page.getSearchText())
.or().like(SystemField::getType, page.getSearchText())
.or().like(SystemField::getGetValueContext, page.getSearchText())
);
}
return R.ok(systemFieldService.page(page, queryWrapper));
}
/**
* 通过id查询系统字段定义
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}" )
public R getById(@PathVariable("handle" ) String handle) {
return R.ok(systemFieldService.getById(handle));
}
/**
* 通过code查询系统字段定义
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code" )
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(systemFieldService.getByCode(site, code));
}
/**
* 通过code删除系统字段定义
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code" )
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(systemFieldService.deleteByCode(site, code));
}
/**
* 新增系统字段定义
* @param systemField 系统字段定义
* @return R
*/
@ApiOperation(value = "新增系统字段定义", notes = "新增系统字段定义")
@SysLog("新增系统字段定义" )
@PostMapping
@PreAuthorize("@pms.hasPermission('mes_system_field_save')" )
public R save(@RequestBody SystemField systemField) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(systemFieldService.save(site, user, systemField));
}
/**
* 修改系统字段定义
* @param systemField 系统字段定义
* @return R
*/
@ApiOperation(value = "修改系统字段定义", notes = "修改系统字段定义")
@SysLog("修改系统字段定义" )
@PutMapping
@PreAuthorize("@pms.hasPermission('mes_system_field_save')" )
public R updateById(@RequestBody SystemField systemField) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(systemFieldService.updateById(site, user, systemField));
}
/**
* 通过id删除系统字段定义
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除系统字段定义", notes = "通过id删除系统字段定义")
@SysLog("通过id删除系统字段定义" )
@DeleteMapping("/{handle}" )
@PreAuthorize("@pms.hasPermission('mes_system_field_del')" )
public R removeById(@PathVariable String handle) {
return R.ok(systemFieldService.removeById(handle));
}
}

View File

@ -0,0 +1,18 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.PrintRule;
import java.util.List;
import java.util.Map;
public interface CustomerPrintRuleService extends IService<PrintRule> {
List<PrintRule> selectList(PrintRule printRule);
void doSave(List<PrintRule> printRuleList);
void doDelete(List<PrintRule> printRuleList);
List<Map<String,String>> getLabelCategoryList(String site);
}

View File

@ -0,0 +1,14 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.FieldsCustomLogic;
/**
* 字段与方法绑定
*
* @author aaron
* @date 2022-11-18 13:24:38
*/
public interface FieldsCustomLogicService extends IService<FieldsCustomLogic> {
}

View File

@ -0,0 +1,24 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.LabelCategory;
import org.springframework.transaction.annotation.Transactional;
/**
* 标签类别维护表
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
public interface LabelCategoryService extends IService<LabelCategory> {
LabelCategory getByCode(String site, String code);
boolean deleteByCode(String site, String code);
@Transactional(rollbackFor = Exception.class)
boolean save(String site, String creator, LabelCategory labelCategory);
@Transactional(rollbackFor = Exception.class)
boolean updateById(String site, String updater, LabelCategory labelCategory);
}

View File

@ -0,0 +1,13 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
/**
* 打印模板变量关系维护明细表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
public interface LabelFieldAllocationDetailService extends IService<LabelFieldAllocationDetail> {
}

View File

@ -0,0 +1,27 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.LabelFieldAllocation;
import org.springframework.transaction.annotation.Transactional;
/**
* 打印模板变量关系维护主表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
public interface LabelFieldAllocationService extends IService<LabelFieldAllocation> {
LabelFieldAllocation getByCode(String site, String code);
boolean deleteByCode(String site, String code);
@Transactional(rollbackFor = Exception.class)
boolean save(String site, String creator, LabelFieldAllocation labelFieldAllocation);
@Transactional(rollbackFor = Exception.class)
boolean updateById(String site, String updater, LabelFieldAllocation labelFieldAllocation);
LabelFieldAllocation labelNumberInfo(String site, String labelNumber);
}

View File

@ -0,0 +1,27 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.PrintLabelTemplate;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 打印标签模板维护
*
* @author MIHUYO
* @date 2022-10-24 17:13:11
*/
public interface PrintLabelTemplateService extends IService<PrintLabelTemplate> {
PrintLabelTemplate getFullById(String handle);
boolean validateAndSave(String site, String user, PrintLabelTemplate printLabelTemplate);
boolean validateAndUpdate(String site, String user, PrintLabelTemplate printLabelTemplate);
void doUpload(String site, String templateCode, MultipartFile multipartFile) throws Exception;
List<PrintLabelTemplate> selectList(PrintLabelTemplate printLabelTemplate);
}

View File

@ -0,0 +1,14 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.PrintRecord;
/**
* 打印记录表
*
* @author aaron
* @date 2022-10-29 13:40:49
*/
public interface PrintRecordService extends IService<PrintRecord> {
}

View File

@ -0,0 +1,28 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.Printer;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 打印机注册
*
* @author MIHUYO
* @date 2022-10-27 10:51:42
*/
public interface PrinterService extends IService<Printer> {
Printer getByCode(String site, String code);
boolean deleteByCode(String site, String code);
@Transactional(rollbackFor = Exception.class)
boolean save(String site, Printer printer);
@Transactional(rollbackFor = Exception.class)
boolean updateById(String site, Printer printer);
List<Printer> selectList(Printer printer);
}

View File

@ -0,0 +1,33 @@
package com.foreverwin.nlv.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.nlv.print.entity.SystemField;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* 系统字段定义
*
* @author MIHUYO
* @date 2022-10-28 09:17:15
*/
public interface SystemFieldService extends IService<SystemField> {
SystemField getByCode(String site, String code);
boolean deleteByCode(String site, String code);
@Transactional(rollbackFor = Exception.class)
boolean save(String site, String creator, SystemField systemField);
@Transactional(rollbackFor = Exception.class)
boolean updateById(String site, String updater, SystemField systemField);
SystemField getFieldData(String site, String fieldNumber);
List<String> getSystemFieldValue(String site, String fieldNumber, Map<String, Object> baseData);
List<String> getSystemFieldValue(String site, String fieldNumber, Map<String, SystemField> systemFieldMap, Map<String, Object> baseData);
}

View File

@ -0,0 +1,58 @@
package com.foreverwin.nlv.print.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.nlv.print.entity.PrintRule;
import com.foreverwin.nlv.print.mapper.CustomerPrintRuleMapper;
import com.foreverwin.nlv.print.service.CustomerPrintRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Service
@Transactional(rollbackFor = Exception.class)
public class CustomerCustomerPrintRuleServiceImpl extends ServiceImpl<CustomerPrintRuleMapper, PrintRule> implements CustomerPrintRuleService {
@Autowired
private CustomerPrintRuleMapper customerPrintRuleMapper;
@Override
public List<PrintRule> selectList(PrintRule printRule) {
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printRule);
return super.list(queryWrapper);
}
@Override
public void doSave(List<PrintRule> printRuleList) {
LocalDateTime time = LocalDateTime.now();
for(PrintRule printRule: printRuleList){
PrintRule message = new PrintRule();
message.setHandle(printRule.getHandle());
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(message);
super.remove(queryWrapper);
printRule.setCreatedDateTime(time);
super.save(printRule);
}
}
@Override
public void doDelete(List<PrintRule> printRuleList) {
for(PrintRule printRule: printRuleList){
QueryWrapper<PrintRule> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printRule);
super.remove(queryWrapper);
}
}
@Override
public List<Map<String, String>> getLabelCategoryList(String site) {
return customerPrintRuleMapper.selectLabelCategory(site);
}
}

View File

@ -0,0 +1,18 @@
package com.foreverwin.nlv.print.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.nlv.print.entity.FieldsCustomLogic;
import com.foreverwin.nlv.print.mapper.FieldsCustomLogicMapper;
import com.foreverwin.nlv.print.service.FieldsCustomLogicService;
import org.springframework.stereotype.Service;
/**
* 字段与方法绑定
*
* @author aaron
* @date 2022-11-18 13:24:38
*/
@Service
public class FieldsCustomLogicServiceImpl extends ServiceImpl<FieldsCustomLogicMapper, FieldsCustomLogic> implements FieldsCustomLogicService {
}

View File

@ -0,0 +1,73 @@
package com.foreverwin.nlv.print.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.nlv.print.entity.LabelCategory;
import com.foreverwin.nlv.print.mapper.LabelCategoryMapper;
import com.foreverwin.nlv.print.service.LabelCategoryService;
import lombok.AllArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
/**
* 标签类别维护表
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
@Service
@AllArgsConstructor
public class LabelCategoryServiceImpl extends ServiceImpl<LabelCategoryMapper, LabelCategory> implements LabelCategoryService {
@Override
public LabelCategory getByCode(String site, String code) {
LabelCategory labelCategory = getById(LabelCategory.genHandle(site, code));
if(labelCategory == null) {
return null;
}
return labelCategory;
}
@Override
public boolean deleteByCode(String site, String code) {
String id = LabelCategory.genHandle(site, code);
return removeById(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean save(String site, String creator, LabelCategory labelCategory) {
labelCategory.setSite(site);
String handle = LabelCategory.genHandle(site, labelCategory.getLabelCategoryId());
labelCategory.setHandle(handle);
labelCategory.setModifyUser(creator);
labelCategory.setModifyDateTime(LocalDateTime.now());
try {
return super.save(labelCategory);
} catch (Exception e) {
if(e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateById(String site, String updater, LabelCategory labelCategory) {
String handle = labelCategory.getHandle();
if(StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
return super.updateById(labelCategory);
}
}

View File

@ -0,0 +1,21 @@
package com.foreverwin.nlv.print.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
import com.foreverwin.nlv.print.mapper.LabelFieldAllocationDetailMapper;
import com.foreverwin.nlv.print.service.LabelFieldAllocationDetailService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
* 打印模板变量关系维护明细表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Service
@AllArgsConstructor
public class LabelFieldAllocationDetailServiceImpl extends ServiceImpl<LabelFieldAllocationDetailMapper, LabelFieldAllocationDetail> implements LabelFieldAllocationDetailService {
}

View File

@ -0,0 +1,151 @@
package com.foreverwin.nlv.print.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.iep.common.utils.HandleBoProcessor;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.nlv.print.entity.LabelFieldAllocation;
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
import com.foreverwin.nlv.print.entity.SystemField;
import com.foreverwin.nlv.print.mapper.LabelFieldAllocationMapper;
import com.foreverwin.nlv.print.service.LabelFieldAllocationDetailService;
import com.foreverwin.nlv.print.service.LabelFieldAllocationService;
import com.foreverwin.nlv.print.service.SystemFieldService;
import lombok.AllArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
import java.util.List;
/**
* 打印模板变量关系维护主表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Service
@AllArgsConstructor
public class LabelFieldAllocationServiceImpl extends ServiceImpl<LabelFieldAllocationMapper, LabelFieldAllocation> implements LabelFieldAllocationService {
private final LabelFieldAllocationDetailService labelFieldAllocationDetailService;
private final SystemFieldService systemFieldService;
private final LabelFieldAllocationMapper labelFieldAllocationMapper;
@Override
public LabelFieldAllocation getByCode(String site, String code) {
LabelFieldAllocation labelFieldAllocation = getById(LabelFieldAllocation.genHandle(site, code));
if(labelFieldAllocation == null) {
return null;
}
String id = labelFieldAllocation.getHandle();
List<LabelFieldAllocationDetail> labelFieldAllocationDetailList = labelFieldAllocationDetailService.list(Wrappers.<LabelFieldAllocationDetail>query().lambda().eq(LabelFieldAllocationDetail::getZLabelFieldAllocationBo, id).orderByAsc(LabelFieldAllocationDetail::getSeq));
if (labelFieldAllocationDetailList != null && labelFieldAllocationDetailList.size() > 0){
for (LabelFieldAllocationDetail labelFieldAllocationDetail : labelFieldAllocationDetailList){
SystemField systemField = systemFieldService.getById(SystemField.genHandle(site, labelFieldAllocationDetail.getFieldNumber()));
labelFieldAllocationDetail.setFieldDescription(systemField.getFieldDescription());
}
labelFieldAllocation.setLabelFieldAllocationDetailList(labelFieldAllocationDetailList);
}
return labelFieldAllocation;
}
@Override
public boolean deleteByCode(String site, String code) {
String id = LabelFieldAllocation.genHandle(site, code);
labelFieldAllocationDetailService.remove(Wrappers.<LabelFieldAllocationDetail>query().lambda().eq(LabelFieldAllocationDetail::getZLabelFieldAllocationBo, id));
return removeById(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean save(String site, String creator, LabelFieldAllocation labelFieldAllocation) {
labelFieldAllocation.setSite(site);
String handle = LabelFieldAllocation.genHandle(site, labelFieldAllocation.getLabelNumber());
LocalDateTime time = LocalDateTime.now();
String user = SecurityUtils.getUserName();
labelFieldAllocation.setModifyUser(user);
labelFieldAllocation.setModifyDateTime(time);
labelFieldAllocation.setHandle(handle);
try {
if (labelFieldAllocation.getLabelFieldAllocationDetailList() != null && labelFieldAllocation.getLabelFieldAllocationDetailList().size() > 0)
{
for(LabelFieldAllocationDetail labelFieldAllocationDetail : labelFieldAllocation.getLabelFieldAllocationDetailList()) {
validateBeforeAdditionalDetailAddAndUpdate(site, labelFieldAllocationDetail);
labelFieldAllocationDetail.setHandle(LabelFieldAllocationDetail.genHandle( handle, labelFieldAllocationDetail.getLabelField()));
labelFieldAllocationDetail.setZLabelFieldAllocationBo(handle);
labelFieldAllocationDetail.setFieldNumber(labelFieldAllocationDetail.getFieldNumber());
labelFieldAllocationDetail.setModifyUser(user);
labelFieldAllocationDetail.setModifyDateTime(time);
}
labelFieldAllocationDetailService.saveBatch(labelFieldAllocation.getLabelFieldAllocationDetailList());
}
return super.save(labelFieldAllocation);
} catch (Exception e) {
if(e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateById(String site, String updater, LabelFieldAllocation labelFieldAllocation) {
String handle = labelFieldAllocation.getHandle();
if(StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
LocalDateTime time = LocalDateTime.now();
String user = SecurityUtils.getUserName();
labelFieldAllocation.setModifyUser(user);
labelFieldAllocation.setModifyDateTime(time);
labelFieldAllocation.setSite(site);
labelFieldAllocationDetailService.remove(Wrappers.<LabelFieldAllocationDetail>query().lambda().eq(LabelFieldAllocationDetail::getZLabelFieldAllocationBo, handle));
if (labelFieldAllocation.getLabelFieldAllocationDetailList() != null && labelFieldAllocation.getLabelFieldAllocationDetailList().size() > 0)
{
for(LabelFieldAllocationDetail labelFieldAllocationDetail : labelFieldAllocation.getLabelFieldAllocationDetailList()) {
validateBeforeAdditionalDetailAddAndUpdate(site, labelFieldAllocationDetail);
labelFieldAllocationDetail.setHandle(LabelFieldAllocationDetail.genHandle( handle, labelFieldAllocationDetail.getLabelField()));
labelFieldAllocationDetail.setZLabelFieldAllocationBo(handle);
labelFieldAllocationDetail.setFieldNumber(labelFieldAllocationDetail.getFieldNumber());
labelFieldAllocationDetail.setModifyUser(user);
labelFieldAllocationDetail.setModifyDateTime(time);
}
labelFieldAllocationDetailService.saveBatch(labelFieldAllocation.getLabelFieldAllocationDetailList());
}
return super.updateById(labelFieldAllocation);
}
@Override
public LabelFieldAllocation labelNumberInfo(String site, String labelNumber) {
String fieldBo = HandleBoProcessor.genHandle(LabelFieldAllocation.KW_Z_LABEL_FIELD_ALLOCATION_BO, site, labelNumber);
LabelFieldAllocation labelFieldAllocation;
labelFieldAllocation = this.getById(fieldBo);
List<LabelFieldAllocationDetail> detailList = labelFieldAllocationMapper.labelNumberInfo(site, fieldBo);
if (labelFieldAllocation != null) {
labelFieldAllocation.setLabelFieldAllocationDetailList(detailList);
}
return labelFieldAllocation;
}
public void validateBeforeAdditionalDetailAddAndUpdate(String site, LabelFieldAllocationDetail labelFieldAllocationDetail){
if (StrUtil.isBlank(labelFieldAllocationDetail.getFieldNumber())){
throw BusinessException.build("明细项字段编号不能为空");
}
if (StrUtil.isNotBlank(labelFieldAllocationDetail.getFieldNumber()) && systemFieldService.getById(SystemField.genHandle(site, labelFieldAllocationDetail.getFieldNumber())) == null){
throw BusinessException.build("明细项字段编号[" + labelFieldAllocationDetail.getFieldNumber() + "]不存在");
}
}
}

View File

@ -0,0 +1,132 @@
package com.foreverwin.nlv.print.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.nlv.print.entity.PrintLabelTemplate;
import com.foreverwin.nlv.print.mapper.PrintLabelTemplateMapper;
import com.foreverwin.nlv.print.service.PrintLabelTemplateService;
import lombok.AllArgsConstructor;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* 打印标签模板维护
*
* @author MIHUYO
* @date 2022-10-24 17:13:11
*/
@Service
@AllArgsConstructor
public class PrintLabelTemplateServiceImpl extends ServiceImpl<PrintLabelTemplateMapper, PrintLabelTemplate> implements PrintLabelTemplateService {
private final static Logger logger = LoggerFactory.getLogger(PrintLabelTemplateServiceImpl.class);
private final PrintLabelTemplateMapper printLabelTemplateMapper;
@Override
public PrintLabelTemplate getFullById(String handle) {
PrintLabelTemplate printLabelTemplate = getById(handle);
if (printLabelTemplate == null) {
return null;
}
return printLabelTemplate;
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean validateAndSave(String site, String user, PrintLabelTemplate printLabelTemplate) {
String handle = PrintLabelTemplate.genHandle(site, printLabelTemplate.getTemplateCode());
validatePrintLabelTemplateExist(handle);
printLabelTemplate.setHandle(handle);
printLabelTemplate.setSite(site);
printLabelTemplate.setCreatedUser(user);
printLabelTemplate.setCreatedDateTime(LocalDateTime.now());
return save(printLabelTemplate);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean validateAndUpdate(String site, String user, PrintLabelTemplate printLabelTemplate) {
return updateById(printLabelTemplate);
}
@Override
public boolean removeById(java.io.Serializable id) {
return super.removeById(id);
}
/**
* 判断当前打印标签模板是否存在
*
* @param handle
*/
private void validatePrintLabelTemplateExist(String handle) {
//存在性校验
if (StrUtil.isNotBlank(handle)) {
PrintLabelTemplate dbPrintLabelTemplate = printLabelTemplateMapper.selectById(handle);
if (dbPrintLabelTemplate != null) {
throw BusinessException.build("打印标签模板已经存在,无法新建");
}
}
}
@Override
public void doUpload(String site, String templateCode, MultipartFile multipartFile) throws Exception {
site = TenantContextHolder.getTenantStrId();
List<Map<String, Object>> list = printLabelTemplateMapper.selectFastCode("FastCodeBO:" + site + ",FTP", "PrintLabelTemplateMaintenance");
if (list.size() == 0) {
throw new MybatisPlusException("请先在快码维护的快码编号FTP里维护字段代码为PrintLabelTemplateMaintenance的模板上传路径");
}
String url = list.get(0).get("EF1") == null ? "" : list.get(0).get("EF1").toString();
int port = list.get(0).get("EF2") == null ? 21 : Integer.parseInt(list.get(0).get("EF2").toString());
String userName = list.get(0).get("EF3") == null ? "" : list.get(0).get("EF3").toString();
String password = list.get(0).get("EF4") == null ? "" : list.get(0).get("EF4").toString();
String path = list.get(0).get("EF5") == null ? "" : list.get(0).get("EF5").toString();
FTPClient ftp = new FTPClient();
ftp.setControlEncoding("UTF-8");
ftp.connect(url, port);
ftp.login(userName, password);
ftp.enterLocalPassiveMode(); // 开启被动模式
int replyCode = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(replyCode)) {
throw new MybatisPlusException("登录FTP服务器" + url + ":" + port + "失败");
}
boolean flag = ftp.changeWorkingDirectory(path);//检查上传路径是否存在 如果不存在返回false
if (!flag) {
ftp.makeDirectory(path);//创建上传的路径 该方法只能创建一级目录,在这里如果/home/ftpUser存在则可创建image
}
ftp.changeWorkingDirectory(path);//指定上传路径
ftp.setFileType(FTP.BINARY_FILE_TYPE);//指定上传文件的类型 二进制文件
InputStream local = multipartFile.getInputStream();
ftp.storeFile(templateCode + ".lab", local);//第一个参数是文件名
logger.info("template {} uploaded to path {}, with reply: {}", templateCode, path, ftp.getReplyString());
local.close();//关闭文件流
ftp.logout();//退出
ftp.disconnect();//断开连接
}
@Override
public List<PrintLabelTemplate> selectList(PrintLabelTemplate printLabelTemplate) {
QueryWrapper<PrintLabelTemplate> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printLabelTemplate);
return super.list(queryWrapper);
}
}

View File

@ -0,0 +1,18 @@
package com.foreverwin.nlv.print.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.nlv.print.entity.PrintRecord;
import com.foreverwin.nlv.print.mapper.PrintRecordMapper;
import com.foreverwin.nlv.print.service.PrintRecordService;
import org.springframework.stereotype.Service;
/**
* 打印记录表
*
* @author aaron
* @date 2022-10-29 13:40:49
*/
@Service
public class PrintRecordServiceImpl extends ServiceImpl<PrintRecordMapper, PrintRecord> implements PrintRecordService {
}

View File

@ -0,0 +1,179 @@
package com.foreverwin.nlv.print.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.iep.smd.feign.RemoteResourceService;
import com.foreverwin.mom.common.core.constant.SecurityConstants;
import com.foreverwin.nlv.print.entity.Printer;
import com.foreverwin.nlv.print.mapper.PrinterMapper;
import com.foreverwin.nlv.print.service.PrinterService;
import com.foreverwin.iep.smd.entity.Resrce;
import com.foreverwin.mom.common.core.constant.CommonConstants;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 打印机注册
*
* @author MIHUYO
* @date 2022-10-27 10:51:42
*/
@Service
@AllArgsConstructor
public class PrinterServiceImpl extends ServiceImpl<PrinterMapper, Printer> implements PrinterService {
private final RemoteResourceService remoteResourceService;
@Autowired
private PrinterMapper printerMapper;
@Override
public Printer getByCode(String site, String code) {
Printer printer;
printer = getById(Printer.genHandle(site, code));
if (printer == null) {
return null;
}
return printer;
}
@Override
public boolean deleteByCode(String site, String code) {
String id = Printer.genHandle(site, code);
return removeById(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean save(String site, Printer printer) {
validateBeforeSaveOrUpdate(site, printer);
printer.setSite(site);
LocalDateTime time = LocalDateTime.now();
String user = SecurityUtils.getUserName();
String handle = Printer.genHandle(site, printer.getPrinterId());
printer.setHandle(handle);
printer.setModifyDateTime(time);
printer.setModifyUser(user);
try {
return super.save(printer);
} catch (Exception e) {
if (e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateById(String site, Printer printer) {
String handle = printer.getHandle();
LocalDateTime time = LocalDateTime.now();
String user = SecurityUtils.getUserName();
printer.setModifyDateTime(time);
printer.setModifyUser(user);
if (StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
validateBeforeSaveOrUpdate(site, printer);
return super.updateById(printer);
}
private void validateBeforeSaveOrUpdate(String site, Printer printer) {
if (StrUtil.isBlank(printer.getPrintScenario())) {
throw BusinessException.build("打印场景不能为空");
}
String resourceStr = printer.getResource();
if (StrUtil.contains(resourceStr,"@")) {
if ("工序打印-operation".equals(printer.getPrintScenario())) {
// 判断是否为工序打印
String[] resourceArray = resourceStr.split("@");
List<String> resourceHandleList = Arrays.stream(resourceArray).map(s -> Resrce.genHandle(site, s)).collect(Collectors.toList());
R<List<Resrce>> byIds = remoteResourceService.getByIds(resourceHandleList, SecurityConstants.FROM_IN);
if (CommonConstants.FAIL.equals(byIds.getCode())) {
throw BusinessException.build("关联资源作业[" + printer.getResource() + "]获取资源信息失败");
}else {
List<Resrce> resrceList = byIds.getData();
if (resrceList.size() != resourceArray.length) {
throw BusinessException.build("关联资源作业[" + printer.getResource() + "]获取资源信息失败");
}
for (Resrce resrceBody : resrceList) {
// 异常打印机
String errorResource = "";
// 判断资源是否存在
String resrce = resrceBody.getResrce();
if (StrUtil.isNotBlank(printer.getResource()) && resrce == null) {
throw BusinessException.build("关联资源作业[" + printer.getResource() + "]不存在");
}
// 判断资源是否已存在打印机
List<Printer> printers = printerMapper.selectList(Wrappers.<Printer>lambdaQuery()
.ne(Printer::getPrinterId, printer.getPrinterId())
.like(Printer::getResource, resrce));
if (printers.size() > 0) {
// 已存在得打印机
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < printers.size(); i++) {
Printer printer1 = printers.get(i);
if (printers.size() == i+1) {
stringBuilder.append(printer1.getPrinterId());
}else {
stringBuilder.append(printer1.getPrinterId()).append(",");
}
}
errorResource = stringBuilder.toString();
}
if (errorResource.length() > 0) {
throw BusinessException.build("该资源作业[" + resrce + "]已关联打印机[" + errorResource + "]不允许再绑定");
}
}
}
}else {
throw BusinessException.build("关联资源作业[" + printer.getResource() + "]时,只允许工序打印绑定多个资源");
}
}else {
if (StrUtil.isNotEmpty(printer.getResource())){
List<Printer> printers = printerMapper.selectList(Wrappers.<Printer>lambdaQuery()
.ne(Printer::getPrinterId, printer.getPrinterId())
.like(Printer::getResource, printer.getResource()));
if (printers.size() > 0) {
// 已存在得打印机
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < printers.size(); i++) {
Printer printer1 = printers.get(i);
if (printers.size() == i+1) {
stringBuilder.append(printer1.getPrinterId());
}else {
stringBuilder.append(printer1.getPrinterId()).append(",");
}
}
throw BusinessException.build("该资源作业[" + printer.getResource() + "]已关联打印机[" + stringBuilder + "]不允许再绑定");
}
}
}
}
@Override
public List<Printer> selectList(Printer printer) {
QueryWrapper<Printer> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(printer);
return super.list(queryWrapper);
}
}

View File

@ -0,0 +1,285 @@
package com.foreverwin.nlv.print.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.nlv.print.dto.LabelFieldSpecificLogicDTO;
import com.foreverwin.nlv.print.entity.FieldsCustomLogic;
import com.foreverwin.nlv.print.service.FieldsCustomLogicService;
import com.foreverwin.nlv.print.entity.SystemField;
import com.foreverwin.nlv.print.mapper.SystemFieldMapper;
import com.foreverwin.nlv.print.service.SystemFieldService;
import com.foreverwin.nlv.print.util.ArrayUtil;
import com.jayway.jsonpath.JsonPath;
import lombok.AllArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.lang.reflect.Method;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 系统字段定义
*
* @author MIHUYO
* @date 2022-10-28 09:17:15
*/
@Service
@AllArgsConstructor
public class SystemFieldServiceImpl extends ServiceImpl<SystemFieldMapper, SystemField> implements SystemFieldService {
private final FieldsCustomLogicService fieldsCustomLogicService;
private final SystemFieldMapper systemFieldMapper;
@Override
public SystemField getByCode(String site, String code) {
SystemField systemField = getById(SystemField.genHandle(site, code));
if(systemField == null) {
return null;
}
return systemField;
}
@Override
public boolean deleteByCode(String site, String code) {
String id = SystemField.genHandle(site, code);
return removeById(id);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean save(String site, String creator, SystemField systemField) {
systemField.setSite(site);
String handle = SystemField.genHandle(site, systemField.getFieldNumber());
systemField.setHandle(handle);
systemField.setModifyUser(creator);
systemField.setModifyDateTime(LocalDateTime.now());
try {
return super.save(systemField);
} catch (Exception e) {
if(e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateById(String site, String updater, SystemField systemField) {
String handle = systemField.getHandle();
if(StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
return super.updateById(systemField);
}
@Override
public SystemField getFieldData(String site, String fieldNumber) {
if (StrUtil.isBlank(fieldNumber)) {
throw BusinessException.build("field number should not be null");
}
return this.getById(SystemField.genHandle(site, fieldNumber));
}
/**
* 获取系统字段的实际值
* @param site
* @param fieldNumber
* @param baseData
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public List<String> getSystemFieldValue(String site, String fieldNumber, Map<String, Object> baseData) {
return getSystemFieldValue(site, fieldNumber, null, baseData);
}
/**
* 获取系统字段的实际值(缓存预处理)
* @param site
* @param fieldNumber
* @param systemFieldMap
* @param baseData
* @return
*/
@Transactional(propagation = Propagation.SUPPORTS)
@Override
public List<String> getSystemFieldValue(String site, String fieldNumber, Map<String, SystemField> systemFieldMap, Map<String, Object> baseData) {
try {
long current = System.currentTimeMillis();
long current1 = System.currentTimeMillis();
SystemField systemField;
if(systemFieldMap != null && systemFieldMap.size() > 0) {
systemField = systemFieldMap.get(fieldNumber);
} else {
systemField = getFieldData(site, fieldNumber);
}
System.out.println("get system field data:" + (System.currentTimeMillis() - current));
String type = systemField.getType();
LocalDateTime now = LocalDateTime.now();
baseData.put("site", site);
baseData.put("dateTime", DateUtil.format(now, "yyyy-MM-dd hh:mm:ss"));
String context = StrUtil.isEmpty(systemField.getGetValueContext())? "" : systemField.getGetValueContext();
// key值转换成驼峰标识
Map<String, Object> camelCaseMap = new HashMap<>();
ArrayUtil.transferKeyToUnderline(baseData, camelCaseMap, new HashSet<>());
System.out.println("transfer key to underline:" + (System.currentTimeMillis() - current));
List<String> resultList = new ArrayList<>();
// SQL
if ("sql".equals(type)) {
current = System.currentTimeMillis();
if (camelCaseMap != null) {
for (Map.Entry<String, Object> entry : camelCaseMap.entrySet()) {
context = context.replace("${" + entry.getKey() + "}", "" + entry.getValue() + "");
}
}
List<Map<String, Object>> list = systemFieldMapper.executeSqlQuery(context);
for (Map<String, Object> map1 : list) {
if (map1 == null) {
throw BusinessException.build("打印时根据系统字段["+systemField.getFieldNumber()+"]没有获取到对应的值!");
}
String fieldValue = map1.get(fieldNumber) == null ? "" : map1.get(fieldNumber).toString();
resultList.add(fieldValue);
}
System.out.println("sql field time:" + (System.currentTimeMillis() - current));
}
// JSON PATH
if ("pattern".equals(type)) {
current = System.currentTimeMillis();
String json = JSONObject.toJSONString(camelCaseMap);
Object temp;
try {
//为了解决包装标签中设置了34个Field,而实际baseData中可能只有其中一部分
//其他没有的,程式在此自动赋固定值 FIELD_EMPTY
if(context.substring(2).indexOf("Field")>-1)
{
if(json.indexOf(context.substring(2))>-1)
{
temp = JsonPath.read(json, context);
}else
{
temp="FIELD_EMPTY";
}
}else {
temp = JsonPath.read(json, context);
}
}catch (Exception e){
throw BusinessException.build("系统定义字段[" + fieldNumber + "]解析错误"+e.getMessage());
}
if (temp != null && temp instanceof net.minidev.json.JSONArray) {
net.minidev.json.JSONArray arrValue = (net.minidev.json.JSONArray) temp;
StringBuffer sb = new StringBuffer();
arrValue.forEach(a -> {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(a);
});
resultList.add(sb.toString());
} else {
resultList.add(String.valueOf(temp));
}
System.out.println("json path field time:" + (System.currentTimeMillis() - current));
}
// JSON SCRIPT
if ("script".equals(type)) {
current = System.currentTimeMillis();
Object result = this.evaScripts(fieldNumber, context, camelCaseMap);
resultList.add(String.valueOf(result));
System.out.println("script field time:" + (System.currentTimeMillis() - current));
}
// 固定值
if ("fixed".equals(type)) {
List<FieldsCustomLogic> list = fieldsCustomLogicService.list(Wrappers.<FieldsCustomLogic>lambdaQuery()
.eq(FieldsCustomLogic::getSite, site)
.eq(FieldsCustomLogic::getFieldNumber, fieldNumber));
if (list.size() > 0) {
FieldsCustomLogic fieldsCustomLogic = list.get(0);
String methodName = fieldsCustomLogic.getFunctionName();
Class clazz = Class.forName("com.foreverwin.business.label.service.impl.LabelFieldSpecificLogicServiceImpl");
Method method = clazz.getMethod(methodName, LabelFieldSpecificLogicDTO.class);
LabelFieldSpecificLogicDTO dto = new LabelFieldSpecificLogicDTO();
dto.setSite(site);
Object result = method.invoke(clazz.newInstance(), dto);
String returnType = method.getGenericReturnType().getTypeName();
if ("java.util.List<java.lang.String>".equals(returnType)) {
return (List<String>) result;
} else {
resultList.add((String) result);
}
} else {
throw BusinessException.build("特定逻辑的字段[" + fieldNumber + "]未维护对应的执行方法");
}
}
System.out.println("system field [" + fieldNumber + "] costs:" + (System.currentTimeMillis() - current1));
return resultList;
} catch (Exception e) {
throw BusinessException.build(e.getMessage() == null ? e.toString() : e.getMessage());
}
}
/**
* 解析js表达式
*
* @param fieldName
* @param script
* @param camelCaseMap
* @return
*/
public Object evaScripts(String fieldName, String script, Map<String, Object> camelCaseMap) {
// convert values
try {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript");
//替换js中自定义字段
Pattern p=Pattern.compile("(#\\{)([\\w]+)(\\})");
Matcher matcher = p.matcher(script);
while (matcher.find()){
String group = matcher.group(0);
String param = group.substring(2,group.length()-1);
List<String> systemFieldValue = getSystemFieldValue(TenantContextHolder.getTenantStrId(), param, camelCaseMap);
script=script.replaceFirst("(#\\{)([\\w]+)(\\})",systemFieldValue.get(0));
}
String function = "function parse(data) {\n" + script + "\n}";
engine.eval(function);
Invocable invoke = (Invocable) engine;
SerializeConfig config = new SerializeConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 下划线转驼峰
Object result = invoke.invokeFunction("parse", camelCaseMap); // 将map数据对象作为js函数参数值,可通过json对象的方式获取
if (result.toString().indexOf("null")>=0){
throw BusinessException.build(fieldName);
}
return result;
} catch (Exception ex) {
throw BusinessException.build("JS解析失败编号:" + ex.getMessage());
}
}
}

View File

@ -0,0 +1,295 @@
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class HttpTest {
public static final String origin = "http://localhost:8080";
@Test
public void getTokenTest() throws Exception {
System.out.println(getToken());
}
/**
* 获取今日生产线派工任务接口测试
* @throws Exception
*/
@Test
public void listTodayProductionLineDispatchTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
String productionLine = "DP0101";
HttpGet getRequest = new HttpGet(origin + "/iep-tds/tds-dispatch/api/line-dispatch/today?productionLine=" + productionLine);
String token = getToken();
getRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
getRequest.setHeader("TENANT-ID", "FW01");
getRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(getRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 获取可派工工单数据接口接口测试
* @throws Exception
*/
@Test
public void listApiAvailableLineDispatchShopOrderTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
String productionLine = "DP0101";
HttpGet getRequest = new HttpGet(origin + "/iep-tds/tds-dispatch/api/list-available-line-dispatch-shop-order?current=1&size=10&productionLine=" + productionLine);
String token = getToken();
getRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
getRequest.setHeader("TENANT-ID", "FW01");
getRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(getRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 产线手动新增派工任务接口
* @throws Exception
*/
@Test
public void addLineDispatchTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/iep-tds/tds-dispatch/api/add-line-dispatch");
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
postRequest.setHeader("TENANT-ID", "FW01");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
AddLineDispatchRequest request = new AddLineDispatchRequest();
request.setUsername("syngna");
AddLineDispatchDetail detail = new AddLineDispatchDetail();
detail.setProductionLine("DP0102");
detail.setProductionOptions("B");
detail.setShopOrder("CP-MO-230302-001");
LocalDateTime startDate = LocalDateTime.now();
detail.setDispatchStartDateTime(startDate);
detail.setDispatchEndDateTime(startDate.plusMinutes(600));
detail.setDurations(BigDecimal.valueOf(600));
detail.setDispatchQty(BigDecimal.valueOf(50));
detail.setEffectImmediately(true);
request.setDetails(Arrays.asList(detail));
String requestBody = JSON.toJSONStringWithDateFormat(request, "yyyy-MM-dd HH:mm:ss");
postRequest.setEntity(new StringEntity(requestBody, "utf-8"));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 修改产线派工任务接口
* @throws Exception
*/
@Test
public void modifyLineDispatchTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/iep-tds/tds-dispatch/api/modify-line-dispatch");
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
postRequest.setHeader("TENANT-ID", "FW01");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
ModifyDispatchRequest detail = new ModifyDispatchRequest();
detail.setUsername("syngna");
detail.setDispatchHandle("1787303832088698881");
detail.setProductionLine("DP0103");
detail.setRecalculate(false);
LocalDateTime startDate = LocalDateTime.now();
detail.setDispatchStartDateTime(startDate);
detail.setDispatchEndDateTime(startDate.plusMinutes(500));
detail.setDurations(BigDecimal.valueOf(500));
detail.setDispatchQty(BigDecimal.valueOf(40));
detail.setEffectImmediately(true);
String requestBody = JSON.toJSONStringWithDateFormat(detail, "yyyy-MM-dd HH:mm:ss");
postRequest.setEntity(new StringEntity(requestBody, "utf-8"));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 修改产线派工任务状态接口
* @throws Exception
*/
@Test
public void modifyProductStatusTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/iep-tds/tds-dispatch/api/modify-product-status");
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
postRequest.setHeader("TENANT-ID", "FW01");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
ModifyDispatchProductStatusRequest detail = new ModifyDispatchProductStatusRequest();
detail.setUsername("syngna");
detail.setDispatchHandle("1787303832088698881");
detail.setProductStatus("2");
// detail.setCompleteQty(BigDecimal.valueOf(10));
String requestBody = JSON.toJSONStringWithDateFormat(detail, "yyyy-MM-dd HH:mm:ss");
postRequest.setEntity(new StringEntity(requestBody, "utf-8"));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 永久删除任务接口
* @throws Exception
*/
@Test
public void realDeleteTest() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/iep-tds/tds-dispatch/api/delete-real");
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
postRequest.setHeader("TENANT-ID", "FW01");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
RealDeleteDispatchRequest detail = new RealDeleteDispatchRequest();
detail.setUsername("syngna");
detail.setDispatchHandle("1787297299137257473");
String requestBody = JSON.toJSONStringWithDateFormat(detail, "yyyy-MM-dd HH:mm:ss");
postRequest.setEntity(new StringEntity(requestBody, "utf-8"));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}
/**
* 获取今日生产线派工任务接口测试
* @throws Exception
*/
/*@Test
public void loadFurnaceSynchronous() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/iep-tds/api/line-dispatch/today");
LoadFurnaceDTO loadFurnaceDTO = new LoadFurnaceDTO();
loadFurnaceDTO.setLoadFurnaceEqu("B02");
loadFurnaceDTO.setLoadFurnaceEquDes("B02");
loadFurnaceDTO.setMaterialCode("ITEM1040");
loadFurnaceDTO.setLoadBatchNumber("B02006");
loadFurnaceDTO.setLoadTime("2024-03-15 14:07:46");
loadFurnaceDTO.setLoadBy("YN000333");
LoadFurnaceMaterialConsumptionDTO detail1 = new LoadFurnaceMaterialConsumptionDTO();
LoadFurnaceMaterialConsumptionDTO detail2 = new LoadFurnaceMaterialConsumptionDTO();
LoadFurnaceMaterialConsumptionDTO detail3 = new LoadFurnaceMaterialConsumptionDTO();
detail1.setMaterialCode("ITEM1031");
detail1.setQty(BigDecimal.valueOf(1.0));
detail1.setUom("千克");
detail2.setMaterialCode("ITEM1037");
detail2.setQty(BigDecimal.valueOf(10));
detail2.setUom("KG");
detail3.setMaterialCode("ITEM1038");
detail3.setQty(BigDecimal.valueOf(6));
detail3.setUom("KG");
loadFurnaceDTO.setMaterialConsumptionData(Arrays.asList(detail1));
// loadFurnaceDTO.setMaterialConsumptionData(Arrays.asList(detail1, detail2, detail3));
String requestBody = JSON.toJSONString(loadFurnaceDTO);
//String requestBody = "{\"loadFurnaceEqu\":\"B02\",\"loadFurnaceEquDes\":\"B02\",\"materialCode\":\"ITEM1040\",\"loadBatchNumber\":\"B02006\",\"loadTime\":\"2024-03-15 14:07:46\",\"materialConsumptionData\":[{\"materialCode\":\"ITEM1031\",\"qty\":1.0,\"uom\":\"千克\"}],\"loadBy\":\"YN000333\"}";
System.out.println(requestBody);
String token = getToken();
postRequest.setHeader(HttpHeaders.AUTHORIZATION, CommonConstant.AUTH_BEARER + token);
postRequest.setHeader("TENANT-ID", "XYSI");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, CommonConstant.CONTENT_TYPE_JSON);
postRequest.setEntity(new StringEntity(requestBody, CommonConstant.CHARSET_UTF8));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
System.out.println(responseJson);
}*/
public String getToken() throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost postRequest = new HttpPost(origin + "/auth/oauth/token?randomStr=blockPuzzle&grant_type=password");
// 构建请求参数
List<NameValuePair> pair = new ArrayList<>();
pair.add(new BasicNameValuePair("username", "admin"));
pair.add(new BasicNameValuePair("password", "JFat0Zdc"));
postRequest.setHeader(HttpHeaders.AUTHORIZATION, "Basic bW9tOm1vbQ==");
postRequest.setHeader("TENANT-ID", "FW01");
postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
postRequest.setEntity(new UrlEncodedFormEntity(pair, "utf-8"));
// 调用登陆接口获取token
HttpResponse response = httpClient.execute(postRequest);
String responseString = EntityUtils.toString(response.getEntity());
// 解析返回的 JSON 数据
ObjectMapper objectMapper = new ObjectMapper();
JsonNode responseJson = objectMapper.readTree(responseString);
String accessToken = responseJson.get("access_token").asText();
System.out.println(responseJson);
return accessToken;
}
}

22
print-db/pom.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<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>com.foreverwin</groupId>
<artifactId>nlv-print</artifactId>
<version>4.5.0</version>
</parent>
<artifactId>print-db</artifactId>
<dependencies>
<dependency>
<groupId>com.foreverwin</groupId>
<artifactId>print-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,16 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.PrintRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
@Mapper
public interface CustomerPrintRuleMapper extends BaseMapper<PrintRule> {
List<Map<String,String>> selectLabelCategory(@Param("site") String site);
}

View File

@ -0,0 +1,16 @@
package com.foreverwin.nlv.print.mapper;
import com.foreverwin.mom.common.data.datascope.MomBaseMapper;
import com.foreverwin.nlv.print.entity.FieldsCustomLogic;
import org.apache.ibatis.annotations.Mapper;
/**
* 字段与方法绑定
*
* @author aaron
* @date 2022-11-18 13:24:38
*/
@Mapper
public interface FieldsCustomLogicMapper extends MomBaseMapper<FieldsCustomLogic> {
}

View File

@ -0,0 +1,16 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.LabelCategory;
import org.apache.ibatis.annotations.Mapper;
/**
* 标签类别维护表
*
* @author MIHUYO
* @date 2022-10-28 16:36:54
*/
@Mapper
public interface LabelCategoryMapper extends BaseMapper<LabelCategory> {
}

View File

@ -0,0 +1,16 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
import org.apache.ibatis.annotations.Mapper;
/**
* 打印模板变量关系维护明细表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Mapper
public interface LabelFieldAllocationDetailMapper extends BaseMapper<LabelFieldAllocationDetail> {
}

View File

@ -0,0 +1,22 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.LabelFieldAllocation;
import com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 打印模板变量关系维护主表
*
* @author MIHUYO
* @date 2022-10-28 09:15:39
*/
@Mapper
public interface LabelFieldAllocationMapper extends BaseMapper<LabelFieldAllocation> {
List<LabelFieldAllocationDetail> labelNumberInfo(@Param("site") String site, @Param("fieldBo") String fieldBo);
}

View File

@ -0,0 +1,21 @@
package com.foreverwin.nlv.print.mapper;
import com.foreverwin.mom.common.data.datascope.MomBaseMapper;
import com.foreverwin.nlv.print.entity.PrintLabelTemplate;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 打印标签模板维护
*
* @author MIHUYO
* @date 2022-10-24 17:13:11
*/
@Mapper
public interface PrintLabelTemplateMapper extends MomBaseMapper<PrintLabelTemplate> {
List<Map<String,Object>> selectFastCode(@Param("fastCodeBO") String fastCodeBO, @Param("code") String code);
}

View File

@ -0,0 +1,27 @@
package com.foreverwin.nlv.print.mapper;
import com.foreverwin.mom.common.data.datascope.MomBaseMapper;
import com.foreverwin.nlv.print.entity.PrintRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 打印记录表
*
* @author aaron
* @date 2022-10-29 13:40:49
*/
@Mapper
public interface PrintRecordMapper extends MomBaseMapper<PrintRecord> {
/**
* 依 条码 获取打印记录对象
* @param site
* @param barcodeNumber
* @return
*/
PrintRecord selectPrintReocrdByBarcodeNumber(@Param("site") String site, @Param("barcodeNumber") String barcodeNumber);
}

View File

@ -0,0 +1,28 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.Printer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 打印机注册
*
* @author MIHUYO
* @date 2022-10-27 10:51:42
*/
@Mapper
public interface PrinterMapper extends BaseMapper<Printer> {
/**
* 获取打印机
* @param site
* @param operationType 后台数据样式 基膜-JM
* @param resource
* @return
*/
List<String> selectPrinter(@Param("site") String site, @Param("operationType") String operationType, @Param("resource") String resource);
}

View File

@ -0,0 +1,22 @@
package com.foreverwin.nlv.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.nlv.print.entity.SystemField;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 系统字段定义
*
* @author MIHUYO
* @date 2022-10-28 09:17:15
*/
@Mapper
public interface SystemFieldMapper extends BaseMapper<SystemField> {
List<Map<String, Object>> executeSqlQuery(@Param("sql") String sql);
}

View File

@ -0,0 +1,30 @@
<?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="com.foreverwin.nlv.print.mapper.CustomerPrintRuleMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.foreverwin.nlv.print.entity.PrintRule">
<id column="HANDLE" property="handle" />
<result column="SITE" property="site" />
<result column="CUSTOMER_CODE" property="customerCode" />
<result column="OPERATION" property="operation" />
<result column="STATUS" property="status" />
<result column="RULE1" property="rule1" />
<result column="PRINT_NUMBER1" property="printNumber1" />
<result column="RULE2" property="rule2" />
<result column="PRINT_NUMBER2" property="printNumber2" />
<result column="RULE3" property="rule3" />
<result column="PRINT_NUMBER3" property="printNumber3" />
<result column="CREATED_DATE_TIME" property="createdDateTime" />
<result column="CREATED_USER" property="createdUser" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
HANDLE, SITE, CUSTOMER_CODE, OPERATION, STATUS, RULE1, PRINT_NUMBER1, RULE2, PRINT_NUMBER2, RULE3, PRINT_NUMBER3, CREATED_DATE_TIME, CREATED_USER
</sql>
<!-- 查询模板类别 -->
<select id="selectLabelCategory" resultType="java.util.LinkedHashMap">
SELECT LABEL_CATEGORY_ID,LABEL_CATEGORY_NAME FROM PRINT_LABEL_CATEGORY WHERE SITE=#{site}
</select>
</mapper>

View File

@ -0,0 +1,13 @@
<?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="com.foreverwin.nlv.print.mapper.FieldsCustomLogicMapper">
<resultMap id="fieldsCustomLogicMap" type="com.foreverwin.nlv.print.entity.FieldsCustomLogic">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="fieldNumber" column="FIELD_NUMBER"/>
<result property="functionName" column="FUNCTION_NAME"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,15 @@
<?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="com.foreverwin.nlv.print.mapper.LabelCategoryMapper">
<resultMap id="labelCategoryMap" type="com.foreverwin.nlv.print.entity.LabelCategory">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="labelCategoryId" column="LABEL_CATEGORY_ID"/>
<result property="labelCategoryName" column="LABEL_CATEGORY_NAME"/>
<result property="modifyDateTime" column="MODIFY_DATE_TIME"/>
<result property="modifyUser" column="MODIFY_USER"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,16 @@
<?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="com.foreverwin.nlv.print.mapper.LabelFieldAllocationDetailMapper">
<resultMap id="labelFieldAllocationDetailMap" type="com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail">
<id property="handle" column="HANDLE"/>
<result property="seq" column="SEQ"/>
<result property="zLabelFieldAllocationBo" column="Z_LABEL_FIELD_ALLOCATION_BO"/>
<result property="labelField" column="LABEL_FIELD"/>
<result property="fieldNumber" column="FIELD_NUMBER"/>
<result property="modifyDateTime" column="MODIFY_DATE_TIME"/>
<result property="modifyUser" column="MODIFY_USER"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,30 @@
<?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="com.foreverwin.nlv.print.mapper.LabelFieldAllocationMapper">
<resultMap id="labelFieldAllocationMap"
type="com.foreverwin.nlv.print.entity.LabelFieldAllocation">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="labelNumber" column="LABEL_NUMBER"/>
<result property="labelType" column="LABEL_TYPE"/>
<result property="labelDescription" column="LABEL_DESCRIPTION"/>
<result property="modifyUser" column="MODIFY_USER"/>
<result property="modifyDateTime" column="MODIFY_DATE_TIME"/>
</resultMap>
<select id="labelNumberInfo" resultType="com.foreverwin.nlv.print.entity.LabelFieldAllocationDetail">
SELECT A.SEQ SEQ,
A.LABEL_FIELD,
A.FIELD_NUMBER,
B.FIELD_DESCRIPTION
FROM PRINT_LABEL_FIELD_ALLOCATION_DETAIL A
LEFT JOIN PRINT_SYSTEM_FIELD B ON A.FIELD_NUMBER = B.FIELD_NUMBER
WHERE PRINT_LABEL_FIELD_ALLOCATION_BO = #{fieldBo}
AND B.SITE = #{site}
ORDER BY SEQ, A.MODIFY_DATE_TIME
</select>
</mapper>

View File

@ -0,0 +1,38 @@
<?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="com.foreverwin.nlv.print.mapper.PrintRecordMapper">
<resultMap id="printRecordMap" type="com.foreverwin.nlv.print.entity.PrintRecord">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="shopOrder" column="SHOP_ORDER"/>
<result property="barcodeNumber" column="BARCODE_NUMBER"/>
<result property="barcodeType" column="BARCODE_TYPE"/>
<result property="printTimes" column="PRINT_TIMES"/>
<result property="copies" column="COPIES"/>
<result property="lastPrintTime" column="LAST_PRINT_TIME"/>
<result property="printTmpl" column="PRINT_TMPL"/>
<result property="printContent" column="PRINT_CONTENT"/>
<result property="basedataContent" column="BASEDATA_CONTENT"/>
<result property="printerName" column="PRINTER_NAME"/>
<result property="operationType" column="OPERATION_TYPE"/>
<result property="printScenario" column="PRINT_SCENARIO"/>
<result property="createdUser" column="CREATED_USER"/>
<result property="modifiedUser" column="MODIFIED_USER"/>
<result property="createdDateTime" column="CREATED_DATE_TIME"/>
<result property="modifiedDateTime" column="MODIFIED_DATE_TIME"/>
</resultMap>
<sql id="Base_Column_List">
HANDLE, SITE, SHOP_ORDER, BARCODE_NUMBER, BARCODE_TYPE, PRINT_TIMES, COPIES, LAST_PRINT_TIME, PRINT_TMPL, PRINT_CONTENT,BASEDATA_CONTENT, PRINTER_NAME, OPERATION_TYPE, PRINT_SCENARIO, CREATED_USER, MODIFIED_USER, CREATED_DATE_TIME, MODIFIED_DATE_TIME
</sql>
<select id="selectPrintReocrdByBarcodeNumber" resultMap="printRecordMap">
SELECT <include refid="Base_Column_List"/>
FROM Z_PRINT_RECORD WHERE SITE=#{site} AND BARCODE_NUMBER=#{barcodeNumber}
LIMIT 0,1
</select>
</mapper>

View File

@ -0,0 +1,28 @@
<?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="com.foreverwin.nlv.print.mapper.PrinterMapper">
<resultMap id="printerRegesterMap" type="com.foreverwin.nlv.print.entity.Printer">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="printerId" column="PRINTER_ID"/>
<result property="operationType" column="OPERATION_TYPE"/>
<result property="printScenario" column="PRINT_SCENARIO"/>
<result property="locationDesc" column="LOCATION_DESC"/>
<result property="resource" column="RESOURCE"/>
<result property="ipAddress" column="IP_ADDRESS"/>
<result property="modifyDateTime" column="MODIFY_DATE_TIME"/>
<result property="modifyUser" column="MODIFY_USER"/>
</resultMap>
<select id="selectPrinter" resultType="String">
SELECT PRINTER_ID FROM Z_PRINTER
<where>
<if test="site!=null and site!=''"> AND SITE=#{site}</if>
<if test="operationType!=null and operationType!=''"> AND OPERATION_TYPE=#{operationType}</if>
<if test="resource!=null and resource!=''"> AND INSTR(RESOURCE, #{resource}) > 0</if>
</where>
</select>
</mapper>

View File

@ -0,0 +1,21 @@
<?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="com.foreverwin.nlv.print.mapper.SystemFieldMapper">
<resultMap id="systemFieldMap" type="com.foreverwin.nlv.print.entity.SystemField">
<id property="handle" column="HANDLE"/>
<result property="site" column="SITE"/>
<result property="fieldNumber" column="FIELD_NUMBER"/>
<result property="fieldDescription" column="FIELD_DESCRIPTION"/>
<result property="type" column="TYPE"/>
<result property="getValueContext" column="GET_VALUE_CONTEXT"/>
<result property="modifyDateTime" column="CREATED_DATE_TIME"/>
<result property="modifyUser" column="CREATED_USER"/>
</resultMap>
<select id="executeSqlQuery" resultType="java.util.LinkedHashMap">
${sql}
</select>
</mapper>