diff --git a/README.md b/README.md index c6248d3..ea2d8a4 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ ##浠水县后端服务 1. ssjygl-xs-common 本地和云端后端服务公用代码 2. ssjygl-xs-local 本地后端服务 -3. ssjygl-xs-service 云端后端服务 \ No newline at end of file +3. ssjygl-xs-service 云端后端服务 + +2021年7月改版开发分支 \ No newline at end of file diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerType.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerType.java new file mode 100644 index 0000000..cd2d0c7 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/CustomerType.java @@ -0,0 +1,14 @@ +package com.cowr.model; + +import com.cowr.model.base.BaseCustomerType; + +/** + * Generated by COWR Mon Jul 26 16:28:20 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public class CustomerType extends BaseCustomerType { + public static final CustomerType dao = new CustomerType().dao(); +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java index 9e2b65c..7b26c44 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java @@ -3,7 +3,7 @@ package com.cowr.model; import com.jfinal.plugin.activerecord.ActiveRecordPlugin; /** - * Generated by COWR Fri Feb 26 16:03:22 CST 2021 + * Generated by COWR Mon Jul 26 16:28:20 CST 2021 *
  * Example:
  * public void configPlugin(Plugins me) {
@@ -14,7 +14,7 @@ import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
  * 
*/ public class _MappingKit { - + public static void mapping(ActiveRecordPlugin arp) { arp.addMapping("auth_license", "truck_license", AuthLicense.class); arp.addMapping("transport", "id", Transport.class); @@ -39,6 +39,7 @@ public class _MappingKit { arp.addMapping("purchase", "id", Purchase.class); arp.addMapping("supermarket", "id", Supermarket.class); arp.addMapping("customer", "id", Customer.class); + arp.addMapping("customer_type", "id", CustomerType.class); arp.addMapping("customer_receiver", "id", CustomerReceiver.class); arp.addMapping("customer_register", "id", CustomerRegister.class); arp.addMapping("customer_contact", "id", CustomerContact.class); diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomer.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomer.java index 39f74b0..633caec 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomer.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomer.java @@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean; import com.alibaba.fastjson.annotation.JSONField; /** - * Generated by COWR Thu Aug 20 11:16:08 CST 2020 + * Generated by COWR Mon Jul 26 16:28:20 CST 2021 * TableName: customer * Remarks: 客户相关 - 客户 * PrimaryKey: id @@ -15,8 +15,8 @@ public abstract class BaseCustomer> extends BaseModel< public static final String tablename = "customer"; - @JSONField(serialize = false) - public String getTablename() { + @JSONField(serialize=false) + public String getTablename(){ return tablename; } @@ -25,20 +25,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: INT(10) * isNullable: NO * isPrimaryKey: YES - * defaultValue: - * - * @param id + * defaultValue: + * @param id */ - @JSONField(name = "id") + @JSONField(name="id") public void setId(Integer id) { set("id", id); } - + /** - * @return id + * @return id */ - @JSONField(name = "id") + @JSONField(name="id") public Integer getId() { return getInt("id"); } @@ -48,20 +47,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(128) * isNullable: NO * isPrimaryKey: NO - * defaultValue: - * - * @param name + * defaultValue: + * @param name */ - @JSONField(name = "name") + @JSONField(name="name") public void setName(String name) { set("name", name); } - + /** - * @return name + * @return name */ - @JSONField(name = "name") + @JSONField(name="name") public String getName() { return getStr("name"); } @@ -71,20 +69,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(256) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param address 开票地址 */ - @JSONField(name = "address") + @JSONField(name="address") public void setAddress(String address) { set("address", address); } - + /** * @return address 开票地址 */ - @JSONField(name = "address") + @JSONField(name="address") public String getAddress() { return getStr("address"); } @@ -94,20 +91,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(20) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param phone 开票电话(可以是座机) */ - @JSONField(name = "phone") + @JSONField(name="phone") public void setPhone(String phone) { set("phone", phone); } - + /** * @return phone 开票电话(可以是座机) */ - @JSONField(name = "phone") + @JSONField(name="phone") public String getPhone() { return getStr("phone"); } @@ -117,20 +113,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(255) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param texpayerName 开票公司名称 */ - @JSONField(name = "texpayer_name") + @JSONField(name="texpayer_name") public void setTexpayerName(String texpayerName) { set("texpayer_name", texpayerName); } - + /** * @return texpayer_name 开票公司名称 */ - @JSONField(name = "texpayer_name") + @JSONField(name="texpayer_name") public String getTexpayerName() { return getStr("texpayer_name"); } @@ -140,20 +135,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(20) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param texpayerNum 税号 */ - @JSONField(name = "texpayer_num") + @JSONField(name="texpayer_num") public void setTexpayerNum(String texpayerNum) { set("texpayer_num", texpayerNum); } - + /** * @return texpayer_num 税号 */ - @JSONField(name = "texpayer_num") + @JSONField(name="texpayer_num") public String getTexpayerNum() { return getStr("texpayer_num"); } @@ -163,43 +157,41 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(128) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param bankName 开户行名称 */ - @JSONField(name = "bank_name") + @JSONField(name="bank_name") public void setBankName(String bankName) { set("bank_name", bankName); } - + /** * @return bank_name 开户行名称 */ - @JSONField(name = "bank_name") + @JSONField(name="bank_name") public String getBankName() { return getStr("bank_name"); } /** * name: bank_account - * type: VARCHAR(20) + * type: VARCHAR(128) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * + * defaultValue: * @param bankAccount 开户行账号 */ - @JSONField(name = "bank_account") + @JSONField(name="bank_account") public void setBankAccount(String bankAccount) { set("bank_account", bankAccount); } - + /** * @return bank_account 开户行账号 */ - @JSONField(name = "bank_account") + @JSONField(name="bank_account") public String getBankAccount() { return getStr("bank_account"); } @@ -209,20 +201,19 @@ public abstract class BaseCustomer> extends BaseModel< * type: VARCHAR(256) * isNullable: YES * isPrimaryKey: NO - * defaultValue: - * - * @param memo + * defaultValue: + * @param memo */ - @JSONField(name = "memo") + @JSONField(name="memo") public void setMemo(String memo) { set("memo", memo); } - + /** - * @return memo + * @return memo */ - @JSONField(name = "memo") + @JSONField(name="memo") public String getMemo() { return getStr("memo"); } @@ -233,19 +224,18 @@ public abstract class BaseCustomer> extends BaseModel< * isNullable: NO * isPrimaryKey: NO * defaultValue: 0 - * - * @param del + * @param del */ - @JSONField(name = "del") + @JSONField(name="del") public void setDel(Integer del) { set("del", del); } - + /** - * @return del + * @return del */ - @JSONField(name = "del") + @JSONField(name="del") public Integer getDel() { return getInt("del"); } @@ -256,19 +246,18 @@ public abstract class BaseCustomer> extends BaseModel< * isNullable: NO * isPrimaryKey: NO * defaultValue: 0 - * * @param type 是否预付费客户,0.不是,1.是 */ - @JSONField(name = "type") + @JSONField(name="type") public void setType(Integer type) { set("type", type); } - + /** * @return type 是否预付费客户,0.不是,1.是 */ - @JSONField(name = "type") + @JSONField(name="type") public Integer getType() { return getInt("type"); } @@ -279,22 +268,65 @@ public abstract class BaseCustomer> extends BaseModel< * isNullable: NO * isPrimaryKey: NO * defaultValue: 1 - * * @param invoiceType 1.普票,2.专票 */ - @JSONField(name = "invoice_type") + @JSONField(name="invoice_type") public void setInvoiceType(Integer invoiceType) { set("invoice_type", invoiceType); } - + /** * @return invoice_type 1.普票,2.专票 */ - @JSONField(name = "invoice_type") + @JSONField(name="invoice_type") public Integer getInvoiceType() { return getInt("invoice_type"); } + /** + * name: weight_discount + * type: DECIMAL(6,4) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: 1.0000 + * @param weightDiscount 重量折扣系数 + */ + @JSONField(name="weight_discount") + public void setWeightDiscount(java.math.BigDecimal weightDiscount) { + set("weight_discount", weightDiscount); + } + + + /** + * @return weight_discount 重量折扣系数 + */ + @JSONField(name="weight_discount") + public java.math.BigDecimal getWeightDiscount() { + return get("weight_discount"); + } + + /** + * name: customer_type_id + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: 0 + * @param customerTypeId 客户分类id + */ + @JSONField(name="customer_type_id") + public void setCustomerTypeId(Integer customerTypeId) { + set("customer_type_id", customerTypeId); + } + + + /** + * @return customer_type_id 客户分类id + */ + @JSONField(name="customer_type_id") + public Integer getCustomerTypeId() { + return getInt("customer_type_id"); + } + } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerType.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerType.java new file mode 100644 index 0000000..2844e0c --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseCustomerType.java @@ -0,0 +1,90 @@ +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 Mon Jul 26 16:28:20 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public abstract class BaseCustomerType> extends BaseModel implements IBean { + + public static final String tablename = "customer_type"; + + @JSONField(serialize=false) + public String getTablename(){ + return tablename; + } + + /** + * name: id + * type: INT(10) + * isNullable: NO + * isPrimaryKey: YES + * defaultValue: + * @param id + */ + @JSONField(name="id") + public void setId(Integer id) { + set("id", id); + } + + + /** + * @return id + */ + @JSONField(name="id") + public Integer getId() { + return getInt("id"); + } + + /** + * name: name + * type: VARCHAR(255) + * isNullable: YES + * isPrimaryKey: NO + * defaultValue: + * @param name 类型名称 + */ + @JSONField(name="name") + public void setName(String name) { + set("name", name); + } + + + /** + * @return name 类型名称 + */ + @JSONField(name="name") + public String getName() { + return getStr("name"); + } + + /** + * name: desc + * type: VARCHAR(255) + * isNullable: YES + * isPrimaryKey: NO + * defaultValue: + * @param desc 类型描述 + */ + @JSONField(name="desc") + public void setDesc(String desc) { + set("desc", desc); + } + + + /** + * @return desc 类型描述 + */ + @JSONField(name="desc") + public String getDesc() { + return getStr("desc"); + } + + +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeController.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeController.java new file mode 100644 index 0000000..191be84 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeController.java @@ -0,0 +1,24 @@ +package com.cowr.ssjygl.customer.type; + +import com.cowr.common.view.Result; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Mon Jul 26 16:28:29 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +public class CustomerTypeController extends Controller { + + /** + * 返回所有 customer_type 客户相关 - 客户分类定义 + */ + public void list() { + renderJson(Result.object(CustomerTypeService.me.list())); + } + + public void treedata() { + renderJson(Result.object(CustomerTypeService.me.treedata())); + } +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypePKValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypePKValidator.java new file mode 100644 index 0000000..82f81ee --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypePKValidator.java @@ -0,0 +1,25 @@ +package com.cowr.ssjygl.customer.type; + + +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerType; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Mon Jul 26 16:28:30 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +public class CustomerTypePKValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + validateRequired("id", "id", "id 必填"); + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + } + + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} \ No newline at end of file diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeService.java new file mode 100644 index 0000000..45eaef3 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeService.java @@ -0,0 +1,52 @@ +package com.cowr.ssjygl.customer.type; + +import com.cowr.common.base.BaseService; +import com.cowr.common.utils.DataUtil; +import com.cowr.model.CustomerType; +import com.jfinal.log.Log; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.Record; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +/** + * Generated by COWR Mon Jul 26 16:28:30 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +public class CustomerTypeService extends BaseService { + private static final Log log = Log.getLog(CustomerTypeService.class); + public static final CustomerTypeService me = new CustomerTypeService(); + + public List treedata() { + List list = Db.find("select id, name, -1 pid from customer_type "); + List cus = Db.find("select concat('customer_id_', id) id, name, customer_type_id pid, id customer_id from customer "); + + list.addAll(cus); + + List out = DataUtil.transformToTreeFormat(list); + + out.sort(new Comparator() { + @Override + public int compare(Record o1, Record o2) { + if (o1.getInt("id") == 0 || o2.getInt("id") == 0) { + return -1; + } else { + return o1.getInt("id") - o2.getInt("id"); + } + } + }); + + List root = new ArrayList<>(); + root.add(new Record().set("id", -1).set("name", "全部").set("children", out)); + + return root; + } + + public List list() { + return CustomerType.dao.find("select * from customer_type"); + } +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeValidator.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeValidator.java new file mode 100644 index 0000000..6f101fd --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/type/CustomerTypeValidator.java @@ -0,0 +1,38 @@ +package com.cowr.ssjygl.customer.type; + +import com.cowr.common.validator.CrudParamValidator; +import com.cowr.common.view.Result; +import com.cowr.model.CustomerType; +import com.jfinal.core.Controller; + +/** + * Generated by COWR Mon Jul 26 16:28:30 CST 2021 + * TableName: customer_type + * Remarks: 客户相关 - 客户分类定义 + * PrimaryKey: id + */ +public class CustomerTypeValidator extends CrudParamValidator { + @Override + protected void validate(Controller c) { + // 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断 + if (!"save".equals(getActionMethodName())) { + validateRequired("id", "id", "id 必填"); + + validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647"); + } + + validateString("name", 1, 255, "name", "name 长度 0~255"); + validateString("desc", 0, 255, "desc", "desc 长度 0~255"); + + // 使用 model 更新时,model 不能只有主键有值 + // 这里用 getActionMethodName 写死,判断是 update 时,才做验证 + // 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段 + if ("edit".equals(getActionMethodName())) { + validateUpdateModel(CustomerType.class, "", true); // 忽略不在model中的字段 + } + } + + protected void handleError(Controller c) { + c.renderJson(Result.failed(getErrmsg())); + } +} \ No newline at end of file diff --git a/ssjygl-xsx-common/src/main/java/generator/Main.java b/ssjygl-xsx-common/src/main/java/generator/Main.java index 2967cb1..d64e1eb 100644 --- a/ssjygl-xsx-common/src/main/java/generator/Main.java +++ b/ssjygl-xsx-common/src/main/java/generator/Main.java @@ -83,6 +83,7 @@ public class Main { "ticket_invalid_verify", "ticket_log", "ticket_receive", + "customer_type", }; PropKit.use("db.properties"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/Printer.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/Printer.java index 85247e9..a633cc4 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/Printer.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/device/Printer.java @@ -20,7 +20,7 @@ public class Printer { return; } lock.lock(); - try { + try (FileInputStream fis = new FileInputStream(file)) { Socket socket = new Socket(); socket.setOOBInline(false); socket.setTcpNoDelay(true); @@ -30,45 +30,49 @@ public class Printer { socket.setSoTimeout(15000); socket.connect(new InetSocketAddress(ip, port), 5000); - FileInputStream fis = new FileInputStream(file); - OutputStream out = socket.getOutputStream(); - int l1 = (int) (file.length() >> 56); - int l2 = (int) (file.length() >> 48); - int l3 = (int) (file.length() >> 40); - int l4 = (int) (file.length() >> 32); - int l5 = (int) (file.length() >> 24); - int l6 = (int) (file.length() >> 16); - int l7 = (int) (file.length() >> 8); - int l8 = (int) file.length(); - out.write(l1); - out.write(l2); - out.write(l3); - out.write(l4); - out.write(l5); - out.write(l6); - out.write(l7); - out.write(l8); - out.flush(); - byte[] buf = new byte[1024]; + try (OutputStream out = socket.getOutputStream()) { + int l1 = (int) (file.length() >> 56); + int l2 = (int) (file.length() >> 48); + int l3 = (int) (file.length() >> 40); + int l4 = (int) (file.length() >> 32); + int l5 = (int) (file.length() >> 24); + int l6 = (int) (file.length() >> 16); + int l7 = (int) (file.length() >> 8); + int l8 = (int) file.length(); - while (true) { - int read = fis.read(buf); - if (read == -1) { - break; - } - out.write(buf, 0, read); + out.write(l1); + out.write(l2); + out.write(l3); + out.write(l4); + out.write(l5); + out.write(l6); + out.write(l7); + out.write(l8); out.flush(); - } - fis.close(); + byte[] buf = new byte[1024]; - InputStream in = socket.getInputStream(); - while (true) { - int i = in.read(); - if (i != 0) { - break; + while (true) { + int read = fis.read(buf); + if (read == -1) { + break; + } + out.write(buf, 0, read); + out.flush(); } + + InputStream in = socket.getInputStream(); + while (true) { + int i = in.read(); + if (i != 0) { + break; + } + } + socket.close(); + } catch (Exception e) { + throw e; } - socket.close(); + } catch (Exception e) { + throw e; } finally { lock.unlock(); } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/printer/ExcelHelper.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/printer/ExcelHelper.java index e57a25f..f323c1c 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/printer/ExcelHelper.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/devicectrl/printer/ExcelHelper.java @@ -1,15 +1,15 @@ package com.cowr.local.ssjygl.devicectrl.printer; import com.jfinal.log.Log; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellAddress; -import org.apache.poi.xssf.usermodel.XSSFClientAnchor; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbookFactory; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; @@ -20,14 +20,11 @@ public class ExcelHelper { static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); public static Workbook genExcel(Map model, File tplFile) { - FileInputStream is = null; - try { + try (FileInputStream is = new FileInputStream(tplFile)) { long st = System.currentTimeMillis(); Map addrMap; CellAddress datetimePrint; - is = new FileInputStream(tplFile); - Workbook workbook = XSSFWorkbookFactory.create(is); log.debug("读取模板耗时:" + (System.currentTimeMillis() - st)); Sheet sheet = workbook.getSheetAt(0); @@ -70,15 +67,6 @@ public class ExcelHelper { return workbook; } catch (Exception e) { log.error(e.getMessage(), e); - } finally { - if (is != null) { - try { - is.close(); - is = null; - } catch (IOException e) { - log.error(e.getMessage(), e); - } - } } return null; diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/jobs/ClearTempFileJob.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/jobs/ClearTempFileJob.java new file mode 100644 index 0000000..946abd3 --- /dev/null +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/jobs/ClearTempFileJob.java @@ -0,0 +1,69 @@ +package com.cowr.local.ssjygl.jobs; + +import com.cowr.local.ssjygl.devicectrl.common.Const; +import com.cowr.local.ssjygl.main.Config; +import com.jfinal.log.Log; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.io.File; + +public class ClearTempFileJob implements Job { + private static Log log = Log.getLog(ClearTempFileJob.class); + + private void clearImg() { + long now = System.currentTimeMillis(); + String dir = Config.getRootPath() + File.separator + Const.LicenseImgTmpFolder; + + File baseDir = new File(dir); + File[] files = baseDir.listFiles(); + + for (int i = 0; i < files.length; i++) { + File img = files[i]; + long st = img.lastModified(); + + // 缩略图 名称带 _ , 原图名称带 - ,超过2天后,都删掉 + if (img.getName().contains("_") || img.getName().contains("-")) { + if (now - st > 2 * 24 * 60 * 60 * 1000) { + img.delete(); + } + } + } + } + + private void clearXlsx() { + long now = System.currentTimeMillis(); + String dir = Config.getRootPath() + File.separator + Const.PringExcelTmpFolder; + + File baseDir = new File(dir); + File[] files = baseDir.listFiles(); + + for (int i = 0; i < files.length; i++) { + File xlsx = files[i]; + long st = xlsx.lastModified(); + if (now - st > 2 * 24 * 60 * 60 * 1000) { + xlsx.delete(); + } + } + } + + public void clear() { + try { + clearImg(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + try { + clearXlsx(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + clear(); + } +} diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java index 2f78597..fb3df54 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java @@ -24,6 +24,7 @@ import com.cowr.local.ssjygl.driver.DriverController; import com.cowr.local.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController; import com.cowr.local.ssjygl.invoice.log.InvoiceLogController; import com.cowr.local.ssjygl.invoice.receive.InvoiceReceiveController; +import com.cowr.local.ssjygl.jobs.ClearTempFileJob; import com.cowr.local.ssjygl.netty.NettyClient; import com.cowr.local.ssjygl.netty.SocketIOService; import com.cowr.local.ssjygl.order.invalidverify.OrderInvalidVerifyController; @@ -64,14 +65,10 @@ import com.cowr.model._MappingKit; import com.cowr.ssjygl.CacheData; import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController; import com.cowr.ssjygl.cctv.CctvController; -import com.cowr.local.ssjygl.prepay.PrepayController; -import com.cowr.local.ssjygl.overall.OverallController; import com.cowr.ssjygl.modifylog.ModifyLogController; import com.cowr.ssjygl.stat.invoice.InvoiceUseController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; -import com.cowr.local.ssjygl.stat.sale.OrderStatController; import com.cowr.ssjygl.stat.transfer.OrderTransferStatController; -import com.cowr.local.ssjygl.system.sysuser.SysuserController; import com.cowr.ssjygl.transportcompany.TransportCompanyService; import com.cowr.ssjygl.transprice.TransPriceService; import com.jfinal.config.*; @@ -88,10 +85,6 @@ import com.jfinal.plugin.druid.DruidPlugin; import com.jfinal.plugin.druid.DruidStatViewHandler; import com.jfinal.plugin.redis.RedisPlugin; import com.jfinal.template.Engine; -import com.cowr.common.Interceptor.ReporterInterceptor; -import com.cowr.common.handler.GlobalHandler; -import com.cowr.common.view.JsonRenderFactory; -import com.cowr.model._MappingKit; import java.io.File; import java.sql.Connection; @@ -409,6 +402,8 @@ public class Config extends JFinalConfig { } catch (Exception e) { log.error(e.getMessage(), e); } + + new ClearTempFileJob().clear(); } catch (Exception e) { log.error(e.getMessage(), e); } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java index bad3d3d..76283bf 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/LocalOrderService.java @@ -465,9 +465,7 @@ public class LocalOrderService { return null; } - FileOutputStream output = null; - Workbook wb = null; - + Workbook wb = null; try { Object invoice_type = data.get("invoice_type"); // 可能是 null @@ -491,27 +489,21 @@ public class LocalOrderService { System.currentTimeMillis() )); - output = new FileOutputStream(out); - wb.write(output); + try (FileOutputStream output = new FileOutputStream(out)) { + wb.write(output); - log.debug("生成票据打印文件: %s", out.getAbsolutePath()); - log.debug("生成文件耗时2:%s", System.currentTimeMillis() - st); + log.debug("生成票据打印文件: %s", out.getAbsolutePath()); + log.debug("生成文件耗时2:%s", System.currentTimeMillis() - st); - return out; + return out; + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } } catch (Exception e) { log.error(e.getMessage(), e); return null; } finally { - if (output != null) { - try { - output.flush(); - output.close(); - output = null; - } catch (IOException e) { - log.error(e.getMessage(), e); - } - } - if (wb != null) { try { wb.close(); diff --git a/ssjygl-xsx-local/src/main/resources/job.properties b/ssjygl-xsx-local/src/main/resources/job.properties index 6312fb6..0c4ae42 100644 --- a/ssjygl-xsx-local/src/main/resources/job.properties +++ b/ssjygl-xsx-local/src/main/resources/job.properties @@ -6,4 +6,9 @@ synctask.enable=true # 在零点检查前一天未完成的集团订单,将开始执行的置为已完成,将未开始的置为取消 checkundonordercluster.job=com.cowr.local.ssjygl.jobs.CheckUndonOrderclusterJob checkundonordercluster.cron= 1 0 0 * * ? -checkundonordercluster.enable=true \ No newline at end of file +checkundonordercluster.enable=true + +# 删除超过2天的无用图片、打印生成的 excel +cleartempfile.job=com.cowr.local.ssjygl.jobs.ClearTempFileJob +cleartempfile.cron= 1 0 1 * * ? +cleartempfile.enable=true \ No newline at end of file diff --git a/ssjygl-xsx-local/src/main/resources/prod/config.properties b/ssjygl-xsx-local/src/main/resources/prod/config.properties index a9f3b45..a261e05 100644 --- a/ssjygl-xsx-local/src/main/resources/prod/config.properties +++ b/ssjygl-xsx-local/src/main/resources/prod/config.properties @@ -24,7 +24,7 @@ default_scale_wait_time=8000 weigh.max=49 #集团订单剩余量在结算时的剩余量预警值 -surplus.threshold=30 +surplus.threshold=125 #打印用到的配置信息 print.vendor=浠水县长投环保有限公司 diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java index e5c4e6d..225e7df 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java @@ -61,6 +61,7 @@ import com.cowr.service.ssjygl.truck.TruckController; import com.cowr.ssjygl.CacheData; import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController; import com.cowr.ssjygl.cctv.CctvController; +import com.cowr.ssjygl.customer.type.CustomerTypeController; import com.cowr.ssjygl.modifylog.ModifyLogController; import com.cowr.ssjygl.stat.invoice.InvoiceUseController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; @@ -184,6 +185,7 @@ public class Config extends JFinalConfig { me.add("/customer/register", CustomerRegisterController.class); me.add("/customer/pact", CustomerPactController.class); me.add("/customer/csp", CustomerSupermarketProductController.class); + me.add("/customer/type", CustomerTypeController.class); // -- 预付费 me.add("/prepay", PrepayController.class); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java index f40f43c..c553c6b 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java @@ -52,8 +52,6 @@ public class PrepayController extends BaseController { } Integer supermarket_id = getInt("supermarket_id"); - Integer invoice_type = getInt("invoice_type"); - String stm = get("stm"); String etm = get("etm"); String truck_license = get("truck_license"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java index 7bda4c8..c62908e 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java @@ -7,7 +7,6 @@ import com.cowr.common.view.Result; import com.cowr.model.Customer; import com.cowr.model.CustomerReceiver; import com.cowr.model.Sysuser; -import com.cowr.service.ssjygl.customer.register.CustomerRegisterService; import com.cowr.service.ssjygl.main.AuthInterceptor; import com.cowr.ssjygl.system.sysuser.SysuserPKValidator; import com.cowr.ssjygl.system.sysuser.SysuserValidator; @@ -71,8 +70,9 @@ public class SysuserController extends Controller { String receiver_phone = get("receiver_phone"); String receiver_address = get("receiver_address"); Integer invoice_type = getInt("invoice_type", 1); + Integer customer_type_id = getInt("customer_type_id", 1); - renderJson(SysuserSyncService.me.saveCustomer(model, texpayer_name, receiver_name, receiver_phone, receiver_address, invoice_type, tokenuser)); + renderJson(SysuserSyncService.me.saveCustomer(model, texpayer_name, receiver_name, receiver_phone, receiver_address, invoice_type, customer_type_id, tokenuser)); } /** @@ -137,9 +137,10 @@ public class SysuserController extends Controller { String receiver_phone = get("receiver_phone"); String receiver_address = get("receiver_address"); Integer invoice_type = getInt("invoice_type", 1); + Integer customer_type_id = getInt("customer_type_id", 0); Sysuser model = getModel(Sysuser.class, "", true); // 忽略不在model中的字段 - renderJson(SysuserSyncService.me.updateCustomer(model, texpayer_name, receiver_name, receiver_phone, receiver_address, invoice_type, tokenuser)); + renderJson(SysuserSyncService.me.updateCustomer(model, texpayer_name, receiver_name, receiver_phone, receiver_address, invoice_type, customer_type_id, tokenuser)); } /** diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserSyncService.java index f2a2984..ba2504f 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserSyncService.java @@ -139,10 +139,11 @@ public class SysuserSyncService extends BaseSyncService { /** * 是否财务经理 * 预付费审批、退费审批 + * * @param roleid * @return */ - public boolean isFinanceManager(Integer roleid){ + public boolean isFinanceManager(Integer roleid) { if (roleid == null) return false; return roleid.equals(RoleEnum.FINANCEMANAGER.getRoleid()); } @@ -369,6 +370,7 @@ public class SysuserSyncService extends BaseSyncService { String receiver_phone, String receiver_address, Integer invoice_type, + Integer customer_type_id, Sysuser tokenuser ) { try { @@ -385,6 +387,7 @@ public class SysuserSyncService extends BaseSyncService { customer.setName(texpayer_name); customer.setTexpayerName(texpayer_name); customer.setInvoiceType(invoice_type); + customer.setCustomerTypeId(customer_type_id); if (customer.checkDuplicate("name")) { return Result.failed(false, "名称已存在"); @@ -464,6 +467,7 @@ public class SysuserSyncService extends BaseSyncService { String receiver_phone, String receiver_address, Integer invoice_type, + Integer customer_type_id, Sysuser tokenuser ) { try { @@ -504,6 +508,7 @@ public class SysuserSyncService extends BaseSyncService { customer.setName(texpayer_name); customer.setTexpayerName(texpayer_name); customer.setInvoiceType(invoice_type); + customer.setCustomerTypeId(customer_type_id); chkobj.setName(model.getName()); chkobj.setPhone(model.getPhone());