init: 导入项目

This commit is contained in:
fengjun
2024-07-02 11:40:01 +08:00
commit 4c8e6701f2
7158 changed files with 1199718 additions and 0 deletions

117
commonapi/pom.xml Normal file
View File

@@ -0,0 +1,117 @@
<?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.ag.jngh</groupId>
<artifactId>AG_ONE</artifactId>
<version>1.0</version>
</parent>
<artifactId>commonapi</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>commonapi Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>1.8.3.RELEASE</version>
</dependency>
<!--<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>RELEASE</version>
</dependency>-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>anji-jsonGroup</groupId>
<artifactId>anji-jsonArtifact</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>QLExpress</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies>
<build>
<finalName>commonapi</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

View File

@@ -0,0 +1,157 @@
package com.ag.algroithm;
import com.ag.algroithm.data.CntrProerty;
import com.ag.algroithm.data.ContantDataTwoChant;
import com.ag.algroithm.instance.HungarianAlgorithm;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class YardCntrPlanAlgorithm {
/**
* select * from port_cntr where substring(yard_position,1,2)='F1' and E_F_ID='F' and CNTR_OPERATOR_COD='XWWL' and good_notes='磷酸一铵'
*
* 呗位 3-15
*
* 3 5 79 11 13 15 从这7个呗位找14个箱子
* @param args
*/
public static void main(String args[]) {
//Aver表示平均每个拖卡都能分到对应拖卡呗位的箱子
// ContantDataAver contantData = new ContantDataAver();
//Aver表示其中有一个拖卡的呗位没有箱子
ContantDataTwoChant contantData = new ContantDataTwoChant();
List arrlist = contantData.data();
Map datamap=new HashMap();
double[][] matrix = new double[7][200];
for (int i = 1; i < 6; i++) {
String[][][][] namelist = new String[5][5][6][3];
for (Object cntrProerty1 : arrlist) {
CntrProerty cntrProerty = (CntrProerty) cntrProerty1;
namelist[cntrProerty.getRow()][cntrProerty.getFloor()][cntrProerty.getChant()][cntrProerty.getDirect()] = cntrProerty.getCntrno();
}
System.out.println("===================T" + i + "=================");
computeOcclusion(namelist, 3, 0, i,matrix,datamap);
}
for(int x=0; x<matrix.length; x++)//循环输出二维数组的for循环嵌套
{
for(int y=0; y<matrix[x].length; y++)
{
if(y==19) {
// if(matrix[x][y]!=0)
System.out.print(x+"@"+y+":"+matrix[x][y] + ","+"\n");
}else{
// if(matrix[x][y]!=0)
System.out.print(x+"@"+y+":"+matrix[x][y] + ",");
}
if(matrix[x][y]==0.0){
matrix[x][y]=10000.0;
}
}
}
HungarianAlgorithm b = new HungarianAlgorithm(matrix);
int[] match = b.execute();
// System.out.println(computeCost(matrix,match));
// System.out.println(Arrays.toString(matrix));
for (int i = 0; i < matrix.length; i++) {
System.out.println("matrix["+i+"]["+match[i]+"]"+"=代价:=="+matrix[i][match[i]]+"==箱号:=="+datamap.get("matrix["+i+"]["+match[i]+"]"));
}
}
/**
* 计算出箱子路径长度和是否有遮挡,计算匈牙利算法的代价
* floors 总层数
* 目标位置,排数 rows 呗数 chant
*
* @param namelist
*/
public static void computeOcclusion(String[][][][] namelist, int floors, int rows, int chant, double[][] matrix, Map datamap) {
//i表示排数 j表示层数 k 表示呗 m表示方向排*50权重呗*10权重 遮挡*80权重
for (int i = 1; i < namelist.length; i++) {
for (int j = 1; j < namelist[i].length; j++) {
for (int k = 1; k < namelist[i][j].length; k++) {
for (int m = 0; m <= 1; m++) {
if (j < 4) {
if (namelist[i][j][k][m] != null) {
if (namelist[i][j][k][m].contains("@pre")) {
namelist[i][j][k][m] = namelist[i][j][k][m].substring(0, namelist[i][j][k][m].indexOf("@pre"));
}
}
boolean flag = false;
//如果上面存在箱子标记一下
if (namelist[i][j + 1][k][m] != null) {
if (k == chant) {
if (namelist[i][j][k][m] != null) {
//1排+1呗+3总层数-2层+方向0,呗移动*30
//排*呗位
matrix[chant][i+k*11+(floors-j)+m]=(i + (Math.abs(k - chant)*30 + 1) + (floors - j) - 1);
namelist[i][j][k][m] = (i + (Math.abs(k - chant) + 1) + (floors - j) - 1) + "@" + namelist[i][j][k][m] + "@pre" + "@chant";
}
} else if (namelist[i][j][k][m] != null) {
matrix[chant][i+k*11+(floors-j)+m]=(i + (Math.abs(k - chant)*30 + 1) + (floors - j) - 1);
namelist[i][j][k][m] = (i + (Math.abs(k - chant) + 1) + (floors - j) - 1) + "@" + namelist[i][j][k][m] + "@pre";
}
flag = true;
}
if (namelist[i][j][k][m] != null) {
if (!flag) {
if (k == chant) {
matrix[chant][i+k*11+(floors-j)+m]=(i + (Math.abs(k - chant)*30 + 1) + (floors - j) - 1);
namelist[i][j][k][m] = (i + (Math.abs(k - chant) + 1) + (floors - j) - 1) + "@" + namelist[i][j][k][m] + "@chant";
} else {
matrix[chant][i+k*11+(floors-j)+m]=(i + (Math.abs(k - chant)*30 + 1) + (floors - j) - 1);
namelist[i][j][k][m] = (i + (Math.abs(k - chant) + 1) + (floors - j) - 1) + "@" + namelist[i][j][k][m];
}
}
int s=i+k*11+(floors-j)+m;
System.out.println( "matrix["+chant+"]["+s+"]最终====namelist[" + i + "][" + j + "][" + k + "][" + m + "]=" + namelist[i][j][k][m]);
datamap.put("matrix["+chant+"]["+s+"]",namelist[i][j][k][m]);
}
}
}
}
}
}
}
/**
* @param i 排号
* @param j 层
* @param k 呗位
* @param m 方向
* @param cntrno
*/
public void computefinalCntrPosition(int i, int j, int k, int m, String cntrno) {
}
}

View File

@@ -0,0 +1,73 @@
package com.ag.algroithm.data;
public class CntrProerty {
private int row; //行
private int chant;//呗 理解为列
private int floor; //层
private int direct;//方向
public int getDirect() {
return direct;
}
public void setDirect(int direct) {
this.direct = direct;
}
public String getCntrno() {
return cntrno;
}
public void setCntrno(String cntrno) {
this.cntrno = cntrno;
}
private String cntrno;
private int pathLength;//路径长度
private String isOcclusion;//有无遮挡
public int getRow() {
return row;
}
public void setRow(int row) {
this.row = row;
}
public int getChant() {
return chant;
}
public void setChant(int chant) {
this.chant = chant;
}
public int getFloor() {
return floor;
}
public void setFloor(int floor) {
this.floor = floor;
}
public int getPathLength() {
return this.row + this.floor - 1;
}
public void setPathLength(int pathLength) {
this.pathLength = pathLength;
}
public String getIsOcclusion() {
return isOcclusion;
}
public void setIsOcclusion(String isOcclusion) {
this.isOcclusion = isOcclusion;
}
}

View File

@@ -0,0 +1,162 @@
package com.ag.algroithm.data;
import java.util.ArrayList;
import java.util.List;
public class ContantData {
/**
* 火车位置
*
* 12345
*
* 如果火车位置在第三排1和2排改成2和1排对于小于火车位置的用火车位置-排数
* 后面345排改成123排对于大于火车位置的用实际排数-火车位置+1
* @return
*/
public int getTrainpostion(){
return 3;
}
/**
* 箱子分布图
* @return
*/
public List data(){
List<CntrProerty> arrlist = new ArrayList<CntrProerty>();
/*
1排 1 呗========
* */
CntrProerty cntrProerty = new CntrProerty();
//一排一层一列A1
cntrProerty.setRow(1);
cntrProerty.setFloor(1);
cntrProerty.setChant(1);
cntrProerty.setCntrno("A1");
cntrProerty.setDirect(0);//左边
CntrProerty cntrProerty2 = new CntrProerty();
//一排二层一列A2
cntrProerty2.setRow(1);
cntrProerty2.setFloor(2);
cntrProerty2.setChant(1);
cntrProerty2.setCntrno("A2");
cntrProerty2.setDirect(0);//左边
CntrProerty cntrProerty3 = new CntrProerty();
//一排三层一列A3
cntrProerty3.setRow(1);
cntrProerty3.setFloor(3);
cntrProerty3.setChant(1);
cntrProerty3.setCntrno("A3");
cntrProerty3.setDirect(0);//左边
/*
2 排 1呗========
* */
CntrProerty cntrProertyTwoRow = new CntrProerty();
//2排一层一列AA1
cntrProertyTwoRow.setRow(2);
cntrProertyTwoRow.setFloor(1);
cntrProertyTwoRow.setChant(1);
cntrProertyTwoRow.setCntrno("AA1");
cntrProertyTwoRow.setDirect(0);//左边
CntrProerty cntrProertyTwoRowTwoFloor = new CntrProerty();
//2排二层一列AA2
cntrProertyTwoRowTwoFloor.setRow(2);
cntrProertyTwoRowTwoFloor.setFloor(2);
cntrProertyTwoRowTwoFloor.setChant(1);
cntrProertyTwoRowTwoFloor.setCntrno("AA2");
cntrProertyTwoRowTwoFloor.setDirect(0);//左边
CntrProerty cntrProertyTwoRowThreeFloor = new CntrProerty();
//2排三层一列AA3
cntrProertyTwoRowThreeFloor.setRow(2);
cntrProertyTwoRowThreeFloor.setFloor(3);
cntrProertyTwoRowThreeFloor.setChant(1);
cntrProertyTwoRowThreeFloor.setCntrno("AA3");
cntrProertyTwoRowThreeFloor.setDirect(0);//左边
arrlist.add(cntrProerty);
arrlist.add(cntrProerty2);
arrlist.add(cntrProerty3);
arrlist.add(cntrProertyTwoRow);
arrlist.add(cntrProertyTwoRowTwoFloor);
arrlist.add(cntrProertyTwoRowThreeFloor);
/*
1排 2 呗========
* */
CntrProerty cntrProertytwochant = new CntrProerty();
//一排一层2列B1
cntrProertytwochant.setRow(1);
cntrProertytwochant.setFloor(1);
cntrProertytwochant.setChant(2);
cntrProertytwochant.setCntrno("B1");
cntrProertytwochant.setDirect(0);//左边
CntrProerty cntrProertytwochant2 = new CntrProerty();
//一排二层2列B2
cntrProertytwochant2.setRow(1);
cntrProertytwochant2.setFloor(2);
cntrProertytwochant2.setChant(2);
cntrProertytwochant2.setCntrno("B2");
cntrProertytwochant2.setDirect(0);//左边
CntrProerty cntrProertytwochant3 = new CntrProerty();
//一排三层2列B3
cntrProertytwochant3.setRow(1);
cntrProertytwochant3.setFloor(3);
cntrProertytwochant3.setChant(2);
cntrProertytwochant3.setCntrno("B3");
cntrProertytwochant3.setDirect(0);//左边
/*
2 排 2呗========
* */
CntrProerty cntrProertyTwoRowTwochant = new CntrProerty();
//2排一层2列D1
cntrProertyTwoRowTwochant.setRow(2);
cntrProertyTwoRowTwochant.setFloor(1);
cntrProertyTwoRowTwochant.setChant(2);
cntrProertyTwoRowTwochant.setCntrno("BB1");
cntrProertyTwoRowTwochant.setDirect(0);//左边
CntrProerty cntrProertyTwoRowTwoFloorTwochant = new CntrProerty();
//2排二层2列D2
cntrProertyTwoRowTwoFloorTwochant.setRow(2);
cntrProertyTwoRowTwoFloorTwochant.setFloor(2);
cntrProertyTwoRowTwoFloorTwochant.setChant(2);
cntrProertyTwoRowTwoFloorTwochant.setCntrno("BB2");
cntrProertyTwoRowTwoFloorTwochant.setDirect(0);//左边
CntrProerty cntrProertyTwoRowThreeFloorTwochant = new CntrProerty();
//2排三层2列D3
cntrProertyTwoRowThreeFloorTwochant.setRow(2);
cntrProertyTwoRowThreeFloorTwochant.setFloor(3);
cntrProertyTwoRowThreeFloorTwochant.setChant(2);
cntrProertyTwoRowThreeFloorTwochant.setCntrno("BB3");
cntrProertyTwoRowThreeFloorTwochant.setDirect(0);//左边
/*
2排 2呗========
* */
CntrProerty cntrProertyGG = new CntrProerty();
//一排一层一列A1
cntrProertyGG.setRow(2);
cntrProertyGG.setFloor(1);
cntrProertyGG.setChant(2);
cntrProertyGG.setCntrno("GG1");
cntrProertyGG.setDirect(1);//右边
arrlist.add(cntrProertytwochant);
arrlist.add(cntrProertytwochant2);
arrlist.add(cntrProertytwochant3);
arrlist.add(cntrProertyTwoRowTwochant);
arrlist.add(cntrProertyTwoRowTwoFloorTwochant);
arrlist.add(cntrProertyTwoRowThreeFloorTwochant);
arrlist.add(cntrProertyGG);
return arrlist;
}
}

View File

@@ -0,0 +1,91 @@
package com.ag.algroithm.data;
import java.util.ArrayList;
import java.util.List;
public class ContantDataAver {
/**
* 箱子分布图
* @return
*/
public List data(){
List<CntrProerty> arrlist = new ArrayList<CntrProerty>();
/*
1排 1 呗 0 左边========
* */
CntrProerty cntrProerty = new CntrProerty();
//一排一层一列A1
cntrProerty.setRow(1);
cntrProerty.setFloor(3);
cntrProerty.setChant(1);
cntrProerty.setCntrno("A1");
cntrProerty.setDirect(0);//左边
arrlist.add(cntrProerty);
/*
2 排 2呗 0 左边========
* */
CntrProerty cntrProertyTwoRowTwochant = new CntrProerty();
//2排一层2列D1
cntrProertyTwoRowTwochant.setRow(2);
cntrProertyTwoRowTwochant.setFloor(3);
cntrProertyTwoRowTwochant.setChant(2);
cntrProertyTwoRowTwochant.setCntrno("BB1");
cntrProertyTwoRowTwochant.setDirect(0);//左边
CntrProerty cntrProertyTwoRowTwoFloorTwochant = new CntrProerty();
/*
1 排 3呗 1 右边========
* */
CntrProerty cntrProertyTwoRowTwochant1 = new CntrProerty();
//2排一层2列H1
cntrProertyTwoRowTwochant1.setRow(1);
cntrProertyTwoRowTwochant1.setFloor(3);
cntrProertyTwoRowTwochant1.setChant(3);
cntrProertyTwoRowTwochant1.setCntrno("H1");
cntrProertyTwoRowTwochant1.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant1);
/*
2 排 4呗 1 右边========
* */
CntrProerty cntrProertyTwoRowTwochant2 = new CntrProerty();
//2排一层2列H1
cntrProertyTwoRowTwochant2.setRow(2);
cntrProertyTwoRowTwochant2.setFloor(3);
cntrProertyTwoRowTwochant2.setChant(4);
cntrProertyTwoRowTwochant2.setCntrno("KK1");
cntrProertyTwoRowTwochant2.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant2);
/*
1 排 5呗 1 右边========
* */
CntrProerty cntrProertyTwoRowTwochant3 = new CntrProerty();
//2排一层2列H1
cntrProertyTwoRowTwochant3.setRow(1);
cntrProertyTwoRowTwochant3.setFloor(3);
cntrProertyTwoRowTwochant3.setChant(5);
cntrProertyTwoRowTwochant3.setCntrno("L1");
cntrProertyTwoRowTwochant3.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant3);
arrlist.add(cntrProertyTwoRowTwochant);
arrlist.add(cntrProertyTwoRowTwoFloorTwochant);
return arrlist;
}
}

View File

@@ -0,0 +1,100 @@
package com.ag.algroithm.data;
import java.util.ArrayList;
import java.util.List;
public class ContantDataTwoChant {
/**
* 箱子分布图
* @return
*/
public List data(){
List<CntrProerty> arrlist = new ArrayList<CntrProerty>();
/*
1排 1 呗 0 左边========
* */
CntrProerty cntrProerty = new CntrProerty();
//一排一层一列A1
cntrProerty.setRow(1);
cntrProerty.setFloor(3);
cntrProerty.setChant(1);
cntrProerty.setCntrno("A1");
cntrProerty.setDirect(0);//左边
arrlist.add(cntrProerty);
/*
2 排 2呗 0 左边========
* */
CntrProerty cntrProertyTwoRowTwochant = new CntrProerty();
//2排一层2列D1
cntrProertyTwoRowTwochant.setRow(2);
cntrProertyTwoRowTwochant.setFloor(3);
cntrProertyTwoRowTwochant.setChant(2);
cntrProertyTwoRowTwochant.setCntrno("BB1");
cntrProertyTwoRowTwochant.setDirect(0);//左边
CntrProerty cntrProertyTwoRowTwoFloorTwochant = new CntrProerty();
/*
1 排 3呗 1 右边========
* */
CntrProerty cntrProertyTwoRowTwochant1 = new CntrProerty();
//2排一层2列H1
cntrProertyTwoRowTwochant1.setRow(1);
cntrProertyTwoRowTwochant1.setFloor(3);
cntrProertyTwoRowTwochant1.setChant(3);
cntrProertyTwoRowTwochant1.setCntrno("H1");
cntrProertyTwoRowTwochant1.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant1);
/*
2 排 4呗 1 右边========
**/
CntrProerty cntrProertyTwoRowTwochant2 = new CntrProerty();
//2排一层2列H1
cntrProertyTwoRowTwochant2.setRow(2);
cntrProertyTwoRowTwochant2.setFloor(3);
cntrProertyTwoRowTwochant2.setChant(4);
cntrProertyTwoRowTwochant2.setCntrno("KK1");
cntrProertyTwoRowTwochant2.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant2);
arrlist.add(cntrProertyTwoRowTwochant);
arrlist.add(cntrProertyTwoRowTwoFloorTwochant);
CntrProerty cntrProertyTwoRowTwochant4 = new CntrProerty();
//1排一层4H1
cntrProertyTwoRowTwochant4.setRow(1);
cntrProertyTwoRowTwochant4.setFloor(3);
cntrProertyTwoRowTwochant4.setChant(5);
cntrProertyTwoRowTwochant4.setCntrno("L");
cntrProertyTwoRowTwochant4.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant4);
/*
1 排 5呗 1 右边========
* */
CntrProerty cntrProertyTwoRowTwochant3 = new CntrProerty();
//2排一层4H1
cntrProertyTwoRowTwochant3.setRow(1);
cntrProertyTwoRowTwochant3.setFloor(3);
cntrProertyTwoRowTwochant3.setChant(4);
cntrProertyTwoRowTwochant3.setCntrno("K");
cntrProertyTwoRowTwochant3.setDirect(1);//右边
arrlist.add(cntrProertyTwoRowTwochant3);
return arrlist;
}
}

View File

@@ -0,0 +1,337 @@
package com.ag.algroithm.instance;
import java.util.Arrays;
/* Copyright (c) 2012 Kevin L. Stern
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* An implementation of the Hungarian algorithm for solving the assignment
* problem. An instance of the assignment problem consists of a number of
* workers along with a number of jobs and a cost matrix which gives the cost of
* assigning the i'th worker to the j'th job at position (i, j). The goal is to
* find an assignment of workers to jobs so that no job is assigned more than
* one worker and so that no worker is assigned to more than one job in such a
* manner so as to minimize the total cost of completing the jobs.
* <p>
*
* An assignment for a cost matrix that has more workers than jobs will
* necessarily include unassigned workers, indicated by an assignment value of
* -1; in no other circumstance will there be unassigned workers. Similarly, an
* assignment for a cost matrix that has more jobs than workers will necessarily
* include unassigned jobs; in no other circumstance will there be unassigned
* jobs. For completeness, an assignment for a square cost matrix will give
* exactly one unique worker to each job.
* <p>
*
* This version of the Hungarian algorithm runs in time O(n^3), where n is the
* maximum among the number of workers and the number of jobs.
*
* @author Kevin L. Stern
*/
public class HungarianAlgorithm {
private final double[][] costMatrix;
private final int rows, cols, dim;
private final double[] labelByWorker, labelByJob;
private final int[] minSlackWorkerByJob;
private final double[] minSlackValueByJob;
private final int[] matchJobByWorker, matchWorkerByJob;
private final int[] parentWorkerByCommittedJob;
private final boolean[] committedWorkers;
/**
* Construct an instance of the algorithm.
*
* @param costMatrix
* the cost matrix, where matrix[i][j] holds the cost of assigning
* worker i to job j, for all i, j. The cost matrix must not be
* irregular in the sense that all rows must be the same length; in
* addition, all entries must be non-infinite numbers.
*/
public HungarianAlgorithm(double[][] costMatrix) {
this.dim = Math.max(costMatrix.length, costMatrix[0].length);
this.rows = costMatrix.length;
this.cols = costMatrix[0].length;
this.costMatrix = new double[this.dim][this.dim];
for (int w = 0; w < this.dim; w++) {
if (w < costMatrix.length) {
if (costMatrix[w].length != this.cols) {
throw new IllegalArgumentException("Irregular cost matrix");
}
for (int j = 0; j < this.cols; j++) {
if (Double.isInfinite(costMatrix[w][j])) {
throw new IllegalArgumentException("Infinite cost");
}
if (Double.isNaN(costMatrix[w][j])) {
throw new IllegalArgumentException("NaN cost");
}
}
this.costMatrix[w] = Arrays.copyOf(costMatrix[w], this.dim);
} else {
this.costMatrix[w] = new double[this.dim];
}
}
labelByWorker = new double[this.dim];
labelByJob = new double[this.dim];
minSlackWorkerByJob = new int[this.dim];
minSlackValueByJob = new double[this.dim];
committedWorkers = new boolean[this.dim];
parentWorkerByCommittedJob = new int[this.dim];
matchJobByWorker = new int[this.dim];
Arrays.fill(matchJobByWorker, -1);
matchWorkerByJob = new int[this.dim];
Arrays.fill(matchWorkerByJob, -1);
}
/**
* Compute an initial feasible solution by assigning zero labels to the
* workers and by assigning to each job a label equal to the minimum cost
* among its incident edges.
*/
protected void computeInitialFeasibleSolution() {
for (int j = 0; j < dim; j++) {
labelByJob[j] = Double.POSITIVE_INFINITY;
}
for (int w = 0; w < dim; w++) {
for (int j = 0; j < dim; j++) {
if (costMatrix[w][j] < labelByJob[j]) {
labelByJob[j] = costMatrix[w][j];
}
}
}
}
/**
* Execute the algorithm.
*
* @return the minimum cost matching of workers to jobs based upon the
* provided cost matrix. A matching value of -1 indicates that the
* corresponding worker is unassigned.
*/
public int[] execute() {
/*
* Heuristics to improve performance: Reduce rows and columns by their
* smallest element, compute an initial non-zero dual feasible solution and
* create a greedy matching from workers to jobs of the cost matrix.
*/
reduce();
computeInitialFeasibleSolution();
greedyMatch();
int w = fetchUnmatchedWorker();
while (w < dim) {
initializePhase(w);
executePhase();
w = fetchUnmatchedWorker();
}
int[] result = Arrays.copyOf(matchJobByWorker, rows);
for (w = 0; w < result.length; w++) {
if (result[w] >= cols) {
result[w] = -1;
}
}
return result;
}
/**
* Execute a single phase of the algorithm. A phase of the Hungarian algorithm
* consists of building a set of committed workers and a set of committed jobs
* from a root unmatched worker by following alternating unmatched/matched
* zero-slack edges. If an unmatched job is encountered, then an augmenting
* path has been found and the matching is grown. If the connected zero-slack
* edges have been exhausted, the labels of committed workers are increased by
* the minimum slack among committed workers and non-committed jobs to create
* more zero-slack edges (the labels of committed jobs are simultaneously
* decreased by the same amount in order to maintain a feasible labeling).
* <p>
*
* The runtime of a single phase of the algorithm is O(n^2), where n is the
* dimension of the internal square cost matrix, since each edge is visited at
* most once and since increasing the labeling is accomplished in time O(n) by
* maintaining the minimum slack values among non-committed jobs. When a phase
* completes, the matching will have increased in size.
*/
protected void executePhase() {
while (true) {
int minSlackWorker = -1, minSlackJob = -1;
double minSlackValue = Double.POSITIVE_INFINITY;
for (int j = 0; j < dim; j++) {
if (parentWorkerByCommittedJob[j] == -1) {
if (minSlackValueByJob[j] < minSlackValue) {
minSlackValue = minSlackValueByJob[j];
minSlackWorker = minSlackWorkerByJob[j];
minSlackJob = j;
}
}
}
if (minSlackValue > 0) {
updateLabeling(minSlackValue);
}
parentWorkerByCommittedJob[minSlackJob] = minSlackWorker;
if (matchWorkerByJob[minSlackJob] == -1) {
/*
* An augmenting path has been found.
*/
int committedJob = minSlackJob;
int parentWorker = parentWorkerByCommittedJob[committedJob];
while (true) {
int temp = matchJobByWorker[parentWorker];
match(parentWorker, committedJob);
committedJob = temp;
if (committedJob == -1) {
break;
}
parentWorker = parentWorkerByCommittedJob[committedJob];
}
return;
} else {
/*
* Update slack values since we increased the size of the committed
* workers set.
*/
int worker = matchWorkerByJob[minSlackJob];
committedWorkers[worker] = true;
for (int j = 0; j < dim; j++) {
if (parentWorkerByCommittedJob[j] == -1) {
double slack = costMatrix[worker][j] - labelByWorker[worker]
- labelByJob[j];
if (minSlackValueByJob[j] > slack) {
minSlackValueByJob[j] = slack;
minSlackWorkerByJob[j] = worker;
}
}
}
}
}
}
/**
*
* @return the first unmatched worker or {@link #dim} if none.
*/
protected int fetchUnmatchedWorker() {
int w;
for (w = 0; w < dim; w++) {
if (matchJobByWorker[w] == -1) {
break;
}
}
return w;
}
/**
* Find a valid matching by greedily selecting among zero-cost matchings. This
* is a heuristic to jump-start the augmentation algorithm.
*/
protected void greedyMatch() {
for (int w = 0; w < dim; w++) {
for (int j = 0; j < dim; j++) {
if (matchJobByWorker[w] == -1 && matchWorkerByJob[j] == -1
&& costMatrix[w][j] - labelByWorker[w] - labelByJob[j] == 0) {
match(w, j);
}
}
}
}
/**
* Initialize the next phase of the algorithm by clearing the committed
* workers and jobs sets and by initializing the slack arrays to the values
* corresponding to the specified root worker.
*
* @param w
* the worker at which to root the next phase.
*/
protected void initializePhase(int w) {
Arrays.fill(committedWorkers, false);
Arrays.fill(parentWorkerByCommittedJob, -1);
committedWorkers[w] = true;
for (int j = 0; j < dim; j++) {
minSlackValueByJob[j] = costMatrix[w][j] - labelByWorker[w]
- labelByJob[j];
minSlackWorkerByJob[j] = w;
}
}
/**
* Helper method to record a matching between worker w and job j.
*/
protected void match(int w, int j) {
matchJobByWorker[w] = j;
matchWorkerByJob[j] = w;
}
/**
* Reduce the cost matrix by subtracting the smallest element of each row from
* all elements of the row as well as the smallest element of each column from
* all elements of the column. Note that an optimal assignment for a reduced
* cost matrix is optimal for the original cost matrix.
*/
protected void reduce() {
for (int w = 0; w < dim; w++) {
double min = Double.POSITIVE_INFINITY;
for (int j = 0; j < dim; j++) {
if (costMatrix[w][j] < min) {
min = costMatrix[w][j];
}
}
for (int j = 0; j < dim; j++) {
costMatrix[w][j] -= min;
}
}
double[] min = new double[dim];
for (int j = 0; j < dim; j++) {
min[j] = Double.POSITIVE_INFINITY;
}
for (int w = 0; w < dim; w++) {
for (int j = 0; j < dim; j++) {
if (costMatrix[w][j] < min[j]) {
min[j] = costMatrix[w][j];
}
}
}
for (int w = 0; w < dim; w++) {
for (int j = 0; j < dim; j++) {
costMatrix[w][j] -= min[j];
}
}
}
/**
* Update labels with the specified slack by adding the slack value for
* committed workers and by subtracting the slack value for committed jobs. In
* addition, update the minimum slack values appropriately.
*/
protected void updateLabeling(double slack) {
for (int w = 0; w < dim; w++) {
if (committedWorkers[w]) {
labelByWorker[w] += slack;
}
}
for (int j = 0; j < dim; j++) {
if (parentWorkerByCommittedJob[j] != -1) {
labelByJob[j] -= slack;
} else {
minSlackValueByJob[j] -= slack;
}
}
}
}

View File

@@ -0,0 +1,34 @@
package com.ag.algroithm.instance;
import java.util.HashSet;
import java.util.Set;
public class Hungtest {
public static void main(String args[]){
double[][] matrix = new double[][] {
new double[] { 6.0, 0.0, 7.0, 5.0 },
new double[] { 2.0, 6.0, 2.0, 6.0 },
new double[] { 2.0, 7.0, 2.0, 1.0 },
new double[] { 9.0, 4.0, 7.0, 1.0 }
};
HungarianAlgorithm b = new HungarianAlgorithm(matrix);
int[] match = b.execute();
System.out.println(computeCost(matrix,match));
}
private static double computeCost(double[][] matrix, int[] match) {
double result = 0;
Set<Integer> visited = new HashSet<Integer>();
for (int i = 0; i < matrix.length; i++) {
if (match[i] == -1) {
continue;
}
System.out.println("matrix["+i+"]["+match[i]+"]"+"==="+matrix[i][match[i]]);
result += matrix[i][match[i]];
}
return result;
}
}

View File

@@ -0,0 +1,378 @@
package com.ag.base;
//import com.ag.util.Page;
import com.ag.util.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public abstract class BaseDAO<T> implements IBaseRepository<T> {
@Override
public abstract JdbcTemplate getJdbcTemplate();
protected abstract SqlUtil<T> getSqlUtil();
protected Logger logger = LoggerFactory.getLogger(getClass());
@Override
public int update(String sql, Object... params)
throws DataAccessException {
logger.info(StrUtil.join("sql==\n", sql));
return this.getJdbcTemplate().update(sql, params);
}
@Override
public T get(String sql, Class<T> returnType, Object... params)
throws DataAccessException {
RowMapper<T> rowMapper = new BeanPropertyRowMapper<>(returnType);
logger.info( sql);
List<T> l = this.getJdbcTemplate().query(sql, params, rowMapper);
if (l.isEmpty()) {
return null;
} else {
return l.get(0);
}
// return this.jdbcTemplate.queryForObject(sql, rowMapper, params);
}
@Override
public List<T> list(String sql, Class<T> returnType, Object... params)
throws DataAccessException {
RowMapper<T> rowMapper = new BeanPropertyRowMapper<>(returnType);
logger.info( sql);
return this.getJdbcTemplate().query(sql, rowMapper, params);
}
private List<T> list(String sql, Class<T> returnType)
throws DataAccessException {
RowMapper<T> rowMapper = new BeanPropertyRowMapper<>(returnType);
logger.info( sql);
return this.getJdbcTemplate().query(sql, rowMapper);
}
@Override
public List<T> listSingleColumn(String sql, Class<T> returnType,
Object... params) throws DataAccessException {
RowMapper<T> rowMapper = new SingleColumnRowMapper<>(returnType);
return this.getJdbcTemplate().query(sql, rowMapper, params);
}
// protected int count(String sql, List<Object> params)
// throws DataAccessException {
// return this.jdbcTemplate.queryForObject(sql, params.toArray(),
// Integer.class);
// }
@Override
public int count(String sql, Object... params)
throws DataAccessException {
return this.getJdbcTemplate().queryForObject(sql, params, Integer.class);
}
/*public List<T> queryByPage(String sql, Class<T> returnType, Page page) {
String count_sql = StringUtils.join("select count(0) from (",sql,") as t");
page.setCount(this.count(count_sql));
if(page.getCount() == 0){
return null;
}
sql = StringUtils.join(sql,IBaseRepository.limit_sql);
return this.list(sql, returnType, page.getOffset(),
page.getRows());
}*/
/*public List<T> queryByPage(String sql, Class<T> returnType, Page page, Object... params) {
if(params == null){
queryByPage(sql, returnType, page);
}
//记录数
String count_sql = StringUtils.join("select count(0) from (",sql,") as t");
page.setCount(this.count(count_sql, params));
if(page.getCount() == 0){
return null;
}
//对象列表
Object[] paramsAddPage = paramAddPage(page, params);
sql = StringUtils.join(sql,IBaseRepository.limit_sql);
return this.list(sql, returnType, paramsAddPage);
}*/
/*private Object[] paramAddPage(Page page, Object... params){
List<Object> lst = new ArrayList<Object>();
for(Object obj : params){
lst.add(obj);
}
lst.add(page.getOffset());
lst.add(page.getRows());
return lst.toArray();
}*/
/*public static void main(String[] args) {
String sql = "select * from t_default_cc where id=? and name=?";
IBaseRepository<DefaultCc> base = new BaseRepositoryImpl<DefaultCc>();
base.queryByPage(sql, DefaultCc.class, new Page(), 37, "ddskm");
}*/
@Override
public int save(T t) {
String sql = getSqlUtil().getSaveSql(t);
return update(sql);
}
@Override
public int update(T t, Object... param) {
String sql = getSqlUtil().getUpdateSql(t, param);
return update(sql);
}
@Override
public int update(T t, String[] needUpdCol, Object... param) {
String sql = getSqlUtil().getUpdateSql(t, needUpdCol, param);
return update(sql);
}
@Override
public int deleteStatus(T t, String pkColName, String deleteColName) {
String sql = getSqlUtil().getDeleteSql(t, pkColName, deleteColName);
return update(sql);
}
// public int delete(T t, String pkColName) {
// String sql = getSqlUtil().deleteSql(t, pkColName);
// return this.getJdbcTemplate().update(sql);
// }
@Override
public int delete(T t, Object... colNames){
String sql = getSqlUtil().deleteEqSql(t, colNames);
return update(sql);
}
@Override
public T findById(T t, Class<T> returnType, String pkColName) {
String sql = getSqlUtil().getFindSql(t, pkColName);
return get(sql, returnType);
}
//全表查询
@Override
public List<T> findAll(Class<T> returnType) {
String sql = getSqlUtil().getFindAllSql(returnType);
return list(sql, returnType);
}
/**
* 指定where条件查询示例
* @Autowired
private DefaultBussniessImpl bizDao;//spring注入
*************************************************
* BaseCategory bc = new BaseCategory();
* bc.setTenancyId("b00");
* List<BaseCategory> bcs = bizDao.findByEqCriteria(bc, BaseCategory.class, "tenancy_Id", "byagent");
*
* 执行sql查询 select * from base_category where byagent=null and tenancy_Id='b00'
* @param entity 目标sql的对象映射
* @param returnType 返回类型
* @param colName 查询列(数组)
* @return 查询list
*/
@Override
@Deprecated
public List<T> findByEqCriteria(T entity, Class<T> returnType, Object... colName) {
String sql = findByEqSql(entity, colName);
return list(sql, returnType);
}
@Override
@Deprecated
public String findByEqSql(T entity, Object... colName) {
return getSqlUtil().getEqCriteriaSql(entity, colName);
}
@Override
public List<T> findByEntity(T entity, Class<T> returnType, boolean isAllTable) {
String sql = getSelectByEntity(entity, isAllTable);
return list(sql, returnType);
}
/**
* 动态where条件查询示例
* @Autowired
private DefaultBussniessImpl bizDao;//spring注入
*************************************************
* BaseCategory bc = new BaseCategory();
* bc.setId("a");
* bc.setIsAll((short)55);
* List<BaseCategory> bcs = bizDao.findByEntity(bc, BaseCategory.class);
*
* 执行sql查询 select * from base_category where id='a' and is_all=55
* @param entity 目标sql的对象映射
* @param returnType 返回类型
* @return 查询list
*/
@Override
public List<T> findByEntity(T entity, Class<T> returnType) {
String sql = getSelectByEntity(entity, false);
return list(sql, returnType);
}
@Override
public String getSelectByEntity(T entity, boolean isAllTable) {
return getSqlUtil().getSelectByEntity(entity, isAllTable);
}
@Override
public int findByCount(T entity, Object... colName){
String sql = "select count(0) from (" + findByEqSql(entity, colName) + ") tab";
return count(sql);
}
private int[] batchUpdate(String... sql){
/**/
String mylog = "##batchSql start \n";
//sql打印最多10条
int logMax = sql.length > 10 ? 10 : sql.length;
for (int i = 0; i < logMax; i++){
mylog = StrUtil.join(mylog, sql[i]);
}
mylog = StrUtil.join(mylog, "\n total update records is "+sql.length);
logger.info(mylog);
int pageSize = 1000;
if (sql.length <= pageSize){
this.getJdbcTemplate().batchUpdate(sql);
logger.info("update complete "+sql.length);
} else {
int currPage = 0;
while (true){
int begin = currPage * pageSize;
int end = (currPage + 1) * pageSize;
if (end > sql.length) {
end = sql.length;
}
this.getJdbcTemplate().batchUpdate(getPageSql(sql, begin, end));
logger.info("Update complete from {} to {}", begin+1, end);
if (end >= sql.length){
break;
}
currPage ++;
}
}
logger.info("batchSql end##");
return null;
}
private String[] getPageSql(String[] sql, int begin, int end){
List<String> sqls = new ArrayList<>();
for (int i = begin; i < end; i++){
sqls.add(sql[i]);
}
return sqls.toArray(new String[0]);
}
@Override
public int[] saveAll(List<T> lst){
if(CollectionUtils.isEmpty(lst)){
return null;
}
String[] sqls = new String[lst.size()];
for(int i=0; i<sqls.length; i++){
sqls[i] = getSqlUtil().getSaveSql(lst.get(i));
}
return this.batchUpdate(sqls);
}
@Override
public int[] updateAll(List<T> lst, Object... colName){
return updateAll(lst, null, colName);
}
@Override
public int[] updateAll(List<T> lst, String[] needUpdCol, Object... colName){
if(CollectionUtils.isEmpty(lst)){
return null;
}
String[] sqls = new String[lst.size()];
for(int i=0; i<sqls.length; i++){
sqls[i] = getSqlUtil().getUpdateSql(lst.get(i), needUpdCol, colName);
}
return this.batchUpdate(sqls);
}
@Override
public int[] deleteAll(List<T> lst, Object... colNames){
if(CollectionUtils.isEmpty(lst)){
return null;
}
String[] sqls = new String[lst.size()];
for(int i=0; i<sqls.length; i++){
sqls[i] = getSqlUtil().deleteEqSql(lst.get(i), colNames);
}
return this.batchUpdate(sqls);
}
@Override
public List<Map<String, Object>> queryForList(String sql, Object... args){
return getJdbcTemplate().queryForList(sql, args);
}
@Override
public List<T> findInIds(Class<T> tClz, String ids, String idColName){
List<T> result = new ArrayList<>();
if (StrUtil.isEmpty(ids)){
return result;
}
int pageSize = 1000;
String[] array = ids.split(",");
if (array.length <= pageSize){
String sql = getSqlUtil().findInIds(tClz, ids, idColName);
return list(sql, tClz);
}
List<String> pageIds = new ArrayList<>();
String sb = "";
for (int i=0; i<array.length; i++){
sb = StrUtil.join(sb, array[i], ",");
if ((i+1) % pageSize == 0){
pageIds.add(sb.substring(0, sb.length()-1));
sb = "";
} else if (i == array.length-1){
pageIds.add(sb.substring(0, sb.length()-1));
}
}
for (String pageId : pageIds){
String sql = getSqlUtil().findInIds(tClz, pageId, idColName);
result.addAll(list(sql, tClz));
}
return result;
}
/*public static void main(String[] args) {
String ids = "a,b,c,d,e,f,g,h";
int pageSize = 8;
String[] array = ids.split(",");
String sb = "";
List<String> pageIds = new ArrayList<>();
for (int i=0; i<array.length; i++){
sb = StrUtil.join(sb, array[i], ",");
if ((i+1) % pageSize == 0){
pageIds.add(sb.substring(0, sb.length()-1));
sb = "";
} else if (i == array.length-1){
pageIds.add(sb.substring(0, sb.length()-1));
}
}
for (String id : pageIds){
System.out.println(id);
}
}*/
}

View File

@@ -0,0 +1,25 @@
package com.ag.base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class BaseRepositoryImpl<T> extends BaseDAO<T> {
@Autowired
private JdbcTemplate jdbcTemplatebusiness;//数据源
private SqlUtil<T> sqlUtil = new SqlUtil<>();//表名映射
@Override
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplatebusiness;
}
@Override
protected SqlUtil<T> getSqlUtil() {
return sqlUtil;
}
}

View File

@@ -0,0 +1,147 @@
package com.ag.base;
import cn.hutool.core.collection.CollectionUtil;
import com.ag.util.UUIDUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.*;
/**
* Created by Administrator on 2017/4/12 0012.
*/
public abstract class BaseService {
protected void callExcetion(String msg){
throw new RuntimeException(msg);
}
protected Map<String,String> getRequestMap(HttpServletRequest request){
Map<String,String> map = new HashMap<>();
Enumeration em = request.getParameterNames();
while (em.hasMoreElements()) {
String name = (String) em.nextElement();
String value = request.getParameter(name);
map.put(name, value);
}
return map;
}
protected String[] getRequestParam(HttpServletRequest request){
List<String> lst = new ArrayList<>();
Enumeration em = request.getParameterNames();
while (em.hasMoreElements()) {
String name = (String) em.nextElement();
if (name.contains("%") || name.contains("#") || name.contains("$")){
continue;
}
lst.add(name);
}
return lst.toArray(new String[0]);
}
protected String[] getJSONParam(String update){
List<String> lst = new ArrayList<>();
List<JSONObject> array = JSON.parseArray(update, JSONObject.class);
if (CollectionUtil.isEmpty(array)){
return null;
}
Set<String> set = array.get(0).keySet();
for (String name : set) {
if (name.contains("%") || name.contains("#") || name.contains("$")){
continue;
}
lst.add(name);
}
return lst.toArray(new String[0]);
}
protected String[] getRequestEnum(HttpServletRequest request){
List<String> lst = new ArrayList<>();
Enumeration em = request.getParameterNames();
while (em.hasMoreElements()) {
lst.add(em.nextElement().toString());
}
return (String[])lst.toArray();
}
protected Map<String,String> getScriptMap (jdk.nashorn.api.scripting.ScriptObjectMirror so){
Map<String,String> map = new HashMap<>();
for(Map.Entry<String, Object> en: so.entrySet()){
//System.out.println(en.getKey()+" : "+en.getValue());
String name = en.getKey();
String value = String.valueOf(en.getValue());
map.put(name, value);
}
return map;
}
protected void printMap(Map<String,String> map){
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
}
protected String getSysUserName(HttpServletRequest request){
Object userName = request.getSession().getAttribute("sys.username");
return userName == null ? "" : userName.toString();
}
protected String getSysUserName(org.json.JSONObject json){
if (json.has("sys.username")) {
return json.getString("sys.username");
}
return null;
}
protected String getTenancyId(HttpServletRequest request){
Object tenancyId = request.getSession().getAttribute("sys.tenancyId");
return tenancyId == null ? null : tenancyId.toString();
}
protected String getTenancyId(org.json.JSONObject json){
if (json.has("sys.username")) {
return json.getString("sys.tenancyId");
}
return null;
}
protected Date getNow(){
return new Date();
}
protected void setSaveUser(HttpServletRequest request, ISerializable ent){
ent.setCreatedBy(getSysUserName(request));
ent.setUpdatedBy(getSysUserName(request));
ent.setCreatedOn(getNow());
ent.setUpdatedOn(getNow());
ent.setTenancyId(getTenancyId(request));
ent.setId(UUIDUtil.getUUID());
}
protected void setSaveUser(org.json.JSONObject json, ISerializable ent){
ent.setCreatedBy(getSysUserName(json));
ent.setUpdatedBy(getSysUserName(json));
ent.setCreatedOn(getNow());
ent.setUpdatedOn(getNow());
ent.setTenancyId(getTenancyId(json));
ent.setId(UUIDUtil.getUUID());
}
protected void setUpdateUser(HttpServletRequest request, ISerializable ent){
ent.setUpdatedBy(getSysUserName(request));
ent.setUpdatedOn(getNow());
}
protected void setUpdateUser(org.json.JSONObject json, ISerializable ent){
ent.setUpdatedBy(getSysUserName(json));
ent.setUpdatedOn(getNow());
}
protected String getUserIpAddress(org.json.JSONObject json){
return json.has("sys.userIpAddress")?json.getString("sys.userIpAddress"):null;
}
public static void main(String[] args) throws IOException {
}
}

View File

@@ -0,0 +1,25 @@
package com.ag.base;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
/**
* Created by yangxh on 2019/7/30.
*/
@Repository
public class DefaultBussniessImpl<T> extends BaseDAO<T> {
@Autowired
private JdbcTemplate jdbcTemplatebusiness;//数据源
private SqlUtil<T> sqlUtil = new OriginalSqlUtil<>();//表名映射
@Override
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplatebusiness;
}
@Override
protected SqlUtil<T> getSqlUtil() {
return sqlUtil;
}
}

View File

@@ -0,0 +1,122 @@
package com.ag.base;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.List;
import java.util.Map;
/**
* 使用此接口需遵循一定的规则规则内容可在SqlUtil中对转表名和转列名做适当的调整。<br/>
* 该版本示例对象名IntegralUser-》表名c_integral_user<br/>
* 字段名integralTypeId-》列名integral_type_id<br/>
* ..另外java中值类型int,long,double,flout!=null数据库中相应int,long,decimal字段不能判断为空varchar类型不受此影响<br/>
* ..Java中boolean类型默认值为noinstanceof判断结果为String请设计为int便于扩展<br/>
* 更多内容敬请期待。。。
* @param <T>
*/
public interface IBaseRepository<T> {
String limit_sql = " limit ?,?";
JdbcTemplate getJdbcTemplate();
/**
* 保存
* @param entity 实体类
*/
int save(T entity);
/**
* 根据主键修改单个对象
* @param entity 主键字段不能空
* @param colName 主键列名例如type_id
*/
int update(T entity, Object... colName);
int update(T entity, String[] needUpdCol, Object... colName);
/**
* 根据主键删除单个对象(update删除字段非delete语句)
* @param entity 主键字段和删除字段的值不能空
* @param pkColName 主键列名例如type_id
* @param deleteColName 需删除的列名例如deleted并且属性字段deleted值不能为空
*/
int deleteStatus(T entity, String pkColName, String deleteColName);
/**
* delete脚本
* @param t
* @param colNames
* @return
*/
//int delete(T t, String pkColName);
int delete(T t, Object... colNames);
/**
* 根据主键查询单个对象
* @param entity 主键字段不能空
* @param returnType 返回值
* @param pkColName 主键列名例如type_id
*/
T findById(T entity, Class<T> returnType, String pkColName);
/**
* 遍历单对象集合
*/
List<T> findAll(Class<T> claz);
int update(String sql, Object... params);
T get(String sql, Class<T> returnType, Object... params)
throws DataAccessException;
List<T> list(String sql, Class<T> returnType, Object... params);
int count(String sql, Object... params);
/**
* 分页查询对象需要自己拼好sql
List<T> queryByPage(String sql, Class<T> returnType, Page page);*/
/**
* 支持通配符的分页查询
List<T> queryByPage(String sql, Class<T> returnType, Page page, Object... params);*/
/**
* 查询单列
*/
public List<T> listSingleColumn(String sql, Class<T> returnType, Object... params)
throws DataAccessException;
/**
* 简单条件查询,自动过滤查询条件为空或空值的字段
*/
List<T> findByEqCriteria(T entity, Class<T> returnType, Object... colName);
int findByCount(T entity, Object... colName);
//T packPOJO(Map<String, String> map, Class<T> clz);
String findByEqSql(T entity, Object... colName);
int[] saveAll(List<T> lst);
int[] updateAll(List<T> lst, Object... colName);
int[] updateAll(List<T> lst, String[] needUpdCol, Object... colName);
//int[] deleteAll(List<T> lst, String pkColName);
int[] deleteAll(List<T> lst, Object... colNames);
List<Map<String, Object>> queryForList(String sql, Object... args);
List<T> findInIds(Class<T> tClz, String ids, String idColName);
List<T> findByEntity(T entity, Class<T> returnType, boolean isAllTable);
List<T> findByEntity(T entity, Class<T> returnType);
String getSelectByEntity(T entity, boolean isAllTable);
}

View File

@@ -0,0 +1,90 @@
package com.ag.base;
import com.wb.common.KvBean;
import java.util.List;
/**
* Description:rdedis接口服务
* Create Date: 2021/3/18
*/
public interface IRedisService {
/**
* 初始化所有缓存
*/
default void redisLoad(){}
/**
* 刷新key(读表并覆盖)
* @param dictName
*/
default void refreshByDictName(String dictName){}
/**
* 从Redis中获取字典全部返回值大数据量不推荐使用可以使用likeByKey方法
* @param dictName
* @return
*/
default List<KvBean> getAllByKey(String dictName){return null;}
default List<KvBean> getAllByKey(String dictName, String tenancyId){return null;}
default List<KvBean> likeByKey(String dictName, String key){return null;}
default List<KvBean> likeByKey(String dictName, String key, String tenancyId){return null;}
default List<KvBean> likeByKey(String dictName, String key, Integer begIndex, Integer length){return null;}
/**
* 分页+模糊查询不指定分页按20条数据返回只取分页key为null
* @param dictName 表名
* @param key 只取分页值为null
* @param tenancyId 租户
* @param begIndex 下标从0开始
* @param length 获取数量
* @return
*/
default List<KvBean> likeByKey(String dictName, String key, String tenancyId, Integer begIndex, Integer length) {return null;}
/**
* key 转 value
* @param dictName
* @param key
* @return
*/
default String getTargetName(String dictName, String key){return null;}
default String getTargetName(String dictName, String key, String tenancyId){return null;}
/**
* 多key的精确查找
* @param dictName
* @param keys
* @return
*/
default List<KvBean> findByMultKeys(String dictName, String keys) {return null;}
default List<KvBean> findByMultKeys(String dictName, String keys, String tenancyId) {return null;}
/**
* 自定义key存入 Redis中
*/
default void putCustomizeKey(String keyName, String list){}
/**
* 获取自定义key
*/
default String getCustomizeKey(String key){return null;}
default void delKey(String key){}
/**
* 获取多组key暂无实现
* @param collection
* @return
default Map<String, List<T>> findByKey(Collection<String> collection){return null;}
*/
}

View File

@@ -0,0 +1,24 @@
package com.ag.base;
import java.io.Serializable;
import java.util.Date;
/**
* Created by Administrator on 2017/4/12 0012.
*/
public interface ISerializable extends Serializable {
default void setCreatedBy(String createuser){}
default void setCreatedOn(Date createtime){}
default void setUpdatedBy(String updateuser){}
default void setUpdatedOn(Date updatetime){}
default void setTenancyId(String tenancyId){}
default void setDelFlag(Integer delFlag){}
default void setId(String id){}
}

View File

@@ -0,0 +1,15 @@
package com.ag.base;
//import com.ag.entity.WbCompany;
/**
* Created by Administrator on 2017/3/28 0028.
*/
public class OriginalSqlUtil<T> extends SqlUtil<T> {
protected String getTableName(T t){
String tableName = t.getClass().getSimpleName();
tableName = tableName.substring(0, 1).toLowerCase() + tableName.substring(1, tableName.length());
return toLower(tableName);
}
}

View File

@@ -0,0 +1,91 @@
package com.ag.base;
import cn.hutool.core.date.DateUtil;
import com.ag.util.TimeUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* Created by Administrator on 2017/4/12 0012.
*/
public class ParamUtil<T> extends SqlUtil<T> {
public T packPOJO(Map<String, String> map, Class<T> clz){
T t = getEntity(clz);
if(t == null){
return null;
}
Method[] ms=t.getClass().getMethods();
for(Method m: ms) {
String fieldName = getFieldName(m);
if(fieldName == null){
continue;
}
if(!StringUtils.isEmpty(map.get(fieldName))){
setMethodValue(t, m, map.get(fieldName));
continue;
}
String colName = toLower(fieldName).toUpperCase();
if(!StringUtils.isEmpty(map.get(colName))){
setMethodValue(t, m, map.get(colName));
}
}
return t;
}
private void setMethodValue(T t, Method m, String paramVal) {
String paramType = m.getParameterTypes()[0].toString();
try {
if(paramType.contains("String")){
m.invoke(t, paramVal);
} else if(paramType.contains("Integer")){
m.invoke(t, Integer.valueOf(paramVal));
} else if(paramType.contains("Double")){
m.invoke(t, Double.valueOf(paramVal));
} else if(paramType.contains("Short")){
m.invoke(t, Short.valueOf(paramVal));
} else if(paramType.contains("Long")){
m.invoke(t, Long.valueOf(paramVal));
} else if(paramType.contains("Date")){
/*if (paramVal.length()>19) {
paramVal = paramVal.substring(0, 19);
}*/
m.invoke(t, TimeUtil.getTimestamp(paramVal));
} else if(paramType.contains("BigDecimal")){
m.invoke(t, new BigDecimal(paramVal));
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void printMap(Map<String,String> map){
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("key= " + entry.getKey() + " and value= " + entry.getValue());
}
}
public static void main(String[] args) {
/*List<String> mlist = new ArrayList<>();
mlist.add("zhu");
mlist.add("wen");
mlist.add("tao");
// List转成数组
String[] array = mlist.toArray(new String[0]);
// 输出数组
for (int i = 0; i < array.length; i++) {
System.out.println("array--> " + array[i]);
}*/
Date date = DateUtil.parse("2021-06-01 00:00:00.000");
System.out.println(DateUtil.formatDateTime(date));
}
}

View File

@@ -0,0 +1,66 @@
package com.ag.base;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Created by Administrator on 2017/3/23 0023.
*/
@Component
public class Reflect implements ApplicationContextAware {
private static Reflect reflect = null;
private static ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
applicationContext = arg0;
}
private Reflect(){
}
public static Reflect newInstance(){
if(reflect == null){
reflect = new Reflect();
}
return reflect;
}
public Object getBeanById(String id){
return applicationContext.getBean(id);
}
/*private Object execute(final String clsPath, final String methodName, HttpServletRequest request, HttpServletResponse response) {
String methodN = methodName;
if(StringUtils.isEmpty(methodName)){
methodN = "execute";
}
//System.out.println("clsPath::"+clsPath);
try {
Class<?> clz = Class.forName(clsPath);
Object obj = clz.newInstance();
Method m = clz.getMethod(methodN, HttpServletRequest.class, HttpServletResponse.class);
return m.invoke(obj, request, response);
}catch (Exception ex){
ex.printStackTrace();
}
return null;
}*/
public Object execute(final String beanId) {
//System.out.println("clsPath::"+clsPath);
/*try {
Class<?> clz = Class.forName(clsPath);
Object obj = clz.newInstance();
return obj;
}catch (Exception ex){
ex.printStackTrace();
}
return null;*/
return applicationContext.getBean(beanId);
}
}

View File

@@ -0,0 +1,715 @@
package com.ag.base;
import com.ag.util.StrUtil;
import org.springframework.util.CollectionUtils;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* Created by Administrator on 2017/3/28 0028.
*/
public class SqlUtil<T> {
public String getSaveSql(T t) {
String tableName = getTableName(t);
StringBuilder colSql = new StringBuilder();
StringBuilder valueSql = new StringBuilder();
Method[] ms = t.getClass().getMethods();
for (Method m : ms) {
String colName = getColName(m);
//??????
if (colName != null) {
String colValue = getColValue(m, t);
//????
if (colValue != null) {
colSql.append("").append(colName).append("").append(",");
valueSql.append(colValue).append(",");
}
}
}
String saveSql = StrUtil.join("insert into ", tableName, "(", subLastStr(colSql.toString()), ") values (", subLastStr(valueSql.toString()), ")");
return saveSql;
}
/*public String getUpdateSql(T t, String paramId) {
String tableName = getTableName(t);
StringBuilder setSql = new StringBuilder();
String pkValue = "";//?????
Method[] ms = t.getClass().getMethods();
for (Method m : ms) {
String colName = getColName(m);
//??????
if (colName != null) {
String colValue = getColValue(m, t, "update");
//????????
if (colName.toLowerCase().equals(paramId.toLowerCase())) {
pkValue = colValue;
continue;
}
//????
if (colValue != null) {
setSql.append("").append(colName).append("").append("=").append(colValue).append(",");
}
}
}
String updateSql = StrUtil.join("update " , tableName , " set " , subLastStr(setSql.toString()) , " where " , paramId , "=" , pkValue);
return updateSql;
}*/
public String getUpdateSql(T t, Object... colNames) {
return getUpdateSql(t, null, colNames);
}
public String getUpdateSql(T t, String[] colArr, Object... colNames) {
String tableName = getTableName(t);
StringBuilder setSql = new StringBuilder();
String needSql = "";
Method[] ms = t.getClass().getMethods();
for (Method m : ms) {
boolean isSet = true;
String colName = getColName(m);
//列名不为空
if (colName != null) {
for (Object aColName : colNames) {
//列名为参数不能增加进set
if (colName.toLowerCase().equals(aColName.toString().toLowerCase())) {
isSet = false;
break;
}
}
}
if (isSet && colName != null) {
String colValue = getColValue(m, t);
if (colValue != null) {
setSql.append("").append(colName).append("").append("=").append(colValue).append(",");
} else {
if (colArr == null) {
continue;
}
for (String needCol : colArr) {
if (colName.toLowerCase().equals(needCol.toLowerCase())) {
needSql = StrUtil.join(needSql, colName, "=null,");
break;
}
}
}
}
}
setSql.append(needSql);
String whereSql = getWhereSql(t, colNames);
if (StrUtil.isEmpty(whereSql)) {
throw new RuntimeException("更新语句where条件不能为空");
}
String updateSql = StrUtil.join("update ", tableName, " set ", subLastStr(setSql.toString()), " where ", whereSql.substring(4, whereSql.length()));
return updateSql;
}
public String getDeleteSql(T t, String pkColName, String deleteColName) {
String tableName = getTableName(t);
String setSql = "";
String whereSql = "";
Method[] ms = t.getClass().getMethods();
for (Method m : ms) {
//????????
if (deleteColName.equals(getColName(m))) {
setSql = StrUtil.join("", deleteColName, "=", getColValue(m, t));
}
//????where??
if (pkColName.equals(getColName(m))) {
whereSql = StrUtil.join("", pkColName, "=", getColValue(m, t));
}
}
String deleteSql = StrUtil.join("update ", tableName, " set ", setSql, " where ", whereSql);
return deleteSql;
}
public String deleteSql(T t, String pkColName) {
StringBuilder sql = new StringBuilder("delete from ");
sql.append(getTableName(t)).append(" where ").append(pkColName).append(" = ");
String pkValue = "";//?????
Method[] ms = t.getClass().getMethods();
for (Method m : ms) {
String colName = getColName(m);
// ??????
if (colName != null) {
String colValue = getColValue(m, t);
// ????????
if (colName.toLowerCase().equals(pkColName.toLowerCase())) {
pkValue = colValue;
break;
}
}
}
sql.append(pkValue);
return sql.toString();
}
public String deleteEqSql(T t, Object... colName) {
String tableName = getTableName(t);
String deleteSql = "delete from " + tableName;
Method[] ms = t.getClass().getMethods();
String whereSql = "";
for (Method m : ms) {
for (Object aColName : colName) {
if (aColName.toString().equalsIgnoreCase(getColName(m))) {
String val = getColValue(m, t);
if (val != null) {
whereSql = StrUtil.join(whereSql,
" and ", aColName, "=", val);
} else {
throw new RuntimeException("删除方法中,列名" + aColName + "值不能为空!");
}
break;
}
}
}
if (!"".equals(whereSql)) {
deleteSql += " where " + whereSql.substring(4, whereSql.length());
} else {
throw new RuntimeException("不能做整表删除!");
}
//System.out.println("deleteSql:"+deleteSql);
return deleteSql;
}
private String getWhereSql(T t, Object... colName) {
Method[] ms = t.getClass().getMethods();
String whereSql = "";
for (Method m : ms) {
for (Object aColName : colName) {
if (aColName.toString().equalsIgnoreCase(getColName(m))) {
String val = getColValue(m, t);
if (val != null) {
whereSql = StrUtil.join(whereSql,
" and ", aColName, "=", val);
}
break;
}
}
}
return whereSql;
}
private String getNeedWhereSql(T t, Object... colName) {
Method[] ms = t.getClass().getMethods();
String whereSql = "";
for (Method m : ms) {
for (Object aColName : colName) {
if (aColName.toString().equalsIgnoreCase(getColName(m))) {
String val = getColValue(m, t);
if (val == null){
val = "null";
}
whereSql = StrUtil.join(whereSql, " and ", aColName, "=", val);
break;
}
}
}
return whereSql;
}
public String getFindSql(T t, String pkColName) {
String tableName = getTableName(t);
Method[] ms = t.getClass().getMethods();
String whereSql = "";
for (Method m : ms) {
String colName = getColName(m);
//列名不为空
if (colName != null && pkColName.equalsIgnoreCase(colName)) {
whereSql = StrUtil.join("", pkColName, "=", getColValue(m, t));
}
}
String findSql = StrUtil.join("select * from ", tableName, " where ", whereSql);
return findSql;
}
public String getFindAllSql(Class<T> claz) {
String tableName = "";
try {
tableName = getTableName(claz.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
String findAllSql = "select * from " + tableName;
return findAllSql;
}
public String getEqCriteriaSql(T t, Object... colName) {
String tableName = getTableName(t);
String whereSql = getNeedWhereSql(t, colName);
String findSql = "select * from " + tableName;
if (!"".equals(whereSql)) {
findSql += " where " + whereSql.substring(4, whereSql.length());
}else {
findSql += " where 1=2 ";
//throw new RuntimeException("查询条件不能为空,请检查查询对象参数!");
}
//System.out.println("findSql:"+findSql);
return findSql;
}
public String getSelectByEntity(T t, boolean isAllTable){
String tableName = getTableName(t);
Method[] ms = t.getClass().getMethods();
String whereSql = "", val = null;
for (Method m : ms) {
String colName = getColName(m);
if (colName != null){
val = getColValue(m, t);
}else {
val = null;
}
if (val != null) {
whereSql = StrUtil.join(whereSql," and ", colName, "=", val);
}
}
String findSql = "select * from " + tableName;
if (!"".equals(whereSql)) {
findSql += " where " + whereSql.substring(4, whereSql.length());
} else if (!isAllTable){
findSql += " where 1=2 ";
//throw new RuntimeException("查询条件不能为空,请检查查询对象参数!");
}
return findSql;
}
/**
* ??????????
* ??????
*/
protected String getTableName(T t) {
String tableName = t.getClass().getSimpleName();
//????????
tableName = StrUtil.join(tableName.substring(0, 1).toLowerCase(), tableName.substring(1, tableName.length()));
//??Entity
//tableName = tableName.substring(0, tableName.indexOf("Entity"));
//return "t_"+toLower(tableName)+"";
return "C_" + toLower(tableName);
}
/**
* ??????????
* ???????????get?????
*/
public String getColName(Method m) {
String name = m.getName();
//???getClass?get*??
if (!name.startsWith("get") || "getClass".equals(name)) {
return null;
} else {
//????get
String param = name.substring(3, name.length());
//?????
param = firstToLower(param);
//????????????_
return toLower(param);
}
}
protected String getFieldName(Method m) {
String name = m.getName();
//???getClass?get*??
if (!name.startsWith("set")) {
return null;
} else {
String param = name.substring(3, name.length());
return firstToLower(param);
}
}
/**
* ??value?????????
*/
public String getColValue(Method m, T t) {
Object value = null;
try {
//??????
value = m.invoke(t);
} catch (Exception e) {
e.printStackTrace();
}
if (value == null) {
return null;
}
if (value instanceof Number) {
return String.valueOf(value);
} else if (value instanceof Date) {
return StrUtil.join("to_date('", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value), "','yyyy-MM-dd HH24:mi:ss')");
} else if (value instanceof Boolean) {
return String.valueOf(value);
} else if (value instanceof String) {
//??update?????!=null?????????
//if ("update".equals(type)) {
if (((String) value).contains("'")) {
value = ((String) value).replace("'", "''");
}
return StrUtil.join("'", value, "'");
/*} else {
if (!StringUtils.isEmpty(value)) {
return StrUtil.join("'", value, "'");
}
}*/
} /*else {
return String.valueOf(value);
}*/
return null;
}
/**
* ?????
*/
protected String firstToLower(String param) {
return StrUtil.join(param.substring(0, 1).toLowerCase(), param.substring(1, param.length()));
}
protected String firstToUpper(String param) {
return StrUtil.join(param.substring(0, 1).toUpperCase(), param.substring(1, param.length()));
}
/**
* ???????_?????
*/
protected String toLower(String param) {
StringBuilder sb = new StringBuilder();
char[] col = param.toCharArray();
for (char ch : col) {
if (Character.isUpperCase(ch)) {
sb.append("_").append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString();
}
/**
* ??????
*/
private String subLastStr(String param) {
return param.substring(0, param.length() - 1);
}
/**
* ??????????
*/
private Object getFieldValueByName(Object o, String fieldName) {
try {
String firstLetter = fieldName.substring(0, 1).toUpperCase();
String getter = StrUtil.join("get", firstLetter, fieldName.substring(1));
Method method = o.getClass().getMethod(getter);
return method.invoke(o);
} catch (Exception e) {
return null;
}
}
/**
* ??????????id1,id2,id3??
*
* @param lst
* @param fieldName "userId"
* @return
*/
public String getAddInIds(List<T> lst, String fieldName) {
if (CollectionUtils.isEmpty(lst)){
return "''";
}
String ids = "";
for (T t : lst) {
Object obj = getFieldValueByName(t, fieldName);
if (obj instanceof String) {
ids = StrUtil.join(ids, "'", obj, "',");
} else {
ids = StrUtil.join(ids, obj, ",");
}
}
return subLastStr(ids);
}
public T getEntity(Class<T> tClz) {
try {
return tClz.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String findInIds(Class<T> tClz, String ids, String idColName){
if (StrUtil.isEmpty(ids)){
ids = "''";
}
if (StrUtil.isEmpty(idColName)){
idColName = "ID";
}
if (!ids.startsWith("'")){
ids = StrUtil.converIdsToSql(ids);
}
String sql = getFindAllSql(tClz);
return StrUtil.join(sql, " where ", idColName, " in (", ids, ")");
}
/*public T getEntity() {
Class clz = getClass();
Type sType = clz.getGenericSuperclass();
Type[] generics = ((ParameterizedType) sType).getActualTypeArguments();
Class<T> tClz = (Class<T>) generics[0];
try {
return tClz.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}*/
/*
public T packPOJO(Map<String, String> map, Class<T> clz){
T t = this.getEntity(clz);
if(t == null){
return t;
}
Method[] ms=t.getClass().getMethods();
for(Method m: ms) {
String fieldName = getFieldName(m);
if(fieldName == null){
continue;
}
if(!StringUtils.isEmpty(map.get(fieldName))){
setMethodValue(t, m, map.get(fieldName));
continue;
}
String colName = toLower(fieldName).toUpperCase();
if(!StringUtils.isEmpty(map.get(colName))){
setMethodValue(t, m, map.get(colName));
continue;
}
}
return t;
}
private void setMethodValue(T t, Method m, String paramVal) {
String paramType = m.getParameterTypes()[0].toString();
try {
if(paramType.indexOf("String") > -1){
m.invoke(t, paramVal);
}else if(paramType.indexOf("Integer") > -1){
m.invoke(t, Integer.valueOf(paramVal));
}else if(paramType.indexOf("Double") > -1){
m.invoke(t, Double.valueOf(paramVal));
}else if(paramType.indexOf("Date") > -1){
m.invoke(t, new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(paramVal));
}
} catch (Exception e) {
e.printStackTrace();
}
}*/
/*private void setFieldValue(T t, Field field, String paramVal) {
String fieldType = field.getType().toString();
String fieldName = field.getName();
if(fieldType.indexOf("String") > -1){
String setMethodName = "set"+firstToUpper(fieldName);
}else if(fieldType.indexOf("Integer") > -1){
}else if(fieldType.indexOf("Double") > -1){
}else if(fieldType.indexOf("Date") > -1){
}
}*/
public static void main(String[] args) {
//System.out.println(new SqlUtil().toLower("dci22!@第sndDdV21"));
/*List<BaseCategory> lst = new ArrayList<>();
for (int i=0 ; i<100; i++){*/
BaseCategory bc = new BaseCategory();
bc.setId("a");
//bc.setTenancyId("b00");
bc.setIsAll((short)55);
/*bc.setNotes("ddd");
bc.setEnabled(new BigDecimal(0));*/
//bc.setCreatedBy("admin's");
//bc.setCreatedOn(new Date());
/*lst.add(bc);
}*/
long on = System.currentTimeMillis();
//for (BaseCategory bc : lst){
// System.out.println(new SqlUtil<BaseCategory>().getSaveSql(bc));
// System.out.println(new SqlUtil<BaseCategory>().getUpdateSql(bc, "tenancy_Id"));
// System.out.println(new SqlUtil<BaseCategory>().getUpdateSql(bc, "tenancy_Id", "notes"));
// System.out.println(new SqlUtil<BaseCategory>().getUpdateSql(bc, new String[]{"updated_On", "is_All", "tenancy_Id"}, "created_by"));
//}
System.out.println(new SqlUtil<>().getEqCriteriaSql(bc, "tenancy_Id", "byagent"));
System.out.println(new SqlUtil<>().getSelectByEntity(bc, false ));
System.out.println(new SqlUtil<>().getEqCriteriaSql(new BaseCategory(), "tenancy_Id", "byagent"));
System.out.println(new SqlUtil<>().getSelectByEntity(new BaseCategory(), false ));
long end = System.currentTimeMillis();
System.out.println(end - on);
/*
SqlUtil<SettlementHead> wbUtil = new SqlUtil<SettlementHead>();
SettlementHead wb = new SettlementHead();
wb.setId(UUIDUtil.getUUID());
wb.setBillNo(null);
wb.setEnabled(1);
wb.setInvoiceType(6);
wb.setTicketDate(new Date());
String sql = wbUtil.getSaveSql(wb);
wb.setPaymentCustomerId("778");
System.out.println(sql);
System.out.println(wbUtil.getUpdateSql(wb, "ID", "BILL_NO"));
/*long lg1 = System.currentTimeMillis();
SqlUtil<WbCompany> wbUtil = new SqlUtil<WbCompany>();
Map<String, String> map = new HashMap<String, String>();
//request中的属性获取策略目前是属性名 > 字段名大写
map.put("companyId", "bea3f0f49ba3496ca5c846a6e9580a66");
//map.put("companyId", UUIDUtil.getUUID());
map.put("companyName", "dixms");
map.put("addR", "地址");
map.put("createtime", "2014-07-08 12:30:00");
map.put("COMPANY_ID", "779");
//map.put("COUNTRY", "98");
map.put("IS_NUM", "56");
WbCompany wb = wbUtil.packPOJO(map, WbCompany.class);
String sql = wbUtil.getSaveSql(wb);
String usql = wbUtil.getUpdateSql(wb, "COMPANY_ID");
long lg2 = System.currentTimeMillis();
System.out.println(sql);
System.out.println(usql);
System.out.println(lg2 - lg1);*/
}
static class BaseCategory{
private String id;
private String tenancyId;
private String description;
private String notes;
private Short isAll;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private Integer effectived;
private BigDecimal enabled;
private String bizScope;
private Integer byagent;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getEffectived() {
return effectived;
}
public void setEffectived(Integer effectived) {
this.effectived = effectived;
}
public String getBizScope() {
return bizScope;
}
public void setBizScope(String bizScope) {
this.bizScope = bizScope;
}
public Integer getByagent() {
return byagent;
}
public void setByagent(Integer byagent) {
this.byagent = byagent;
}
public Short getIsAll() {
return isAll;
}
public void setIsAll(Short isAll) {
this.isAll = isAll;
}
public BigDecimal getEnabled() {
return enabled;
}
public void setEnabled(BigDecimal enabled) {
this.enabled = enabled;
}
}
}

View File

@@ -0,0 +1,20 @@
package com.ag.commonFace;
import com.ag.entity.fee.ItemProperties;
import com.ag.entity.fee.Tariff;
import com.ag.entity.fee.TariffRitem;
import java.util.List;
import java.util.Map;
/**
* Created by yangxh on 2022/3/11.
*/
public interface ITariffExtService {
void generateDescription(Tariff tariff, List<TariffRitem> ritems, List<ItemProperties> properties);
Map<String, String> getSpecialOperChar(String tariffId);
void synDescription(String contractId, String itemId, String tenancyId);
}

View File

@@ -0,0 +1,71 @@
package com.ag.config;
import javax.sql.DataSource;
import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
/**
* @description: 动态数据源代理类
* @author: WangN
* @create: 2019-08-16
*/
public abstract class AbstractDataSourceProxy implements DataSource, Closeable {
public abstract DataSource getMainDataSource();
@Override
public void close() throws IOException {
((Closeable)getMainDataSource()).close();
}
@Override
public Connection getConnection() throws SQLException {
return getMainDataSource().getConnection();
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return getMainDataSource().getConnection(username, password);
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return getMainDataSource().unwrap(iface);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return getMainDataSource().isWrapperFor(iface);
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return getMainDataSource().getLogWriter();
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
getMainDataSource().setLogWriter(out);
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
getMainDataSource().setLoginTimeout(seconds);
}
@Override
public int getLoginTimeout() throws SQLException {
return getMainDataSource().getLoginTimeout();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return getMainDataSource().getParentLogger();
}
}

View File

@@ -0,0 +1,23 @@
package com.ag.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import javax.sql.DataSource;
/**
* @description: 主工程基础数据源
* @author: WangN
* @create: 2019-08-19
*/
//@Repository
public class BaseDataSourceCfg extends AbstractDataSourceProxy {
//web工程配置的数据源beanName=dataSource
@Autowired
private DataSource dataSource;
@Override
public DataSource getMainDataSource() {
return this.dataSource;
}
}

View File

@@ -0,0 +1,74 @@
package com.ag.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.stereotype.Repository;
import redis.clients.jedis.JedisPoolConfig;
/**
* @description: jedis连接工厂代理
* @author: WangN
* @create: 2019-09-18
*/
//@Repository
public class JedisConnectionFactoryProxy extends JedisConnectionFactory {
@Autowired
private JedisConnectionFactory jedisConnectionFactory;
@Override
public RedisConnection getConnection() {
return jedisConnectionFactory.getConnection();
}
@Override
public String getHostName() {
return jedisConnectionFactory.getHostName();
}
@Override
public void setHostName(String hostName) {
jedisConnectionFactory.setHostName(hostName);
}
@Override
public String getPassword() {
return jedisConnectionFactory.getPassword();
}
@Override
public void setPassword(String password) {
jedisConnectionFactory.setPassword(password);
}
@Override
public int getPort() {
return jedisConnectionFactory.getPort();
}
@Override
public void setPort(int port) {
jedisConnectionFactory.setPort(port);
}
@Override
public JedisPoolConfig getPoolConfig() {
return jedisConnectionFactory.getPoolConfig();
}
@Override
public void setPoolConfig(JedisPoolConfig poolConfig) {
jedisConnectionFactory.setPoolConfig(poolConfig);
}
@Override
public int getDatabase() {
return jedisConnectionFactory.getDatabase();
}
@Override
public void setDatabase(int index) {
jedisConnectionFactory.setDatabase(index);
}
}

View File

@@ -0,0 +1,88 @@
package com.ag.config;
import org.apache.http.Header;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @description: 调用http
* @author: WangN
* @create: 2019-11-13
*/
@Configuration
public class RestTemplateConfig {
/**
* 返回RestTemplate
* @param factory
* @return
*/
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(clientHttpRequestFactory());
restTemplate.setErrorHandler(new DefaultResponseErrorHandler());
return restTemplate;
}
/**
* ClientHttpRequestFactory接口的另一种实现方式推荐使用
* HttpComponentsClientHttpRequestFactory底层使用Httpclient连接池的方式创建Http连接请求
* @return
*/
@Bean
public HttpComponentsClientHttpRequestFactory clientHttpRequestFactory(){
//Httpclient连接池长连接保持30秒
PoolingHttpClientConnectionManager connectionManager =
new PoolingHttpClientConnectionManager(30, TimeUnit.SECONDS);
//设置总连接数
connectionManager.setMaxTotal(1000);
//设置同路由的并发数
connectionManager.setDefaultMaxPerRoute(1000);
//设置header
List<Header> headers = new ArrayList<Header>();
headers.add(new BasicHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.04"));
headers.add(new BasicHeader("Accept-Encoding", "gzip, deflate"));
headers.add(new BasicHeader("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3"));
headers.add(new BasicHeader("Connection", "keep-alive"));
//创建HttpClient
HttpClient httpClient = HttpClientBuilder.create()
.setConnectionManager(connectionManager)
.setDefaultHeaders(headers)
.setRetryHandler(new DefaultHttpRequestRetryHandler(3, true)) //设置重试次数
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) //设置保持长连接
.build();
//创建HttpComponentsClientHttpRequestFactory实例
HttpComponentsClientHttpRequestFactory requestFactory =
new HttpComponentsClientHttpRequestFactory(httpClient);
//设置客户端和服务端建立连接的超时时间
requestFactory.setConnectTimeout(12000);
//设置客户端从服务端读取数据的超时时间
requestFactory.setReadTimeout(12000);
//设置从连接池获取连接的超时时间,不宜过长
requestFactory.setConnectionRequestTimeout(200);
//缓冲请求数据默认为true。通过POST或者PUT大量发送数据时建议将此更改为false以免耗尽内存
requestFactory.setBufferRequestBody(true);
return requestFactory;
}
}

View File

@@ -0,0 +1,584 @@
package com.ag.entity.account;
import java.util.Date;
public class FeeDetail {
private String id;
private String tenancyId;
private String bussinessCode;
private String feeGroupId;
private String feeListId;
private String tariffId;
private String clientCode;
private String clientName;
private String clientDesc;
private Double weight;
private Double volume;
private Double pieces;
private Double quantity;
private Double actualRate;
private Double calcMoney;
private Double derateMoney;
private Double finalMoney;
private Double discount;
private Double stRate;
private Double stMoney;
private Integer paymentType;
private String enteredFlag;
private String itemCode;
private String notes;
private String currency;
private String unitId;
private String settleBy;
private Date settleOn;
private String invoiceId;
private String invoiceNo;
private Integer invoiceKind;
private String contractId;
private String contractName;
private String checkFlag;
private String checkName;
private Date checkTime;
private String invalidFlag;
private String invalidBy;
private Date invalidOn;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private String payReceiveType;
private String serialNo;
private String jobCategoryCode;
private Date jobFinishDate;
private Integer enabled;
private Date outTime;
private Date inTime;
private Integer payFlag;
private Date settleTimeOn;
private Date settleTimeEnd;
private String manualNodes;
private Integer derateDays;
private Integer settleDays;
private String invoiceType;
private String settlementCode;
private String originalItemName;
private Integer calcDays;
private String sourceItemCode;
private String tariffNote;
private String tariffDescription;
private Integer settleStatus;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getBussinessCode() {
return bussinessCode;
}
public void setBussinessCode(String bussinessCode) {
this.bussinessCode = bussinessCode;
}
public String getFeeGroupId() {
return feeGroupId;
}
public void setFeeGroupId(String feeGroupId) {
this.feeGroupId = feeGroupId;
}
public String getFeeListId() {
return feeListId;
}
public void setFeeListId(String feeListId) {
this.feeListId = feeListId;
}
public String getTariffId() {
return tariffId;
}
public void setTariffId(String tariffId) {
this.tariffId = tariffId;
}
public String getClientCode() {
return clientCode;
}
public void setClientCode(String clientCode) {
this.clientCode = clientCode;
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public String getClientDesc() {
return clientDesc;
}
public void setClientDesc(String clientDesc) {
this.clientDesc = clientDesc;
}
public Double getWeight() {
return weight;
}
public void setWeight(Double weight) {
this.weight = weight;
}
public Double getVolume() {
return volume;
}
public void setVolume(Double volume) {
this.volume = volume;
}
public Double getPieces() {
return pieces;
}
public void setPieces(Double pieces) {
this.pieces = pieces;
}
public Double getQuantity() {
return quantity;
}
public void setQuantity(Double quantity) {
this.quantity = quantity;
}
public Double getActualRate() {
return actualRate;
}
public void setActualRate(Double actualRate) {
this.actualRate = actualRate;
}
public Double getCalcMoney() {
return calcMoney;
}
public void setCalcMoney(Double calcMoney) {
this.calcMoney = calcMoney;
}
public Double getDerateMoney() {
return derateMoney;
}
public void setDerateMoney(Double derateMoney) {
this.derateMoney = derateMoney;
}
public Double getFinalMoney() {
return finalMoney;
}
public void setFinalMoney(Double finalMoney) {
this.finalMoney = finalMoney;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Double getStRate() {
return stRate;
}
public void setStRate(Double stRate) {
this.stRate = stRate;
}
public Double getStMoney() {
return stMoney;
}
public void setStMoney(Double stMoney) {
this.stMoney = stMoney;
}
public Integer getPaymentType() {
return paymentType;
}
public void setPaymentType(Integer paymentType) {
this.paymentType = paymentType;
}
public String getEnteredFlag() {
return enteredFlag;
}
public void setEnteredFlag(String enteredFlag) {
this.enteredFlag = enteredFlag;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getUnitId() {
return unitId;
}
public void setUnitId(String unitId) {
this.unitId = unitId;
}
public String getSettleBy() {
return settleBy;
}
public void setSettleBy(String settleBy) {
this.settleBy = settleBy;
}
public Date getSettleOn() {
return settleOn;
}
public void setSettleOn(Date settleOn) {
this.settleOn = settleOn;
}
public String getInvoiceId() {
return invoiceId;
}
public void setInvoiceId(String invoiceId) {
this.invoiceId = invoiceId;
}
public String getInvoiceNo() {
return invoiceNo;
}
public void setInvoiceNo(String invoiceNo) {
this.invoiceNo = invoiceNo;
}
public Integer getInvoiceKind() {
return invoiceKind;
}
public void setInvoiceKind(Integer invoiceKind) {
this.invoiceKind = invoiceKind;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public String getContractName() {
return contractName;
}
public void setContractName(String contractName) {
this.contractName = contractName;
}
public String getCheckFlag() {
return checkFlag;
}
public void setCheckFlag(String checkFlag) {
this.checkFlag = checkFlag;
}
public String getCheckName() {
return checkName;
}
public void setCheckName(String checkName) {
this.checkName = checkName;
}
public Date getCheckTime() {
return checkTime;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public String getInvalidFlag() {
return invalidFlag;
}
public void setInvalidFlag(String invalidFlag) {
this.invalidFlag = invalidFlag;
}
public String getInvalidBy() {
return invalidBy;
}
public void setInvalidBy(String invalidBy) {
this.invalidBy = invalidBy;
}
public Date getInvalidOn() {
return invalidOn;
}
public void setInvalidOn(Date invalidOn) {
this.invalidOn = invalidOn;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getPayReceiveType() {
return payReceiveType;
}
public void setPayReceiveType(String payReceiveType) {
this.payReceiveType = payReceiveType;
}
public String getSerialNo() {
return serialNo;
}
public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}
public String getJobCategoryCode() {
return jobCategoryCode;
}
public void setJobCategoryCode(String jobCategoryCode) {
this.jobCategoryCode = jobCategoryCode;
}
public Date getJobFinishDate() {
return jobFinishDate;
}
public void setJobFinishDate(Date jobFinishDate) {
this.jobFinishDate = jobFinishDate;
}
public Integer getEnabled() {
return enabled;
}
public void setEnabled(Integer enabled) {
this.enabled = enabled;
}
public Date getOutTime() {
return outTime;
}
public void setOutTime(Date outTime) {
this.outTime = outTime;
}
public Date getInTime() {
return inTime;
}
public void setInTime(Date inTime) {
this.inTime = inTime;
}
public Integer getPayFlag() {
return payFlag;
}
public void setPayFlag(Integer payFlag) {
this.payFlag = payFlag;
}
public Date getSettleTimeOn() {
return settleTimeOn;
}
public void setSettleTimeOn(Date settleTimeOn) {
this.settleTimeOn = settleTimeOn;
}
public Date getSettleTimeEnd() {
return settleTimeEnd;
}
public void setSettleTimeEnd(Date settleTimeEnd) {
this.settleTimeEnd = settleTimeEnd;
}
public String getManualNodes() {
return manualNodes;
}
public void setManualNodes(String manualNodes) {
this.manualNodes = manualNodes;
}
public Integer getDerateDays() {
return derateDays;
}
public void setDerateDays(Integer derateDays) {
this.derateDays = derateDays;
}
public Integer getSettleDays() {
return settleDays;
}
public void setSettleDays(Integer settleDays) {
this.settleDays = settleDays;
}
public String getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(String invoiceType) {
this.invoiceType = invoiceType;
}
public String getSettlementCode() {
return settlementCode;
}
public void setSettlementCode(String settlementCode) {
this.settlementCode = settlementCode;
}
public String getOriginalItemName() {
return originalItemName;
}
public void setOriginalItemName(String originalItemName) {
this.originalItemName = originalItemName;
}
public Integer getCalcDays() {
return calcDays;
}
public void setCalcDays(Integer calcDays) {
this.calcDays = calcDays;
}
public String getSourceItemCode() {
return sourceItemCode;
}
public void setSourceItemCode(String sourceItemCode) {
this.sourceItemCode = sourceItemCode;
}
public String getTariffNote() {
return tariffNote;
}
public void setTariffNote(String tariffNote) {
this.tariffNote = tariffNote;
}
public String getTariffDescription() {
return tariffDescription;
}
public void setTariffDescription(String tariffDescription) {
this.tariffDescription = tariffDescription;
}
public Integer getSettleStatus() {
return settleStatus;
}
public void setSettleStatus(Integer settleStatus) {
this.settleStatus = settleStatus;
}
}

View File

@@ -0,0 +1,118 @@
package com.ag.entity.account;
import com.ag.base.ISerializable;
import java.util.Date;
public class SerialConfig implements ISerializable {
private String id;
private String code;
private String description;
private String prefix;
private String postfix;
private Integer numLength;
private String tenancyId;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private Integer validFlag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getPostfix() {
return postfix;
}
public void setPostfix(String postfix) {
this.postfix = postfix;
}
public Integer getNumLength() {
return numLength;
}
public void setNumLength(Integer numLength) {
this.numLength = numLength;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getValidFlag() {
return validFlag;
}
public void setValidFlag(Integer validFlag) {
this.validFlag = validFlag;
}
}

View File

@@ -0,0 +1,44 @@
package com.ag.entity.account;
import java.util.Date;
public class SerialNo {
private String id;
private String configId;
private Date day;
private Integer currentNo;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
}
public Date getDay() {
return day;
}
public void setDay(Date day) {
this.day = day;
}
public Integer getCurrentNo() {
return currentNo;
}
public void setCurrentNo(Integer currentNo) {
this.currentNo = currentNo;
}
}

View File

@@ -0,0 +1,249 @@
package com.ag.entity.account.vo;
import com.ag.entity.account.FeeDetail;
import com.ag.entity.fee.AccountPoints;
import com.ag.entity.fee.BaseChargingItem;
import com.ag.entity.fee.face.ReqSource;
import com.ag.entity.fee.vo.ContractItemVO;
import com.ag.entity.fee.vo.ContractVO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 计费对象基类,不包含数据源对象和计费过程对象
* transient序列化与反序列化时不作为传递参数
*/
public class BizVO implements Serializable {
private String tenancyId;//租户
private String operMan;//操作员
private Map<String, String> conditionMap;//参数map
private String jsonDataSource;//json数据源
transient private String accountPointId;//计费点编号
transient private List<AccountPoints> pointLst;//计费点费目
transient private Map<String, List<AccountPoints>> allPonitsMap;//计费点分组
transient private Map<String, BaseChargingItem> itemMap;//所有基础费目(费用明细取名称)
private String shipperCode;//货主编号
private String shipperName;//提示错误信息使用
private String companyCode;//驳船编号
private String companyName;//提示错误信息使用
transient private String payerCode;//付费人编号(废弃)
transient private ContractVO defaultContractVo;//默认合同相关,费目(计免),费率(条件)
transient private String itemIds;//费目逗号分割
transient private String itemId;//费目
transient private String categoryId;//费类
transient private ContractItemVO shipperItemVO;
transient private ContractItemVO companyItemVO;
transient private List<ContractVO> appendContractVO = new ArrayList<>();//合同追加(查询全部合同,赋值给客户,查询所有月结客户使用)
transient private Date bizTime;//业务时间(查找合同有效期)
private ReqSource reqSource;
private List<FeeDetail> details = new ArrayList<>();
private Date startDate;
private Date endDate;
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getOperMan() {
return operMan;
}
public void setOperMan(String operMan) {
this.operMan = operMan;
}
public Map<String, String> getConditionMap() {
return conditionMap;
}
public void setConditionMap(Map<String, String> conditionMap) {
this.conditionMap = conditionMap;
}
public String getJsonDataSource() {
return jsonDataSource;
}
public void setJsonDataSource(String jsonDataSource) {
this.jsonDataSource = jsonDataSource;
}
public String getAccountPointId() {
return accountPointId;
}
public void setAccountPointId(String accountPointId) {
this.accountPointId = accountPointId;
}
public List<AccountPoints> getPointLst() {
return pointLst;
}
public void setPointLst(List<AccountPoints> pointLst) {
this.pointLst = pointLst;
}
public Map<String, List<AccountPoints>> getAllPonitsMap() {
return allPonitsMap;
}
public void setAllPonitsMap(Map<String, List<AccountPoints>> allPonitsMap) {
this.allPonitsMap = allPonitsMap;
}
public Map<String, BaseChargingItem> getItemMap() {
return itemMap;
}
public void setItemMap(Map<String, BaseChargingItem> itemMap) {
this.itemMap = itemMap;
}
public String getShipperCode() {
return shipperCode;
}
public void setShipperCode(String shipperCode) {
this.shipperCode = shipperCode;
}
public String getShipperName() {
return shipperName;
}
public void setShipperName(String shipperName) {
this.shipperName = shipperName;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getPayerCode() {
return payerCode;
}
public void setPayerCode(String payerCode) {
this.payerCode = payerCode;
}
public ContractVO getDefaultContractVo() {
return defaultContractVo;
}
public void setDefaultContractVo(ContractVO defaultContractVo) {
this.defaultContractVo = defaultContractVo;
}
public String getItemIds() {
return itemIds;
}
public void setItemIds(String itemIds) {
this.itemIds = itemIds;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public ContractItemVO getShipperItemVO() {
return shipperItemVO;
}
public void setShipperItemVO(ContractItemVO shipperItemVO) {
this.shipperItemVO = shipperItemVO;
}
public ContractItemVO getCompanyItemVO() {
return companyItemVO;
}
public void setCompanyItemVO(ContractItemVO companyItemVO) {
this.companyItemVO = companyItemVO;
}
public List<ContractVO> getAppendContractVO() {
return appendContractVO;
}
public void setAppendContractVO(List<ContractVO> appendContractVO) {
this.appendContractVO = appendContractVO;
}
public Date getBizTime() {
return bizTime;
}
public void setBizTime(Date bizTime) {
this.bizTime = bizTime;
}
public ReqSource getReqSource() {
return reqSource;
}
public void setReqSource(ReqSource reqSource) {
this.reqSource = reqSource;
}
public List<FeeDetail> getDetails() {
return details;
}
public void setDetails(List<FeeDetail> details) {
this.details = details;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
}

View File

@@ -0,0 +1,113 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
public class AccountPoints implements ISerializable {
private String id;
private String tenancyId;
private String pointCode;
private String pointName;
private String categoryId;
private String customerId;
private String itemId;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getPointCode() {
return pointCode;
}
public void setPointCode(String pointCode) {
this.pointCode = pointCode;
}
public String getPointName() {
return pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
}

View File

@@ -0,0 +1,157 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import com.alibaba.fastjson.JSON;
import java.util.Date;
import java.util.List;
/**
* CBaseCategory entity. @author MyEclipse Persistence Tools
*/
public class BaseCategory implements ISerializable {
// Fields
private String id;
private String tenancyId;
private String description;
private String notes;
private Integer isAll;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private Integer effectived;
private Integer enabled;
private String bizScope;
private Integer byagent;
private Integer delFlag;
public Integer getByagent() {
return byagent;
}
public void setByagent(Integer byagent) {
this.byagent = byagent;
}
// Constructors
/** default constructor */
public BaseCategory() {
}
// Property accessors
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return this.tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String getNotes() {
return this.notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Integer getIsAll() {
return isAll;
}
public void setIsAll(Integer isAll) {
this.isAll = isAll;
}
public Integer getEffectived() {
return effectived;
}
public void setEffectived(Integer effectived) {
this.effectived = effectived;
}
public Integer getEnabled() {
return enabled;
}
public void setEnabled(Integer enabled) {
this.enabled = enabled;
}
public String getBizScope() {
return bizScope;
}
public void setBizScope(String bizScope) {
this.bizScope = bizScope;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,353 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
/**
* CBaseChargingItem entity. @author MyEclipse Persistence Tools
*/
public class BaseChargingItem implements ISerializable {
// Fields
private String id;
private String tenancyId;
private String description;
private String categoryId;
private String invoiceType;
private String unit;
private Integer lifeStatus;
private Double minAmount;
private Double maxAmount;
private Integer isFormat;
private String notes;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private Integer accountType;
private Integer formatUnit;
private String currency;
private String glCode;
private Integer flatRate;
private Double tonsStere;
private Integer byday;
private Integer byton;
private Integer byagent;
private Integer derateType;//分段减免类型(0=前免1=后免)
private Integer derateDay;//分段减免天
private Integer enabled;//是否参考价
private Integer amountFormat;
private String payCode;
private String receiveCode;
private String itemCode;
private String enCode;
private String sourceItemCode;
private Double currencyRatio;
private String parentCode;
private Integer delFlag;
// Constructors
/** default constructor */
public BaseChargingItem() {
}
// Property accessors
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return this.tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCategoryId() {
return this.categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getInvoiceType() {
return this.invoiceType;
}
public void setInvoiceType(String invoiceType) {
this.invoiceType = invoiceType;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Integer getLifeStatus() {
return this.lifeStatus;
}
public void setLifeStatus(Integer lifeStatus) {
this.lifeStatus = lifeStatus;
}
public Double getMinAmount() {
return this.minAmount;
}
public void setMinAmount(Double minAmount) {
this.minAmount = minAmount;
}
public Double getMaxAmount() {
return this.maxAmount;
}
public void setMaxAmount(Double maxAmount) {
this.maxAmount = maxAmount;
}
public Integer getIsFormat() {
return this.isFormat;
}
public void setIsFormat(Integer isFormat) {
this.isFormat = isFormat;
}
public String getNotes() {
return this.notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getAccountType() {
return accountType;
}
public void setAccountType(Integer accountType) {
this.accountType = accountType;
}
public Integer getFormatUnit() {
return formatUnit;
}
public void setFormatUnit(Integer formatUnit) {
this.formatUnit = formatUnit;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getGlCode() {
return glCode;
}
public void setGlCode(String glCode) {
this.glCode = glCode;
}
public Integer getFlatRate() {
return flatRate;
}
public void setFlatRate(Integer flatRate) {
this.flatRate = flatRate;
}
public Double getTonsStere() {
return tonsStere;
}
public void setTonsStere(Double tonsStere) {
this.tonsStere = tonsStere;
}
public Integer getByday() {
return byday;
}
public void setByday(Integer byday) {
this.byday = byday;
}
public Integer getByton() {
return byton;
}
public void setByton(Integer byton) {
this.byton = byton;
}
public Integer getByagent() {
return byagent;
}
public void setByagent(Integer byagent) {
this.byagent = byagent;
}
public Integer getDerateType() {
return derateType;
}
public void setDerateType(Integer derateType) {
this.derateType = derateType;
}
public Integer getDerateDay() {
return derateDay;
}
public void setDerateDay(Integer derateDay) {
this.derateDay = derateDay;
}
public Integer getEnabled() {
return enabled;
}
public void setEnabled(Integer enabled) {
this.enabled = enabled;
}
public Integer getAmountFormat() {
return amountFormat;
}
public void setAmountFormat(Integer amountFormat) {
this.amountFormat = amountFormat;
}
public String getPayCode() {
return payCode;
}
public void setPayCode(String payCode) {
this.payCode = payCode;
}
public String getReceiveCode() {
return receiveCode;
}
public void setReceiveCode(String receiveCode) {
this.receiveCode = receiveCode;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getEnCode() {
return enCode;
}
public void setEnCode(String enCode) {
this.enCode = enCode;
}
public String getSourceItemCode() {
return sourceItemCode;
}
public void setSourceItemCode(String sourceItemCode) {
this.sourceItemCode = sourceItemCode;
}
public Double getCurrencyRatio() {
return currencyRatio;
}
public void setCurrencyRatio(Double currencyRatio) {
this.currencyRatio = currencyRatio;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,377 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
/**
* Created by Administrator on 2017/4/25 0025.
*/
public class Contract implements ISerializable {
private String id;
private String tenancyId;
private String description;
private String notes;
private Integer lifeStatus;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private String contractNo;
private String originalContractId;
private Date effectiveDate;
private Date expiredDate;
private Integer confirmStatus;
private String confirmUser;
private Date confirmDate;
private String paymentAgent;
private Integer paymentType;
private Integer contractType;
private Date expandTo;
private String tradeType;
private String bizScope;
private Integer category;
private String version;
private String versionMemo;
private Integer currencyId;
private String approveMemo;
private String filePath;
private String originalName;
private Integer isDefault;
private String tradeId;
private String iEId;
private String clientCode;
private String vesselVisitId;
private String vesselName;
private String voyage;
private String address;
private String cargoTypeCode;
private Integer calcFlag;
private Integer delFlag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Integer getLifeStatus() {
return lifeStatus;
}
public void setLifeStatus(Integer lifeStatus) {
this.lifeStatus = lifeStatus;
}
public String getContractNo() {
return contractNo;
}
public void setContractNo(String contractNo) {
this.contractNo = contractNo;
}
public String getOriginalContractId() {
return originalContractId;
}
public void setOriginalContractId(String originalContractId) {
this.originalContractId = originalContractId;
}
public Date getEffectiveDate() {
return effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public Date getExpiredDate() {
return expiredDate;
}
public void setExpiredDate(Date expiredDate) {
this.expiredDate = expiredDate;
}
public Integer getConfirmStatus() {
return confirmStatus;
}
public void setConfirmStatus(Integer confirmStatus) {
this.confirmStatus = confirmStatus;
}
public String getConfirmUser() {
return confirmUser;
}
public void setConfirmUser(String confirmUser) {
this.confirmUser = confirmUser;
}
public Date getConfirmDate() {
return confirmDate;
}
public void setConfirmDate(Date confirmDate) {
this.confirmDate = confirmDate;
}
public String getPaymentAgent() {
return paymentAgent;
}
public void setPaymentAgent(String paymentAgent) {
this.paymentAgent = paymentAgent;
}
public Integer getPaymentType() {
return paymentType;
}
public void setPaymentType(Integer paymentType) {
this.paymentType = paymentType;
}
public Integer getContractType() {
return contractType;
}
public void setContractType(Integer contractType) {
this.contractType = contractType;
}
public Date getExpandTo() {
return expandTo;
}
public void setExpandTo(Date expandTo) {
this.expandTo = expandTo;
}
public String getTradeType() {
return tradeType;
}
public void setTradeType(String tradeType) {
this.tradeType = tradeType;
}
public String getBizScope() {
return bizScope;
}
public void setBizScope(String bizScope) {
this.bizScope = bizScope;
}
public Integer getCategory() {
return category;
}
public void setCategory(Integer category) {
this.category = category;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getVersionMemo() {
return versionMemo;
}
public void setVersionMemo(String versionMemo) {
this.versionMemo = versionMemo;
}
public Integer getCurrencyId() {
return currencyId;
}
public void setCurrencyId(Integer currencyId) {
this.currencyId = currencyId;
}
public String getApproveMemo() {
return approveMemo;
}
public void setApproveMemo(String approveMemo) {
this.approveMemo = approveMemo;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public Integer getIsDefault() {
return isDefault;
}
public void setIsDefault(Integer isDefault) {
this.isDefault = isDefault;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getTradeId() {
return tradeId;
}
public void setTradeId(String tradeId) {
this.tradeId = tradeId;
}
public String getiEId() {
return iEId;
}
public void setiEId(String iEId) {
this.iEId = iEId;
}
public String getClientCode() {
return clientCode;
}
public void setClientCode(String clientCode) {
this.clientCode = clientCode;
}
public String getVesselVisitId() {
return vesselVisitId;
}
public void setVesselVisitId(String vesselVisitId) {
this.vesselVisitId = vesselVisitId;
}
public String getVesselName() {
return vesselName;
}
public void setVesselName(String vesselName) {
this.vesselName = vesselName;
}
public String getVoyage() {
return voyage;
}
public void setVoyage(String voyage) {
this.voyage = voyage;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCargoTypeCode() {
return cargoTypeCode;
}
public void setCargoTypeCode(String cargoTypeCode) {
this.cargoTypeCode = cargoTypeCode;
}
public Integer getCalcFlag() {
return calcFlag;
}
public void setCalcFlag(Integer calcFlag) {
this.calcFlag = calcFlag;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,133 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
/**
* Created by Administrator on 2017/4/25 0025.
*/
public class ContractCategory implements ISerializable {
private String id;
private String tenancyId;
private String contractId;
private String categoryId;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private Integer isAll;
private Integer effectived;
private String bizScope;
private Integer byagent;
private String notes;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public Integer getIsAll() {
return isAll;
}
public void setIsAll(Integer isAll) {
this.isAll = isAll;
}
public Integer getEffectived() {
return effectived;
}
public void setEffectived(Integer effectived) {
this.effectived = effectived;
}
public String getBizScope() {
return bizScope;
}
public void setBizScope(String bizScope) {
this.bizScope = bizScope;
}
public Integer getByagent() {
return byagent;
}
public void setByagent(Integer byagent) {
this.byagent = byagent;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
}

View File

@@ -0,0 +1,398 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
/**
* Created by Administrator on 2017/4/25 0025.
*/
public class ContractItem implements ISerializable {
private String id;
private String tenancyId;
private String contractId;
private String categoryId;
private String itemId;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private String invoiceType;
private String unit;
private Integer lifeStatus;
private Double minAmount;
private Double maxAmount;
private Integer isFormat;
private String notes;
private Integer accountType;
private Integer formatUnit;
private String currency;
private String glCode;
private Integer flatRate;
private Double tonsStere;
private Integer byday;
private Integer byton;
private Integer byagent;
private Integer derateType;//分段减免类型(0=前免1=后免)
private Integer derateDay;//分段减免天
private Integer enabled;//是否参考价
private Integer amountFormat;
private Double minTon;
private String receiveCode;
private String payCode;
private String itemCode;
private String enCode;
private String sourceItemCode;
private Double currencyRatio;
private String receiveCurrency;
private String payCurrency;
private String receiveMan;
private String payMan;
private Integer delFlag;
private String formula;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(String invoiceType) {
this.invoiceType = invoiceType;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Integer getLifeStatus() {
return lifeStatus;
}
public void setLifeStatus(Integer lifeStatus) {
this.lifeStatus = lifeStatus;
}
public Double getMinAmount() {
return minAmount;
}
public void setMinAmount(Double minAmount) {
this.minAmount = minAmount;
}
public Double getMaxAmount() {
return maxAmount;
}
public void setMaxAmount(Double maxAmount) {
this.maxAmount = maxAmount;
}
public Integer getIsFormat() {
return isFormat;
}
public void setIsFormat(Integer isFormat) {
this.isFormat = isFormat;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public Integer getAccountType() {
return accountType;
}
public void setAccountType(Integer accountType) {
this.accountType = accountType;
}
public Integer getFormatUnit() {
return formatUnit;
}
public void setFormatUnit(Integer formatUnit) {
this.formatUnit = formatUnit;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public String getGlCode() {
return glCode;
}
public void setGlCode(String glCode) {
this.glCode = glCode;
}
public Integer getFlatRate() {
return flatRate;
}
public void setFlatRate(Integer flatRate) {
this.flatRate = flatRate;
}
public Double getTonsStere() {
return tonsStere;
}
public void setTonsStere(Double tonsStere) {
this.tonsStere = tonsStere;
}
public Integer getByday() {
return byday;
}
public void setByday(Integer byday) {
this.byday = byday;
}
public Integer getByton() {
return byton;
}
public void setByton(Integer byton) {
this.byton = byton;
}
public Integer getByagent() {
return byagent;
}
public void setByagent(Integer byagent) {
this.byagent = byagent;
}
public Integer getDerateType() {
return derateType;
}
public void setDerateType(Integer derateType) {
this.derateType = derateType;
}
public Integer getDerateDay() {
return derateDay;
}
public void setDerateDay(Integer derateDay) {
this.derateDay = derateDay;
}
public Integer getEnabled() {
return enabled;
}
public void setEnabled(Integer enabled) {
this.enabled = enabled;
}
public Integer getAmountFormat() {
return amountFormat;
}
public void setAmountFormat(Integer amountFormat) {
this.amountFormat = amountFormat;
}
public Double getMinTon() {
return minTon;
}
public void setMinTon(Double minTon) {
this.minTon = minTon;
}
public String getReceiveCode() {
return receiveCode;
}
public void setReceiveCode(String receiveCode) {
this.receiveCode = receiveCode;
}
public String getPayCode() {
return payCode;
}
public void setPayCode(String payCode) {
this.payCode = payCode;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getEnCode() {
return enCode;
}
public void setEnCode(String enCode) {
this.enCode = enCode;
}
public String getSourceItemCode() {
return sourceItemCode;
}
public void setSourceItemCode(String sourceItemCode) {
this.sourceItemCode = sourceItemCode;
}
public Double getCurrencyRatio() {
return currencyRatio;
}
public void setCurrencyRatio(Double currencyRatio) {
this.currencyRatio = currencyRatio;
}
public String getReceiveCurrency() {
return receiveCurrency;
}
public void setReceiveCurrency(String receiveCurrency) {
this.receiveCurrency = receiveCurrency;
}
public String getPayCurrency() {
return payCurrency;
}
public void setPayCurrency(String payCurrency) {
this.payCurrency = payCurrency;
}
public String getReceiveMan() {
return receiveMan;
}
public void setReceiveMan(String receiveMan) {
this.receiveMan = receiveMan;
}
public String getPayMan() {
return payMan;
}
public void setPayMan(String payMan) {
this.payMan = payMan;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public String getFormula() {
return formula;
}
public void setFormula(String formula) {
this.formula = formula;
}
}

View File

@@ -0,0 +1,78 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
public class ContractRelation implements ISerializable {
private String id;
private String contractId;
private String customerId;
private String tenancyId;
private String createdBy;
private Date createdOn;
private Integer delFlag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public String getCustomerId() {
return customerId;
}
public void setCustomerId(String customerId) {
this.customerId = customerId;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,77 @@
package com.ag.entity.fee;
public class ItemProperties {
private String id;
private String tenancyId;
private String itemId;
private String propertyName;
private Integer isShowOperator;
private Integer dispOrder;
private String propertyCode;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getPropertyName() {
return propertyName;
}
public void setPropertyName(String propertyName) {
this.propertyName = propertyName;
}
public Integer getIsShowOperator() {
return isShowOperator;
}
public void setIsShowOperator(Integer isShowOperator) {
this.isShowOperator = isShowOperator;
}
public Integer getDispOrder() {
return dispOrder;
}
public void setDispOrder(Integer dispOrder) {
this.dispOrder = dispOrder;
}
public String getPropertyCode() {
return propertyCode;
}
public void setPropertyCode(String propertyCode) {
this.propertyCode = propertyCode;
}
}

View File

@@ -0,0 +1,353 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
import java.util.Date;
/**
* CTariff entity. @author MyEclipse Persistence Tools
*/
public class Tariff implements ISerializable {
// Fields
private String id;
private String tenancyId;
private String chargingId;
private Double rate;
private String currency;
private Integer amountFormat;
private Integer formatUnit;
private String notes;
private String createdBy;
private Date createdOn;
private String updatedBy;
private Date updatedOn;
private String contractId;
private Integer sort;
private Double volPrice;
private String receiveCode;
private String payCode;
private Double receiveRate;
private Double payRate;
private String receiveCurrency;
private String payCurrency;
private String keyDescription;
private String valDescription;
private Date effectiveDate;
private Date expiredDate;
private String appendlxNotes;
private Integer confirmStatus;
private String confirmBy;
private Date confirmOn;
private Integer delFlag;
private Integer byton;
private Double minAmount;
private Double maxAmount;
private Integer isFormat;
private Integer verifyFlag;
private String receiveMan;
private String payMan;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
@Override
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getChargingId() {
return chargingId;
}
public void setChargingId(String chargingId) {
this.chargingId = chargingId;
}
public Double getRate() {
return rate;
}
public void setRate(Double rate) {
this.rate = rate;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public Integer getAmountFormat() {
return amountFormat;
}
public void setAmountFormat(Integer amountFormat) {
this.amountFormat = amountFormat;
}
public Integer getFormatUnit() {
return formatUnit;
}
public void setFormatUnit(Integer formatUnit) {
this.formatUnit = formatUnit;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getCreatedBy() {
return createdBy;
}
@Override
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
@Override
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
@Override
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
@Override
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Double getVolPrice() {
return volPrice;
}
public void setVolPrice(Double volPrice) {
this.volPrice = volPrice;
}
public String getReceiveCode() {
return receiveCode;
}
public void setReceiveCode(String receiveCode) {
this.receiveCode = receiveCode;
}
public String getPayCode() {
return payCode;
}
public void setPayCode(String payCode) {
this.payCode = payCode;
}
public Double getReceiveRate() {
return receiveRate;
}
public void setReceiveRate(Double receiveRate) {
this.receiveRate = receiveRate;
}
public Double getPayRate() {
return payRate;
}
public void setPayRate(Double payRate) {
this.payRate = payRate;
}
public String getReceiveCurrency() {
return receiveCurrency;
}
public void setReceiveCurrency(String receiveCurrency) {
this.receiveCurrency = receiveCurrency;
}
public String getPayCurrency() {
return payCurrency;
}
public void setPayCurrency(String payCurrency) {
this.payCurrency = payCurrency;
}
public String getKeyDescription() {
return keyDescription;
}
public void setKeyDescription(String keyDescription) {
this.keyDescription = keyDescription;
}
public String getValDescription() {
return valDescription;
}
public void setValDescription(String valDescription) {
this.valDescription = valDescription;
}
public Date getEffectiveDate() {
return effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public Date getExpiredDate() {
return expiredDate;
}
public void setExpiredDate(Date expiredDate) {
this.expiredDate = expiredDate;
}
public String getAppendlxNotes() {
return appendlxNotes;
}
public void setAppendlxNotes(String appendlxNotes) {
this.appendlxNotes = appendlxNotes;
}
public Integer getConfirmStatus() {
return confirmStatus;
}
public void setConfirmStatus(Integer confirmStatus) {
this.confirmStatus = confirmStatus;
}
public String getConfirmBy() {
return confirmBy;
}
public void setConfirmBy(String confirmBy) {
this.confirmBy = confirmBy;
}
public Date getConfirmOn() {
return confirmOn;
}
public void setConfirmOn(Date confirmOn) {
this.confirmOn = confirmOn;
}
public Integer getDelFlag() {
return delFlag;
}
@Override
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Integer getByton() {
return byton;
}
public void setByton(Integer byton) {
this.byton = byton;
}
public Double getMinAmount() {
return minAmount;
}
public void setMinAmount(Double minAmount) {
this.minAmount = minAmount;
}
public Double getMaxAmount() {
return maxAmount;
}
public void setMaxAmount(Double maxAmount) {
this.maxAmount = maxAmount;
}
public Integer getIsFormat() {
return isFormat;
}
public void setIsFormat(Integer isFormat) {
this.isFormat = isFormat;
}
public Integer getVerifyFlag() {
return verifyFlag;
}
public void setVerifyFlag(Integer verifyFlag) {
this.verifyFlag = verifyFlag;
}
public String getReceiveMan() {
return receiveMan;
}
public void setReceiveMan(String receiveMan) {
this.receiveMan = receiveMan;
}
public String getPayMan() {
return payMan;
}
public void setPayMan(String payMan) {
this.payMan = payMan;
}
}

View File

@@ -0,0 +1,98 @@
package com.ag.entity.fee;
import com.ag.base.ISerializable;
public class TariffMultistep implements ISerializable {
private String id;
private String tenancyId;
private String tariffId;
private Integer startVal;
private Integer endVal;
private Double stepRate;
private Double discount;
private Integer eachDay;
private Double addRate;
private Integer delFlag;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getTariffId() {
return tariffId;
}
public void setTariffId(String tariffId) {
this.tariffId = tariffId;
}
public Integer getStartVal() {
return startVal;
}
public void setStartVal(Integer startVal) {
this.startVal = startVal;
}
public Integer getEndVal() {
return endVal;
}
public void setEndVal(Integer endVal) {
this.endVal = endVal;
}
public Double getStepRate() {
return stepRate;
}
public void setStepRate(Double stepRate) {
this.stepRate = stepRate;
}
public Double getDiscount() {
return discount;
}
public void setDiscount(Double discount) {
this.discount = discount;
}
public Integer getEachDay() {
return eachDay;
}
public void setEachDay(Integer eachDay) {
this.eachDay = eachDay;
}
public Double getAddRate() {
return addRate;
}
public void setAddRate(Double addRate) {
this.addRate = addRate;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,61 @@
package com.ag.entity.fee;
import java.util.Date;
public class TariffOperLog {
private String id;
private String contractName;
private String itemName;
private String description;
private String createdBy;
private Date createdOn;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getContractName() {
return contractName;
}
public void setContractName(String contractName) {
this.contractName = contractName;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
}

View File

@@ -0,0 +1,104 @@
package com.ag.entity.fee;
import com.ag.entity.fee.face.IRuleCondition;
/**
* CTariffRitem entity. @author MyEclipse Persistence Tools
*/
public class TariffRitem implements IRuleCondition {
// Fields
private String id;
private String tenancyId;
private String ruleId;
private String keyName;
private String operChar;
private String compareVal;
private String compareName;
private String comname1;
private Integer delFlag;
// Constructors
/** default constructor */
public TariffRitem() {
}
// Property accessors
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getTenancyId() {
return this.tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getRuleId() {
return ruleId;
}
public void setRuleId(String ruleId) {
this.ruleId = ruleId;
}
public String getKeyName() {
return this.keyName;
}
public void setKeyName(String keyName) {
this.keyName = keyName;
}
public String getOperChar() {
return this.operChar;
}
public void setOperChar(String operChar) {
this.operChar = operChar;
}
public String getCompareVal() {
return this.compareVal;
}
public void setCompareVal(String compareVal) {
this.compareVal = compareVal;
}
public String getCompareName() {
return compareName;
}
public void setCompareName(String compareName) {
this.compareName = compareName;
}
public String getComname1() {
return comname1;
}
public void setComname1(String comname1) {
this.comname1 = comname1;
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
}

View File

@@ -0,0 +1,20 @@
package com.ag.entity.fee.face;
/**
* Created by Administrator on 2018-03-17.
*/
public interface IBulkTon {
Double getTon();//根据择大计收规则生成最终的计费吨
void setTon(Double ton);
Double getVolume();//体积
Double getWeight();//重量
default double getOverWeight(){
return 0;
}
default void setOverWeight(double overWeight){
}
}

View File

@@ -0,0 +1,48 @@
package com.ag.entity.fee.face;
/**
* Created by Administrator on 2017/7/11 0011.
*/
public interface ICondition {
String billNo = "billNo";//提单号
String cntr = "cntr";//箱号,逗号分割
String itemId = "itemId";//费目编号
String vid = "vid";//船号
String cntrId = "cntrId";//箱批次号,逗号分割
String ieId = "ieId";//进出口状态
String TIME_ON = "TIME_ON";//时间起始
String TIME_END = "TIME_END";//时间截止
String LAST_ACCOUNT_ON = "LAST_ACCOUNT_ON";//上次结算日期
String companyId = "companyId";//船公司
String shipperId = "shipperId";//货主
String planTime = "planTime";//计划提箱时间
String lclId = "lclId";//是否拼箱0=整箱1=散货和拼柜
String rpId = "rpId";//设备交接单号
//String eventId = "eventId";//计费事件
String tradeId = "tradeId";//外贸=1内贸=2
String tcId = "tcId";//转关标志0=否1=是
String isStorage = "isStorage";//是否入库null=否1=是
String weight = "weight";//重量
String volume = "volume";//体积
String outStoreId = "outStoreId";//出库编号
String billType = "billType";//提单类型
String isPrepare = "isPrepare";//预插电
String CARGO_TYPE = "CARGO_TYPE";//货类
String CARGO_NAME = "CARGO_NAME";//货名
String RATE = "RATE";//费率冗余,显示用
String DEFAULT_CURRENCY = "CNY";//默认币种
String QUANTITY = "QUANTITY";//作业量
String LIN_ID = "LIN_ID";//营运人编码
String CAR_AGE = "CAR_AGE";//货代编码
String DERATE_TYPE = "DERATE_TYPE";//前免=0后免=2
String DERATE_DAY = "DERATE_DAY";//减免天
String DERATE_MONEY = "DERATE_MONEY";//减免金额
String DISCOUNT = "DISCOUNT";//折扣, 100
String C_CLIENT_TYPE = "C_CLIENT_TYPE";//客户类型代码
String CURRENCY_RATIO = "CURRENCY_RATIO";//应收/应付兑换比例cny/usd=8
}

View File

@@ -0,0 +1,31 @@
package com.ag.entity.fee.face;
import com.ag.entity.account.vo.BizVO;
/**
* Created by Administrator on 2017/7/11 0011.
*/
public interface IFeeBase {
/**
* 调用计费并直接保存到 费用明细,无返回值
*/
default void call(String reqStr){}
/**
* 返回费用明细集合
* return List<FeeDetail>
*/
default String callback(String reqStr){
return null;
}
/**
* 返回数据源+费用明细集合
* return List<SourceAndFeeDetail>
*/
default String callbackSource(String reqStr){
return null;
}
}

View File

@@ -0,0 +1,18 @@
package com.ag.entity.fee.face;
/**
* Created by Administrator on 2017/6/8 0008.
* 费率条件,计减免条件
*/
public interface IRuleCondition {
String getRuleId();
String getKeyName();
String getOperChar();
String getCompareVal();
}

View File

@@ -0,0 +1,94 @@
package com.ag.entity.fee.face;
import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yangxh on 2019/8/1.
*/
public class ReqSource implements Serializable {
private String tenancyId;//租户(必填)
private String contractId;//合同号(选填)
private String accountPointCode;//计费事件(与费目编号二选一)
private String itemId;//费目编号(与计费事件二选一)
private String operMan;//操作员(必填)
private List<SourceProperty> sourceProperties = new ArrayList<>();//数据源计算属性
private String categoryId;//港杂费001堆存费002
private JSONObject other = new JSONObject();
private String exceptionId;
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getContractId() {
return contractId;
}
public void setContractId(String contractId) {
this.contractId = contractId;
}
public String getAccountPointCode() {
return accountPointCode;
}
public void setAccountPointCode(String accountPointCode) {
this.accountPointCode = accountPointCode;
}
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getOperMan() {
return operMan;
}
public void setOperMan(String operMan) {
this.operMan = operMan;
}
public List<SourceProperty> getSourceProperties() {
return sourceProperties;
}
public void setSourceProperties(List<SourceProperty> sourceProperties) {
this.sourceProperties = sourceProperties;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId;
}
public JSONObject getOther() {
return other;
}
public void setOther(JSONObject other) {
this.other = other;
}
public String getExceptionId() {
return exceptionId;
}
public void setExceptionId(String exceptionId) {
this.exceptionId = exceptionId;
}
}

View File

@@ -0,0 +1,145 @@
package com.ag.entity.fee.face;
import com.ag.entity.account.FeeDetail;
import com.ag.entity.fee.ContractItem;
import com.ag.entity.fee.vo.TariffVO;
import com.alibaba.fastjson.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by yangxh on 2019/8/1.
*/
public class SourceProperty implements Serializable {
/**
* 调用方参数
*/
private String bizId;//业务编号(必填)
private String bizTime;//业务时间(必填)
private String bizType;//业务类别代码(提供给报表使用, SH=舱单RE=设备交接单HI=整柜堆存ST=仓储RF=插拔电BC=散货拖运)
private JSONObject property = new JSONObject();//计费属性
private JSONObject spare = new JSONObject();//备用map, 计费调用方预留属性, 计费不使用.
/**
* 计费用参数
*/
private Integer criteriaNum;
private String sort;
private TariffVO tariffVO;
private ContractItem contractItem;
private FeeDetail payDetail;
private FeeDetail receiveDetail;
private TariffVO derateTariff;//带减免规则的费率
/**
* 返回给调用方
*/
private List<TariffVO> backTariffs = new ArrayList<>();
public String getBizId() {
return bizId;
}
public void setBizId(String bizId) {
this.bizId = bizId;
}
public String getBizTime() {
return bizTime;
}
public void setBizTime(String bizTime) {
this.bizTime = bizTime;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public JSONObject getProperty() {
return property;
}
public void setProperty(JSONObject property) {
this.property = property;
}
public Integer getCriteriaNum() {
return criteriaNum;
}
public void setCriteriaNum(Integer criteriaNum) {
this.criteriaNum = criteriaNum;
}
public String getSort() {
return sort;
}
public void setSort(String sort) {
this.sort = sort;
}
public TariffVO getTariffVO() {
return tariffVO;
}
public void setTariffVO(TariffVO tariffVO) {
this.tariffVO = tariffVO;
}
public ContractItem getContractItem() {
return contractItem;
}
public void setContractItem(ContractItem contractItem) {
this.contractItem = contractItem;
}
public FeeDetail getPayDetail() {
return payDetail;
}
public void setPayDetail(FeeDetail payDetail) {
this.payDetail = payDetail;
}
public FeeDetail getReceiveDetail() {
return receiveDetail;
}
public void setReceiveDetail(FeeDetail receiveDetail) {
this.receiveDetail = receiveDetail;
}
public TariffVO getDerateTariff() {
return derateTariff;
}
public void setDerateTariff(TariffVO derateTariff) {
this.derateTariff = derateTariff;
}
public JSONObject getSpare() {
return spare;
}
public void setSpare(JSONObject spare) {
this.spare = spare;
}
public List<TariffVO> getBackTariffs() {
return backTariffs;
}
public void setBackTariffs(List<TariffVO> backTariffs) {
this.backTariffs = backTariffs;
}
}

View File

@@ -0,0 +1,41 @@
package com.ag.entity.fee.vo;
import com.ag.entity.fee.BaseChargingItem;
import com.ag.entity.fee.ContractItem;
import com.ag.entity.fee.ItemProperties;
import java.util.List;
/**
* Created by Administrator on 2017/6/1 0001.
*/
public class ContractItemVO extends ContractItem {
private List<TariffVO> tariffLst;//一级费率(费率表客户为空)
private BaseChargingItem baseItem;
private List<ItemProperties> itemProperties;
public List<TariffVO> getTariffLst() {
return tariffLst;
}
public void setTariffLst(List<TariffVO> tariffLst) {
this.tariffLst = tariffLst;
}
public BaseChargingItem getBaseItem() {
return baseItem;
}
public void setBaseItem(BaseChargingItem baseItem) {
this.baseItem = baseItem;
}
public List<ItemProperties> getItemProperties() {
return itemProperties;
}
public void setItemProperties(List<ItemProperties> itemProperties) {
this.itemProperties = itemProperties;
}
}

View File

@@ -0,0 +1,32 @@
package com.ag.entity.fee.vo;
import com.ag.entity.fee.Contract;
import java.util.List;
/**
* Created by Administrator on 2017/5/6 0006.
*/
public class ContractVO extends Contract {
private List<ContractItemVO> itemLst;
public List<ContractItemVO> getItemLst() {
return itemLst;
}
public void setItemLst(List<ContractItemVO> itemLst) {
this.itemLst = itemLst;
}
private String dateFormat;
public String getDateFormat() {
return dateFormat;
}
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
}

View File

@@ -0,0 +1,30 @@
package com.ag.entity.fee.vo;
import com.ag.entity.account.FeeDetail;
import com.ag.entity.fee.face.SourceProperty;
import java.util.List;
/**
* Created by yangxh on 2019/8/23.
*/
public class SourceAndFeeDetail {
private SourceProperty source;
private List<FeeDetail> feeDetails;
public SourceProperty getSource() {
return source;
}
public void setSource(SourceProperty source) {
this.source = source;
}
public List<FeeDetail> getFeeDetails() {
return feeDetails;
}
public void setFeeDetails(List<FeeDetail> feeDetails) {
this.feeDetails = feeDetails;
}
}

View File

@@ -0,0 +1,34 @@
package com.ag.entity.fee.vo;
import com.ag.entity.fee.Tariff;
import com.ag.entity.fee.TariffMultistep;
import com.ag.entity.fee.TariffRitem;
import com.ag.entity.fee.face.IRuleCondition;
import java.util.List;
/**
* CTariff entity. @author MyEclipse Persistence Tools
*/
public class TariffVO extends Tariff {
private List<TariffRitem> ritemList;//费率条件
private List<TariffMultistep> stepList;//阶梯费率
public void setRitemList(List<TariffRitem> ritemList) {
this.ritemList = ritemList;
}
public List<TariffMultistep> getStepList() {
return stepList;
}
public List<TariffRitem> getRitemList() {
return ritemList;
}
public void setStepList(List<TariffMultistep> stepList) {
this.stepList = stepList;
}
}

View File

@@ -0,0 +1,118 @@
package com.ag.entity.log;
import com.ag.base.ISerializable;
import java.util.Date;
public class DefineLogConfig implements ISerializable {
private String id;
private String bizCol;
private String keywordCol;
private String bizType;
private String menuName;
private String bean;
private String method;
private String createdBy;
private java.util.Date createdOn;
private String updatedBy;
private java.util.Date updatedOn;
private String controlName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getBizCol() {
return bizCol;
}
public void setBizCol(String bizCol) {
this.bizCol = bizCol;
}
public String getKeywordCol() {
return keywordCol;
}
public void setKeywordCol(String keywordCol) {
this.keywordCol = keywordCol;
}
public String getBizType() {
return bizType;
}
public void setBizType(String bizType) {
this.bizType = bizType;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getBean() {
return bean;
}
public void setBean(String bean) {
this.bean = bean;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getControlName() {
return controlName;
}
public void setControlName(String controlName) {
this.controlName = controlName;
}
}

View File

@@ -0,0 +1,528 @@
package com.ag.entity.topic;
import java.util.Date;
public class RemqMsgCustom {
private String assignReceiveMan;
public String getAssignReceiveMan() {
return assignReceiveMan;
}
public void setAssignReceiveMan(String assignReceiveMan) {
this.assignReceiveMan = assignReceiveMan;
}
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.ID
*
* @mbggenerated
*/
private String id;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.BUSINESS_KEY
*
* @mbggenerated
*/
private String businessKey;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.BUSINESS_TYPE
*
* @mbggenerated
*/
private String businessType;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.BUSINESS_URL
*
* @mbggenerated
*/
private String businessUrl;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.MSG_INFO
*
* @mbggenerated
*/
private String msgInfo;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.RECEIVE_FLAG
*
* @mbggenerated
*/
private String receiveFlag;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.RECEIVE_TIM
*
* @mbggenerated
*/
private Date receiveTim;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.CREATED_BY
*
* @mbggenerated
*/
private String createdBy;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.CREATED_ON
*
* @mbggenerated
*/
private Date createdOn;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.UPDATED_BY
*
* @mbggenerated
*/
private String updatedBy;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.UPDATED_ON
*
* @mbggenerated
*/
private Date updatedOn;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.CHAT_NAME
*
* @mbggenerated
*/
private String chatName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.SR_FLAG
*
* @mbggenerated
*/
private String srFlag;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.RE_USER_ID
*
* @mbggenerated
*/
private String reUserId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.PARENT_ID
*
* @mbggenerated
*/
private String parentId;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column REMQ_MSG_CUSTOM.MSG_ID
*
* @mbggenerated
*/
private String msgId;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.ID
*
* @return the value of REMQ_MSG_CUSTOM.ID
*
* @mbggenerated
*/
public String getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.ID
*
* @param id the value for REMQ_MSG_CUSTOM.ID
*
* @mbggenerated
*/
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.BUSINESS_KEY
*
* @return the value of REMQ_MSG_CUSTOM.BUSINESS_KEY
*
* @mbggenerated
*/
public String getBusinessKey() {
return businessKey;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.BUSINESS_KEY
*
* @param businessKey the value for REMQ_MSG_CUSTOM.BUSINESS_KEY
*
* @mbggenerated
*/
public void setBusinessKey(String businessKey) {
this.businessKey = businessKey == null ? null : businessKey.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.BUSINESS_TYPE
*
* @return the value of REMQ_MSG_CUSTOM.BUSINESS_TYPE
*
* @mbggenerated
*/
public String getBusinessType() {
return businessType;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.BUSINESS_TYPE
*
* @param businessType the value for REMQ_MSG_CUSTOM.BUSINESS_TYPE
*
* @mbggenerated
*/
public void setBusinessType(String businessType) {
this.businessType = businessType == null ? null : businessType.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.BUSINESS_URL
*
* @return the value of REMQ_MSG_CUSTOM.BUSINESS_URL
*
* @mbggenerated
*/
public String getBusinessUrl() {
return businessUrl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.BUSINESS_URL
*
* @param businessUrl the value for REMQ_MSG_CUSTOM.BUSINESS_URL
*
* @mbggenerated
*/
public void setBusinessUrl(String businessUrl) {
this.businessUrl = businessUrl == null ? null : businessUrl.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.MSG_INFO
*
* @return the value of REMQ_MSG_CUSTOM.MSG_INFO
*
* @mbggenerated
*/
public String getMsgInfo() {
return msgInfo;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.MSG_INFO
*
* @param msgInfo the value for REMQ_MSG_CUSTOM.MSG_INFO
*
* @mbggenerated
*/
public void setMsgInfo(String msgInfo) {
this.msgInfo = msgInfo == null ? null : msgInfo.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.RECEIVE_FLAG
*
* @return the value of REMQ_MSG_CUSTOM.RECEIVE_FLAG
*
* @mbggenerated
*/
public String getReceiveFlag() {
return receiveFlag;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.RECEIVE_FLAG
*
* @param receiveFlag the value for REMQ_MSG_CUSTOM.RECEIVE_FLAG
*
* @mbggenerated
*/
public void setReceiveFlag(String receiveFlag) {
this.receiveFlag = receiveFlag == null ? null : receiveFlag.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.RECEIVE_TIM
*
* @return the value of REMQ_MSG_CUSTOM.RECEIVE_TIM
*
* @mbggenerated
*/
public Date getReceiveTim() {
return receiveTim;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.RECEIVE_TIM
*
* @param receiveTim the value for REMQ_MSG_CUSTOM.RECEIVE_TIM
*
* @mbggenerated
*/
public void setReceiveTim(Date receiveTim) {
this.receiveTim = receiveTim;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.CREATED_BY
*
* @return the value of REMQ_MSG_CUSTOM.CREATED_BY
*
* @mbggenerated
*/
public String getCreatedBy() {
return createdBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.CREATED_BY
*
* @param createdBy the value for REMQ_MSG_CUSTOM.CREATED_BY
*
* @mbggenerated
*/
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy == null ? null : createdBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.CREATED_ON
*
* @return the value of REMQ_MSG_CUSTOM.CREATED_ON
*
* @mbggenerated
*/
public Date getCreatedOn() {
return createdOn;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.CREATED_ON
*
* @param createdOn the value for REMQ_MSG_CUSTOM.CREATED_ON
*
* @mbggenerated
*/
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.UPDATED_BY
*
* @return the value of REMQ_MSG_CUSTOM.UPDATED_BY
*
* @mbggenerated
*/
public String getUpdatedBy() {
return updatedBy;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.UPDATED_BY
*
* @param updatedBy the value for REMQ_MSG_CUSTOM.UPDATED_BY
*
* @mbggenerated
*/
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.UPDATED_ON
*
* @return the value of REMQ_MSG_CUSTOM.UPDATED_ON
*
* @mbggenerated
*/
public Date getUpdatedOn() {
return updatedOn;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.UPDATED_ON
*
* @param updatedOn the value for REMQ_MSG_CUSTOM.UPDATED_ON
*
* @mbggenerated
*/
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.CHAT_NAME
*
* @return the value of REMQ_MSG_CUSTOM.CHAT_NAME
*
* @mbggenerated
*/
public String getChatName() {
return chatName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.CHAT_NAME
*
* @param chatName the value for REMQ_MSG_CUSTOM.CHAT_NAME
*
* @mbggenerated
*/
public void setChatName(String chatName) {
this.chatName = chatName == null ? null : chatName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.SR_FLAG
*
* @return the value of REMQ_MSG_CUSTOM.SR_FLAG
*
* @mbggenerated
*/
public String getSrFlag() {
return srFlag;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.SR_FLAG
*
* @param srFlag the value for REMQ_MSG_CUSTOM.SR_FLAG
*
* @mbggenerated
*/
public void setSrFlag(String srFlag) {
this.srFlag = srFlag == null ? null : srFlag.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.RE_USER_ID
*
* @return the value of REMQ_MSG_CUSTOM.RE_USER_ID
*
* @mbggenerated
*/
public String getReUserId() {
return reUserId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.RE_USER_ID
*
* @param reUserId the value for REMQ_MSG_CUSTOM.RE_USER_ID
*
* @mbggenerated
*/
public void setReUserId(String reUserId) {
this.reUserId = reUserId == null ? null : reUserId.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.PARENT_ID
*
* @return the value of REMQ_MSG_CUSTOM.PARENT_ID
*
* @mbggenerated
*/
public String getParentId() {
return parentId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.PARENT_ID
*
* @param parentId the value for REMQ_MSG_CUSTOM.PARENT_ID
*
* @mbggenerated
*/
public void setParentId(String parentId) {
this.parentId = parentId == null ? null : parentId.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column REMQ_MSG_CUSTOM.MSG_ID
*
* @return the value of REMQ_MSG_CUSTOM.MSG_ID
*
* @mbggenerated
*/
public String getMsgId() {
return msgId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column REMQ_MSG_CUSTOM.MSG_ID
*
* @param msgId the value for REMQ_MSG_CUSTOM.MSG_ID
*
* @mbggenerated
*/
public void setMsgId(String msgId) {
this.msgId = msgId == null ? null : msgId.trim();
}
}

View File

@@ -0,0 +1,395 @@
package com.ag.entity.webbuiler;
import java.util.Date;
public class WbCompany {
private String id;
private String cnName;
private String enName;
private String country;
private String companyNo;
private String shortName;
private String cnyBankName;
private String cnyBankNo;
private String usdBankName;
private String usdBankNo;
private String portCnName;
private String portEnName;
private String portCode;
private String cnAddress;
private String enAddress;
private String telephone;
private String fax;
private String email;
private String postalCode;
private String website;
private String sipgEdiCode;
private String ediCode;
private String dangerApplyCode;
private String agentDangerApplyCode;
private String customsCode;
private String dangerApplyMan;
private String agentDangerApplyMan;
private String agentCompanyCode;
private String telDangerApply;
private String pccEdiCode;
private String pccTelephone;
private String pccAddress;
private String logo;
private String notes;
private String deptId;
private String easipayCode;
private Date updatedOn;
private String updatedBy;
private String edoSendCod;
private String tinNo;
private String finOrgCode;
private String invCheckMan;
private String invPayMan;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCnName() {
return cnName;
}
public void setCnName(String cnName) {
this.cnName = cnName;
}
public String getEnName() {
return enName;
}
public void setEnName(String enName) {
this.enName = enName;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getCompanyNo() {
return companyNo;
}
public void setCompanyNo(String companyNo) {
this.companyNo = companyNo;
}
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public String getCnyBankName() {
return cnyBankName;
}
public void setCnyBankName(String cnyBankName) {
this.cnyBankName = cnyBankName;
}
public String getCnyBankNo() {
return cnyBankNo;
}
public void setCnyBankNo(String cnyBankNo) {
this.cnyBankNo = cnyBankNo;
}
public String getUsdBankName() {
return usdBankName;
}
public void setUsdBankName(String usdBankName) {
this.usdBankName = usdBankName;
}
public String getUsdBankNo() {
return usdBankNo;
}
public void setUsdBankNo(String usdBankNo) {
this.usdBankNo = usdBankNo;
}
public String getPortCnName() {
return portCnName;
}
public void setPortCnName(String portCnName) {
this.portCnName = portCnName;
}
public String getPortEnName() {
return portEnName;
}
public void setPortEnName(String portEnName) {
this.portEnName = portEnName;
}
public String getPortCode() {
return portCode;
}
public void setPortCode(String portCode) {
this.portCode = portCode;
}
public String getCnAddress() {
return cnAddress;
}
public void setCnAddress(String cnAddress) {
this.cnAddress = cnAddress;
}
public String getEnAddress() {
return enAddress;
}
public void setEnAddress(String enAddress) {
this.enAddress = enAddress;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
public String getSipgEdiCode() {
return sipgEdiCode;
}
public void setSipgEdiCode(String sipgEdiCode) {
this.sipgEdiCode = sipgEdiCode;
}
public String getEdiCode() {
return ediCode;
}
public void setEdiCode(String ediCode) {
this.ediCode = ediCode;
}
public String getDangerApplyCode() {
return dangerApplyCode;
}
public void setDangerApplyCode(String dangerApplyCode) {
this.dangerApplyCode = dangerApplyCode;
}
public String getAgentDangerApplyCode() {
return agentDangerApplyCode;
}
public void setAgentDangerApplyCode(String agentDangerApplyCode) {
this.agentDangerApplyCode = agentDangerApplyCode;
}
public String getCustomsCode() {
return customsCode;
}
public void setCustomsCode(String customsCode) {
this.customsCode = customsCode;
}
public String getDangerApplyMan() {
return dangerApplyMan;
}
public void setDangerApplyMan(String dangerApplyMan) {
this.dangerApplyMan = dangerApplyMan;
}
public String getAgentDangerApplyMan() {
return agentDangerApplyMan;
}
public void setAgentDangerApplyMan(String agentDangerApplyMan) {
this.agentDangerApplyMan = agentDangerApplyMan;
}
public String getAgentCompanyCode() {
return agentCompanyCode;
}
public void setAgentCompanyCode(String agentCompanyCode) {
this.agentCompanyCode = agentCompanyCode;
}
public String getTelDangerApply() {
return telDangerApply;
}
public void setTelDangerApply(String telDangerApply) {
this.telDangerApply = telDangerApply;
}
public String getPccEdiCode() {
return pccEdiCode;
}
public void setPccEdiCode(String pccEdiCode) {
this.pccEdiCode = pccEdiCode;
}
public String getPccTelephone() {
return pccTelephone;
}
public void setPccTelephone(String pccTelephone) {
this.pccTelephone = pccTelephone;
}
public String getPccAddress() {
return pccAddress;
}
public void setPccAddress(String pccAddress) {
this.pccAddress = pccAddress;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getEasipayCode() {
return easipayCode;
}
public void setEasipayCode(String easipayCode) {
this.easipayCode = easipayCode;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public String getEdoSendCod() {
return edoSendCod;
}
public void setEdoSendCod(String edoSendCod) {
this.edoSendCod = edoSendCod;
}
public String getTinNo() {
return tinNo;
}
public void setTinNo(String tinNo) {
this.tinNo = tinNo;
}
public String getFinOrgCode() {
return finOrgCode;
}
public void setFinOrgCode(String finOrgCode) {
this.finOrgCode = finOrgCode;
}
public String getInvCheckMan() {
return invCheckMan;
}
public void setInvCheckMan(String invCheckMan) {
this.invCheckMan = invCheckMan;
}
public String getInvPayMan() {
return invPayMan;
}
public void setInvPayMan(String invPayMan) {
this.invPayMan = invPayMan;
}
}

View File

@@ -0,0 +1,123 @@
package com.ag.entity.webbuiler;
public class WbDept {
private String deptId;
private String deptName;
private String parentDept;
private Double orderIndex;
private String isTenancy;
private String isWeb;
private String tenancyId;
private String telephone;
private String fax;
private String email;
private String isDept;
private String groupId;
private String financeCod;
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getParentDept() {
return parentDept;
}
public void setParentDept(String parentDept) {
this.parentDept = parentDept;
}
public Double getOrderIndex() {
return orderIndex;
}
public void setOrderIndex(Double orderIndex) {
this.orderIndex = orderIndex;
}
public String getIsTenancy() {
return isTenancy;
}
public void setIsTenancy(String isTenancy) {
this.isTenancy = isTenancy;
}
public String getIsWeb() {
return isWeb;
}
public void setIsWeb(String isWeb) {
this.isWeb = isWeb;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getIsDept() {
return isDept;
}
public void setIsDept(String isDept) {
this.isDept = isDept;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getFinanceCod() {
return financeCod;
}
public void setFinanceCod(String financeCod) {
this.financeCod = financeCod;
}
}

View File

@@ -0,0 +1,60 @@
package com.ag.entity.webbuiler;
public class WbDeptPerm {
private String id;
private String deptId;
private String dataDeptId;
private String dataDeptName;
private String dataGroupCode;
private String groupCode;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getDataDeptId() {
return dataDeptId;
}
public void setDataDeptId(String dataDeptId) {
this.dataDeptId = dataDeptId;
}
public String getDataDeptName() {
return dataDeptName;
}
public void setDataDeptName(String dataDeptName) {
this.dataDeptName = dataDeptName;
}
public String getDataGroupCode() {
return dataGroupCode;
}
public void setDataGroupCode(String dataGroupCode) {
this.dataGroupCode = dataGroupCode;
}
public String getGroupCode() {
return groupCode;
}
public void setGroupCode(String groupCode) {
this.groupCode = groupCode;
}
}

View File

@@ -0,0 +1,57 @@
package com.ag.topic;
/**
* @description: 返回
* @author: WangN
* @create: 2019-11-13
*/
public class BaseResponse<T> {
/**
* 是否成功
*/
private boolean success;
/**
* 说明
*/
private String msg;
/**
* 返回数据
*/
private T data;
public BaseResponse() {
}
public BaseResponse(boolean success, String msg, T data) {
this.success = success;
this.msg = msg;
this.data = data;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

View File

@@ -0,0 +1,62 @@
package com.ag.topic;
import com.ag.entity.topic.RemqMsgCustom;
import com.ag.util.ResourceUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newFixedThreadPool;
/**
* @description: redis频道
* @author: WangN
* @create: 2019-10-15
*/
public interface IRedisTopicCtl {
/**
* 获取所有频道信息
* @return
*/
default String getChannel() {
return null;
}
/**
* 发送消息
* @param
* @return
*/
default void send(RemqMsgCustom remqMsgCustom, String channel){
}
/**
* 更新频道信息
* @return
*/
default void putTopic(){
}
/**
* 初始化 redis 频道订阅
*/
default void initRdsChannel(){
}
/**
* 初始化 用户-频道 信息到redis
*/
default void initChannelToUser(){
}
}

View File

@@ -0,0 +1,16 @@
package com.ag.util;
import java.util.Base64;
public class Base64Util {
public static String encode(String string){
Base64.Encoder encoder = Base64.getEncoder();
return encoder.encodeToString(string.getBytes());
}
public static String decode(String string){
Base64.Decoder decoder = Base64.getDecoder();
return new String(decoder.decode(string));
}
}

View File

@@ -0,0 +1,277 @@
package com.ag.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by shaoqiang on 8/28/16.
*/
public class CommonUtil {
/**
* 返回表格的beanlist
* @param object
* @param controlName
* @param cudType
* @param objeclass
* @return
*/
public static List getBeanlist(JSONObject object, String controlName, String cudType, Class objeclass){
if (StrUtil.isEmpty(controlName)){
controlName = "datatable";
}
String datarec1=((com.alibaba.fastjson.JSONObject) JSON.parseArray(object.getString(controlName)).get(0)).get(cudType).toString();
return JSON.parseArray(datarec1, objeclass);
}
/**
* 获取grid中需强制更新的列名
* @param controlName
* @return
*/
public static String[] getNeedColsByJson(JSONObject object, String controlName){
if (StrUtil.isEmpty(controlName)){
controlName = "datatable";
}
String[] keys = null;
JSONArray jsonArray = JSON.parseArray(object.getString(controlName)).getJSONObject(0).getJSONArray("update");
if (!jsonArray.isEmpty()){
com.alibaba.fastjson.JSONObject jsonObject = jsonArray.getJSONObject(0);
Set<String> keySet = jsonObject.keySet();
keySet.removeIf(key -> key.contains("#"));
keys = new String[keySet.size()];
keySet.toArray(keys);
}
return keys;
}
public static String[] getNeedColsByJsonStr(String jsonStr){
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(jsonStr);
Set<String> keySet = jsonObject.keySet();
keySet.removeIf(key -> key.contains("#"));
String[] keys = new String[keySet.size()];
keySet.toArray(keys);
return keys;
}
/**
* 返回编辑表格的json数据
* @param object
* @param dataparam 获取数据参数
* @param type 参数类型 包括create ,destory,update
* @return
*/
public static String parseJson(JSONObject object,String dataparam,String type){
return ((com.alibaba.fastjson.JSONObject) JSON.parseArray(object.getString(dataparam)).get(0)).get(type).toString();
}
public static String SendGET(String url,String param){
String result="";//访问返回结果
BufferedReader read=null;//读取访问结果
try {
//创建url
URL realurl=new URL(url+"?"+param);
//打开连接
URLConnection connection=realurl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
//建立连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段获取到cookies等
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
read = new BufferedReader(new InputStreamReader(
connection.getInputStream(),"UTF-8"));
String line;//循环读取
while ((line = read.readLine()) != null) {
result += line;
}
} catch (IOException e) {
e.printStackTrace();
}finally{
if(read!=null){//关闭流
try {
read.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
public static String time()
{
Date date=new Date();
DateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time=format.format(date);
return time;
}
/**
* 字符串转化为日期格式
* @param date
* @param format
* @return
*/
public static Date getDate(String date,String format){
DateFormat ds=new SimpleDateFormat(format);
Date date1=new Date();
try {
date1= ds.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return date1;
}
/**
* 获取时间函数
* @return
*/
public static Date getNowDate(){
Date nowDate=new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
nowDate=sdf.parse(sdf.format(new Date()));
} catch (ParseException e) {
e.printStackTrace();
}
return nowDate;
};
/**
* 驼峰写法转表字段
* @param JsonString
* @return
*/
public static String upJson(String JsonString) {
if (JsonString == null) {
return "";
}
JSONArray jsonArray = JSONArray.parseArray(JsonString);
List jsonList = new ArrayList();
for (int i = 0; jsonArray != null && i < jsonArray.size(); i++) {
Map jsonMap = new HashMap();
com.alibaba.fastjson.JSONObject jsonObject = jsonArray.getJSONObject(i);
if (jsonObject != null) {
Set<String> set = jsonObject.keySet();
for (String key : set) {
jsonMap.put(underscoreName(key), jsonObject.get(key));
}
jsonList.add(jsonMap);
}
}
//关闭引用检测后,重复引用对象时就不会被$ref代替但是在循环引用时也会导致StackOverflowError异常。
return JSON.toJSONString(jsonList, SerializerFeature.DisableCircularReferenceDetect);
}
/**
* 处理字符
* @param name
* @return
*/
public static String underscoreName(String name) {
StringBuilder result = new StringBuilder();
if (name != null && name.length() > 0) {
// 将第一个字符处理成大写
result.append(name.substring(0, 1).toUpperCase());
// 循环处理其余字符
for (int i = 1; i < name.length(); i++) {
String s = name.substring(i, i + 1);
// 在大写字母前添加下划线
if (s.equals(s.toUpperCase())
&& !Character.isDigit(s.charAt(0))) {
result.append("_");
}
// 其他字符直接转成大写
result.append(s.toUpperCase());
}
}
return result.toString();
}
public static boolean existsField(Class clz,String fieldName){
try{
return clz.getDeclaredField(fieldName)!=null;
}
catch(Exception e){
//throw new RuntimeException(e.getCause());
}
if(clz!=Object.class){
return existsField(clz.getSuperclass(),fieldName);
}
return false;
}
/**
* 不够位数的在前面补0保留code的长度位数字
* @param code
* @return
*/
public static String autoGenericCode(String code) {
String result = "";
// 保留code的位数
result = String.format("%0" + code.length() + "d", Integer.parseInt(code));
return result;
}
/**
* 不够位数的在前面补0保留num的长度位数字
* @param code
* @return
*/
public static String autoGenericCode(String code, int num) {
String result = "";
// 保留num的位数
// 0 代表前面补充0
// num 代表长度为4
// d 代表参数为正数型
result = String.format("%0" + num + "d", Integer.parseInt(code));
return result;
}
/**
* 获取文件路径
* @return
*/
public static String getPath() {
String str = CommonUtil.class.getResource("/").getPath();
String basicPath = str.substring(0, str.indexOf("target"));
String path = basicPath + "target/QhdImtos/wb/document/";
return path;
}
public static void main(String args[]){
/* String port="9090";
String ports[]=port.split(",");
System.out.println(ports[0]);*/
int a=2;
int b=4;
a=a^b^a;
b=b^a^b;
System.out.println(a+"==="+b);
}
}

View File

@@ -0,0 +1,409 @@
package com.ag.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson.JSON;
import org.apache.poi.POIXMLDocument;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
* @Title excel导入操作类
* @Package
* @ClassName: ExcelPoiUtil
* @Description: TODO(导入操作类)
* @author gxw
* @date 2016-9-18 下午05:51:15
* @verson
*/
public class ExcelPoiUtil {
/**
* 转换excle 2003和2007
* @param in
* @return
* @throws IOException
* @throws InvalidFormatException
*/
public static Workbook create(InputStream in) throws
IOException,InvalidFormatException {
if (!in.markSupported()) {
in = new PushbackInputStream(in, 8);
}
if (POIFSFileSystem.hasPOIFSHeader(in)) {
return new HSSFWorkbook(in);
}
if (POIXMLDocument.hasOOXMLHeader(in)) {
return new XSSFWorkbook(OPCPackage.open(in));
}
throw new IllegalArgumentException("你的excel版本目前poi解析不了");
}
/**
* 获取excel数据list
*
* @Title
* @Description TODO(获取excel数据list)
* @param stream
* @param startRow
* @param startCell
* *@param sheetIndex
* @return
*/
public static List<HashMap<Integer, String>> readExcelEmptyBody(InputStream stream, int startRow,
int endRow, int startCell, int endCell, int sheetIndex) {
if (startRow < endRow && endRow != -1) {
return null;
}
if (startCell < endCell && endCell != -1) {
return null;
}
Workbook wb =null;
List<HashMap<Integer, String>> resultList = new ArrayList<HashMap<Integer, String>>();
try {
wb = create(stream);
} catch (InvalidFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Sheet sheet=null;
int sheets= wb.getNumberOfSheets();
int rows=0;
for(int m=0;m<sheets;m++){
rows = wb.getSheetAt(m).getLastRowNum();
if(rows>0){
sheet = wb.getSheetAt(m);
break;
}
}
if(endRow != -1) {
rows = endRow;
}
for (int i = startRow; i <= rows; i++) {
Row row = sheet.getRow(i);
if(row == null){
continue;
}
int cells = row.getLastCellNum();
if (endCell != -1) {
cells = endCell;
}
int count = 0;
HashMap<Integer, String> cellMap = new HashMap<Integer, String>();
for (int j = startCell; j <= cells; j++) {
Cell cell = row.getCell(j);
String cellStr = getStringCellValue(cell);
//System.out.print("\t" + cellStr);
if(cellStr!=""||!cellStr.equals(""))
cellMap.put(count, cellStr);
count++;
}
resultList.add(cellMap);
}
return resultList;
}
/**
* 获取excel数据list
*
* @Title
* @Description TODO(获取excel数据list)
* @param stream
* @param startRow 开始行数 从0 开始
* @param startCell 开始列
* @param endCell 开始列
* @param startCell 开始列
* *@param sheetIndex
* @return
*/
public static List readExcelBody(InputStream stream, int startRow,
int endRow, int startCell, int endCell, int sheetIndex) {
if (startRow < endRow && endRow != -1) {
return null;
}
if (startCell < endCell && endCell != -1) {
return null;
}
List resultList = new ArrayList();
try {
Workbook wb = create(stream);
Sheet sheet = wb.getSheetAt(sheetIndex);
int rows = sheet.getLastRowNum();
if (rows <= 0) {
sheet = wb.getSheetAt(wb.getActiveSheetIndex());
rows = sheet.getLastRowNum();
}
if (endRow != -1) {
rows = endRow;
}
for (int i = startRow; i <= rows; i++) {
Row row = sheet.getRow(i);
if (row == null) continue;
int cells = row.getLastCellNum();
if (endCell != -1) {
cells = endCell;
}
if (cells==-1)
{
continue;
}
int count = 0;
Map cellMap = new HashMap();
for (int j = startCell; j <= cells; j++) {
Cell cell = row.getCell(j);
String cellStr = getStringCellValue(cell);
cellMap.put(count, cellStr);
count++;
}
resultList.add(cellMap);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
List<Integer> nullArr = new ArrayList<Integer>();
nullArr.add(null);
resultList.removeAll(nullArr);
return resultList;
}
/**
* 获取excel数据list
*
* @Title
* @Description TODO(获取excel数据list)
* @param stream
* @param startRow
* @param startCell
* *@param sheetName 使用工作表的名称
* @return
*/
public static List readExcelBody(InputStream stream, int startRow,
int endRow, int startCell, int endCell, String sheetName) {
if (startRow < endRow && endRow != -1) {
return null;
}
if (startCell < endCell && endCell != -1) {
return null;
}
List resultList = new ArrayList();
try {
Workbook wb = create(stream);
Sheet sheet = wb.getSheet(sheetName);
int rows = sheet.getLastRowNum();
if (endRow != -1) {
rows = endRow;
}
for (int i = startRow; i <= rows; i++) {
Row row = sheet.getRow(i);
int cells = row.getLastCellNum();
if (endCell != -1) {
cells = endCell;
}
if (cells==-1)
{
continue;
}
int count = 0;
Map cellMap = new HashMap();
for (int j = startCell; j <= cells; j++) {
Cell cell = row.getCell(j);
String cellStr = getStringCellValue(cell);
cellMap.put(count, cellStr);
count++;
}
resultList.add(cellMap);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
List<Integer> nullArr = new ArrayList<Integer>();
nullArr.add(null);
resultList.removeAll(nullArr);
return resultList;
}
/**
*
* @Title 获取列值string
* @Description TODO(这里用一句话描述这个方法的作用)
* @param cell
* @return
*/
private static String getStringCellValue(Cell cell) {
String strCell = "";
if (cell == null) {
return "";
}
switch (cell.getCellType()) {
case Cell.CELL_TYPE_FORMULA:
try {
/*
* 此处判断使用公式生成的字符串有问题因为HSSFDateUtil.isCellDateFormatted(cell)判断过程中cell
* .getNumericCellValue();方法会抛出java.lang.NumberFormatException异常
*/
if (HSSFDateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
strCell = sdf.format(date);
// strCell = (date.getYear() + 1900) + "-" +
// (date.getMonth() + 1) +"-" +
// date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
break;
} else {
strCell = String.valueOf(cell.getNumericCellValue());
}
} catch (IllegalStateException e) {
strCell = String.valueOf(cell.getRichStringCellValue());
}
break;
case Cell.CELL_TYPE_STRING:
strCell = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {
double d = cell.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(d);
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
strCell = sdf.format(date);
break;
} else {
//strCell = String.valueOf(cell.getNumericCellValue());
DecimalFormat df = new DecimalFormat("0");
strCell = df.format(cell.getNumericCellValue());
break;
}
case Cell.CELL_TYPE_BOOLEAN:
strCell = String.valueOf(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_BLANK:
strCell = "";
break;
default:
strCell = "";
break;
}
return strCell;
}
//判断Excel表格是否有内容
public static int excelIsNull(InputStream stream) {
int rows = 0;
try {
Workbook wb = new HSSFWorkbook(stream);
Sheet sheet = wb.getSheetAt(0);
rows = sheet.getLastRowNum();
} catch (Exception ex) {
ex.printStackTrace();
}
return rows;
}
public static List<List<Object>> readExcel(String filePath) {
ExcelReader reader = ExcelUtil.getReader(filePath);
/*Iterator<Row> iterRow = reader.getWorkbook().getSheetAt(0).rowIterator();
while(iterRow.hasNext()){
Row row = iterRow.next();
Iterator<Cell> iterCell = row.cellIterator();
while(iterCell.hasNext()){
Cell cell = iterCell.next();
if (cell.getCellFormula())
System.out.println(cell.getStringCellValue());
}
}*/
return reader.read();
}
public static List<List<Object>> readExcel(InputStream inputStream) {
ExcelReader reader = ExcelUtil.getReader(inputStream);
return reader.read();
}
public static List<List<Object>> readExcel(File file) {
ExcelReader reader = ExcelUtil.getReader(file);
return reader.read();
}
public static void writeExcel(List<List<?>> data, String filePath, boolean isWriteKeyAsHead){
ExcelWriter writer = ExcelUtil.getWriter(filePath);
writer.write(data, isWriteKeyAsHead);
writer.close();
}
public static void downloadXls(List<List<?>> data, String fileName, boolean isWriteKeyAsHead, HttpServletResponse response) throws IOException {
// 通过工具类创建writer默认创建xls格式
ExcelWriter writer = ExcelUtil.getWriter();
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(data, isWriteKeyAsHead);
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+fileName+".xls");
ServletOutputStream out=response.getOutputStream();
writer.flush(out, true);
writer.close();
IoUtil.close(out);
}
public static void downloadXlsx(List<List<?>> data, String fileName, boolean isWriteKeyAsHead, HttpServletResponse response) throws IOException {
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(data, isWriteKeyAsHead);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename="+fileName+".xlsx");
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
writer.close();
IoUtil.close(out);
}
public static void main(String[] args) {
//List<List<Object>> data = ExcelPoiUtil.readExcel("e:\\data.xlsx");
//System.out.println(JSON.toJSONString(data));
List<String> row1 = CollUtil.newArrayList("aa", "bb", "cc", "dd");
List<String> row2 = CollUtil.newArrayList("aa1", "bb1", "cc1", "dd1");
List<List<?>> rows = CollUtil.newArrayList(row1, row2);
ExcelPoiUtil.writeExcel(rows, "e:\\test.xlsx", true);
}
}

View File

@@ -0,0 +1,84 @@
package com.ag.util;
import java.io.*;
import java.util.*;
/**
* Created by yangxh on 2021/6/3.
*/
public class GenCategoryAttrItemHandler {
private final static String INPUT_FILE_PATH = "E:\\npc.txt";
private final static String OUTPUT_FLIE_PATH = "E:\\npc_site.txt";
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
List<String> source = getDataFromFile();
List<String[]> tmp = new ArrayList<>();
List<String> target = new ArrayList<>();
for (String str : source){
str = str.replace("|", ",");
tmp.add(str.split(","));
}
for (String[] arr : tmp){
arr[2] = String.format("%04d", Integer.valueOf(arr[2])).substring(0, 3)+"x";
arr[3] = String.format("%04d", Integer.valueOf(arr[3]));
arr[4] = arr[4].replace(" ","");
String str = arr[2]+"_"+arr[3]+","+arr[4]+"__"+arr[0]+";"+arr[1];
target.add(str);
}
Collections.sort(target);
writeDataToFile(target);
}
/**
* 从文件提取数据,格式化到程序中
* @throws IOException
*/
public static List<String> getDataFromFile() throws IOException {
List<String> list = new ArrayList<>();
BufferedReader br = null;
try {
File file = new File(INPUT_FILE_PATH);
br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));
String line;
while (null != (line=br.readLine())) {
list.add(line);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != br) {
br.close();
}
}
return list;
}
/**
* 将格式化的数据写入文件中
* @throws IOException
*/
public static void writeDataToFile(List<String> list) throws IOException {
BufferedWriter bw = null;
try {
File file = new File(OUTPUT_FLIE_PATH);
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
for (String str : list) {
bw.write(str); // 将数据写入文件中
bw.newLine(); // 新建一个换行符
bw.flush();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (null != bw) {
bw.close();
}
}
}
}

View File

@@ -0,0 +1,240 @@
package com.ag.util;
import com.alibaba.fastjson.JSON;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
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.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpRequestor {
private static String charset = "utf-8";
private static Log log = LogFactory.getLog(HttpRequestor.class);
public static String Content_Type_FORM = "application/x-www-form-urlencoded;charset=utf-8";
public static String Content_Type_UPLOAD = "multipart/form-data;charset=utf-8";
public static String Content_Type_JSON = "application/json;charset=utf-8";
public static String Content_Type_HTML = "text/html;charset=utf-8";
public static String Content_Type_XML = "text/xml;charset=utf-8";
/**
* Do GET request
*/
public static String doGet(String url) {
try {
HttpClient client = createHttpsClient();
//发送get请求
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
/**请求发送成功,并得到响应**/
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
/**读取服务器返回过来的json字符串数据**/
return EntityUtils.toString(response.getEntity());
}
}
catch (Exception e) {
log.error("请求失败!" + e.getLocalizedMessage());
e.printStackTrace();
}
return null;
}
/**
* post请求(用于key-value格式的参数)
*/
public static String doPost(String url, Map params){
String result = "";
try {
// 定义HttpClient
CloseableHttpClient client = createHttpsClient();
// 实例化HTTP方法
HttpPost httppost = new HttpPost();
httppost.setURI(new URI(url));
//设置参数
List<NameValuePair> nvps = new ArrayList<>();
for (Object key : params.keySet()) {
String name = (String)key;
String value = String.valueOf(params.get(name));
nvps.add(new BasicNameValuePair(name, value));
//System.out.println(name +"-"+value);
}
httppost.setEntity(new UrlEncodedFormEntity(nvps, charset));
HttpResponse response = client.execute(httppost);
HttpEntity httpEntity2 = response.getEntity();
// 如果状态码为200,就是正常返回
int rspCode = response.getStatusLine().getStatusCode();
if (rspCode == HttpStatus.SC_OK) {
result = EntityUtils.toString(httpEntity2);
log.error(httpEntity2);
} else {
result = EntityUtils.toString(httpEntity2);
// 得到返回的字符串
}
//关闭连接
client.close();
}
catch(Exception e){
log.error("执行http请求失败" + e.fillInStackTrace());
e.printStackTrace();
throw new RuntimeException("请求接口出错!请求数据["+JSON.toJSONString(params)+"]");
}
return result.replaceAll("&quot;", "\"");
}
public static String doPost(String url, String requestSoap, String contentType) {
BasicHeader[] headers = new BasicHeader[]{new BasicHeader("Content-Type", Content_Type_JSON)};;
if (!StrUtil.isEmpty(contentType)){
headers = new BasicHeader[]{new BasicHeader("Content-Type", contentType)};
}
return doPost(url, requestSoap, headers);
}
/**
* 请求https的接口
*
* @param url 接口地址
* @param requestSoap 请求报文
* @return
* @throws Exception
*/
private static String doPost(String url, String requestSoap, BasicHeader[] headers) {
String result = "";
try {
CloseableHttpClient closeableHttpClient = createHttpsClient();
// 建立HttpPost对象
//PostMethod postMethod = new PostMethod(url);
HttpPost httppost = new HttpPost(url);
byte[] b = requestSoap.getBytes(charset);
InputStream is = new ByteArrayInputStream(b, 0, b.length);
HttpEntity httpEntity = new InputStreamEntity(is, b.length);
httppost.setEntity(httpEntity);
if (headers != null){
httppost.setHeaders(headers);
}
//httppost.addHeader("Content-Type", Content_Type_JSON);
//httppost.addHeader("Content-Type", "text/html;charset=utf-8");
// httppost.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
//发送Post,并返回一个HttpResponse对象
HttpResponse httpResponse = closeableHttpClient.execute(httppost);
HttpEntity httpEntity2 = httpResponse.getEntity();
// 如果状态码为200,就是正常返回
int rspCode = httpResponse.getStatusLine().getStatusCode();
if (rspCode == HttpStatus.SC_OK) {
result = EntityUtils.toString(httpEntity2);
log.error(httpEntity2);
} else {
result = EntityUtils.toString(httpEntity2);
// 得到返回的字符串
}
//关闭连接
closeableHttpClient.close();
} catch (Exception e) {
log.error("执行http请求失败" + e.fillInStackTrace());
throw new RuntimeException("请求接口出错!请求数据["+requestSoap+"]");
}
return result.replaceAll("&quot;", "\"");
}
/**
* 处理https请求安全证书问题默认接受所有证书
*
* @return
* @throws Exception
*/
public static CloseableHttpClient createHttpsClient() throws Exception {
X509TrustManager x509mgr = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] xcs, String string) {
}
@Override
public void checkServerTrusted(X509Certificate[] xcs, String string) {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
// 设置超时时间: 读取超时,连接超时,请求超时时间
RequestConfig defaultRequestConfig = RequestConfig.custom()
.setSocketTimeout(60000).setConnectTimeout(3000)
.setConnectionRequestTimeout(3000)
.setStaleConnectionCheckEnabled(false).build();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{x509mgr},
new java.security.SecureRandom());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslContext,
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return HttpClients.custom().setSSLSocketFactory(sslsf)
.setDefaultRequestConfig(defaultRequestConfig).build();
}
public static void main(String[] args) throws Exception {
/*String url = "http://localhost:8088/m?xwl=WeixinSelect/planOrderSelect";
Map<String, Object> map = new HashMap<>();
map.put("ORDER_NO", "0");
map.put("ck", "MZ");
HttpRequestor requestor = new HttpRequestor();
String str = requestor.doPost(url, map);*/
/*String url = "http://wx.46202.yq-ic.com/Api/JT.ashx?action=DJK-001";
Map<String, String> map = new HashMap<>();
map.put("username", "JT20190531");
map.put("timestamp", String.valueOf(System.currentTimeMillis()));
String key = "vVrepYXntsovfebDMnOOL1OzPZHRYxtj";
String token = MD5Util.getMD5(key + map.get("timestamp"));
map.put("token", token);
map.put("billNo", "DWHPW1906244");
//map.put("cntr", "AAMU2502495");
String sendStr = JSON.toJSONString(map);
System.out.println(sendStr);
String str = HttpRequestor.doPost(url, JSON.toJSONString(map));
System.out.println(str);*/
// String url = "http://192.168.1.215:8762/DemoController/home";
String url = "http://192.168.1.215:8765/fa";
Map<String, Object> map = new HashMap<>();
map.put("bean", "service-hi");
map.put("method", "/DemoController/save");
map.put("sys.username", "yxh");
//String str = HttpRequestor.doPost(url, map);
//String json="{\"sys.dispname\":\"管理员\",\"sys.userIpAddress\":\"127.0.0.1\",\"sys.date\":1686813321877,\"sys.theme\":\"classic\",\"data\":\"[{\\\"S_ID\\\":\\\"00ee893e3f244cd1bd0ac4a2d43e6303\\\",\\\"NAME\\\":\\\"test11\\\",\\\"%SEX\\\":\\\"女\\\",\\\"SEX\\\":\\\"2\\\",\\\"AGE\\\":\\\"33\\\",\\\"GRADE_COD\\\":\\\"\\\",\\\"CREATED_BY\\\":\\\"22\\\",\\\"CREATED_ON\\\":\\\"2023-02-24T16:00:00.000Z\\\",\\\"UPDATED_BY\\\":\\\"admin\\\",\\\"UPDATED_ON\\\":\\\"2023-02-24T16:00:00.000Z\\\",\\\"#NAME\\\":\\\"test11\\\",\\\"#SEX\\\":\\\"2\\\",\\\"#AGE\\\":33,\\\"#CREATED_BY\\\":\\\"22\\\",\\\"#CREATED_ON\\\":\\\"2023-02-24T16:00:00.000Z\\\",\\\"#UPDATED_BY\\\":\\\"admin\\\",\\\"#UPDATED_ON\\\":\\\"2023-02-25T02:57:29.000Z\\\"}]\",\"basicsLust\":\"\",\"sys.id\":\"004M395CHDLM7\",\"selectUseRole\":{null:\"222\",\"admin/rolemanage.xwl\":\"角色管理\",\"log/operLog.xwl\":\"数据修改日志\",\"admin/dept.xwl\":\"部门管理\",\"common/S_Code/S_PARM1.xwl\":\"系统参数\",\"baseCode/C_Client.xwl\":\"客户管理\",\"sys/msg/topicEdit.xwl\":\"消息订阅\",\"log/sysOperLog.xwl\":\"系统操作日志\",\"sys/msg/websocketModel/personMsg.xwl\":\"我的消息\",\"admin/wbTenancy.xwl\":\"租户管理\",\"feeManage/tariffFee.xwl\":\"合同费率\",\"feeManage/points.xwl\":\"计费事件\",\"common/S_Code/S_Code.xwl\":\"系统代码维护\",\"feeManage/baseDict.xwl\":\"计费元素维护\",\"examples/tabulator/bigdata-table-tabulator.xwl\":\"大数据表格\",\"admin/perm.xwl\":\"权限设置\",\"common/codeSet.xwl\":\"系统下拉代码维护\",\"admin/wbMenu.xwl\":\"菜单维护2\",\"feeManage/item.xwl\":\"费目模板\",\"log/sysExceptionLog.xwl\":\"系统异常日志\",\"examples/basic/dropUpload.xwl\":\"测试\",\"examples/tabulator/group-table-tabulator.xwl\":\"分组表格示例tabulator\",\"feeManage/cate.xwl\":\"费类维护\",\"admin/user.xwl\":\"测试功能\",\"log/userDefineLog.xwl\":\"用户自定义日志\",\"examples/tabulator/simple-table-tabulator.xwl\":\"简单表格示例tabulator\"},\"xwl\":\"common/save-all\",\"sys.roles\":[\"default\",\"administrator\",\"shao\",\"fee\",\"admin\"],\"sys.username\":\"admin\",\"sys.tenancyId\":\"default\",\"mapMenuRes\":{\"admin\":[{\"ename\":\"itemTest\",\"url\":\"common/codeSet.xwl\",\"enabled\":\"0\"},{\"ename\":\"itemTest\",\"url\":\"common/S_Code/S_PARM1.xwl\",\"enabled\":\"0\"},{\"ename\":\"saveBtn\",\"url\":\"feeManage/baseDict.xwl\",\"enabled\":\"1\"},{\"ename\":\"itemTest1\",\"url\":\"common/codeSet.xwl\",\"enabled\":\"1\"},{\"ename\":\"panelTitle\",\"url\":\"common/codeSet.xwl\",\"enabled\":\"1\"}]},\"debugSuffix\":\"-debug\",\"sys.editTheme\":\"default\",\"bean\":\"service-hi\",\"sys.lang\":\"auto\",\"sys.TENANCY_ID\":\"default\",\"sys.userid\":\"admin\",\"subsList\":\"<li><img src=\\\"wb/images/photos/user.png\\\" style=\\\"margin-bottom:3px\\\"/><a onclick=\\\"subsclick('004CH3D8MP8Z4','admin')\\\">市场管理</a></li><li><img src=\\\"wb/images/photos/order.png\\\" style=\\\"margin-bottom:3px\\\"/><a onclick=\\\"subsclick('004CH3D8MOL2G','admin')\\\">客户管理</a></li><li><img src=\\\"wb/images/photos/settle.png\\\" style=\\\"margin-bottom:3px\\\"/><a onclick=\\\"subsclick('004CH3D8MP90F','admin')\\\">代码管理</a></li><li><img src=\\\"wb/images/photos/user.png\\\" style=\\\"margin-bottom:3px\\\"/><a onclick=\\\"subsclick('55cede9c-20b7-4728-9072-c03b6a4cd965','admin')\\\">系统管理</a></li><li><img src=\\\"wb/images/photos/order.png\\\" style=\\\"margin-bottom:3px\\\"/><a onclick=\\\"subsclick('004KC3HC0NO37','admin')\\\">框架示例</a></li>\",\"method\":\"/DemoController/home\",\"sys.useLang\":\"zh_CN\",\"sys.menuid\":\"004CH3D8MP8Z4\",\"sys.logined\":true,\"useRole\":{\"admin\":\"admin\"},\"roleIds\":\",administrator,shao,fee,admin,\",\"sys.ip\":\"127.0.0.1\",\"sys.user\":\"admin\",\"menuid\":\"-1\",\"sys.dataPermSql\":\"select USER_NAME from wb_user where DEPT_ID in(select DATA_DEPT_ID from wb_dept_perm where DEPT_ID in (select DEPT_ID from wb_user wu where USER_NAME ='admin'))\",\"sys.roleList\":\"default,administrator,shao,fee,admin\"}";
String str = HttpRequestor.doPost(url, JSON.toJSONString(map), Content_Type_JSON);
System.out.println(str);
}
}

View File

@@ -0,0 +1,79 @@
package com.ag.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* Created by yangxh on 2019/9/18.
*/
public class JSONUtil {
public static void main(String[] args) {
String test = "{\"fpkjxxXmxxs\": {\n" +
" \"-class\": \"FPKJXX_XMXX\",\n" +
" \"-size\": \"1\",\n" +
" \"fpkXmxx\": [{\n" +
" \"xmmc\": \"ddddff\",\n" +
" \"xmdw\": \"fffff\",\n" +
" \"gggg\": \"cccc\",\n" +
" \"zzzz\": \"fds\",\n" +
" \"kce\": \"扣除额\",\n" +
" \"xmje\": \"项目金额\",\n" +
" \"sl\": \"税率\",\n" +
" \"se\": \"税额\",\n" +
" }]\n" +
" }}";
JSONObject json = JSON.parseObject(test);
System.out.println(JSON.toJSONString(json));
System.out.println(JSON.toJSONString(transKeyUpper(json)));
}
public static JSONObject transKeyUpper(JSONObject o1){
JSONObject o2 = new JSONObject();
o1.forEach((key, value) -> {
if(value instanceof JSONObject){
o2.put(key, transKeyUpper((JSONObject)value));
}else if(value instanceof JSONArray){
o2.put(key, transArray(o1.getJSONArray(key)));
}else if (key.startsWith("@")){
o2.put(key, value);
} else {
o2.put(key, value);
}
});
return o2;
}
public static JSONArray transArray(JSONArray o1){
JSONArray o2 = new JSONArray();
for (int i = 0; i < o1.size(); i++) {
Object jArray=o1.getJSONObject(i);
if(jArray.getClass().toString().endsWith("JSONObject")){
o2.add(transKeyUpper((JSONObject)jArray));
}else if(jArray.getClass().toString().endsWith("JSONArray")){
o2.add(transArray((JSONArray)jArray));
}
}
return o2;
}
private static String toUpper(String param) {
return toLower(param).toUpperCase();
}
private static String toLower(String param) {
StringBuilder sb = new StringBuilder();
char[] col = param.toCharArray();
for (char ch : col) {
if (Character.isUpperCase(ch)) {
sb.append("_").append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString();
}
}

View File

@@ -0,0 +1,38 @@
package com.ag.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PwdCheckUtil {
public static void main(String[] args) {
String str = "123@A";
System.out.println(PwdCheckUtil.isContainsNum(str));
System.out.println(PwdCheckUtil.isContainsUppChar(str));
System.out.println(PwdCheckUtil.isContainsLowChar(str));
System.out.println(PwdCheckUtil.isContainsSpeChar(str));
}
public static boolean isContainsNum(String pwd){
Pattern compile = Pattern.compile(".*[0-9].*");
Matcher matcher = compile.matcher(pwd);
return matcher.matches();
}
public static boolean isContainsUppChar(String pwd){
Pattern compile = Pattern.compile(".*[A-Z].*");
Matcher matcher = compile.matcher(pwd);
return matcher.matches();
}
public static boolean isContainsLowChar(String pwd){
Pattern compile = Pattern.compile(".*[a-z].*");
Matcher matcher = compile.matcher(pwd);
return matcher.matches();
}
public static boolean isContainsSpeChar(String pwd){
Pattern compile = Pattern.compile(".*[ _`~!@#$%^&*()+=|{}:;,.<>/?].*");
Matcher matcher = compile.matcher(pwd);
return matcher.matches();
}
}

View File

@@ -0,0 +1,34 @@
package com.ag.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.ResourceBundle;
/**
* Created by yangxh on 2019/8/27.
*/
public class ResourceUtil {
private static Log log = LogFactory.getLog(ResourceUtil.class);
/**
* 根据配置文件路径和key获取配置参数
* @param key
* @param configPath
* @return
*/
public static String getString(String configPath, String key) {
//如果配置文件唯一可以在类中把configPath成名为常量把ResourceBundle对象声明为全局静态变量
ResourceBundle resourceBundle = getResourceBundle(configPath);
return resourceBundle.getString(key);
}
public static ResourceBundle getResourceBundle(String configPath){
return ResourceBundle.getBundle(configPath);
}
public static String getString(ResourceBundle rb, String key){
return rb.getString(key);
}
}

View File

@@ -0,0 +1,83 @@
package com.ag.util;
import java.io.Serializable;
/**
* Created by Administrator on 2017/5/18 0018.
*/
public class Result implements Serializable {
private boolean success;
private String msg;
private Object obj;
private Integer code;
public static Result build(boolean isSuccess) {
Result result = new Result();
result.setSuccess(isSuccess);
return result;
}
public static Result build(boolean isSuccess, Object obj) {
Result result = new Result();
result.setSuccess(isSuccess);
result.setObj(obj);
return result;
}
public static Result build(boolean isSuccess, String msg) {
Result result = new Result();
result.setSuccess(isSuccess);
result.setMsg(msg);
return result;
}
public static Result build(boolean isSuccess, Object obj, String msg) {
Result result = new Result();
result.setSuccess(isSuccess);
result.setObj(obj);
result.setMsg(msg);
return result;
}
public static Result build(boolean isSuccess, Object obj, String msg, Integer code) {
Result result = new Result();
result.setSuccess(isSuccess);
result.setCode(code);
result.setMsg(msg);
result.setObj(obj);
return result;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getObj() {
return obj;
}
public void setObj(Object obj) {
this.obj = obj;
}
public Integer getCode() {
if (code == null)
code = 0;
return code;
}
public void setCode(Integer code) {
this.code = code;
}
}

View File

@@ -0,0 +1,237 @@
package com.ag.util;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by Administrator on 2017/5/22 0022.
*/
public class StrUtil extends StringUtils {
/**
* 去空格
*
* @param str
* @return
*/
public static String trimString(String str) {
return str == null ? "" : str.trim();
}
/**
* 去除左边从0开始到第一个匹配字符
*
* @param str
* ="1,2,3,4,"
* @param leftFlag
* =","
* @return "2,3,4,"
*/
public static String subLeftString(String str, String leftFlag) {
if (str == null || str.equals("") || !str.contains(leftFlag)) {
return "";
}
return str.substring(str.indexOf(leftFlag) + 1, str.length());
}
/**
* 去除右边第一个匹配字符开始到末尾
*
* @param str
* ="1,2,3,4,"
* @param rightFlag
* =","
* @return "1,2,3,4"
*/
public static String subRightString(String str, String rightFlag) {
if (isEmpty(str)){
return "";
}
if (!str.contains(rightFlag)) {
return str;
}
return str.substring(0, str.lastIndexOf(rightFlag));
}
/**
* 新旧字符串编号比较,移除其中相同的编号
*
* @param oldStr
* 旧字符串编号
* @param newStr
* 新字符串编号
* @see return oldStr 需要删除的对象编号
* @see return newStr 需要新增的对象编号
* @see
* {@code StringBuilder oldStr = new StringBuilder("1,2,3,4,0,");//老编号
* StringBuilder newStr = new StringBuilder("4,2,6,8,9,10,");//新编号}
* @see return oldStr = "1,3,0," oldStr = "6,8,9,10,"
*/
public static void removeDu(StringBuilder oldStr, StringBuilder newStr) {
String a = oldStr.toString();
String b = newStr.toString();
String[] arr1 = a.split(",");
String[] arr2 = b.split(",");
for (int i = 0; i < arr1.length; i++) {
for (int j = 0; j < arr2.length; j++) {
if (arr1[i].equals(arr2[j])) {
arr1[i] = "";
arr2[j] = "";
}
}
}
oldStr.delete(0, oldStr.length());
newStr.delete(0, newStr.length());
for (String str : arr1) {
if (!"".equals(str)) {
oldStr.append(str).append(",");
}
}
for (String str : arr2) {
if (!"".equals(str)) {
newStr.append(str).append(",");
}
}
}
/**
* 将格式为a-b,c-d,e-f,......截取得到a,c,e,.....
*
* @param regedSerialNo_groupCodeStr
* @return
*/
public static String getPartStr(String regedSerialNo_groupCodeStr) {
String[] regedSerialNo_groupCodeStrs = regedSerialNo_groupCodeStr
.split(",");
String regedSerialNoStr = "";
for (String str : regedSerialNo_groupCodeStrs) {
regedSerialNoStr += str.split("-")[0] + ",";
}
return regedSerialNoStr.substring(0, regedSerialNoStr.length() - 1);
}
/**
* 新旧分组组合项目对比 把新分组内的组合项目分为两类 : 一类是之前旧分组中存在的组合项目 另一类是新添加的组合项目
*
* @param newGroupCombStr
* @param oldGroupCombStr
* @return
*/
public static List<String> getNewAndOldGroupCombStr(String newGroupCombStr,
String oldGroupCombStr) {
System.out.println("newGroupCombStr:" + newGroupCombStr);
System.out.println("oldGroupCombStr:" + oldGroupCombStr);
List<String> NewAndOldGroupCombLst = new ArrayList<String>();
// 旧组合项目数组
String[] newGroupCombArray = newGroupCombStr.split(",");
// 新组合项目中仍存在的就组合项目信息
String oldGroupCombStr1 = "";
// 要删除的组合项目信息
String oldGroupCombStr2 = "";
// 新添加的组合项目信息
String newGroupCombStr1 = "";
for (String str : newGroupCombArray) {
if (oldGroupCombStr.contains(str)) {
oldGroupCombStr1 += str + ",";
} else {
newGroupCombStr1 += str + ",";
}
}
// 旧组合项目数组
String[] oldGroupCombArray = oldGroupCombStr.split(",");
for(String str : oldGroupCombArray){
if(!oldGroupCombStr1.contains(str)){
oldGroupCombStr2 += str + ",";
}
}
System.out.println("oldGroupCombStr1:::" + oldGroupCombStr1);
System.out.println("newGroupCombStr1:::" + newGroupCombStr1);
NewAndOldGroupCombLst.add(oldGroupCombStr2);
NewAndOldGroupCombLst.add(newGroupCombStr1);
return NewAndOldGroupCombLst;
}
public static boolean isEmpty(Object object){
return object == null || "".equals(object.toString());
}
public static String firstToLower(String param) {
return join(param.substring(0, 1).toLowerCase() , param.substring(1, param.length()));
}
public static String firstToUpper(String param) {
return join(param.substring(0, 1).toUpperCase() , param.substring(1, param.length()));
}
public static String converIdsToSql(String ids){
if (StrUtil.isEmpty(ids)){
return "";
}
String[] arr = ids.split(",");
Set<String> set = new HashSet<>();
for (String str : arr){
if (isEmpty(str)){
continue;
}
if (set.contains(str)){
continue;
}
set.add(str);
}
String target = "";
for (String str : set){
target = join(target, "'", str, "',");
}
if (isEmpty(target)){
return "''";
}
return target.substring(0, target.length()-1);
}
public static String toUpperCol(String param) {
param = StrUtil.join(param.substring(0, 1).toLowerCase(), param.substring(1, param.length()));
StringBuilder sb = new StringBuilder();
char[] col = param.toCharArray();
for (char ch : col) {
if (Character.isUpperCase(ch)) {
sb.append("_").append(Character.toLowerCase(ch));
} else {
sb.append(ch);
}
}
return sb.toString().toUpperCase();
}
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(converIdsToSql(",b,b,c"));
StringBuilder str1 = new StringBuilder("12,22,32,42,20,");// 老编号
StringBuilder str2 = new StringBuilder("42,22,61,87,9,10,");// 新编号
StrUtil.removeDu(str1, str2);
System.out.println(str1);// 剩下是需要移除对象的编号
System.out.println(str2);// 剩下是需要新建对象的编号
String str = "1,2,3,";
System.out.println(str.lastIndexOf(","));
System.out.println(str.length());
String message = "ORA-12899: 列 \"JT_YWDT_N\".\"WB_USER\".\"USE_MESSAGE\" 的值太大 (实际值: 2, 最大值: 1)";
System.out.println(getStrByPattern(message));
}
public static String getStrByPattern(String input){
Pattern pattern = Pattern.compile("\"(.*?)\"");
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
return matcher.group(1);
}
return null;
}
}

View File

@@ -0,0 +1,546 @@
package com.ag.util;
import org.apache.commons.lang3.StringUtils;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
/**
* Created by Administrator on 2017/6/23 0023.
*/
public class TimeUtil {
public static String getDate(String dateFormat) {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(new Date());
}
public static String getDate(Date date, String dateFormat) {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(date);
}
public static String getDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(new Date());
}
public static String getDate(Date date) {
if (date == null) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
}
public static String getSerDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
return sdf.format(new Date());
}
public static String getTime() {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
return sdf.format(new Date());
}
public static String getTime(Date dt) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
return sdf.format(dt);
}
public static String getDateTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(new Date());
}
public static String getDateTime(Date dt) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(dt);
}
public static String getDateTimeSSS() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
return sdf.format(new Date());
}
public static Date getTimestamp(String strDate) {
if (StrUtil.isEmpty(strDate)){
return null;
}
try {
if (strDate.length() == 10){
strDate += " 00:00:00";
}
return Timestamp.valueOf(strDate);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 通过出生日期返回年龄
*/
public static Integer getAge(String DCsrq) throws Exception {
if (StringUtils.isEmpty(DCsrq)) {
return 0;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date birthDay = sdf.parse(DCsrq);
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
return 0;
/*throw new IllegalArgumentException(
"The birthDay is before Now.It's unbelievable!");*/
}
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
int monthBirth = cal.get(Calendar.MONTH);
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;
if (monthNow <= monthBirth) {
if (monthNow == monthBirth) {
// monthNow==monthBirth
if (dayOfMonthNow < dayOfMonthBirth) {
age--;
} else {
// do nothing
}
} else {
// monthNow>monthBirth
age--;
}
} else {
// monthNow<monthBirth
// donothing
}
return age;
}
/**
* 通过年龄返回出生日期 月和日为当前日期
public static String getCsrq(String csrq, String ageStr) {
if (csrq != null && !"".equals(csrq)) {
return csrq;
}
if (ageStr == null || "".equals(ageStr)) {
return null;
}
int age = Integer.parseInt(ageStr);
if (age <= 0 && age > 100) {
return null;
} */
/*
* SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
* SimpleDateFormat sdf2 = new SimpleDateFormat("-MM-dd"); int year_age
* = Integer.valueOf(sdf1.format(new Date())) - age; String md_age =
* sdf2.format(new Date());
*/
/**
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
int year_age = Integer.valueOf(sdf1.format(new Date())) - age;
return year_age + "-01-01";
}*/
/**
* 获取当前日期是星期几<br>
*
* @param dt
* @return 当前日期是星期几
*/
public static String getWeekOfDate(Date dt) {
String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)
w = 0;
return weekDays[w];
}
/**
* 返回当前日期的指定范围日期dt正数则为当前日期后几天负则为前几天
*
* @param dt
* @return
*/
@SuppressWarnings("static-access")
public static String getSomeDayOfToday(int dt) {
Calendar ca = Calendar.getInstance();
ca.add(ca.DAY_OF_MONTH, dt);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(ca.getTime());
}
/**
* 返回当前日期的指定范围日期,
*
* @param min 正数则为当前时间后几分钟,负则为前几分钟
* @return
*/
@SuppressWarnings("static-access")
public static Date getSomeTimeOfMinute(int min) {
Calendar ca = Calendar.getInstance();
ca.add(ca.MINUTE, min);
return ca.getTime();
/*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(ca.getTime());*/
}
/**
* 补齐日期类型
*/
public static String getFullYYMMDD(String date) {
if (null == date || "".equals(date)) {
return null;
}
Calendar ca = Calendar.getInstance();
int month = ca.get(Calendar.MONTH) + 1;
int day = ca.get(Calendar.DATE);
// 小于7位只取年
String rtnDate = "";
if (date.length() < 7) {
rtnDate = date.substring(0, 4) + "-" + String.valueOf(month) + "-"
+ String.valueOf(day);
} else if (date.length() < 10) {// 小于10位只取年月
rtnDate = date.substring(0, 4) + "-" + date.substring(5, 7) + "-"
+ String.valueOf(day);
} else {
rtnDate = date.substring(0, 4) + "-" + date.substring(5, 7) + "-"
+ date.substring(8, 10);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
return sdf.format(sdf.parse(rtnDate));
} catch (ParseException e) {
e.printStackTrace();
return null;
}
}
/**
* 获得当月第一天
*
* @param date
* @return
public static String getFirstDay() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
return sdf.format(new Date()).concat("-01");
}*/
/**
* 获得当月最后一天
*
public static String getLastDay() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String yearAndMonth = sdf.format(new Date());
Integer days = getDays(yearAndMonth.split("-")[1],
yearAndMonth.split("-")[0]);
return yearAndMonth.concat("-" + days);
}*/
public static Integer getDays(String month, String year) {
String months1 = "01,03,05,07,08,10,12,";
String months2 = "04,06,09,11,";
if (months1.contains(month + ",")) {
return 31;
} else if (months2.contains(month + ",")) {
return 30;
} else {
if (0 == Integer.parseInt(year) % 4
&& 0 != Integer.parseInt(year) % 100) {
return 29;
} else {
return 28;
}
}
}
/**
* 给定时间前后i天
* @param date
* @return
*/
public static Date getTimeLaterDay(Date date, int i){
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
if (i < 0){
i = i + 1;
}
calendar.add(Calendar.DATE, i);
return calendar.getTime();
}
/**
* 给定时间加月份
* @param date
* @param month
* @return
*/
public static Date getTimeByAddMonth(Date date ,Integer month) {
Calendar calendar=Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, month);
return new Timestamp(calendar.getTimeInMillis());
}
/**
* 返回yyMMdd格式
* @return
*/
public static String getDemandDate() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
return sdf.format(new Date());
}
/**
* 判断两个时间是否在差值范围内是返回true否返回false
* @param date1 时间小
* @param date1 时间大
* @param subdu 差值
* @return
*/
public static boolean getDValueByTime(Date date1, Date date2, int subdu){
long time1 = date1.getTime();
long time2 = date2.getTime();
if(time2 - time1 > subdu){
return false;
}else{
return true;
}
}
public static Date getDateFromString(String str) {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date=sdf.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static Date getDateFromToday() {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date=sdf.parse(getDate());
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static int compareDate(String DATE1, String DATE2) {
if(DATE1 == null || DATE2 == null){
return 0;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
Date dt1 = df.parse(DATE1);
Date dt2 = df.parse(DATE2);
if (dt1.getTime() > dt2.getTime()) {
return 1;
} else if (dt1.getTime() < dt2.getTime()) {
return -1;
} else {
return 0;
}
} catch (Exception exception) {
throw new RuntimeException("日期格式异常");
}
}
/**
*两时间比较日期差值堆存天当天返回0
* @param start
* @param end
* @return
*/
public static int compareDaysLimit(Date start, Date end, boolean is24H){
long dayLong = 1000*60*60*24;
long dv;
if (is24H){
dv = (end.getTime() - start.getTime()) / dayLong;
}else {
dv = (getDayZero(end).getTime() - getDayZero(start).getTime()) / dayLong;
}
return (int)dv;
}
/**
* 两时间比较,日期差值,堆存小时,不满一小时=1小时
* @param start
* @param end
* @return
*/
public static int compareHoursLimit(Date start, Date end){
long hourLong = 1000*60*60;
long dv = (end.getTime() - start.getTime()) / hourLong;
return (int)dv + 1;
}
/**
* 两时间比较开始时间小于结束时间返回true
* @param start
* @param end
* @return
*/
public static boolean compareDate(Date start, Date end){
return (end.getTime() - start.getTime()) > 0;
}
/**
* 两个日期之间间隔天数
*
* @param isWork true: 包含工作日 false: 不包含工作日
*
* @return
*/
public static int workDays(String beginDATE, String endDATE, boolean isWork) {
if(beginDATE == null || endDATE == null){
return 0;
}
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date dt1 = df.parse(beginDATE);
Date dt2 = df.parse(endDATE);
int days = (int) ((dt2.getTime()-dt1.getTime())/(1000*60*60*24))+1;
if(isWork){
return days;
}else{
int weeks = days / 7;
int rs = 0;
// 整数周
if (days % 7 == 0) {
rs = days - 2 * weeks;
}
else {
Calendar begCalendar = Calendar.getInstance();
Calendar endCalendar = Calendar.getInstance();
begCalendar.setTime(dt1);
endCalendar.setTime(dt2);
// 周日为1周六为7
int beg = begCalendar.get(Calendar.DAY_OF_WEEK);
int end = endCalendar.get(Calendar.DAY_OF_WEEK);
if (beg > end) {
rs = days - 2 * (weeks + 1);
} else if (beg < end) {
if (end == 7) {
rs = days - 2 * weeks - 1;
} else {
rs = days - 2 * weeks;
}
} else {
if (beg == 1 || beg == 7) {
rs = days - 2 * weeks - 1;
} else {
rs = days - 2 * weeks;
}
}
}
return rs;
}
} catch (Exception exception) {
throw new RuntimeException("日期格式异常");
}
}
/**
* 变更字符串时间转换格式
*
* @param fromFormat 变换前的日期格式
* @param toFormat 变换后的日期格式
* @param date 符合fromFormat格式的日期字符串
*/
public static String changeFormat(String fromFormat, String toFormat, String date) {
SimpleDateFormat oldFormat=new SimpleDateFormat(fromFormat);
Date date1;
String newDate="";
try {
date1 = oldFormat.parse(date);
SimpleDateFormat newFormat=new SimpleDateFormat(toFormat);
newDate = newFormat.format(date1);
} catch (ParseException e) {
e.printStackTrace();
}
return newDate;
}
public static String getWbBegin(String begin){
if (begin.length() < 19){
begin += " 00:00:00";
}
return StrUtil.join("to_date('", begin.substring(0,19),"','yyyy-MM-dd HH24:mi:ss')");
}
public static String getWbEnd(String end){
return getWbBegin(StrUtil.join(end.substring(0,10), " 23:59:59"));
}
//获取时间的零点
public static Date getDayZero(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}
public static void main(String arg[]) {
// System.out.println(TimeUtil.getDValueByTime(TimeUtil.getDayBegin(),TimeUtil.getNowTimestamp(),0));
// System.out.println(TimeUtil.getDValueByTime(TimeUtil.getNowTimestamp(),TimeUtil.getDayBegin(),0));
//System.out.println(compareDate(Timestamp.valueOf("2017-07-09 15:26:07"), Timestamp.valueOf("2017-07-10 00:00:00")));
System.out.println(toOrclDate(new Date()));
//System.out.println(TimeUtil.getDateTime(TimeUtil.getTimeLaterDay(new Date(), -2)));
// 取当前日期:
System.out.println(LocalDate.now());// -> 2014-12-24
// 根据年月日取日期12月就是12
//LocalDate crischristmas = LocalDate.of(2014,-25
// 根据字符串取: 12, 25); // -> 2014-12
System.out.println(LocalDate.parse("2018-02-01")); // 严格按照ISO yyyy-MM-dd验证02写成2都不行当然也有一个重载方法允许自己定义格式
System.out.println(LocalDateTime.now());
System.out.println(LocalDateTime.parse("2018-02-01 13:59:56", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
System.out.println(LocalDateTime.parse("2018-02-01T13:59:57").toString());
Integer one = 128,two = 128;
System.out.println(one == two);
}
public static String toOrclDate(Date date){
if (date == null){
return null;
}
String date2 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
String a= StrUtil.join("to_date('",date2, "','yyyy-MM-dd HH24:mi:ss')");
return a;
}
}

View File

@@ -0,0 +1,133 @@
package com.ag.util;
import java.util.UUID;
/**
* Created by Administrator on 2017/3/29 0029.
*/
public class UUIDUtil {
public UUIDUtil() {
}
/**
* ????UUID
*
* @return String UUID
*/
public static String getUUID() {
return UUID.randomUUID().toString().replaceAll("-","");
}
/**
* ???????UUID
*
* @param number
* int ?????UUID??
* @return String[] UUID??
*/
public static String[] getUUID(int number) {
if (number < 1) {
return null;
}
String[] ss = new String[number];
for (int i = 0; i < number; i++) {
ss[i] = getUUID();
}
return ss;
}
/**
* ????????base64??
*/
public static char[] encode(byte[] data) {
char[] out = new char[((data.length + 2) / 3) * 4];
for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
boolean quad = false;
boolean trip = false;
int val = (0xFF & (int) data[i]);
val <<= 8;
if ((i + 1) < data.length) {
val |= (0xFF & (int) data[i + 1]);
trip = true;
}
val <<= 8;
if ((i + 2) < data.length) {
val |= (0xFF & (int) data[i + 2]);
quad = true;
}
out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 1] = alphabet[val & 0x3F];
val >>= 6;
out[index + 0] = alphabet[val & 0x3F];
}
return out;
}
/**
* ?base64????????????
*/
public static byte[] decode(char[] data) {
int len = ((data.length + 3) / 4) * 3;
if (data.length > 0 && data[data.length - 1] == '=')
--len;
if (data.length > 1 && data[data.length - 2] == '=')
--len;
byte[] out = new byte[len];
int shift = 0;
int accum = 0;
int index = 0;
for (int ix = 0; ix < data.length; ix++) {
int value = codes[data[ix] & 0xFF];
if (value >= 0) {
accum <<= 6;
shift += 6;
accum |= value;
if (shift >= 8) {
shift -= 8;
out[index++] = (byte) ((accum >> shift) & 0xff);
}
}
}
if (index != out.length)
throw new Error("miscalculated data length!");
return out;
}
static private char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
.toCharArray();
static private byte[] codes = new byte[256];
static {
for (int i = 0; i < 256; i++)
codes[i] = -1;
for (int i = 'A'; i <= 'Z'; i++)
codes[i] = (byte) (i - 'A');
for (int i = 'a'; i <= 'z'; i++)
codes[i] = (byte) (26 + i - 'a');
for (int i = '0'; i <= '9'; i++)
codes[i] = (byte) (52 + i - '0');
codes['+'] = 62;
codes['/'] = 63;
}
public static void main(String[] args) throws Exception {
// ???base64
/*String strSrc = "ios";
String strOut = new String(UUIDUtil.encode(strSrc.getBytes("UTF-8")));
System.out.println(strOut);
String strOut2 = new String(UUIDUtil.decode(strOut.toCharArray()),
"UTF-8");
System.out.println(strOut2);*/
long on = System.nanoTime();
long on1 = System.currentTimeMillis();
System.out.println(UUIDUtil.getUUID());
long end = System.nanoTime();
long end1 = System.currentTimeMillis();
System.out.println(end - on);
System.out.println(end1 - on1);
}
}

View File

@@ -0,0 +1,136 @@
package com.ag.util;
import java.util.*;
/**
* Created by yangxh on 2020/2/27.
*/
public class UniqueObjectList<E> implements List<E> {
public UniqueObjectList(){
list = new ArrayList<>();
}
private List<E> list;
@Override
public int size() {
return list.size();
}
@Override
public boolean isEmpty() {
return list.isEmpty();
}
@Override
public boolean contains(Object o) {
return list.contains(o);
}
@Override
public Iterator<E> iterator() {
return list.iterator();
}
@Override
public Object[] toArray() {
return list.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return list.toArray(a);
}
public boolean add(E e) {
if (!list.contains(e)){
return list.add(e);
}
return false;
}
@Override
public boolean remove(Object o) {
return list.remove(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return list.containsAll(c);
}
@Override
public boolean addAll(Collection<? extends E> c) {
for (E e : c){
if (!list.contains(e)){
list.add(e);
}
}
return true;
}
@Override
public boolean addAll(int index, Collection<? extends E> c) {
return list.addAll(index, c);
}
@Override
public boolean removeAll(Collection<?> c) {
return list.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return list.retainAll(c);
}
@Override
public void clear() {
list.clear();
}
@Override
public E get(int index) {
return list.get(index);
}
@Override
public E set(int index, E element) {
return list.set(index, element);
}
@Override
public void add(int index, E element) {
add(index, element);
}
@Override
public E remove(int index) {
return list.remove(index);
}
@Override
public int indexOf(Object o) {
return list.indexOf(o);
}
@Override
public int lastIndexOf(Object o) {
return list.lastIndexOf(o);
}
@Override
public ListIterator<E> listIterator() {
return list.listIterator();
}
@Override
public ListIterator<E> listIterator(int index) {
return list.listIterator(index);
}
@Override
public List<E> subList(int fromIndex, int toIndex) {
return list.subList(fromIndex, toIndex);
}
}

View File

@@ -0,0 +1,260 @@
package com.ag.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
/**
* Created by yangxh on 2020/12/2.
*/
public class WbStoreJson {
private Boolean success;
private Integer total;
private JSONObject metaData = new JSONObject();
private JSONArray rows = new JSONArray();
private final String FIELDS = "fields";
public WbStoreJson(){
setSuccess(true);
JSONArray fields = new JSONArray();
getMetaData().put(FIELDS, fields);
}
public String getJsonStr(WbStoreJson json){
return JSON.toJSONString(json, SerializerFeature.WriteNullStringAsEmpty);
}
public void generate(List<Map<String, Object>> list){
if (list == null){
list = new ArrayList<>();
}
setTotal(list.size());
}
/**
* 1.取出class所有的属性构建fields中的name和type
* 2."get"+属性首字符大写获取list中对象的值row属性为keyvalue=对象的值
* 3.遍历fields和rows
* fields->key="name" value驼峰命名法转为全小写+下划线格式
* rows->新建array新key替换旧key新array赋值给rows
* @param list
* @param clz
*/
public void generate(List list, Class clz){
if (list == null){
list = new ArrayList();
}
setTotal(list.size());
Map<String, Class> classMap = getColNameOrClass(clz);
for (Map.Entry<String, Class> entry : classMap.entrySet()) {
JSONObject json = new JSONObject();
json.put("name", entry.getKey());
json.put("type", getColType(entry.getValue()));
getFields().add(json);
}
for (Object data : list) {
JSONObject json = new JSONObject();
getRows().add(json);
for (Map.Entry<String, Class> entry : classMap.entrySet()) {
String key = entry.getKey();
if (StrUtil.equalsIgnoreCase(key, "serialVersionUID")){
continue;
}
Object val = getValueByMethodStr(data, key);
json.put(key, val);
}
}
for (int i=0; i<getFields().size(); i++){
JSONObject json = getFields().getJSONObject(i);
String oldVal = json.getString("name");
String newVal = StrUtil.toUpperCol(oldVal);
json.put("name", newVal);
}
JSONArray rows = new JSONArray();
for (int i=0; i<getRows().size(); i++){
JSONObject json = getRows().getJSONObject(i);
JSONObject target = new JSONObject();
rows.add(target);
for (Map.Entry<String, Object> entry : json.entrySet()){
String oldKey = entry.getKey();
Object oldVal = entry.getValue();
//驼峰命名法转为全小写+下划线格式
String newKey = StrUtil.toUpperCol(oldKey);
target.put(newKey, oldVal);
}
}
setRows(rows);
}
/*private void replaceArray(JSONArray source, JSONArray target){
for (int i=0; i<source.size(); i++){
JSONObject oldJson = source.getJSONObject(i);
JSONObject newJson = new JSONObject();
target.add(newJson);
for (Map.Entry<String, Object> entry : oldJson.entrySet()){
String oldKey = entry.getKey();
Object oldVal = entry.getValue();
//驼峰命名法转为全小写+下划线格式
String newKey = toLower(oldKey).toUpperCase();
newJson.put(newKey, oldVal);
}
}
}*/
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public JSONObject getMetaData() {
return metaData;
}
public void setMetaData(JSONObject metaData) {
this.metaData = metaData;
}
public JSONArray getRows() {
return rows;
}
public void setRows(JSONArray rows) {
this.rows = rows;
}
/**
* 获取对象的所有属性值
*/
private Map<String, Class> getColNameOrClass(Class clazz) {
//map=列名:类型
Map<String, Class> map = new HashMap<>();
try {
//根据Class对象获得属性 私有的也可以获得
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
/*//首字符小写
String colName = firstToLower(field.getName());
//驼峰命名法转为全小写+下划线格式
colName = toLower(colName).toUpperCase();*/
String colName = field.getName();
map.put(colName, field.getType());
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
private String getColType(Class value) {
if (String.class.isAssignableFrom(value)){
return "string";
}
if (Number.class.isAssignableFrom(value)){
return "number";
}
if (Date.class.isAssignableFrom(value)){
return "timestamp";
}
return "string";
}
private Object getValueByMethodStr(Object o, String colName) {
try {
String firstLetter = colName.substring(0, 1).toUpperCase();
String getter = StrUtil.join("get", firstLetter, colName.substring(1));
Method method = ReflectionUtils.findMethod(o.getClass(), getter);
return ReflectionUtils.invokeMethod(method, o);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private JSONArray getFields() {
return getMetaData().getJSONArray(FIELDS);
}
public static class RedisJsonStr{
private String id;
private String cname;
private String ename;
private String wname;
private String tenancyId;
private String keyName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
public String getWname() {
return wname;
}
public void setWname(String wname) {
this.wname = wname;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
public String getKeyName() {
return keyName;
}
public void setKeyName(String keyName) {
this.keyName = keyName;
}
}
}

View File

@@ -0,0 +1,38 @@
package com.ag.util;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* Created by yangxh on 2021/4/2.
*/
public class WbStoreJsonTest {
public static void main(String[] args) {
WbStoreJson.RedisJsonStr bc1 = new WbStoreJson.RedisJsonStr();
bc1.setId(UUIDUtil.getUUID()+"\",");
bc1.setKeyName("keyName");
bc1.setCname("cName");
WbStoreJson.RedisJsonStr bc2 = new WbStoreJson.RedisJsonStr();
BeanUtil.copyProperties(bc1, bc2);
bc2.setId(UUIDUtil.getUUID());
List<WbStoreJson.RedisJsonStr> bcs = CollectionUtil.newArrayList(bc1, bc2);
WbStoreJson wb = new WbStoreJson();
wb.generate(bcs, WbStoreJson.RedisJsonStr.class);
//所有属性
System.out.println(wb.getJsonStr(wb));
//非null属性
//System.out.println(JSON.toJSONString(wb));
/*List<CBerth> aa = new ArrayList<>();
wb.generate(aa, CBerth.class);
System.out.println(wb.getJsonStr(wb));*/
}
}

View File

@@ -0,0 +1,144 @@
package com.ag.util;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import cn.hutool.json.XML;
import java.util.Iterator;
/**
* Created by yangxh on 2019/9/18.
*/
public class XMLUtil extends XML {
public static String toXml(Object object) throws JSONException {
return toXml(object, null);
}
public static String toXml(Object object, String tagName) throws JSONException {
if(null == object) {
return null;
}
StringBuilder sb = new StringBuilder();
JSONArray ja;
JSONObject jo;
String key;
Iterator<String> keys;
String string;
Object value;
if (object instanceof JSONObject) {
// Emit <tagName>
if (tagName != null) {
sb.append('<');
sb.append(tagName);
}
// Loop thru the keys.
jo = (JSONObject) object;
Iterator<String> eles = jo.keySet().iterator();
while (eles.hasNext()) {
key = eles.next();
value = jo.get(key);
if (key.startsWith("@")){
sb.append(" ").append(key.substring(1)).append("=").append("\"").append(value).append("\"");
eles.remove();
}
}
if (tagName != null) {
sb.append('>');
}
keys = jo.keySet().iterator();
while (keys.hasNext()) {
key = keys.next();
value = jo.get(key);
if (value == null) {
value = "";
} else if (value.getClass().isArray()) {
value = new JSONArray(value);
}
string = value instanceof String ? (String) value : null;
// Emit content in body
if ("content".equals(key)) {
if (value instanceof JSONArray) {
ja = (JSONArray) value;
int i = 0;
for (Object val : ja) {
if (i > 0) {
sb.append('\n');
}
sb.append(XmlUtil.escape(val.toString()));
i++;
}
} else {
sb.append(XmlUtil.escape(value.toString()));
}
// Emit an array of similar keys
} else if (value instanceof JSONArray) {
ja = (JSONArray) value;
for (Object val : ja) {
if (val instanceof JSONArray) {
sb.append('<');
sb.append(key);
sb.append('>');
sb.append(toXml(val));
sb.append("</");
sb.append(key);
sb.append('>');
} else {
sb.append(toXml(val, key));
}
}
} else if ("".equals(value)) {
sb.append('<');
sb.append(key);
sb.append("/>");
// Emit a new tag <k>
} else {
sb.append(toXml(value, key));
}
}
if (tagName != null) {
// Emit the </tagname> close tag
sb.append("</");
sb.append(tagName);
sb.append('>');
}
return sb.toString();
}
if (object != null) {
if (object.getClass().isArray()) {
object = new JSONArray(object);
}
if (object instanceof JSONArray) {
ja = (JSONArray) object;
for (Object val : ja) {
// XML does not have good support for arrays. If an array
// appears in a place where XML is lacking, synthesize an
// <array> element.
sb.append(toXml(val, tagName == null ? "array" : tagName));
}
return sb.toString();
}
}
string = (object == null || "null".equals(object.toString())) ? "" : XmlUtil.escape(object.toString());
return (tagName == null) ? "\"" + string + "\"" : (string.length() == 0) ? "<" + tagName + "/>" : "<" + tagName + ">" + string + "</" + tagName + ">";
}
}

View File

@@ -0,0 +1,67 @@
package com.wb.common;
import java.io.Serializable;
/**
* Description:缓存代码bean移动到公用类型
* Author: wangll
* Version: 1.0
* Create Date: 2020/4/15 0015
*/
public class KvBean implements Serializable{
//表名称
private String keyName;
private String k;
private String v;
private String comv;
private String comv2;
private String tenancyId;
public String getKeyName() {
return keyName;
}
public void setKeyName(String keyName) {
this.keyName = keyName;
}
public String getK() {
return k;
}
public void setK(String k) {
this.k = k;
}
public String getV() {
return v;
}
public void setV(String v) {
this.v = v;
}
public String getComv() {
return comv;
}
public void setComv(String comv) {
this.comv = comv;
}
public String getComv2() {
return comv2;
}
public void setComv2(String comv2) {
this.comv2 = comv2;
}
public String getTenancyId() {
return tenancyId;
}
public void setTenancyId(String tenancyId) {
this.tenancyId = tenancyId;
}
}