添加砂站年产量管理

dev
lisai17@sina.com 2021-09-23 14:26:18 +08:00
parent 4e0227d14c
commit 59107fee73
14 changed files with 405 additions and 19 deletions

View File

@ -20,6 +20,11 @@ public class DateTimeUtil {
return new SimpleDateFormat("yyyy-01-01");
}
};
public static final ThreadLocal<SimpleDateFormat> year = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy");
}
};
public static final ThreadLocal<SimpleDateFormat> month_start = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-01-01");

View File

@ -0,0 +1,14 @@
package com.cowr.model;
import com.cowr.model.base.BaseSupermarketYield;
/**
* Generated by COWR Thu Sep 23 10:25:34 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
@SuppressWarnings("serial")
public class SupermarketYield extends BaseSupermarketYield<SupermarketYield> {
public static final SupermarketYield dao = new SupermarketYield().dao();
}

View File

@ -34,6 +34,8 @@ public class _MappingKit {
arp.addMapping("supermarket_product", "supermarket_id,product_id", SupermarketProduct.class);
// Composite Primary Key order: supermarket_id,customer_id
arp.addMapping("supermarket_customer_distance", "supermarket_id,customer_id", SupermarketCustomerDistance.class);
// Composite Primary Key order: supermarket_id,year
arp.addMapping("supermarket_yield", "supermarket_id,year", SupermarketYield.class);
arp.addMapping("blacklist", "id", Blacklist.class);
arp.addMapping("truck", "license", Truck.class);
arp.addMapping("purchase", "id", Purchase.class);

View File

@ -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 Thu Sep 23 10:25:33 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
@SuppressWarnings("serial")
public abstract class BaseSupermarketYield<M extends BaseSupermarketYield<M>> extends BaseModel<M> implements IBean {
public static final String tablename = "supermarket_yield";
@JSONField(serialize=false)
public String getTablename(){
return tablename;
}
/**
* name: supermarket_id
* type: INT(10)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param supermarketId
*/
@JSONField(name="supermarket_id")
public void setSupermarketId(Integer supermarketId) {
set("supermarket_id", supermarketId);
}
/**
* @return supermarket_id
*/
@JSONField(name="supermarket_id")
public Integer getSupermarketId() {
return getInt("supermarket_id");
}
/**
* name: year
* type: CHAR(4)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param year YYYY
*/
@JSONField(name="year")
public void setYear(String year) {
set("year", year);
}
/**
* @return year YYYY
*/
@JSONField(name="year")
public String getYear() {
return getStr("year");
}
/**
* name: yield
* type: DOUBLE(10,2)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param yield
*/
@JSONField(name="yield")
public void setYield(Double yield) {
set("yield", yield);
}
/**
* @return yield
*/
@JSONField(name="yield")
public Double getYield() {
return getDouble("yield");
}
}

View File

@ -2017,7 +2017,7 @@ public class OrderStatService {
public Workbook trafficStatisticsOfEachSandStationExport(String stm, String etm, String tm, Integer invoice_type) {
Record data = trafficStatisticsOfEachSandStation(stm, etm, tm, invoice_type);
List<Record> list = data.get("data");
List<Supermarket> sups = data.get("supermarket");
List<Record> sups = data.get("supermarket");
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(stm.substring(0, 10) + " ~ " + etm.substring(0, 10) + "各砂站运输量统计表");
@ -2036,29 +2036,36 @@ public class OrderStatService {
row.createCell(a++).setCellValue("退费金额(元)");
Row row2 = sheet.createRow(1);
Row row3 = sheet.createRow(2);
int a2 = 8;
for (Supermarket s : sups) {
row.createCell(a).setCellValue(s.getName());
for (int i=0; i<sups.size(); i++) {
Record s = sups.get(i);
Double yield = DataUtil.getDoubleByRecord(s, "yield");
row.createCell(a).setCellValue(s.getStr("name"));
row2.createCell(a).setCellValue(yield != null ? String.format("%.2f万吨", yield) : "-");
sheet.addMergedRegion(new CellRangeAddress(0, 0, a, a + 1));
sheet.addMergedRegion(new CellRangeAddress(1, 1, a, a + 1));
a += 2;
row2.createCell(a2++).setCellValue("总销售量(吨)");
row2.createCell(a2++).setCellValue("总销售额(元)");
row3.createCell(a2++).setCellValue("总销售量(吨)");
row3.createCell(a2++).setCellValue("总销售额(元)");
}
sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 1, 1));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 2, 2));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 5, 5));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 6, 6));
sheet.addMergedRegion(new CellRangeAddress(0, 1, 7, 7));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 1, 1));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 2, 2));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 3, 3));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 4, 4));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 5, 5));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 6, 6));
sheet.addMergedRegion(new CellRangeAddress(0, 2, 7, 7));
int datalen = list.size();
int colcnt = a;
int rowcnt = 2;
int rowcnt = 3;
for (int i = 0; i < datalen; i++) {
int startrow = rowcnt;
Record sales = list.get(i);
@ -2089,9 +2096,9 @@ public class OrderStatService {
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "prepay_surplus"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "refund_total_amount"));
for (Supermarket s : sups) {
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "xsl_" + s.getId()));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "xse_" + s.getId()));
for (Record s : sups) {
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "xsl_" + s.getInt("id")));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(record, "xse_" + s.getInt("id")));
}
}
@ -2138,7 +2145,15 @@ public class OrderStatService {
*
*/
public Record trafficStatisticsOfEachSandStation(String stm, String etm, String tm, Integer invoice_type) {
List<Supermarket> sups = Supermarket.dao.find("select * from supermarket where id <= 6");
String year = DateTimeUtil.year.get().format(new Date());
if (StrKit.notBlank(tm) && tm.length() > 4) {
year = tm.substring(0, 4);
}
List<Record> sups = Db.find("select t.*, s.yield from supermarket t \n" +
" left join supermarket_yield s on s.supermarket_id = t.id and s.year = ? \n" +
" where id <= 6", year);
String paramsSql = "";
if (invoice_type != null) {

View File

@ -0,0 +1,59 @@
package com.cowr.ssjygl.supermarket.yield;
import com.cowr.common.Const;
import com.cowr.common.base.BaseService;
import com.cowr.common.view.PageParam;
import com.cowr.model.SupermarketYield;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.util.ArrayList;
import java.util.List;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldService extends BaseService {
private static final Log log = Log.getLog(SupermarketYieldService.class);
public static final SupermarketYieldService me = new SupermarketYieldService();
public Page<Record> find(PageParam pp, Integer supermarket_id, String year) {
String selectsql = "select t.*, s.name supermarket_name ";
String fromsql = "from supermarket_yield t \n" +
" left join supermarket s on s.id = t.supermarket_id \n" +
" where 1=1 ";
List<Object> paraList = new ArrayList<>();
if (supermarket_id != null) {
fromsql += " and t.supermarket_id = ? \n";
paraList.add(supermarket_id);
}
if (StrKit.notBlank(year)) {
fromsql += " and t.year = ? \n";
paraList.add(year);
}
String totalRowSql = "select count(*) " + fromsql;
String findSql = selectsql + fromsql;
// 前端传了排序字段,并且排序字段存在相关表中
if (StrKit.notBlank(pp.getSort_field()) && SupermarketYield.dao.hasColunm(pp.getSort_field())) {
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
findSql += " " + Const.ORDER_BY_ASC;
} else {
findSql += " " + Const.ORDER_BY_DESC;
}
}
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
}
}

View File

@ -84,6 +84,7 @@ public class Main {
"ticket_log",
"ticket_receive",
"customer_type",
"supermarket_yield",
};
PropKit.use("db.properties");

View File

@ -51,6 +51,7 @@ import com.cowr.local.ssjygl.supermarket.receiverdistance.SupermarketReceiverDis
import com.cowr.local.ssjygl.supermarket.sandfarmdistance.SupermarketSandfarmDistanceController;
import com.cowr.local.ssjygl.supermarket.stock.StockController;
import com.cowr.local.ssjygl.supermarket.stock.StockSyncService;
import com.cowr.local.ssjygl.supermarket.yield.SupermarketYieldController;
import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.system.sysuser.SysuserController;
import com.cowr.local.ssjygl.ticket.invalidverify.TicketInvalidVerifyController;
@ -192,6 +193,7 @@ public class Config extends JFinalConfig {
me.add("/supermarket/ssd", SupermarketSandfarmDistanceController.class);
me.add("/supermarket/srd", SupermarketReceiverDistanceController.class);
me.add("/supermarket/scd", SupermarketCustomerDistanceController.class);
me.add("/supermarket/yield", SupermarketYieldController.class);
me.add("/purchase", PurchaseController.class);
me.add("/product", ProductController.class);
me.add("/stock", StockController.class);

View File

@ -0,0 +1,22 @@
package com.cowr.local.ssjygl.supermarket.yield;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.ssjygl.supermarket.yield.SupermarketYieldService;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldController extends Controller {
/**
* supermarket_yield -
*/
public void find() {
PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(SupermarketYieldService.me.find(pp, getInt("supermarket_id"), get("year"))));
}
}

View File

@ -49,6 +49,7 @@ import com.cowr.service.ssjygl.supermarket.customerdistance.SupermarketCustomerD
import com.cowr.service.ssjygl.supermarket.receiverdistance.SupermarketReceiverDistanceController;
import com.cowr.service.ssjygl.supermarket.sandfarmdistance.SupermarketSandfarmDistanceController;
import com.cowr.service.ssjygl.supermarket.stock.StockController;
import com.cowr.service.ssjygl.supermarket.yield.SupermarketYieldController;
import com.cowr.service.ssjygl.synctask.SyncTaskService;
import com.cowr.service.ssjygl.system.sysuser.SysuserController;
import com.cowr.service.ssjygl.ticket.invalidverify.TicketInvalidVerifyController;
@ -58,7 +59,6 @@ import com.cowr.service.ssjygl.transport.TransportQueryController;
import com.cowr.service.ssjygl.transportcompany.TransportCompanyController;
import com.cowr.service.ssjygl.truck.TruckController;
import com.cowr.service.ssjygl.truck.truckweightlimit.TruckWeightLimitController;
import com.cowr.ssjygl.truck.weightlimitmodifylog.TruckWeightLimitModifyLogController;
import com.cowr.ssjygl.CacheData;
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
import com.cowr.ssjygl.cctv.CctvController;
@ -69,6 +69,7 @@ import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
import com.cowr.ssjygl.transportcompany.TransportCompanyService;
import com.cowr.ssjygl.transprice.TransPriceService;
import com.cowr.ssjygl.truck.weightlimitmodifylog.TruckWeightLimitModifyLogController;
import com.jfinal.config.*;
import com.jfinal.json.FastJsonFactory;
import com.jfinal.kit.PathKit;
@ -167,6 +168,7 @@ public class Config extends JFinalConfig {
me.add("/supermarket/ssd", SupermarketSandfarmDistanceController.class);
me.add("/supermarket/srd", SupermarketReceiverDistanceController.class);
me.add("/supermarket/scd", SupermarketCustomerDistanceController.class);
me.add("/supermarket/yield", SupermarketYieldController.class);
me.add("/purchase", PurchaseController.class);
me.add("/product", ProductController.class);
me.add("/stock", StockController.class);

View File

@ -0,0 +1,87 @@
package com.cowr.service.ssjygl.supermarket.yield;
import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result;
import com.cowr.model.SupermarketYield;
import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.supermarket.yield.SupermarketYieldService;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldController extends Controller {
/**
* supermarket_yield -
*/
@Before(SupermarketYieldValidator.class)
public void save() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
SupermarketYield model = getModel(SupermarketYield.class, "", true); // 忽略不在model中的字段
renderJson(SupermarketYieldSyncService.me.save(model, tokenuser));
}
/**
* supermarket_yield -
*/
@Before(SupermarketYieldPKValidator.class)
public void del() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
SupermarketYield model = getModel(SupermarketYield.class, "", true); // 忽略不在model中的字段
renderJson(SupermarketYieldSyncService.me.delete(model, tokenuser));
}
/**
* supermarket_yield -
*/
@Before(SupermarketYieldPKValidator.class)
public void restore() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
SupermarketYield model = getModel(SupermarketYield.class, "", true); // 忽略不在model中的字段
renderJson(SupermarketYieldSyncService.me.restore(model, tokenuser));
}
/**
* supermarket_yield -
*/
@Before(SupermarketYieldValidator.class)
public void edit() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
SupermarketYield model = getModel(SupermarketYield.class, "", true); // 忽略不在model中的字段
renderJson(SupermarketYieldSyncService.me.update(model, tokenuser));
}
/**
* supermarket_yield -
*/
public void find() {
PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(SupermarketYieldService.me.find(pp, getInt("supermarket_id"), get("year"))));
}
}

View File

@ -0,0 +1,27 @@
package com.cowr.service.ssjygl.supermarket.yield;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.SupermarketYield;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldPKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("supermarket_id", "supermarket_id", "supermarket_id 必填");
validateInteger("supermarket_id", 1, 2147483647, "supermarket_id", "supermarket_id 范围 1~2147483647");
validateRequired("year", "year", "year 必填");
validateString("year", 1, 4, "year", "year 长度 1~4");
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}

View File

@ -0,0 +1,15 @@
package com.cowr.service.ssjygl.supermarket.yield;
import com.cowr.service.ssjygl.base.BaseSyncService;
import com.jfinal.log.Log;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldSyncService extends BaseSyncService {
private static final Log log = Log.getLog(SupermarketYieldSyncService.class);
public static final SupermarketYieldSyncService me = new SupermarketYieldSyncService();
}

View File

@ -0,0 +1,45 @@
package com.cowr.service.ssjygl.supermarket.yield;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.SupermarketYield;
/**
* Generated by COWR Thu Sep 23 10:25:40 CST 2021
* TableName: supermarket_yield
* Remarks: -
* PrimaryKey: supermarket_id,year
*/
public class SupermarketYieldValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
if (!"save".equals(getActionMethodName())) {
validateRequired("supermarket_id", "supermarket_id", "supermarket_id 必填");
validateInteger("supermarket_id", 1, 2147483647, "supermarket_id", "supermarket_id 范围 1~2147483647");
}
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
if (!"save".equals(getActionMethodName())) {
validateRequired("year", "year", "year 必填");
validateString("year", 1, 4, "year", "year 长度 1~4");
}
if (StrKit.notBlank(c.get("yield"))) { // 可为空字段,当传入值时,才做验证
validateDouble("yield", -9.99999999E8, 9.99999999E8, "yield", "yield 范围 -9.99999999E8~9.99999999E8");
}
// 使用 model 更新时model 不能只有主键有值
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
// 如果确实是需要将主键外的字段置为 null可以在代码生成后删掉这段
if ("edit".equals(getActionMethodName())) {
validateUpdateModel(SupermarketYield.class, "", true); // 忽略不在model中的字段
}
}
protected void handleError(Controller c) {
c.renderJson(Result.failed(getErrmsg()));
}
}