初始化

dev
lisai17@sina.com 2020-08-07 17:11:12 +08:00
commit f4c55cc5f8
440 changed files with 48156 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
.idea/
*.iml
/ssjygl-xsx-common/target/
/ssjygl-xsx-local/target/
/ssjygl-xsx-service/target/
/ssjygl-xsx-devicectrl/target/
/logs/
/ssjygl-xsx-common/logs/
/ssjygl-xsx-local/logs/
/ssjygl-xsx-service/logs/
/ssjygl-xsx-devicectrl/logs/
/ssjygl-xsx-common/out/
/ssjygl-xsx-local/out/
/ssjygl-xsx-service/out/
/ssjygl-xsx-devicectrl/out/
/ssjygl-xsx-common/upload/
/ssjygl-xsx-local/upload/
/ssjygl-xsx-service/upload/
/ssjygl-xsx-devicectrl/upload/
/ssjygl-xsx-common/.idea/
/ssjygl-xsx-local/.idea/
/ssjygl-xsx-service/.idea/
/ssjygl-xsx-devicectrl/.idea/
/gern
/ssjygl-xsx-common/imgfile/
/ssjygl-xsx-local/imgfile/
/ssjygl-xsx-common/xlsfile/
/ssjygl-xsx-local/xlsfile/
/ssjygl-xsx-common/KHT_Log/
/ssjygl-xsx-local/KHT_Log/
/ssjygl-xsx-local/lib/bocommjava/log
/ssjygl-xsx-local/src/main/webapp/upload

7
build.bat Normal file
View File

@ -0,0 +1,7 @@
cd ../ssjygl-xsx-local
start mvn clean package
cd ../ssjygl-xsx-service
start mvn clean package
cd ..

10
build.sh Normal file
View File

@ -0,0 +1,10 @@
cd ssjygl-xsx-common
mvn clean package install
cd ../ssjygl-xsx-local
mvn clean package
cd ../ssjygl-xsx-service
mvn clean package
cd ..

138
ssjygl-xsx-common/pom.xml Normal file
View File

@ -0,0 +1,138 @@
<?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>
<groupId>com.cowr.ssjygl-xsx-common</groupId>
<artifactId>ssjygl-xsx-common</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>砂石经营管理-浠水县-公用代码</name>
<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>
<!-- 使用阿里 maven 库 -->
<repositories>
<repository>
<id>ali-maven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.jfinal</groupId>
<artifactId>jfinal</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.68</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.22</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package com.cowr.common;
public class Const {
public static final String DEFAULT_PASSWORD = "678910"; // 新建用户默认密码
public static final String LOGIC_DEL_KEY = "del"; // 逻辑删除字段
public static final int LOGIC_DEL_INVALID = 1; // 标记为逻辑删除
public static final int LOGIC_DEL_VALID = 0; // 标记为有效数据
public static final int DEFAULT_SN_LEN = 4; // 订单号结尾的序列号默认长度
public static final int DEFAULT_SN_MAX = Double.valueOf(Math.pow(10, DEFAULT_SN_LEN) - 1).intValue(); // 订单号结尾的序列号默认最大值
public static final String ORDER_BY_ASC = "asc"; // 正序
public static final String ORDER_BY_DESC = "desc"; // 倒叙
public static final String REDIS_SEPARATE = ":"; // reids 分隔符
public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象
}

View File

@ -0,0 +1,22 @@
package com.cowr.common.Interceptor;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import javax.servlet.http.HttpServletResponse;
public class CorsInterceptor implements Interceptor {
@Override
public void intercept(Invocation inv) {
inv.invoke();
addCorsHead(inv.getController().getResponse());
}
private void addCorsHead(HttpServletResponse response) {
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader(
"Access-Control-Allow-Headers",
"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
}
}

View File

@ -0,0 +1,35 @@
package com.cowr.common.Interceptor;
import com.cowr.common.view.ActionReporter;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.core.JFinal;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
public class ReporterInterceptor implements Interceptor {
public static List<String> exclude = new ArrayList<String>() {{
add("/camera/recv");
add("/transport/query/real");
add("/stock/get");
add("/transport/query/inSupermarket");
add("/overall/getCompleteOrder");
add("/gps/real");
}};
@Override
public void intercept(Invocation inv) {
Controller c = inv.getController();
HttpServletRequest request = c.getRequest();
String target = request.getRequestURI();
if (!exclude.contains(target)) {
ActionReporter.report(target, c, JFinal.me().getAction(target, new String[]{c.getPara()}));
}
inv.invoke();
}
}

View File

@ -0,0 +1,73 @@
package com.cowr.common.base;
import com.cowr.common.view.Result;
import com.jfinal.core.ActionException;
import com.jfinal.core.Controller;
import com.jfinal.core.NotAction;
import com.jfinal.kit.StrKit;
import com.jfinal.render.RenderManager;
public abstract class BaseController extends Controller {
private static final RenderManager renderManager = RenderManager.me();
public String getUpperCaseVal(String name) {
String value = get(name);
if (StrKit.notBlank(value)) {
value = value.toUpperCase();
}
return value;
}
/**
*
*
* @param name
* @param defaultValue
* @return
*/
public String getUpperCaseVal(String name, String defaultValue) {
String value = get(name, defaultValue);
if (StrKit.notBlank(value)) {
value = value.toUpperCase();
}
return value;
}
private Double toDouble(String value, Double defaultValue) {
try {
if (StrKit.isBlank(value))
return defaultValue;
value = value.trim();
if (value.startsWith("N") || value.startsWith("n"))
return -Double.parseDouble(value.substring(1));
return Double.parseDouble(value);
}
catch (Exception e) {
throw new ActionException(400, renderManager.getRenderFactory().getErrorRender(400), "Can not parse the parameter \"" + value + "\" to Double value.");
}
}
@NotAction
public Double getParaToDouble(String name) {
return toDouble(getPara(name), null);
}
@NotAction
public Double getParaToDouble(String name, Double defaultValue) {
return toDouble(getPara(name), defaultValue);
}
public void renderJsonp(Result json){
String callback = get("callback");
if(StrKit.notBlank(callback)) {
renderJavascript(callback + "(" + json.toJSONString() + ");");
}else{
renderJson(json);
}
}
}

View File

@ -0,0 +1,121 @@
package com.cowr.common.base;
import com.alibaba.fastjson.annotation.JSONField;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.IBean;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Table;
import com.cowr.common.Const;
import com.cowr.common.utils.StrUtil;
public abstract class BaseModel<M extends Model<M>> extends Model<M> implements IBean {
private static final Log log = Log.getLog(BaseModel.class);
private static final String tablename = "";
public String getTablename() {
return tablename;
}
/**
*
*
* @param colunm
* @return
*/
public boolean hasColunm(String colunm) {
return _getTable().getColumnTypeMap().containsKey(colunm);
}
/**
* del
*
* @return
*/
public boolean hasDelKey() {
return hasColunm(Const.LOGIC_DEL_KEY);
}
@JSONField(serialize = false)
public String[] getPKey() {
return _getTable().getPrimaryKey();
}
/**
*
*
* @return
*/
public M findByPk() {
Table table = _getTable();
String[] pKeys = table.getPrimaryKey();
if (pKeys == null) {
log.debug(table.getName() + " 未找到主键字段");
pKeys = new String[0];
}
Object[] vals = new Object[pKeys.length];
for (int i = 0; i < pKeys.length; i++) {
vals[i] = get(pKeys[i]);
}
if (vals.length == 1) {
return findById(vals[0]);
} else {
return findByIds(vals);
}
}
/**
*
*
* @return boolean
*/
public boolean checkExistsByPk() {
return findByPk() != null;
}
/**
* model
*
* @param columns
* @return
*/
public M findByColumns(String... columns) {
Object[] vals = new Object[columns.length];
for (int i = 0; i < columns.length; i++) {
vals[i] = get(columns[i]);
}
String sql = StrUtil.findFirstByColumnsSql(_getTable().getName(), columns);
return findFirst(sql, vals);
}
/**
*
*
* @param columns
* @return
*/
public boolean checkDuplicate(String... columns) {
return findByColumns(columns) != null;
}
/**
*
*
* @return
*/
public M clone() {
try {
Model<?> ar = this.getClass().newInstance();
ar._setAttrs(this._getAttrs());
return (M) ar;
} catch (InstantiationException | IllegalAccessException e) {
log.error(e.getMessage(), e);
}
return null;
}
}

View File

@ -0,0 +1,388 @@
package com.cowr.common.base;
import com.cowr.common.enums.Enums;
import com.cowr.common.utils.StrUtil;
import com.cowr.model.Sysuser;
import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom;
import com.jfinal.plugin.activerecord.Model;
import com.cowr.common.Const;
import com.cowr.common.view.Result;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
public class BaseService {
private static Log log = Log.getLog(BaseService.class);
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result checkExistsByPk(BaseModel model) {
return Result.success(model.checkExistsByPk());
}
/**
*
*
* @param model
* @param columns
* @return
*/
public Result checkDuplicate(BaseModel model, String... columns) {
return Result.success(model.checkDuplicate(columns));
}
/**
*
*
* @param model
* @param columns
* @return
*/
public Result save(BaseModel model, String... columns) {
if (model.checkDuplicate(columns)) {
return Result.failed(false, StrUtil.join(Arrays.asList(columns), ",") + " 数据重复");
} else {
return save(model);
}
}
public Result save(BaseModel model, Sysuser sysuser, String... columns) {
if (model.checkDuplicate(columns)) {
return Result.failed(false, StrUtil.join(Arrays.asList(columns), ",") + " 数据重复");
} else {
return save(model, sysuser);
}
}
/**
*
*
* @param model
* @param sysuser
* @return
*/
public Result save(BaseModel model, Sysuser sysuser) {
try {
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try {
boolean ret = model.save();
if (ret) {
ret = ModifyLogService.me.save(model, null, Enums.DataOpType.SAVE.getId(), sysuser);
}
return ret;
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
}
});
return ret ? Result.object(model) : Result.failed(false, "新增失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e.getMessage().contains("PRIMARY")) {
return Result.failed(false, "主键冲突");
} else {
return Result.failed(false, e.getMessage());
}
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result save(BaseModel model) {
try {
boolean ret = model.save();
return ret ? Result.object(model) : Result.failed(false, "新增失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e.getMessage().contains("PRIMARY")) {
return Result.failed(false, "主键冲突");
} else {
return Result.failed(false, e.getMessage());
}
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result delete(BaseModel model) {
try {
// 如果存在逻辑删除字段 del则只做逻辑删除不做物理删除
if (model.hasDelKey()) {
return logicDel(model);
}
// 注意这里有 !,找到后才做 delete 操作
if (!model.checkExistsByPk()) {
return Result.failed(false, "按主键未找到对应记录");
}
return Result.object(model.delete());
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "删除失败");
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result delete(BaseModel model, Sysuser sysuser) {
try {
// 如果存在逻辑删除字段 del则只做逻辑删除不做物理删除
if (model.hasDelKey()) {
return logicDel(model, sysuser);
}
// 注意这里有 !,找到后才做 delete 操作
if (!model.checkExistsByPk()) {
return Result.failed(false, "按主键未找到对应记录");
}
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try{
boolean ret = model.delete();
if (ret) {
ret = ModifyLogService.me.save(model, (BaseModel) model.findByPk(), Enums.DataOpType.DELETE.getId(), sysuser);
}
return ret;
}catch (Exception e){
log.error(e.getMessage(), e);
return false;
}
}
});
return Result.object(ret);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "删除失败");
}
}
/**
*
*
* @param model
* @return
*/
public Result logicDel(BaseModel model) {
try {
if (!model.hasDelKey()) {
return Result.failed(false, "不存在逻辑删除字段");
}
model.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_INVALID); // 逻辑删除字段统一用 del
return update(model);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "删除失败");
}
}
/**
*
*
* @param model
* @return
*/
public Result logicDel(BaseModel model, Sysuser sysuser) {
try {
if (!model.hasDelKey()) {
return Result.failed(false, "不存在逻辑删除字段");
}
model.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_INVALID); // 逻辑删除字段统一用 del
return update(model, sysuser);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "删除失败");
}
}
/**
*
*
* @param model
* @return
*/
public Result restore(BaseModel model) {
try {
if (!model.hasDelKey()) {
return Result.failed(false, "不存在逻辑删除字段");
}
model.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_VALID); // 逻辑删除字段统一用 del
return update(model);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "恢复失败");
}
}
/**
*
*
* @param model
* @return
*/
public Result restore(BaseModel model, Sysuser sysuser) {
try {
if (!model.hasDelKey()) {
return Result.failed(false, "不存在逻辑删除字段");
}
model.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_VALID); // 逻辑删除字段统一用 del
return update(model, sysuser);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "恢复失败");
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result update(BaseModel model) {
try {
// 注意这里有 !,找到后才做 update 操作
BaseModel oldobj = (BaseModel) model.findByPk();
if (oldobj == null) {
return Result.failed(false, "按主键未找到对应记录");
}
boolean ret = model.update();
// 将修改后的对象返回
String[] keys = model._getAttrNames();
for (String key : keys) {
oldobj.set(key, model.get(key));
}
return ret ? Result.object(oldobj) : Result.failed(false, "修改失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "修改失败");
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result update(BaseModel model, Sysuser sysuser) {
try {
// 注意这里有 !,找到后才做 update 操作
BaseModel oldobj = (BaseModel) model.findByPk();
if (oldobj == null) {
return Result.failed(false, "按主键未找到对应记录");
}
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() {
try{
boolean ret = model.update();
if (ret) {
ret = ModifyLogService.me.save(model, oldobj, Enums.DataOpType.UPDATE.getId(), sysuser);
}
return ret;
}catch (Exception e){
log.error(e.getMessage(), e);
return false;
}
}
});
// 将修改后的对象返回
String[] keys = model._getAttrNames();
for (String key : keys) {
oldobj.set(key, model.get(key));
}
return ret ? Result.object(oldobj) : Result.failed(false, "修改失败");
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.failed(false, "修改失败");
}
}
/**
*
*
* @param model BaseModel
* @return Result
*/
public Result findByPk(BaseModel model) {
return Result.object(model.findByPk(), "按主键未找到记录");
}
/**
*
*
* @param list ? extends Model
* @return
*/
public Result batchSave(List<? extends Model> list) {
try {
boolean flag = Db.tx(new IAtom() {
@Override
public boolean run() throws SQLException {
int[] ret = Db.batchSave(list, list.size());
return true;
}
});
return Result.object(flag);
} catch (Exception e) {
log.error(e.getMessage(), e);
if (e.getMessage().contains("PRIMARY")) {
return Result.failed(false, "主键冲突");
} else {
return Result.failed(false, e.getMessage());
}
}
}
}

View File

@ -0,0 +1,26 @@
package com.cowr.common.cache;
import com.jfinal.plugin.activerecord.cache.ICache;
import com.jfinal.plugin.redis.Redis;
public class RedisArpCache implements ICache {
@Override
public <T> T get(String cacheName, Object key) {
return Redis.use(cacheName).get(key);
}
@Override
public void put(String cacheName, Object key, Object value) {
Redis.use(cacheName).set(key, value);
}
@Override
public void remove(String cacheName, Object key) {
Redis.use(cacheName).del(key);
}
@Override
public void removeAll(String cacheName) {
}
}

View File

@ -0,0 +1,26 @@
package com.cowr.common.ctrl;
import com.jfinal.core.Controller;
import com.jfinal.kit.HttpKit;
import com.jfinal.upload.UploadFile;
/**
*
*/
public class HomeController extends Controller {
public void index() {
renderJson("ret", "接口联通测试");
}
public void img() {
try {
String data = HttpKit.readData(getRequest());
System.out.println(data);
} catch (Exception e) {
e.printStackTrace();
}
renderJson("ret", true);
}
}

View File

@ -0,0 +1,89 @@
package com.cowr.common.enums;
import com.jfinal.kit.StrKit;
public interface Enums {
enum MsgTarget {
LOGIN, // 注册
HEARTBEAT, // 心跳
HEARTBEATREPLY, // 心跳回复
SYNCTASK, // 数据同步
SYNCRECV, // 数据同步反馈
}
/**
*
*/
enum DataOpType {
SAVE(1), // 新增
UPDATE(2), // 修改
DELETE(3); // 删除
int id;
DataOpType(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
/**
*
*/
enum CtrlFlowEnum {
R, // 入场(兼容同一个磅有两个摄像头)
C, // 出场(兼容同一个磅有两个摄像头)
T; // 一个磅,一个摄像头,,即可以进,也可以出
/**
* which
* name
* @param which
* @return
*/
public static boolean isValid(String which){
if(StrKit.isBlank(which)){
return false;
}
for(CtrlFlowEnum ctrl : CtrlFlowEnum.values()){
if(which.startsWith(ctrl.name())){
return true;
}
}
return false;
}
}
/**
* which
*/
enum WhichEnum{
R01, // 入场 01
C01, // 出场 01
}
enum RowEnum{
FRONT(1),
BACK(2);
int id;
RowEnum(int id){
this.id = id;
}
public int getId() {
return id;
}
}
enum PrinterIdEnum {
printer1,
printer2,
}
}

View File

@ -0,0 +1,68 @@
package com.cowr.common.enums;
import java.util.ArrayList;
import java.util.List;
/**
1
2()
3
4
5
9
*/
public enum OrderStateEnum {
INITIAL(1),
ENTERED(2),
LOADED(3),
LEAVE(4),
RECEIVED(5),
INVALID(9);
OrderStateEnum(int stateid) {
this.stateid = stateid;
}
private int stateid;
public int getStateid() {
return stateid;
}
public void setStateid(int stateid) {
this.stateid = stateid;
}
/**
* stateid
* @param stateid
* @return
*/
public static boolean hasStateId(int stateid){
for(OrderStateEnum stateEnum : OrderStateEnum.values()){
if(stateEnum.stateid == OrderStateEnum.INITIAL.getStateid()){ // state == 1 是后端在添加订单时设置的
continue;
}
if(stateEnum.stateid == stateid){
return true;
}
}
return false;
}
public static List<Integer> getStateIdArr(){
List<Integer> list = new ArrayList<>();
for(OrderStateEnum stateEnum : OrderStateEnum.values()){
if(stateEnum.stateid == OrderStateEnum.INITIAL.getStateid()){
continue;
}
list.add(stateEnum.getStateid());
}
return list;
}
}

View File

@ -0,0 +1,58 @@
package com.cowr.common.enums;
import java.util.ArrayList;
import java.util.List;
/**
1
2
3
4.
5.
*/
public enum OrderTypeEnum {
SALE(1),
TRANSFER(2),
TEMP(3),
TRASH(4),
PURCHASE(5);
OrderTypeEnum(int typeid) {
this.typeid = typeid;
}
private int typeid;
public int getTypeid() {
return typeid;
}
public void setTypeid(int typeid) {
this.typeid = typeid;
}
/**
* typeid
* @param typeid
* @return
*/
public static boolean hasStateId(int typeid){
for(OrderTypeEnum stateEnum : OrderTypeEnum.values()){
if(stateEnum.typeid == typeid){
return true;
}
}
return false;
}
public static List<Integer> getTypeIdArr(){
List<Integer> list = new ArrayList<>();
for(OrderTypeEnum stateEnum : OrderTypeEnum.values()){
list.add(stateEnum.getTypeid());
}
return list;
}
}

View File

@ -0,0 +1,12 @@
package com.cowr.common.enums;
/**
*
*
*/
public class TruckRodState {
public static final int state_1 = 1; // 未在系统中登记的车牌,未入场。红色。
public static final int state_2 = 2; // 已在系统中登记的车牌,未入场。绿色。
public static final int state_3 = 3; // 正在入场(已抬杆,但没有入场称重)。黄色。
public static final int state_4 = 4; // 已入场(有入场称重)。灰色。
}

View File

@ -0,0 +1,72 @@
package com.cowr.common.enums;
import java.util.ArrayList;
import java.util.List;
/**
type role type role
1
2
3customer
4.
5.
*/
public enum UserTypeEnum {
CONFIG(0), // 系统配置管理
SUPERMARKET(1),
TRANSCO(2),
CUSTOMER(3),
DRIVER(4),
LEAD(5); // 砂石公司领导
private Integer typeid;
public Integer getTypeid() {
return typeid;
}
public void setTypeid(Integer typeid) {
this.typeid = typeid;
}
UserTypeEnum(Integer typeid){
this.typeid = typeid;
}
public static UserTypeEnum getUserType(Integer typeid){
for( UserTypeEnum t :UserTypeEnum.values()){
if(t.typeid == typeid){
return t;
}
}
return null;
}
/**
* typeid
* @param typeid
* @return
*/
public static boolean hasTypeId(Integer typeid){
for(UserTypeEnum t :UserTypeEnum.values()){
if(t.typeid == typeid){
return true;
}
}
return false;
}
public static List<Integer> getTypeIdArr(){
List<Integer> list = new ArrayList<>();
for(UserTypeEnum t :UserTypeEnum.values()){
list.add(t.getTypeid());
}
return list;
}
}

View File

@ -0,0 +1,28 @@
package com.cowr.common.handler;
import com.jfinal.handler.Handler;
import com.jfinal.log.Log;
import com.cowr.common.Interceptor.ReporterInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by lisai on 03/22.
*
*/
public class GlobalHandler extends Handler {
private static Log log = Log.getLog(GlobalHandler.class);
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
long starttime = System.currentTimeMillis();
next.handle(target, request, response, isHandled);
if (!ReporterInterceptor.exclude.contains(target)) {
log.debug("req [" + target + "] time -> " + (System.currentTimeMillis() - starttime) + " ms");
}
}
}

View File

@ -0,0 +1,37 @@
package com.cowr.common.netty;
import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import java.util.List;
public class JSONDecoder extends ByteToMessageDecoder {
//目标对象类型进行解码
private Class<?> target;
public JSONDecoder(Class target) {
this.target = target;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
if (in.readableBytes() < 4) { //不够长度丢弃
return;
}
in.markReaderIndex(); //标记一下当前的readIndex的位置
int dataLength = in.readInt(); // 读取传送过来的消息的长度。ByteBuf 的readInt()方法会让他的readIndex增加4
if (in.readableBytes() < dataLength) { //读到的消息体长度如果小于我们传送过来的消息长度则resetReaderIndex. 这个配合markReaderIndex使用的。把readIndex重置到mark的地方
in.resetReaderIndex();
return;
}
byte[] data = new byte[dataLength];
in.readBytes(data);
Object obj = JSON.parseObject(data, target); //将byte数据转化为我们需要的对象
out.add(obj);
}
}

View File

@ -0,0 +1,28 @@
package com.cowr.common.netty;
import com.alibaba.fastjson.JSON;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
public class JSONEncoder extends MessageToByteEncoder {
//目标对象类型进行编码
private Class<?> target;
public JSONEncoder(Class target) {
this.target = target;
}
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
if (target.isInstance(msg)) {
byte[] data = JSON.toJSONBytes(msg); //使用fastJson将对象转换为byte
out.writeInt(data.length); //先将消息长度写入,也就是消息头
out.writeBytes(data); //消息体中包含我们要发送的数据
}else{
System.out.println("encode instance error: " + msg.getClass());
}
}
}

View File

@ -0,0 +1,93 @@
package com.cowr.common.plugin;
import com.jfinal.log.Log;
import com.jfinal.plugin.IPlugin;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.CharsetUtil;
import java.util.HashMap;
import java.util.Map;
public class NettyServerPlugin implements IPlugin {
private static Log log = Log.getLog(NettyServerPlugin.class);
private int port;
private Map<Channel, Integer> map = new HashMap<>();
private ServerBootstrap serverBootstrap;
private EventLoopGroup workerGroup;
private EventLoopGroup bossGroup;
public NettyServerPlugin(int port){
this.port = port;
}
@Override
public boolean start() {
bossGroup = new NioEventLoopGroup();
workerGroup = new NioEventLoopGroup();
try {
serverBootstrap = new ServerBootstrap();
serverBootstrap.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(
new IdleStateHandler(5, 5, 5),
new StringEncoder(CharsetUtil.UTF_8),
new LineBasedFrameDecoder(4096),
new StringDecoder(CharsetUtil.UTF_8),
new MsgHandler()
);
}
})
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true);
// Bind and start to accept incoming connections.
ChannelFuture f = serverBootstrap.bind(port);
// f.addListener((ChannelFutureListener) future -> {
// if (!future.isSuccess()) {
// map.remove(f.channel());
// }
// });
f.sync();
f.channel().closeFuture().sync();
return true;
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
return false;
} finally {
workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully();
}
}
@Override
public boolean stop() {
if (serverBootstrap != null) {
workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully();
serverBootstrap = null;
}
return true;
}
private static class MsgHandler extends SimpleChannelInboundHandler<String> {
@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, String s) throws Exception {
}
}
}

View File

@ -0,0 +1,112 @@
package com.cowr.common.plugin;
import com.jfinal.plugin.IPlugin;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Enumeration;
import java.util.Properties;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;
/**
* Created by lisai on 2015/5/27.
*/
public class QuartzPlugin implements IPlugin {
private SchedulerFactory sf = null;
private Scheduler sched = null;
private String config = "job.properties";
private Properties properties;
public QuartzPlugin(String config) {
this.config = config;
}
public QuartzPlugin() {
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean start() {
sf = new StdSchedulerFactory();
try {
sched = sf.getScheduler();
} catch (SchedulerException e) {
new RuntimeException(e);
}
loadProperties();
Enumeration enums = properties.keys();
while (enums.hasMoreElements()) {
String key = enums.nextElement() + "";
if (!key.endsWith("job")) {
continue;
}
String cronKey = key.substring(0, key.indexOf("job")) + "cron";
String enable = key.substring(0, key.indexOf("job")) + "enable";
if (isDisableJob(enable)) {
continue;
}
String jobClassName = properties.get(key) + "";
String jobCronExp = properties.getProperty(cronKey) + "";
Class clazz;
try {
clazz = Class.forName(jobClassName);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
JobDetail job = newJob(clazz).withIdentity(jobClassName,
jobClassName).build();
CronTrigger trigger = newTrigger()
.withIdentity(jobClassName, jobClassName)
.withSchedule(cronSchedule(jobCronExp)).build();
Date ft = null;
try {
ft = sched.scheduleJob(job, trigger);
sched.start();
} catch (SchedulerException ee) {
new RuntimeException(ee);
}
System.out.println(job.getKey() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
}
return true ;
}
private boolean isDisableJob(String enable) {
return Boolean.valueOf(properties.get(enable) + "") == false;
}
private void loadProperties() {
properties = new Properties();
InputStream is = QuartzPlugin.class.getClassLoader()
.getResourceAsStream(config);
try {
properties.load(is);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public boolean stop() {
try {
sched.shutdown();
} catch (SchedulerException e) {
e.printStackTrace();
return false;
}
return true;
}
public static void main(String[]args) {
QuartzPlugin plugin = new QuartzPlugin();
plugin.start();
System.out.println("执行成功!!!");
}
}

View File

@ -0,0 +1,72 @@
package com.cowr.common.plugin;
import com.alibaba.fastjson.JSONObject;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.listener.ConnectListener;
import com.corundumstudio.socketio.listener.DataListener;
import com.corundumstudio.socketio.listener.DisconnectListener;
import com.jfinal.plugin.IPlugin;
import com.jfinal.plugin.activerecord.Record;
import org.apache.poi.ss.formula.functions.T;
public class SocketIOServerPlugin implements IPlugin {
private int port;
private SocketIOServer server;
public SocketIOServerPlugin(int port) {
this.port = port;
}
public void pub(String channel, Record params){
if(server != null) {
server.getBroadcastOperations().sendEvent(channel, params);
}
}
public void pub(String channel, JSONObject params){
if(server != null) {
server.getBroadcastOperations().sendEvent(channel, params);
}
}
@Override
public boolean start() {
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(port);
server = new SocketIOServer(config);
server.start();
return true;
}
@Override
public boolean stop() {
if(server != null){
server.stop();
}
return true;
}
public void addEventListener(String eventName, Class<T> eventClass, DataListener<T> listener){
if(server != null) {
server.addEventListener(eventName, eventClass, listener);
}
}
public void addConnectListener(ConnectListener listener){
if(server != null){
server.addConnectListener(listener);
}
}
public void addDisconnectListener(DisconnectListener listener){
if(server != null){
server.addDisconnectListener(listener);
}
}
}

View File

@ -0,0 +1,66 @@
package com.cowr.common.serializer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.jfinal.log.Log;
import com.jfinal.plugin.redis.serializer.ISerializer;
/**
* Created by lisai on 16/12/17.
*/
public class CowrSerializer implements ISerializer {
private static Log log = Log.getLog(CowrSerializer.class);
public static final ISerializer me = new CowrSerializer();
@Override
public byte[] keyToBytes(String key) {
return key.getBytes();
}
@Override
public String keyFromBytes(byte[] bytes) {
return new String(bytes);
}
@Override
public byte[] fieldToBytes(Object field) {
return JSON.toJSONBytes(field);
}
@Override
public Object fieldFromBytes(byte[] bytes) {
if( bytes == null ){
return null;
}
try{
return JSON.parse(bytes);
}catch (Exception e){
log.error(e.getMessage(), e);
return null;
}
}
@Override
public byte[] valueToBytes(Object value) {
SerializeConfig mapping = new SerializeConfig();
// mapping.put(org.bson.types.ObjectId.class, new ObjectIdSerializer()); // mongodb ObjectId
return JSON.toJSONBytes(value, mapping);
}
@Override
public Object valueFromBytes(byte[] bytes) {
if( bytes == null ){
return null;
}
try{
return JSON.parse(bytes);
}catch (Exception e){
log.error(e.getMessage(), e);
return null;
}
}
}

View File

@ -0,0 +1,94 @@
package com.cowr.common.utils;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.util.Arrays;
public class AESUtil {
public static byte[] encrypt(String key, byte[] origData) throws GeneralSecurityException {
byte[] keyBytes = getKeyBytes(key);
byte[] buf = new byte[16];
System.arraycopy(keyBytes, 0, buf, 0, keyBytes.length > buf.length ? keyBytes.length : buf.length);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(buf, "AES"), new IvParameterSpec(keyBytes));
return cipher.doFinal(origData);
}
public static byte[] decrypt(String key, byte[] crypted) throws GeneralSecurityException {
byte[] keyBytes = getKeyBytes(key);
byte[] buf = new byte[16];
System.arraycopy(keyBytes, 0, buf, 0, keyBytes.length > buf.length ? keyBytes.length : buf.length);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(buf, "AES"), new IvParameterSpec(keyBytes));
return cipher.doFinal(crypted);
}
private static byte[] getKeyBytes(String key) {
byte[] bytes = key.getBytes();
return bytes.length == 16 ? bytes : Arrays.copyOf(bytes, 16);
}
public static String encrypt(String key, String val) throws GeneralSecurityException {
byte[] origData = val.getBytes();
byte[] crypted = encrypt(key, origData);
return parseByte2HexStr(crypted);
}
public static String decrypt(String key, String val) throws GeneralSecurityException, UnsupportedEncodingException {
byte[] crypted = parseHexStr2Byte(val);
byte[] origData = decrypt(key, crypted);
return new String(origData, "utf-8");
}
/**
* 16
*
* @param buf
* @return
*/
public static String parseByte2HexStr(byte buf[]) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
/**
* 16
*
* @param hexStr
* @return
*/
public static byte[] parseHexStr2Byte(String hexStr) {
if (hexStr.length() < 1)
return null;
byte[] result = new byte[hexStr.length() / 2];
for (int i = 0; i < hexStr.length() / 2; i++) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result[i] = (byte) (high * 16 + low);
}
return result;
}
public static void main(String[] args) throws Exception {
String content = "加密之前加密之前加密之前";
String password = "21";
System.out.println("加密之前:" + content);
String hexStrResult = encrypt(password, content);
System.out.println("加密之后:" + hexStrResult);
System.out.println("解密后的内容:" + decrypt(password, hexStrResult));
}
}

View File

@ -0,0 +1,198 @@
package com.cowr.common.utils;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
public class ChineseNumberUtil {
private static final String[] BEFORE_SCALE = {"万", "仟", "佰", "拾", "亿", "仟", "佰", "拾", "万", "仟", "佰", "拾", ""};
private static final String[] AFTER_SCALE = {"角", "分"};
private static final String DEFAULT_PATH_SEPARATOR = ".";
private static final Map<String, String> NUMBER_MAPPING = new HashMap<String, String>();
static {
NUMBER_MAPPING.put("0", "零");
NUMBER_MAPPING.put("1", "壹");
NUMBER_MAPPING.put("2", "贰");
NUMBER_MAPPING.put("3", "叁");
NUMBER_MAPPING.put("4", "肆");
NUMBER_MAPPING.put("5", "伍");
NUMBER_MAPPING.put("6", "陆");
NUMBER_MAPPING.put("7", "柒");
NUMBER_MAPPING.put("8", "捌");
NUMBER_MAPPING.put("9", "玖");
}
public static String getChineseNumber(String number) {
return getChineseNumber(number, null, null);
}
public static String getChineseNumber(String number, String unit, String postfix) {
String[] numbers = StrUtil.strToStrArray(number, DEFAULT_PATH_SEPARATOR);
if (numbers.length > 2) {
new NumberFormatException("数字格式错误!");
}
int length = numbers[0].length();
int isZero = 0;
StringBuffer result = new StringBuffer();
for (int i = 0; i < length; i++) {
String digit = String.valueOf(numbers[0].charAt(i));
// 第一个就是 0
if(i == 0 && "0".equals(digit)){
result.append(NUMBER_MAPPING.get("0"));
}
boolean allZero = true; // 如果后继的全部是零,则跳出
for (int j = i; j < length; j++) {
if (numbers[0].charAt(j) != '0') {
allZero = false;
break;
}
}
if (allZero) {
boolean hasValue = false;
for (int z = i; z >= 0; z--) {
if (numbers[0].charAt(z) != '0' && length - z <= 7 && length - z >= 5) {
hasValue = true;
break;
}
}
// 加万单位
if ((length - i > 4 && length <= 8) || (hasValue && length - i > 4)) {
result.append(BEFORE_SCALE[8]);
}
// 加亿单位
if (length - i >= 9) {
result.append(BEFORE_SCALE[4]);
}
break;
}
if (length < 9 && length - i == 5) {
if (!"0".equals(digit) && isZero > 0) {
result.append(NUMBER_MAPPING.get("0"));
}
if ("0".equals(digit)) {
result.append(BEFORE_SCALE[8]);
if (isZero > 0) {
result.append(NUMBER_MAPPING.get("0"));
}
continue;
}
}
if ("0".equals(digit) && length > 9 && length - i == 9) {
result.append(BEFORE_SCALE[4]);
continue;
}
if (isZero < 1 || !"0".equals(digit)) {
if ("0".equals(digit)) {
if (length - i != 6 && length - i != 7) {
result.append(NUMBER_MAPPING.get(digit));
}
} else {
result.append(NUMBER_MAPPING.get(digit));
}
if (!"0".equals(digit)) {
result.append(BEFORE_SCALE[BEFORE_SCALE.length - length + i]);
}
}
if ("0".equals(digit)) {
isZero++;
} else {
isZero = 0;
}
}
result.append(unit == null ? "圆" : result.append(unit));
if (numbers.length == 1) {
result.append(postfix == null ? "整" : result.append(postfix));
return result.toString();
}
length = numbers[1].length();
for (int j = 0; j < length; j++) {
if (j > 2) {
break;
}
if (numbers[1].charAt(j) == '0') {
continue;
}
result.append(NUMBER_MAPPING.get(String.valueOf(numbers[1].charAt(j))));
result.append(AFTER_SCALE[j]);
}
result.append(postfix == null ? "整" : result.append(postfix));
return result.toString();
}
public static String getChineseNumber(int number) {
return getChineseNumber(new Integer(number));
}
public static String getChineseNumber(int number, String unit, String postfix) {
return getChineseNumber(new Integer(number), unit, postfix);
}
public static String getChineseNumber(Long number) {
return getChineseNumber(number.toString(), null, null);
}
public static String getChineseNumber(Integer number) {
return getChineseNumber(number.toString(), null, null);
}
public static String getChineseNumber(Integer number, String unit, String postfix) {
return getChineseNumber(number.toString(), unit, postfix);
}
public static String getChineseNumber(Long number, String unit, String postfix) {
return getChineseNumber(number.toString(), unit, postfix);
}
public static String getChineseNumber(long number) {
return getChineseNumber(new Long(number));
}
public static String getChineseNumber(long number, String unit, String postfix) {
return getChineseNumber(new Long(number), unit, postfix);
}
public static String getChineseNumber(double number, String unit, String postfix) {
DecimalFormat f = (DecimalFormat) DecimalFormat.getInstance();
f.applyLocalizedPattern("#.##");
return getChineseNumber(f.format(number), unit, postfix);
}
public static String getChineseNumber(double number) {
return getChineseNumber(number, null, null);
}
public static String getChineseNumber(Double number) {
return getChineseNumber(number.doubleValue());
}
public static String getChineseNumber(Double number, String unit, String postfix) {
return getChineseNumber(number.doubleValue(), unit, postfix);
}
public static void main(String[] args) {
// System.out.println(getChineseNumber(0));
// System.out.println(getChineseNumber(10));
// System.out.println(getChineseNumber(01));
System.out.println(getChineseNumber(0101));
// System.out.println(getChineseNumber(1994));
// System.out.println(getChineseNumber(1994.1115));
// System.out.println(getChineseNumber(19941115));
}
}

View File

@ -0,0 +1,140 @@
package com.cowr.common.utils;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DataUtil {
/**
*
*
* @param sNodes
* @return
*/
public static List<Record> transformToTreeFormat(List<Record> sNodes){
Map<String, String> setting = new HashMap<String, String>();
setting.put("idKey", "id");
setting.put("pIdKey", "pid");
setting.put("childKey", "children");
return transformToTreeFormat(setting, sNodes);
}
/**
*
* {
* idKey : 'id',
* pIdKey : 'pid',
* childKey : 'children'
* }
*
* @param setting
* @param sNodes
*/
public static List<Record> transformToTreeFormat(Map<String, String> setting, List<Record> sNodes){
List<Record> r = new ArrayList<Record>();
String key = setting.get("idKey");
String parentKey = setting.get("pIdKey");
String childKey = setting.get("childKey");
if ( !StrKit.notBlank(key, parentKey, childKey) ){
return r;
}
Map<Object, Record> tmpMap = new HashMap<Object, Record>();
for( Record node : sNodes ){
tmpMap.put(node.get(key), node);
}
for( Record node : sNodes ){
Object id = node.get(key);
Object pid = node.get(parentKey);
if( tmpMap.containsKey(pid) && !id.equals(pid) ){
Record pnode = tmpMap.get(pid);
if( pnode.get(childKey) == null ){
pnode.set(childKey, new ArrayList<Record>());
}
((ArrayList<Record>)pnode.get(childKey)).add(node);
}else{
r.add(node);
}
}
return r;
}
public static Record cloneRecord(Record record) {
return cloneRecord(record, false);
}
/**
* record
* @param record
* @param deep
* @return
*/
public static Record cloneRecord(Record record, boolean deep){
String[] keys = record.getColumnNames();
Record out = new Record();
for(String key : keys){
Object object = record.get(key);
if(deep && object instanceof Record){
object = cloneRecord((Record) object);
}
out.set(key, object);
}
return out;
}
/**
* record double BigDecimal double
* @param record
* @param key
* @return
*/
public static Double getDoubleByRecord(Record record, String key){
if(record == null){
return null;
}
Object obj = record.get(key);
if(obj == null){
return null;
}
if(obj instanceof Double){
return record.getDouble(key);
}
if(obj instanceof BigDecimal){
return record.getBigDecimal(key).doubleValue();
}
if(obj instanceof String){
return Double.valueOf(record.getStr(key));
}
return null;
}
public static Double getDefaultByRecord(Record record, String key){
Double obj = getDoubleByRecord(record, key);
return obj == null ? 0.0 : obj;
}
}

View File

@ -0,0 +1,67 @@
package com.cowr.common.utils;
import com.jfinal.kit.StrKit;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateTimeUtil {
public static final String ymdhms = "yyyy-MM-dd HH:mm:ss";
public static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
public static final ThreadLocal<SimpleDateFormat> sdfymd = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy年MM月dd日");
}
};
public static final ThreadLocal<SimpleDateFormat> sd = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM");
}
};
public static final ThreadLocal<SimpleDateFormat> sdfym = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy年MM月");
}
};
public static final ThreadLocal<SimpleDateFormat> sdfhms = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
public static final ThreadLocal<SimpleDateFormat> sdfhm = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm");
}
};
/**
*
* @param str
* @param fmt
* @return
*/
public static boolean isValidDate(String str, String fmt) {
if (!StrKit.notBlank(str, fmt)) {
return false;
}
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
try {
// 设置lenient为false.
// 否则SimpleDateFormat会比较宽松地验证日期比如2007/02/29会被接受并转换成2007/03/01
sdf.setLenient(false);
Date tm = sdf.parse(str);
return sdf.format(tm).equals(str); // 将转换后的时间再格式化,和原字符串对比,检查是否一致
} catch (ParseException e) {
// e.printStackTrace();
// 如果throw java.text.ParseException或者NullPointerException就说明格式不对
return false;
}
}
}

View File

@ -0,0 +1,107 @@
package com.cowr.common.utils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.jfinal.kit.Base64Kit;
import com.jfinal.log.Log;
import net.coobird.thumbnailator.Thumbnails;
import sun.misc.BASE64Decoder;
import java.io.*;
import java.util.Base64;
public class ImageUtil {
private static Log log = Log.getLog(ImageUtil.class);
public static File createThumbnail(File imageFile, String newname) throws IOException {
if (imageFile == null || imageFile.isDirectory() || !imageFile.exists()) {
return null;
}
String oldpath = imageFile.getAbsolutePath();
String outfmt = oldpath.substring(oldpath.lastIndexOf(".") + 1, oldpath.length()).toLowerCase();
String newpath = imageFile.getParentFile().getAbsolutePath() + "/" + newname;
Thumbnails.of(oldpath).scale(0.7f).outputFormat(outfmt).toFile(newpath);
File newfile = new File(newpath);
if (newfile != null && newfile.exists()) {
return newfile;
}
return null;
}
public static boolean generateImage(String imgStr, File imgFile) {// 对字节数组字符串进行Base64解码并生成图片
if (imgStr == null) // 图像数据为空
return false;
BASE64Decoder decoder = new BASE64Decoder();
OutputStream out = null;
try {
// Base64解码
byte[] bytes = decoder.decodeBuffer(imgStr);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) {// 调整异常数据
bytes[i] += 256;
}
}
// 生成图片
out = new FileOutputStream(imgFile);
out.write(bytes);
out.flush();
out.close();
return true;
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
public static byte[] getQRCodeImage(String text, int width, int height, String format) throws WriterException, IOException {
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix bitMatrix = qrCodeWriter.encode(text, BarcodeFormat.QR_CODE, width, height);
ByteArrayOutputStream out = null;
try{
out = new ByteArrayOutputStream();
MatrixToImageWriter.writeToStream(bitMatrix, format, out);
return out.toByteArray();
}catch (Exception e){
throw e;
}finally {
if(out!= null){
out.close();
}
}
}
public static String getQRCodeBase64(String text, int width, int height, String format) throws IOException, WriterException {
return Base64Kit.encode(getQRCodeImage(text, width, height, format));
}
public static void main(String[] args) {
File file = new File("C:\\Users\\lisai\\Desktop\\402-1-鄂A7D1P11148.jpg");
try {
createThumbnail(file, "123");
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,39 @@
package com.cowr.common.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
public class JsonUtil {
public static JSONObject key2Lower(JSONObject obj){
return key2Lower(obj, false);
}
/**
* json key
* @param obj
* @param deep
* @return
*/
public static JSONObject key2Lower(JSONObject obj, boolean deep){
if(obj == null || obj.isEmpty()){
return obj;
}
JSONObject out = new JSONObject();
for( String key : obj.keySet() ){
Object tmp = obj.get(key);
if( tmp instanceof JSONObject && deep ){
tmp = key2Lower((JSONObject)tmp, deep);
}else if( tmp instanceof JSONArray && deep ){
JSONArray arr = (JSONArray) tmp;
for(int i=0; i<arr.size(); i++){
arr.set(i, key2Lower(arr.getJSONObject(i), deep));
}
}
out.put(key.toLowerCase(), tmp);
}
return out;
}
}

View File

@ -0,0 +1,55 @@
package com.cowr.common.utils;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
/**
* Created by pixii on 2015/11/21.
*/
public class MathUtil {
public static int getLongLength(BigDecimal numericalValue) {
String sNumericalValue = numericalValue.toPlainString();
String[] arrayValues = { "", "" };
if (!(sNumericalValue.indexOf(".") < 0)) {
arrayValues = sNumericalValue.split("\\.");
} else {
arrayValues[0] = sNumericalValue;
}
if (arrayValues[0].contains("-")) {
arrayValues[0] = arrayValues[0].replaceAll("-", "");
}
int intLength = arrayValues[0].length();
return intLength;
}
public static BigDecimal round(BigDecimal val, int scale) {
int intLength = getLongLength(val);
MathContext context = new MathContext(intLength + scale, RoundingMode.HALF_UP);
return val.round(context);
}
/**
* double
* @param d
* @return
*/
public static double round4(double d){
int b = (int) d;
if(d - 0.4 >= b){
b++;
return b;
}
else
return b;
}
}

View File

@ -0,0 +1,34 @@
package com.cowr.common.utils;
import javax.servlet.http.HttpServletRequest;
public class ReqUtil {
/**
* IP使request.getRemoteAddr();使IP,
* X-Forwarded-ForIPIP
* X-Forwarded-ForunknownIP
* X-Forwarded-For192.168.1.110, 192.168.1.120, 192.168.1.130, 192.168.1.100
* IP 192.168.1.110
* @param request
* @return
*/
public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
}

View File

@ -0,0 +1,206 @@
package com.cowr.common.utils;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Record;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StrUtil {
public static final String regphone = "^1[3|4|5|7|8|9][\\d]{9}$"; // 放的比较宽
public static final String DEFAULT_PATH_SEPARATOR = ",";
/**
* adcd
* 129
*
* @param adcd
* @return
*/
public static String getLikeAdcd(String adcd) {
if (StrKit.isBlank(adcd)) {
return "";
}
if ((adcd.length() == 15 && adcd.endsWith("000000000")) || (adcd.length() == 12 && adcd.endsWith("000000"))) {
return adcd.substring(0, 6) + "%";
}
if ((adcd.length() == 15 && adcd.endsWith("000000")) || (adcd.length() == 12 && adcd.endsWith("000"))) {
return adcd.substring(0, 9) + "%";
}
if (adcd.length() == 15 && adcd.endsWith("000")) {
return adcd.substring(0, 12) + "%";
}
return adcd + "%";
}
/**
*
*
* @param adcd
* @return
*/
public static boolean isCounty(String adcd) {
if (StrKit.isBlank(adcd)) {
return false;
}
return (adcd.length() == 15 && adcd.endsWith("000000000")) || (adcd.length() == 12 && adcd.endsWith("000000"));
}
/**
*
*
* @param adcd
* @return
*/
public static boolean isTown(String adcd) {
if (StrKit.isBlank(adcd)) {
return false;
}
return (
adcd.length() == 15 && !adcd.endsWith("000000000") && adcd.endsWith("000000"))
|| (adcd.length() == 12 && !adcd.endsWith("000000") && adcd.endsWith("000")
);
}
/**
*
*
* @param adcd
* @return
*/
public static boolean isVillage(String adcd) {
if (StrKit.isBlank(adcd)) {
return false;
}
return (
adcd.length() == 15 && !adcd.endsWith("000000000") && !adcd.endsWith("000000") && adcd.endsWith("000"))
|| (adcd.length() == 12 && !adcd.endsWith("000000") && !adcd.endsWith("000")
);
}
/**
*
*
* @param adcd
* @return
*/
public static boolean isNaturalVillage(String adcd) {
if (StrKit.isBlank(adcd) || adcd.length() != 15) {
return false;
}
return !adcd.endsWith("000");
}
public static boolean isPhone(String phone) {
return Pattern.matches(regphone, phone);
}
/**
* sql
* @param table
* @param columns
* @return
*/
public static String findByColumnsSql(String table, String... columns) {
StringBuilder sql = new StringBuilder("select * from `");
sql.append(table);
sql.append("` where ");
for (int i=0; i<columns.length; i++) {
if (i > 0) {
sql.append(" and ");
}
sql.append('`').append(columns[i]).append("` = ?");
}
return sql.toString();
}
/**
*
* @param table
* @param columns
* @return
*/
public static String findFirstByColumnsSql(String table, String... columns) {
return findByColumnsSql(table, columns) + " limit 0,1";
}
/**
*
*
* @param str
*
* @return
*/
public static String[] strToStrArray(String str) {
return strToStrArrayManager(str, DEFAULT_PATH_SEPARATOR);
}
/**
* separator
*
* @param str
* @param separator
* @return
*/
public static String[] strToStrArray(String str, String separator) {
return strToStrArrayManager(str, separator);
}
private static String[] strToStrArrayManager(String str, String separator) {
StringTokenizer strTokens = new StringTokenizer(str, separator);
String[] strArray = new String[strTokens.countTokens()];
int i = 0;
while (strTokens.hasMoreTokens()) {
strArray[i] = strTokens.nextToken().trim();
i++;
}
return strArray;
}
public static String getRecordStr(Record record, String key){
String out = record.getStr(key);
if(out == null){
return "";
}
return out;
}
public static boolean validPhone(String phone){
if(StrKit.isBlank(phone)){
return false;
}
Pattern pattern = Pattern.compile(StrUtil.regphone);
Matcher matcher = pattern.matcher(phone);
return matcher.matches();
}
public static String join(Collection var0, String var1) {
StringBuffer var2 = new StringBuffer();
for(Iterator var3 = var0.iterator(); var3.hasNext(); var2.append((String)var3.next())) {
if (var2.length() != 0) {
var2.append(var1);
}
}
return var2.toString();
}
}

View File

@ -0,0 +1,46 @@
package com.cowr.common.validator;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Table;
import com.jfinal.plugin.activerecord.TableMapping;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
/**
*
*/
public abstract class CrudParamValidator extends ParamValidator {
protected void validateUpdateModel(Class modelClass, String modelName) {
validateUpdateModel(modelClass, modelName, true);
}
/**
* model.update()
* com.jfinal.oss.activerecord.Model.update(Model.java:630)
* @param modelClass model class
* @param modelName
*/
protected void validateUpdateModel(Class modelClass, String modelName, boolean skipConvertError) {
Model model = (Model)controller.getModel(modelClass, modelName, skipConvertError);
boolean pass = false;
Table table = TableMapping.me().getTable(modelClass);
String[] pKeys = table.getPrimaryKey();
List<String> pks = Arrays.asList(pKeys);
Set<String> cols = table.getColumnNameSet();
for (String col : cols) {
if (!pks.contains(col) && model.get(col) != null) {
pass = true;
}
}
if (!pass) {
addError("pk", "除主键外的字段不能全是空");
}
}
}

View File

@ -0,0 +1,22 @@
package com.cowr.common.validator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Jun 27 14:48:36 CST 2019
* TableName: customer
* Remarks:
* PrimaryKey: id
*/
public class CustomerIdValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("customer_id", "customer_id", "customer_id 必填");
validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,18 @@
package com.cowr.common.validator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Jun 27 17:01:16 CST 2019
*/
public class DayValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateDate("tm", "yyyy-MM-dd","tm","tm 格式必须为 yyyy-MM-dd");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,18 @@
package com.cowr.common.validator;
import com.jfinal.core.Controller;
import com.cowr.common.view.Result;
/**
* Generated by COWR Thu Jun 27 17:01:16 CST 2019
*/
public class MonthValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateDate("tm", "yyyy-MM","tm","tm 格式必须为 yyyy-MM");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,149 @@
package com.cowr.common.validator;
import com.cowr.common.utils.DateTimeUtil;
import com.jfinal.kit.StrKit;
import com.jfinal.validate.ValidateException;
import com.jfinal.validate.Validator;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* TODO:
*/
public abstract class ParamValidator extends Validator {
/**
*
* handleError errmsg tojson
*/
private Map<String, String> errmsg = new HashMap<>();
/**
* map
* @param errorKey
* @param errorMessage
*/
protected void addError(String errorKey, String errorMessage) {
invalid = true;
errmsg.put(errorKey, errorMessage);
if (shortCircuit) {
throw new ValidateException();
}
}
protected Map<String, String> getErrmsg() {
return this.errmsg;
}
/**
* @param field
* @param datePattern
* @param errorKey key
* @param errorMessage
*/
protected void validateDate(String field, String datePattern, String errorKey, String errorMessage) {
validateDate(field, datePattern, true, errorKey, errorMessage);
}
/**
*
* @param field
* @param datePattern
* @param isRequired
* @param errorKey key
* @param errorMessage
*/
protected void validateDate(String field, String datePattern, boolean isRequired, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
if( !DateTimeUtil.isValidDate(value, datePattern) ){
addError(errorKey, errorMessage);
}
}
/**
* Validate double.
*/
protected void validateBigDecimal(String field, BigDecimal min, BigDecimal max, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
BigDecimal temp = new BigDecimal(value.trim());
if (temp.compareTo(min) < 0 || temp.compareTo(max) > 0 ) {
addError(errorKey, errorMessage);
}
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
}
/**
* Validate double.
*/
protected void validateBigDecimal(String field, String errorKey, String errorMessage) {
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
return ;
}
try {
new BigDecimal(value.trim());
}
catch (Exception e) {
addError(errorKey, errorMessage);
}
}
protected void validateInIntegerArray(String field, List<Integer> chklist, String errorKey, String errorMessage){
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
}
try {
Integer temp = Integer.parseInt(value.trim());
for(Integer integer : chklist){
if(integer.equals(temp)){
return;
}
}
// 没有找到
addError(errorKey, errorMessage);
} catch (Exception e) {
addError(errorKey, errorMessage);
}
}
protected void validateInStringArray(String field, List<String> chklist, String errorKey, String errorMessage){
String value = controller.getPara(field);
if (StrKit.isBlank(value)) {
addError(errorKey, errorMessage);
}
try {
String temp = value.trim();
for(String str : chklist){
if(str.equals(temp)){
return;
}
}
// 没有找到
addError(errorKey, errorMessage);
} catch (Exception e) {
addError(errorKey, errorMessage);
}
}
}

View File

@ -0,0 +1,27 @@
package com.cowr.common.validator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
/**
* Generated by COWR Tue Jun 25 00:41:56 CST 2019
* TableName: sysuser
* Remarks:
* PrimaryKey: id
*/
public class PhoneValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
/**
* /^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/
* /^1[3|4|5|7|8|9][\d]{9}$/
*/
validateString("phone", 0, 11, "phone", "phone 长度1~11"); // 必填项字段长度必须大于0不能超过最大长度
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,19 @@
package com.cowr.common.validator;
import com.jfinal.core.Controller;
import com.cowr.common.view.Result;
public class StartAndEndTimeValidator extends ParamValidator {
@Override
protected void validate(Controller c) {
// setShortCircuit(true);
validateRequired("stm", "stm","stm 必填");
validateRequired("etm", "etm","etm 必填");
validateDate("stm", "yyyy-MM-dd HH:mm:ss","stm","stm 格式错误");
validateDate("etm", "yyyy-MM-dd HH:mm:ss","etm","etm 格式错误");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,42 @@
package com.cowr.common.validator;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StartAndEndintervalValidator extends ParamValidator {
private static DateFormat ymdhms = new SimpleDateFormat(DateTimeUtil.ymdhms);
@Override
protected void validate(Controller c) {
setShortCircuit(true);
validateRequired("stm", "stm", "stm 必填");
validateRequired("etm", "etm", "etm 必填");
validateDate("stm", "yyyy-MM-dd HH:mm:ss", "stm", "stm 格式错误");
validateDate("etm", "yyyy-MM-dd HH:mm:ss", "etm", "etm 格式错误");
String stm = c.getPara("stm");
String etm = c.getPara("etm");
try {
Date st = ymdhms.parse(stm);
Date et = ymdhms.parse(etm);
// 1000 * 60 * 60 * 24 * 31 * 3 3个月
if (et.getTime() - st.getTime() > 1000L * 60 * 60 * 24 * 31 * 12) {
addError("stm_etm", "时间间隔不超过12个月");
}
} catch (ParseException e) {
addError("stm_etm", e.getMessage());
}
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,18 @@
package com.cowr.common.validator;
import com.cowr.common.view.Result;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Jun 27 17:01:16 CST 2019
*/
public class YearValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateDate("tm", "yyyy","tm","tm 格式必须为 yyyy");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,248 @@
/**
* Copyright (c) 2011-2019, James Zhan (jfinal@126.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.cowr.common.view;
import com.jfinal.aop.Interceptor;
import com.jfinal.core.Action;
import com.jfinal.core.Const;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.cowr.common.utils.ReqUtil;
import eu.bitwalker.useragentutils.UserAgent;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
/**
* ActionReporter
*/
public class ActionReporter {
private static Log log = Log.getLog(ActionReporter.class);
private static final String title = "\nJFinal-" + Const.JFINAL_VERSION + " action report -------- ";
private static boolean reportAfterInvocation = true;
private static int maxOutputLengthOfParaValue = 512;
private static Writer writer = new SystemOutWriter();
private static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
public static void setReportAfterInvocation(boolean reportAfterInvocation) {
ActionReporter.reportAfterInvocation = reportAfterInvocation;
}
public static void setMaxOutputLengthOfParaValue(int maxOutputLengthOfParaValue) {
if (maxOutputLengthOfParaValue < 16) {
throw new IllegalArgumentException("maxOutputLengthOfParaValue must more than 16");
}
ActionReporter.maxOutputLengthOfParaValue = maxOutputLengthOfParaValue;
}
public static void setWriter(Writer writer) {
if (writer == null) {
throw new IllegalArgumentException("writer can not be null");
}
ActionReporter.writer = writer;
}
public static boolean isReportAfterInvocation(HttpServletRequest request) {
if (reportAfterInvocation) {
return true;
} else {
String contentType = request.getContentType();
if (contentType != null && contentType.toLowerCase().indexOf("multipart") != -1) {
return true;
} else {
return false;
}
}
}
private static int lineNum(String codeFragment, String fileName){
List<String> lines = null;
int lineNum = 1;
Path path = Paths.get(fileName);
try{
lines = Files.readAllLines(path, Charset.forName("utf-8"));
for(int i = 0; i < lines.size(); i++){
String line = lines.get(i);
lineNum = i + 1;
if(deleteWhitespace(line).toLowerCase().startsWith(codeFragment.toLowerCase())){
break;
}
}
}
catch(Exception e2){
return 1;
}
return lineNum;
}
private static String deleteWhitespace(String str){
if(StrKit.isBlank(str)){
return str;
}
int sz = str.length();
char[] chs = new char[sz];
int count = 0;
for(int i = 0; i < sz; i++){
if(!Character.isWhitespace(str.charAt(i))){
chs[count++] = str.charAt(i);
}
}
if(count == sz){
return str;
}
return new String(chs, 0, count);
}
/**
* class .java
*
* windows 使
* TODO log4j
* @param clazz
* @return
*/
private static String fileName(@SuppressWarnings("rawtypes") Class clazz){
StringBuilder cf = new StringBuilder(System.getProperty("user.dir")).append(File.separator).append("src")
.append(File.separator).append("main").append(File.separator).append("java");
StringBuilder classFile = new StringBuilder()
.append(File.separator).append("src")
.append(File.separator).append("main")
.append(File.separator).append("java");
for(String temp : clazz.getName().split("\\.")){
classFile.append(File.separator).append(temp);
}
String classpath = clazz.getResource("").getPath();
if(!classpath.contains("/target/classes/")){
return classFile.append(".java").toString();
}
String classsrc = classpath.substring(1, classpath.indexOf("/target/classes/"));
return classsrc + classFile.append(".java").toString();
}
/**
* Report the action
*/
public static final void report(String target, Controller controller, Action action) {
StringBuilder sb = new StringBuilder(title).append(sdf.get().format(new Date())).append(" --------------------------\n");
sb.append("Url : ").append(controller.getRequest().getMethod()).append(" ").append(target).append("\n");
Class<? extends Controller> cc = action.getControllerClass();
if(System.getProperty("file.separator").equals("\\")){
sb.append("Controller : ").append(cc.getName()).append(".(").append(cc.getSimpleName()).append(".java:")
.append(lineNum("publicvoid" + action.getMethodName() + "(){", fileName(cc))).append(")");
}else{
sb.append("Controller : ").append(cc.getName()).append(".(").append(cc.getSimpleName()).append(".java:1)");
}
sb.append("\nMethod : ").append(action.getMethodName()).append("\n");
String urlParas = controller.getPara();
if (urlParas != null) {
sb.append("UrlPara : ").append(urlParas).append("\n");
}
Interceptor[] inters = action.getInterceptors();
if (inters.length > 0) {
sb.append("Interceptor : ");
for (int i=0; i<inters.length; i++) {
if (i > 0)
sb.append("\n ");
Interceptor inter = inters[i];
Class<? extends Interceptor> ic = inter.getClass();
sb.append(ic.getName()).append(".(").append(ic.getSimpleName()).append(".java:1)");
}
sb.append("\n");
}
// print all parameters
HttpServletRequest request = controller.getRequest();
Enumeration<String> e = request.getParameterNames();
if (e.hasMoreElements()) {
sb.append("Parameter : ");
while (e.hasMoreElements()) {
String name = e.nextElement();
String[] values = request.getParameterValues(name);
if (values.length == 1) {
sb.append(name).append("=");
if (values[0] != null && values[0].length() > maxOutputLengthOfParaValue) {
sb.append(values[0].substring(0, maxOutputLengthOfParaValue)).append("...");
} else {
sb.append(values[0]);
}
}
else {
sb.append(name).append("[]={");
for (int i=0; i<values.length; i++) {
if (i > 0)
sb.append(",");
sb.append(values[i]);
}
sb.append("}");
}
sb.append(" ");
}
sb.append("\n");
}
String ip = ReqUtil.getIpAddress(request);
//转成UserAgent对象
UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
sb.append("IP : ").append(ip).append("\n");
sb.append("OS : ").append(userAgent.getOperatingSystem().getName()).append("\n");
sb.append("Browser : ").append(userAgent.getBrowser().getName()).append(" ").append(userAgent.getBrowserVersion()).append("\n");
sb.append("--------------------------------------------------------------------------------\n");
try {
writer.write(sb.toString());
writer.flush();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
private static class SystemOutWriter extends Writer {
public void write(String str) throws IOException {
log.debug(str);
}
public void write(char[] cbuf, int off, int len) throws IOException {}
public void flush() throws IOException {}
public void close() throws IOException {}
}
}

View File

@ -0,0 +1,74 @@
package com.cowr.common.view;
import com.jfinal.log.Log;
import com.jfinal.render.Render;
import com.jfinal.render.RenderException;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class ExcelRender extends Render {
private static Log log = Log.getLog(ExcelRender.class);
private final static String CONTENT_TYPE = "application/msexcel;charset="
+ getEncoding();
private String fileName = "";
private Workbook book;
public ExcelRender(String filename, Workbook book) {
this.fileName = filename;
this.book = book;
}
private String encodeFileName(String fileName) {
try {
return URLEncoder.encode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.error(e.getMessage(), e);
return fileName;
}
/*try {
return new String(fileName.getBytes("UTF-8"), "ISO8859-1");
} catch (UnsupportedEncodingException e) {
return fileName;
}*/
}
@Override
public void render() {
this.response.reset();
this.response.setHeader("Content-disposition", "attachment; filename=" + encodeFileName(fileName));
this.response.setContentType(CONTENT_TYPE);
OutputStream os = null;
try {
os = response.getOutputStream();
book.write(os);
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RenderException(e);
} finally {
try {
if (os != null) {
os.flush();
os.close();
}
} catch (IOException e) {
log.error(e.getMessage(), e);
}
if( book != null ){
try {
book.close();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
}
}

View File

@ -0,0 +1,19 @@
package com.cowr.common.view;
import com.jfinal.render.ErrorRender;
import com.jfinal.render.JsonRender;
import com.jfinal.render.Render;
import com.jfinal.render.RenderFactory;
public class JsonRenderFactory extends RenderFactory {
public Render getErrorRender(int errorCode) {
return getErrorRender(errorCode, null);
}
public Render getErrorRender(int errorCode, String view) {
if(errorCode != 400){
return new JsonRender(new Result(errorCode, null, view));
}else{
return new ErrorRender(400, view);
}
}
}

View File

@ -0,0 +1,61 @@
package com.cowr.common.view;
/**
*
*/
public class PageParam {
private String sort_field;
private String sort_order;
private int page = 1; // 当前页码
private int size = 20; // 每页行数
public String getSort_field() {
return sort_field;
}
public void setSort_field(String sort_field) {
this.sort_field = sort_field;
}
public String getSort_order() {
return sort_order;
}
public void setSort_order(String sort_order) {
this.sort_order = sort_order;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public PageParam() {
}
public PageParam(String sort_field, String sort_order, int page, int size) {
this.sort_field = sort_field;
this.sort_order = sort_order;
this.page = page;
this.size = size;
}
public PageParam(int page, int size) {
this.page = page;
this.size = size;
}
}

View File

@ -0,0 +1,131 @@
package com.cowr.common.view;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
/**
*
*/
public class ReportExcelStyle {
public static void setCommonStyle(
Workbook wb,
Sheet sheet,
String title,
String subtitle,
int datalen,
int end_col
){
setCommonStyle(wb, sheet, title, subtitle, datalen, end_col, 4);
}
public static void setCommonStyle(
Workbook wb,
Sheet sheet,
String title,
String subtitle,
int datalen,
int end_col,
int sign_col
){
// 标题 start
Font font = wb.createFont();
font.setBold(true);
font.setFontHeight((short) (18 * 20));
font.setFontName("宋体");
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue(title);
row.setHeight((short) (40 * 20)); // POI中的行高单位是twips ,Office Excel行高单位是pt 设置的行高单位为1/20pt
cell.setCellStyle(cellStyle);
// 标题 end
// 副标题 start
font = wb.createFont();
font.setFontHeight((short) (12 * 20));
font.setFontName("宋体");
cellStyle = wb.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
row = sheet.createRow(1);
row.setHeight((short) (28 * 20));
cell = row.createCell(0);
cell.setCellValue(subtitle);
cell.setCellStyle(cellStyle);
// 副标题 end
// 通用单元格格式
font = wb.createFont();
cellStyle = wb.createCellStyle();
font.setFontHeight((short) (10 * 20));
font.setFontName("宋体");
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
cellStyle.setFont(font);
// 设置通用单元格格式
for (int r = 2; r < datalen + 4; r++) {
row = sheet.getRow(r);
if (row == null) {
row = sheet.createRow(r);
}
for (int c = 0; c < end_col + 1; c++) {
cell = row.getCell(c);
if (cell == null) {
cell = row.createCell(c);
}
cell.setCellStyle(cellStyle);
}
}
font = wb.createFont();
font.setFontHeight((short) (10 * 20));
font.setFontName("宋体");
cellStyle = wb.createCellStyle();
cellStyle.setFont(font);
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
row = sheet.createRow(datalen + 4);
row.setHeight((short) (28 * 20));
cell = row.createCell(1);
cell.setCellValue("统计人签名:");
cell.setCellStyle(cellStyle);
cell = row.createCell(sign_col);
cell.setCellValue("复核人签名:");
cellStyle.setAlignment(HorizontalAlignment.LEFT);//复核人签名 靠左
cell.setCellStyle(cellStyle);
sheet.setMargin(HSSFSheet.BottomMargin, (double) 0.5);// 页边距(下)
sheet.setMargin(HSSFSheet.LeftMargin, (double) 0.1);// 页边距(左)
sheet.setMargin(HSSFSheet.RightMargin, (double) 0.1);// 页边距(右)
sheet.setMargin(HSSFSheet.TopMargin, (double) 0.5);// 页边距(上)
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, end_col));// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, end_col));// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
// 每页打印标题
sheet.setRepeatingRows(new CellRangeAddress(0, 2, -1, -1));//前两位数是设置需要重复打印的行的范围,后两位设置重复打印的列的范围。-1代表不重复打印。用于表头表头换页重复打印
wb.setPrintArea(
0, //sheet index
0, //start column
end_col, //end column
0, //start row
sheet.getLastRowNum() //end row
);
}
}

View File

@ -0,0 +1,224 @@
package com.cowr.common.view;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Record;
import java.util.Map;
public class Result {
private static Log log = Log.getLog(Result.class);
public static final int SUCCESS = 200; // 成功
public static final int PARAM_ERROR = 400; // 失败、参数错误等
public static final int UNAUTHORIZED = 401; // 用户验证失败,或者用户验证信息过期
public static final int PERMISSION_DENIED = 403; // 没有权限
public static final int NOT_FOUND = 404; // 未找到资源
public static final int NOT_ALLOWED = 405; // 请求太频繁同一个用户token)、同一个url、同样的请求参数请求间隔小于0.5秒
public static final int SERVER_ERROR = 500; // 后台错误
public static final int SRC_TIMEOUT = 504; // 请求资源超时
public static final String PERMISSION_DENIED_STR = "没有权限";
public static final String NOT_FOUND_STR = "未找到资源";
public static final String SERVER_ERROR_STR = "后台错误";
public static final String SRC_TIMEOUT_STR = "请求第三方资源超时";
private int code;
private String msg; // 只用字符串,如果有其他类型,用 validerr 返回
private Object data;
private Map<String, String> validerr; // 表单验证失败返回消息
public Result() {
}
public Result(Map<String, String> validerr) {
this.code = PARAM_ERROR;
this.data = null;
this.msg = "表单验证失败";
this.validerr = validerr;
failedlog(this.msg, this.code);
}
public Result(int code, Object data, String msg) {
this.code = code;
this.data = data;
if (msg == null || "".equals(msg)) {
switch (code) {
case PERMISSION_DENIED:
this.msg = PERMISSION_DENIED_STR;
break;
case NOT_FOUND:
this.msg = NOT_FOUND_STR;
break;
case SERVER_ERROR:
this.msg = SERVER_ERROR_STR;
break;
case SRC_TIMEOUT:
this.msg = SRC_TIMEOUT_STR;
break;
}
} else {
this.msg = msg;
}
if (code != SUCCESS) {
failedlog(this.msg, this.code);
}
}
public Result(int code) {
this(code, null, null);
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Object getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Object getData() {
return data;
}
/**
* Record
* TODO
* @return Record
*/
@JSONField(serialize=false)
public Record getRecordData() {
return data != null ? (Record) data : null;
}
public void setData(Object data) {
this.data = data;
}
public Map<String, String> getValiderr() {
return validerr;
}
public void setValiderr(Map<String, String> validerr) {
this.validerr = validerr;
}
public String toJSONString() {
return JSONObject.toJSONString(this);
}
public static Result success(Object data) {
return new Result(Result.SUCCESS, data, null);
}
/**
* data == null msg data != null msg
* Result.object
* code 200, Result.object code 400
*
* @param data
* @param msg
* @return
*/
public static Result success(Object data, String msg) {
return new Result(Result.SUCCESS, data, msg);
}
public static Result success() {
return new Result(Result.SUCCESS);
}
public static Result failed(String msg) {
return new Result(Result.PARAM_ERROR, null, msg);
}
public static Result failedstr(String format, Object... objs) {
return new Result(Result.PARAM_ERROR, null, String.format(format, objs));
}
public static Result failed(Map<String, String> validerr){
return new Result(validerr);
}
public static Result failed(Object ret, String msg) {
return new Result(Result.PARAM_ERROR, ret, msg);
}
public static Result noauth() {
return new Result(Result.UNAUTHORIZED, null, "没有登录,或者登录超时");
}
public static Result notAllowed() {
return new Result(Result.NOT_ALLOWED, null, "请求太频繁");
}
public static Result error() {
return new Result(Result.SERVER_ERROR);
}
public static Result permissionDenied() {
return permissionDenied("没有权限");
}
public static Result permissionDenied(String msg) {
return new Result(Result.PERMISSION_DENIED, null, msg);
}
public static Result object(Object data) {
return Result.object(data, "");
}
/**
*
*
* @param data data != null
* @param msg data == null msg
* @return result
*/
public static Result object(Object data, String msg) {
if (data instanceof Result) {
return (Result) data;
} else if (data instanceof Boolean) {
int code = (Boolean) data ? Result.SUCCESS : Result.PARAM_ERROR;
return new Result(code, data, msg);
} else {
if (data != null) {
return new Result(Result.SUCCESS, data, null);
}
return new Result(Result.PARAM_ERROR, null, msg);
}
}
/**
* SUCCESS debug log
*
* @param msg
*/
private static void failedlog(String msg, int code) {
if (code == NOT_FOUND) { // 404 的就不输出了
return;
}
log.debug(msg);
StackTraceElement[] mStacks = Thread.currentThread().getStackTrace();
for (StackTraceElement s : mStacks) {
if (s.getClassName().contains("com.cowr")
&& !s.getClassName().contains("com.cowr.common.view.Result")
&& !s.getClassName().contains("com.cowr.common.handler.GlobalHandler")
&& !s.getClassName().contains("com.cowr.common.Interceptor")
)
log.debug("-> " + s);
}
}
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseActionCmdLog;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: action_cmd_log
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class ActionCmdLog extends BaseActionCmdLog<ActionCmdLog> {
public static final ActionCmdLog dao = new ActionCmdLog().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseAuthLicense;
/**
* Generated by COWR Fri May 01 23:24:43 CST 2020
* TableName: auth_license
* Remarks: -
* PrimaryKey: truck_license
*/
@SuppressWarnings("serial")
public class AuthLicense extends BaseAuthLicense<AuthLicense> {
public static final AuthLicense dao = new AuthLicense().dao();
}

View File

@ -0,0 +1,31 @@
package com.cowr.model;
public class AuthResult {
private String token;
private Sysuser sysuser;
public AuthResult(String token, Sysuser sysuser) {
this.token = token;
this.sysuser = sysuser;
}
public AuthResult() {
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Sysuser getSysuser() {
return sysuser;
}
public void setSysuser(Sysuser sysuser) {
this.sysuser = sysuser;
}
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseBlacklist;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: blacklist
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Blacklist extends BaseBlacklist<Blacklist> {
public static final Blacklist dao = new Blacklist().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseBocomm;
/**
* Generated by COWR Fri May 29 10:27:06 CST 2020
* TableName: bocomm
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Bocomm extends BaseBocomm<Bocomm> {
public static final Bocomm dao = new Bocomm().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseBocommRequest;
/**
* Generated by COWR Fri May 29 11:23:08 CST 2020
* TableName: bocomm_request
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class BocommRequest extends BaseBocommRequest<BocommRequest> {
public static final BocommRequest dao = new BocommRequest().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseBocommResponse;
/**
* Generated by COWR Fri May 29 11:23:08 CST 2020
* TableName: bocomm_response
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class BocommResponse extends BaseBocommResponse<BocommResponse> {
public static final BocommResponse dao = new BocommResponse().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCctv;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: cctv
* Remarks:
* PrimaryKey: unit_id,unit_type
*/
@SuppressWarnings("serial")
public class Cctv extends BaseCctv<Cctv> {
public static final Cctv dao = new Cctv().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCctvChannels;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: cctv_channels
* Remarks:
* PrimaryKey: id,unit_id,unit_type
*/
@SuppressWarnings("serial")
public class CctvChannels extends BaseCctvChannels<CctvChannels> {
public static final CctvChannels dao = new CctvChannels().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCustomer;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: customer
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Customer extends BaseCustomer<Customer> {
public static final Customer dao = new Customer().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCustomerContact;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: customer_contact
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class CustomerContact extends BaseCustomerContact<CustomerContact> {
public static final CustomerContact dao = new CustomerContact().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseCustomerReceiver;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: customer_receiver
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class CustomerReceiver extends BaseCustomerReceiver<CustomerReceiver> {
public static final CustomerReceiver dao = new CustomerReceiver().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseDeviceConfig;
/**
* Generated by COWR Mon May 04 01:37:44 CST 2020
* TableName: device_config
* Remarks: -
* PrimaryKey: supermarket_id
*/
@SuppressWarnings("serial")
public class DeviceConfig extends BaseDeviceConfig<DeviceConfig> {
public static final DeviceConfig dao = new DeviceConfig().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseDriver;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: driver
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Driver extends BaseDriver<Driver> {
public static final Driver dao = new Driver().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseModifyLog;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: modify_log
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class ModifyLog extends BaseModifyLog<ModifyLog> {
public static final ModifyLog dao = new ModifyLog().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderPurchase;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_purchase
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderPurchase extends BaseOrderPurchase<OrderPurchase> {
public static final OrderPurchase dao = new OrderPurchase().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderSale;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_sale
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderSale extends BaseOrderSale<OrderSale> {
public static final OrderSale dao = new OrderSale().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderSeq;
/**
* Generated by COWR Tue Apr 28 16:04:25 CST 2020
* TableName: order_seq
* Remarks: -
* PrimaryKey: tm,supermarket_id,type
*/
@SuppressWarnings("serial")
public class OrderSeq extends BaseOrderSeq<OrderSeq> {
public static final OrderSeq dao = new OrderSeq().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderTemp;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_temp
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderTemp extends BaseOrderTemp<OrderTemp> {
public static final OrderTemp dao = new OrderTemp().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderTransfer;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_transfer
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderTransfer extends BaseOrderTransfer<OrderTransfer> {
public static final OrderTransfer dao = new OrderTransfer().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrderTrash;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: order_trash
* Remarks: -
* PrimaryKey: sn
*/
@SuppressWarnings("serial")
public class OrderTrash extends BaseOrderTrash<OrderTrash> {
public static final OrderTrash dao = new OrderTrash().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseOrdercluster;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: ordercluster
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Ordercluster extends BaseOrdercluster<Ordercluster> {
public static final Ordercluster dao = new Ordercluster().dao();
}

View File

@ -0,0 +1,66 @@
package com.cowr.model;
public class PostLicenseResult {
private String license;
private boolean uploaded;
private String transport_id;
private String flow;
public String getFlow() {
return flow;
}
public void setFlow(String flow) {
this.flow = flow;
}
private boolean access;
public PostLicenseResult(String license) {
this.license = license;
this.uploaded = false;
this.transport_id = null;
this.access = false;
this.flow = null;
}
public PostLicenseResult(String license, boolean uploaded, String transport_id, boolean access) {
this.license = license;
this.uploaded = uploaded;
this.transport_id = transport_id;
this.access = access;
this.flow = null;
}
public String getLicense() {
return license;
}
public void setLicense(String license) {
this.license = license;
}
public boolean isUploaded() {
return uploaded;
}
public void setUploaded(boolean uploaded) {
this.uploaded = uploaded;
}
public String getTransportId() {
return transport_id;
}
public void setTransportId(String transport_id) {
this.transport_id = transport_id;
}
public boolean isAccess() {
return access;
}
public void setAccess(boolean access) {
this.access = access;
}
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BasePrepayCustomer;
/**
* Generated by COWR Sun May 17 21:43:18 CST 2020
* TableName: prepay_customer
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PrepayCustomer extends BasePrepayCustomer<PrepayCustomer> {
public static final PrepayCustomer dao = new PrepayCustomer().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BasePrepayDetail;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: prepay_detail
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PrepayDetail extends BasePrepayDetail<PrepayDetail> {
public static final PrepayDetail dao = new PrepayDetail().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BasePrepayDetailStateHistory;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: prepay_detail_state_history
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PrepayDetailStateHistory extends BasePrepayDetailStateHistory<PrepayDetailStateHistory> {
public static final PrepayDetailStateHistory dao = new PrepayDetailStateHistory().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BasePrepayTruck;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: prepay_truck
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class PrepayTruck extends BasePrepayTruck<PrepayTruck> {
public static final PrepayTruck dao = new PrepayTruck().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseProduct;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: product
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Product extends BaseProduct<Product> {
public static final Product dao = new Product().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BasePurchase;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: purchase
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Purchase extends BasePurchase<Purchase> {
public static final Purchase dao = new Purchase().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseRefundDetail;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: refund_detail
* Remarks: - 退
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class RefundDetail extends BaseRefundDetail<RefundDetail> {
public static final RefundDetail dao = new RefundDetail().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseRefundDetailStateHistory;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: refund_detail_state_history
* Remarks: - 退
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class RefundDetailStateHistory extends BaseRefundDetailStateHistory<RefundDetailStateHistory> {
public static final RefundDetailStateHistory dao = new RefundDetailStateHistory().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSandfarm;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: sandfarm
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Sandfarm extends BaseSandfarm<Sandfarm> {
public static final Sandfarm dao = new Sandfarm().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseStock;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: stock
* Remarks: -
* PrimaryKey: supermarket_id
*/
@SuppressWarnings("serial")
public class Stock extends BaseStock<Stock> {
public static final Stock dao = new Stock().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseStockModifyLog;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: stock_modify_log
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class StockModifyLog extends BaseStockModifyLog<StockModifyLog> {
public static final StockModifyLog dao = new StockModifyLog().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSupermarket;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: supermarket
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Supermarket extends BaseSupermarket<Supermarket> {
public static final Supermarket dao = new Supermarket().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSupermarketProduct;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: supermarket_product
* Remarks: - product
* PrimaryKey: supermarket_id,product_id
*/
@SuppressWarnings("serial")
public class SupermarketProduct extends BaseSupermarketProduct<SupermarketProduct> {
public static final SupermarketProduct dao = new SupermarketProduct().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSupermarketReceiverDistance;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: supermarket_receiver_distance
* Remarks: -
* PrimaryKey: supermarket_id,customer_receiver_id
*/
@SuppressWarnings("serial")
public class SupermarketReceiverDistance extends BaseSupermarketReceiverDistance<SupermarketReceiverDistance> {
public static final SupermarketReceiverDistance dao = new SupermarketReceiverDistance().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BaseSupermarketSandfarmDistance;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: supermarket_sandfarm_distance
* Remarks: -
* PrimaryKey: supermarket_id,sandfarm_id
*/
@SuppressWarnings("serial")
public class SupermarketSandfarmDistance extends BaseSupermarketSandfarmDistance<SupermarketSandfarmDistance> {
public static final SupermarketSandfarmDistance dao = new SupermarketSandfarmDistance().dao();
}

View File

@ -0,0 +1,63 @@
package com.cowr.model;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.cowr.common.base.BaseModel;
import com.cowr.model.base.BaseSyncTask;
import com.jfinal.kit.StrKit;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: sync_task
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class SyncTask extends BaseSyncTask<SyncTask> {
public static final SyncTask dao = new SyncTask().dao();
private JSONObject _save_data = new JSONObject();
private JSONObject _update_data = new JSONObject();
private JSONObject _delete_data = new JSONObject();
private SyncTask add(JSONObject obj, BaseModel model){
String key = model.getTablename();
if(!obj.containsKey(key)){
JSONObject data = new JSONObject();
data.put("pks", StrKit.join(model.getPKey(), ","));
data.put("data", new JSONArray());
obj.put(key, data);
}
obj.getJSONObject(key).getJSONArray("data").add(model);
return this;
}
public SyncTask addSaveData(BaseModel model){
return add(_save_data, model);
}
public SyncTask addUpdateData(BaseModel model){
return add(_update_data, model);
}
public SyncTask addDeleteData(BaseModel model){
return add(_delete_data, model);
}
public void setJson(){
if(!_save_data.isEmpty() && this.getSaveData() == null){
this.setSaveData(JSONObject.toJSONString(_save_data, SerializerFeature.WriteDateUseDateFormat)); // 新增的数据,就不要发送 null 值了
}
if(!_update_data.isEmpty() && this.getUpdateData() == null){ // 修改的数据,可以发送 null有的字段要设置为 null
this.setUpdateData(JSONObject.toJSONString(_update_data, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat));
}
if(!_delete_data.isEmpty() && this.getDeleteData() == null){
this.setDeleteData(JSONObject.toJSONString(_delete_data, SerializerFeature.WriteDateUseDateFormat));
}
}
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSysuser;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: sysuser
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Sysuser extends BaseSysuser<Sysuser> {
public static final Sysuser dao = new Sysuser().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BaseTransPriceConfigSale;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: trans_price_config_sale
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class TransPriceConfigSale extends BaseTransPriceConfigSale<TransPriceConfigSale> {
public static final TransPriceConfigSale dao = new TransPriceConfigSale().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BaseTransPriceConfigTransfer;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: trans_price_config_transfer
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class TransPriceConfigTransfer extends BaseTransPriceConfigTransfer<TransPriceConfigTransfer> {
public static final TransPriceConfigTransfer dao = new TransPriceConfigTransfer().dao();
}

View File

@ -0,0 +1,15 @@
package com.cowr.model;
import com.cowr.model.base.BaseTransPriceConfigTrash;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: trans_price_config_trash
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class TransPriceConfigTrash extends BaseTransPriceConfigTrash<TransPriceConfigTrash> {
public static final TransPriceConfigTrash dao = new TransPriceConfigTrash().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseTransport;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: transport
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class Transport extends BaseTransport<Transport> {
public static final Transport dao = new Transport().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseTransportCompany;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: transport_company
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public class TransportCompany extends BaseTransportCompany<TransportCompany> {
public static final TransportCompany dao = new TransportCompany().dao();
}

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseTruck;
/**
* Generated by COWR Sun Apr 12 21:56:10 CST 2020
* TableName: truck
* Remarks: -
* PrimaryKey: license
*/
@SuppressWarnings("serial")
public class Truck extends BaseTruck<Truck> {
public static final Truck dao = new Truck().dao();
}

View File

@ -0,0 +1,72 @@
package com.cowr.model;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
/**
* Generated by COWR Sun May 17 21:43:18 CST 2020
* <pre>
* Example:
* public void configPlugin(Plugins me) {
* ActiveRecordPlugin arp = new ActiveRecordPlugin(...);
* _MappingKit.mapping(arp);
* me.add(arp);
* }
* </pre>
*/
public class _MappingKit {
public static void mapping(ActiveRecordPlugin arp) {
arp.addMapping("auth_license", "truck_license", AuthLicense.class);
arp.addMapping("bocomm", "id", Bocomm.class);
arp.addMapping("bocomm_request", "id", BocommRequest.class);
arp.addMapping("bocomm_response", "id", BocommResponse.class);
arp.addMapping("transport", "id", Transport.class);
arp.addMapping("device_config", "supermarket_id", DeviceConfig.class);
arp.addMapping("driver", "id", Driver.class);
arp.addMapping("product", "id", Product.class);
// Composite Primary Key order: supermarket_id,customer_receiver_id
arp.addMapping("supermarket_receiver_distance", "supermarket_id,customer_receiver_id", SupermarketReceiverDistance.class);
arp.addMapping("transport_company", "id", TransportCompany.class);
// Composite Primary Key order: supermarket_id,sandfarm_id
arp.addMapping("supermarket_sandfarm_distance", "supermarket_id,sandfarm_id", SupermarketSandfarmDistance.class);
arp.addMapping("sandfarm", "id", Sandfarm.class);
// Composite Primary Key order: supermarket_id,product_id
arp.addMapping("supermarket_product", "supermarket_id,product_id", SupermarketProduct.class);
arp.addMapping("blacklist", "id", Blacklist.class);
arp.addMapping("truck", "license", Truck.class);
arp.addMapping("purchase", "id", Purchase.class);
arp.addMapping("supermarket", "id", Supermarket.class);
arp.addMapping("customer", "id", Customer.class);
arp.addMapping("customer_receiver", "id", CustomerReceiver.class);
arp.addMapping("customer_contact", "id", CustomerContact.class);
arp.addMapping("prepay_detail", "id", PrepayDetail.class);
arp.addMapping("prepay_detail_state_history", "id", PrepayDetailStateHistory.class);
arp.addMapping("refund_detail", "id", RefundDetail.class);
arp.addMapping("refund_detail_state_history", "id", RefundDetailStateHistory.class);
arp.addMapping("prepay_customer", "id", PrepayCustomer.class);
arp.addMapping("prepay_truck", "id", PrepayTruck.class);
arp.addMapping("sync_task", "id", SyncTask.class);
arp.addMapping("modify_log", "id", ModifyLog.class);
arp.addMapping("action_cmd_log", "id", ActionCmdLog.class);
arp.addMapping("sysuser", "id", Sysuser.class);
arp.addMapping("trans_price_config_trash", "id", TransPriceConfigTrash.class);
arp.addMapping("trans_price_config_transfer", "id", TransPriceConfigTransfer.class);
arp.addMapping("trans_price_config_sale", "id", TransPriceConfigSale.class);
// Composite Primary Key order: unit_id,unit_type
arp.addMapping("cctv", "unit_id,unit_type", Cctv.class);
// Composite Primary Key order: id,unit_id,unit_type
arp.addMapping("cctv_channels", "id,unit_id,unit_type", CctvChannels.class);
arp.addMapping("order_purchase", "sn", OrderPurchase.class);
arp.addMapping("order_temp", "sn", OrderTemp.class);
// Composite Primary Key order: tm,supermarket_id,type
arp.addMapping("order_seq", "tm,supermarket_id,type", OrderSeq.class);
arp.addMapping("order_trash", "sn", OrderTrash.class);
arp.addMapping("stock_modify_log", "id", StockModifyLog.class);
arp.addMapping("ordercluster", "id", Ordercluster.class);
arp.addMapping("order_transfer", "sn", OrderTransfer.class);
arp.addMapping("order_sale", "sn", OrderSale.class);
// Composite Primary Key order: supermarket_id,product_id
arp.addMapping("stock", "supermarket_id,product_id", Stock.class);
}
}

View File

@ -0,0 +1,134 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Fri Apr 17 16:59:35 CST 2020
* TableName: action_cmd_log
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BaseActionCmdLog<M extends BaseActionCmdLog<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "action_cmd_log";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: id
* type: BIGINT(19)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id
*/
@JSONField(name="id")
public void setId(java.lang.Long id) {
set("id", id);
}
/**
* @return id
*/
@JSONField(name="id")
public java.lang.Long getId() {
return getLong("id");
}
/**
* name: create_user_id
* type: INT(10)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param createUserId id
*/
@JSONField(name="create_user_id")
public void setCreateUserId(java.lang.Integer createUserId) {
set("create_user_id", createUserId);
}
/**
* @return create_user_id id
*/
@JSONField(name="create_user_id")
public java.lang.Integer getCreateUserId() {
return getInt("create_user_id");
}
/**
* name: create_user_name
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param createUserName
*/
@JSONField(name="create_user_name")
public void setCreateUserName(java.lang.String createUserName) {
set("create_user_name", createUserName);
}
/**
* @return create_user_name
*/
@JSONField(name="create_user_name")
public java.lang.String getCreateUserName() {
return getStr("create_user_name");
}
/**
* name: create_time
* type: TIMESTAMP(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: CURRENT_TIMESTAMP
* @param createTime
*/
@JSONField(name="create_time")
public void setCreateTime(java.util.Date createTime) {
set("create_time", createTime);
}
/**
* @return create_time
*/
@JSONField(name="create_time")
public java.util.Date getCreateTime() {
return get("create_time");
}
/**
* name: content
* type: JSON(1073741824)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param content
*/
@JSONField(name="content")
public void setContent(java.lang.String content) {
set("content", content);
}
/**
* @return content
*/
@JSONField(name="content")
public java.lang.String getContent() {
return getStr("content");
}
}

View File

@ -0,0 +1,68 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Sun Jun 21 00:41:02 CST 2020
* TableName: auth_license
* Remarks: -
* PrimaryKey: truck_license
*/
@SuppressWarnings("serial")
public abstract class BaseAuthLicense<M extends BaseAuthLicense<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "auth_license";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: truck_license
* type: VARCHAR(10)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param truckLicense
*/
@JSONField(name="truck_license")
public void setTruckLicense(String truckLicense) {
set("truck_license", truckLicense);
}
/**
* @return truck_license
*/
@JSONField(name="truck_license")
public String getTruckLicense() {
return getStr("truck_license");
}
/**
* name: create_time
* type: TIMESTAMP(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: CURRENT_TIMESTAMP
* @param createTime
*/
@JSONField(name="create_time")
public void setCreateTime(java.util.Date createTime) {
set("create_time", createTime);
}
/**
* @return create_time
*/
@JSONField(name="create_time")
public java.util.Date getCreateTime() {
return get("create_time");
}
}

View File

@ -0,0 +1,270 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Fri Apr 17 16:59:35 CST 2020
* TableName: blacklist
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BaseBlacklist<M extends BaseBlacklist<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "blacklist";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: id
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id 使uuid
*/
@JSONField(name="id")
public void setId(java.lang.String id) {
set("id", id);
}
/**
* @return id 使uuid
*/
@JSONField(name="id")
public java.lang.String getId() {
return getStr("id");
}
/**
* name: truck_license
* type: VARCHAR(10)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param truckLicense
*/
@JSONField(name="truck_license")
public void setTruckLicense(java.lang.String truckLicense) {
set("truck_license", truckLicense);
}
/**
* @return truck_license
*/
@JSONField(name="truck_license")
public java.lang.String getTruckLicense() {
return getStr("truck_license");
}
/**
* name: driver_name
* type: VARCHAR(8)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param driverName
*/
@JSONField(name="driver_name")
public void setDriverName(java.lang.String driverName) {
set("driver_name", driverName);
}
/**
* @return driver_name
*/
@JSONField(name="driver_name")
public java.lang.String getDriverName() {
return getStr("driver_name");
}
/**
* name: driver_phone
* type: VARCHAR(11)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param driverPhone
*/
@JSONField(name="driver_phone")
public void setDriverPhone(java.lang.String driverPhone) {
set("driver_phone", driverPhone);
}
/**
* @return driver_phone
*/
@JSONField(name="driver_phone")
public java.lang.String getDriverPhone() {
return getStr("driver_phone");
}
/**
* name: order_sn
* type: VARCHAR(16)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param orderSn
*/
@JSONField(name="order_sn")
public void setOrderSn(java.lang.String orderSn) {
set("order_sn", orderSn);
}
/**
* @return order_sn
*/
@JSONField(name="order_sn")
public java.lang.String getOrderSn() {
return getStr("order_sn");
}
/**
* name: set_time
* type: DATETIME(19)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param setTime
*/
@JSONField(name="set_time")
public void setSetTime(java.util.Date setTime) {
set("set_time", setTime);
}
/**
* @return set_time
*/
@JSONField(name="set_time")
public java.util.Date getSetTime() {
return get("set_time");
}
/**
* name: set_user_id
* type: INT(10)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param setUserId
*/
@JSONField(name="set_user_id")
public void setSetUserId(java.lang.Integer setUserId) {
set("set_user_id", setUserId);
}
/**
* @return set_user_id
*/
@JSONField(name="set_user_id")
public java.lang.Integer getSetUserId() {
return getInt("set_user_id");
}
/**
* name: remove_time
* type: DATETIME(19)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param removeTime
*/
@JSONField(name="remove_time")
public void setRemoveTime(java.util.Date removeTime) {
set("remove_time", removeTime);
}
/**
* @return remove_time
*/
@JSONField(name="remove_time")
public java.util.Date getRemoveTime() {
return get("remove_time");
}
/**
* name: remove_user_id
* type: INT(10)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param removeUserId remove_user_id
*/
@JSONField(name="remove_user_id")
public void setRemoveUserId(java.lang.Integer removeUserId) {
set("remove_user_id", removeUserId);
}
/**
* @return remove_user_id remove_user_id
*/
@JSONField(name="remove_user_id")
public java.lang.Integer getRemoveUserId() {
return getInt("remove_user_id");
}
/**
* name: reason_type
* type: INT(10)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: 1
* @param reasonType 1
2
9
*/
@JSONField(name="reason_type")
public void setReasonType(java.lang.Integer reasonType) {
set("reason_type", reasonType);
}
/**
* @return reason_type 1
2
9
*/
@JSONField(name="reason_type")
public java.lang.Integer getReasonType() {
return getInt("reason_type");
}
/**
* name: reason_detail
* type: VARCHAR(255)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param reasonDetail
*/
@JSONField(name="reason_detail")
public void setReasonDetail(java.lang.String reasonDetail) {
set("reason_detail", reasonDetail);
}
/**
* @return reason_detail
*/
@JSONField(name="reason_detail")
public java.lang.String getReasonDetail() {
return getStr("reason_detail");
}
}

View File

@ -0,0 +1,592 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Wed Jun 24 01:50:19 CST 2020
* TableName: bocomm
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BaseBocomm<M extends BaseBocomm<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "bocomm";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: id
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id uuid
*/
@JSONField(name="id")
public void setId(String id) {
set("id", id);
}
/**
* @return id uuid
*/
@JSONField(name="id")
public String getId() {
return getStr("id");
}
/**
* name: uuid
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param uuid uuid
*/
@JSONField(name="uuid")
public void setUuid(String uuid) {
set("uuid", uuid);
}
/**
* @return uuid uuid
*/
@JSONField(name="uuid")
public String getUuid() {
return getStr("uuid");
}
/**
* name: order_sn
* type: CHAR(16)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param orderSn xml PayMerTranNo
*/
@JSONField(name="order_sn")
public void setOrderSn(String orderSn) {
set("order_sn", orderSn);
}
/**
* @return order_sn xml PayMerTranNo
*/
@JSONField(name="order_sn")
public String getOrderSn() {
return getStr("order_sn");
}
/**
* name: type
* type: SMALLINT(5)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param type 13
*/
@JSONField(name="type")
public void setType(Integer type) {
set("type", type);
}
/**
* @return type 13
*/
@JSONField(name="type")
public Integer getType() {
return getInt("type");
}
/**
* name: paymertranno
* type: VARCHAR(32)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param paymertranno order_sn + HHmmssSSS
*/
@JSONField(name="paymertranno")
public void setPaymertranno(String paymertranno) {
set("paymertranno", paymertranno);
}
/**
* @return paymertranno order_sn + HHmmssSSS
*/
@JSONField(name="paymertranno")
public String getPaymertranno() {
return getStr("paymertranno");
}
/**
* name: amount
* type: DECIMAL(12,2)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param amount
*/
@JSONField(name="amount")
public void setAmount(java.math.BigDecimal amount) {
set("amount", amount);
}
/**
* @return amount
*/
@JSONField(name="amount")
public java.math.BigDecimal getAmount() {
return get("amount");
}
/**
* name: transcene
* type: VARCHAR(20)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param transcene
B2C-JSAPI-ALIPAY
B2C-JSAPI-WECHAT
*/
@JSONField(name="transcene")
public void setTranscene(String transcene) {
set("transcene", transcene);
}
/**
* @return transcene
B2C-JSAPI-ALIPAY
B2C-JSAPI-WECHAT
*/
@JSONField(name="transcene")
public String getTranscene() {
return getStr("transcene");
}
/**
* name: validperiod
* type: DATETIME(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param validperiod 14
*/
@JSONField(name="validperiod")
public void setValidperiod(java.util.Date validperiod) {
set("validperiod", validperiod);
}
/**
* @return validperiod 14
*/
@JSONField(name="validperiod")
public java.util.Date getValidperiod() {
return get("validperiod");
}
/**
* name: state
* type: SMALLINT(5)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: 1
* @param state 1.使
2.
3.
5.
9.
*/
@JSONField(name="state")
public void setState(Integer state) {
set("state", state);
}
/**
* @return state 1.使
2.
3.
5.
9.
*/
@JSONField(name="state")
public Integer getState() {
return getInt("state");
}
/**
* name: transtate
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param transtate INITIAL
PROCESS
SUCCESS
FAILURE
*/
@JSONField(name="transtate")
public void setTranstate(String transtate) {
set("transtate", transtate);
}
/**
* @return transtate INITIAL
PROCESS
SUCCESS
FAILURE
*/
@JSONField(name="transtate")
public String getTranstate() {
return getStr("transtate");
}
/**
* name: transtatecode
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param transtatecode
*/
@JSONField(name="transtatecode")
public void setTranstatecode(String transtatecode) {
set("transtatecode", transtatecode);
}
/**
* @return transtatecode
*/
@JSONField(name="transtatecode")
public String getTranstatecode() {
return getStr("transtatecode");
}
/**
* name: transtatemsg
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param transtatemsg
*/
@JSONField(name="transtatemsg")
public void setTranstatemsg(String transtatemsg) {
set("transtatemsg", transtatemsg);
}
/**
* @return transtatemsg
*/
@JSONField(name="transtatemsg")
public String getTranstatemsg() {
return getStr("transtatemsg");
}
/**
* name: batchno
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param batchno
*/
@JSONField(name="batchno")
public void setBatchno(String batchno) {
set("batchno", batchno);
}
/**
* @return batchno
*/
@JSONField(name="batchno")
public String getBatchno() {
return getStr("batchno");
}
/**
* name: finaltime
* type: DATETIME(19)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param finaltime
*/
@JSONField(name="finaltime")
public void setFinaltime(java.util.Date finaltime) {
set("finaltime", finaltime);
}
/**
* @return finaltime
*/
@JSONField(name="finaltime")
public java.util.Date getFinaltime() {
return get("finaltime");
}
/**
* name: trancontent
* type: VARCHAR(500)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param trancontent ,
*/
@JSONField(name="trancontent")
public void setTrancontent(String trancontent) {
set("trancontent", trancontent);
}
/**
* @return trancontent ,
*/
@JSONField(name="trancontent")
public String getTrancontent() {
return getStr("trancontent");
}
/**
* name: mermemo
* type: VARCHAR(200)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param mermemo ,
*/
@JSONField(name="mermemo")
public void setMermemo(String mermemo) {
set("mermemo", mermemo);
}
/**
* @return mermemo ,
*/
@JSONField(name="mermemo")
public String getMermemo() {
return getStr("mermemo");
}
/**
* name: subopenid
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param subopenid
*/
@JSONField(name="subopenid")
public void setSubopenid(String subopenid) {
set("subopenid", subopenid);
}
/**
* @return subopenid
*/
@JSONField(name="subopenid")
public String getSubopenid() {
return getStr("subopenid");
}
/**
* name: banktranno
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param banktranno
*/
@JSONField(name="banktranno")
public void setBanktranno(String banktranno) {
set("banktranno", banktranno);
}
/**
* @return banktranno
*/
@JSONField(name="banktranno")
public String getBanktranno() {
return getStr("banktranno");
}
/**
* name: thirdparty
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param thirdparty
*/
@JSONField(name="thirdparty")
public void setThirdparty(String thirdparty) {
set("thirdparty", thirdparty);
}
/**
* @return thirdparty
*/
@JSONField(name="thirdparty")
public String getThirdparty() {
return getStr("thirdparty");
}
/**
* name: thirdpartytranno
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param thirdpartytranno
*/
@JSONField(name="thirdpartytranno")
public void setThirdpartytranno(String thirdpartytranno) {
set("thirdpartytranno", thirdpartytranno);
}
/**
* @return thirdpartytranno
*/
@JSONField(name="thirdpartytranno")
public String getThirdpartytranno() {
return getStr("thirdpartytranno");
}
/**
* name: create_time
* type: DATETIME(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue:
* @param createTime
*/
@JSONField(name="create_time")
public void setCreateTime(java.util.Date createTime) {
set("create_time", createTime);
}
/**
* @return create_time
*/
@JSONField(name="create_time")
public java.util.Date getCreateTime() {
return get("create_time");
}
/**
* name: change_time
* type: TIMESTAMP(19)
* isNullable: NO
* isPrimaryKey: NO
* defaultValue: CURRENT_TIMESTAMP
* @param changeTime
*/
@JSONField(name="change_time")
public void setChangeTime(java.util.Date changeTime) {
set("change_time", changeTime);
}
/**
* @return change_time
*/
@JSONField(name="change_time")
public java.util.Date getChangeTime() {
return get("change_time");
}
/**
* name: payacctno
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param payacctno
*/
@JSONField(name="payacctno")
public void setPayacctno(String payacctno) {
set("payacctno", payacctno);
}
/**
* @return payacctno
*/
@JSONField(name="payacctno")
public String getPayacctno() {
return getStr("payacctno");
}
/**
* name: payacctname
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param payacctname
*/
@JSONField(name="payacctname")
public void setPayacctname(String payacctname) {
set("payacctname", payacctname);
}
/**
* @return payacctname
*/
@JSONField(name="payacctname")
public String getPayacctname() {
return getStr("payacctname");
}
/**
* name: submerptcid
* type: VARCHAR(100)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param submerptcid SubMerPtcId
*/
@JSONField(name="submerptcid")
public void setSubmerptcid(String submerptcid) {
set("submerptcid", submerptcid);
}
/**
* @return submerptcid SubMerPtcId
*/
@JSONField(name="submerptcid")
public String getSubmerptcid() {
return getStr("submerptcid");
}
}

View File

@ -0,0 +1,112 @@
package com.cowr.model.base;
import com.cowr.common.base.BaseModel;
import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Fri May 29 11:23:08 CST 2020
* TableName: bocomm_request
* Remarks: -
* PrimaryKey: id
*/
@SuppressWarnings("serial")
public abstract class BaseBocommRequest<M extends BaseBocommRequest<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "bocomm_request";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: id
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id uuid
*/
@JSONField(name="id")
public void setId(String id) {
set("id", id);
}
/**
* @return id uuid
*/
@JSONField(name="id")
public String getId() {
return getStr("id");
}
/**
* name: bocomm_id
* type: CHAR(32)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param bocommId bocomm id
*/
@JSONField(name="bocomm_id")
public void setBocommId(String bocommId) {
set("bocomm_id", bocommId);
}
/**
* @return bocomm_id bocomm id
*/
@JSONField(name="bocomm_id")
public String getBocommId() {
return getStr("bocomm_id");
}
/**
* name: trancode
* type: VARCHAR(255)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param trancode
*/
@JSONField(name="trancode")
public void setTrancode(String trancode) {
set("trancode", trancode);
}
/**
* @return trancode
*/
@JSONField(name="trancode")
public String getTrancode() {
return getStr("trancode");
}
/**
* name: xml
* type: VARCHAR(1000)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param xml xml
*/
@JSONField(name="xml")
public void setXml(String xml) {
set("xml", xml);
}
/**
* @return xml xml
*/
@JSONField(name="xml")
public String getXml() {
return getStr("xml");
}
}

Some files were not shown because too many files have changed in this diff Show More