添加打印二维码

dev
lisai17@sina.com 2020-08-14 17:39:16 +08:00
parent 100f1c13f0
commit 34a0c62a1b
20 changed files with 429 additions and 149 deletions

View File

@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Thu Aug 13 23:05:38 CST 2020
* Generated by COWR Fri Aug 14 11:13:17 CST 2020
* TableName: invoice_log
* Remarks: - 使
* PrimaryKey: id
@ -22,24 +22,24 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
/**
* name: id
* type: INT(10)
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id
* @param id uuid
*/
@JSONField(name="id")
public void setId(Integer id) {
public void setId(String id) {
set("id", id);
}
/**
* @return id
* @return id uuid
*/
@JSONField(name="id")
public Integer getId() {
return getInt("id");
public String getId() {
return getStr("id");
}
/**

View File

@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean;
import com.alibaba.fastjson.annotation.JSONField;
/**
* Generated by COWR Fri Aug 14 00:06:21 CST 2020
* Generated by COWR Fri Aug 14 11:13:17 CST 2020
* TableName: invoice_receive
* Remarks: -
* PrimaryKey: id
@ -22,24 +22,24 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
/**
* name: id
* type: INT(10)
* type: CHAR(32)
* isNullable: NO
* isPrimaryKey: YES
* defaultValue:
* @param id
* @param id uuid
*/
@JSONField(name="id")
public void setId(Integer id) {
public void setId(String id) {
set("id", id);
}
/**
* @return id
* @return id uuid
*/
@JSONField(name="id")
public Integer getId() {
return getInt("id");
public String getId() {
return getStr("id");
}
/**

View File

@ -7,7 +7,7 @@ import com.cowr.model.InvoiceLog;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Aug 13 22:45:08 CST 2020
* Generated by COWR Fri Aug 14 11:13:22 CST 2020
* TableName: invoice_log
* Remarks: - 使
* PrimaryKey: id
@ -16,7 +16,7 @@ public class InvoiceLogPKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
validateString("id", 1, 32, "id", "id 长度 1~32");
}
protected void handleError(Controller c) {

View File

@ -7,7 +7,7 @@ import com.cowr.common.view.Result;
import com.cowr.model.InvoiceLog;
/**
* Generated by COWR Thu Aug 13 23:09:29 CST 2020
* Generated by COWR Fri Aug 14 11:13:22 CST 2020
* TableName: invoice_log
* Remarks: - 使
* PrimaryKey: id
@ -19,7 +19,7 @@ public class InvoiceLogValidator extends CrudParamValidator {
if (!"save".equals(getActionMethodName())) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
validateString("id", 1, 32, "id", "id 长度 1~32");
}
validateInteger("invoice_receive_id", 1, 2147483647, "invoice_receive_id", "invoice_receive_id 范围 1~2147483647");

View File

@ -3,10 +3,11 @@ package com.cowr.ssjygl.invoice.receive;
import com.cowr.common.validator.CrudParamValidator;
import com.cowr.common.view.Result;
import com.cowr.model.InvoiceReceive;
import com.jfinal.core.Controller;
/**
* Generated by COWR Thu Aug 13 22:45:08 CST 2020
* Generated by COWR Fri Aug 14 11:13:22 CST 2020
* TableName: invoice_receive
* Remarks: -
* PrimaryKey: id
@ -15,7 +16,7 @@ public class InvoiceReceivePKValidator extends CrudParamValidator {
@Override
protected void validate(Controller c) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
validateString("id", 1, 32, "id", "id 长度 1~32");
}
protected void handleError(Controller c) {

View File

@ -7,7 +7,7 @@ import com.cowr.common.view.Result;
import com.cowr.model.InvoiceReceive;
/**
* Generated by COWR Fri Aug 14 00:06:27 CST 2020
* Generated by COWR Fri Aug 14 11:13:22 CST 2020
* TableName: invoice_receive
* Remarks: -
* PrimaryKey: id
@ -18,31 +18,12 @@ public class InvoiceReceiveValidator extends CrudParamValidator {
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
if (!"save".equals(getActionMethodName())) {
validateRequired("id", "id", "id 必填");
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
validateString("id", 1, 32, "id", "id 长度 1~32");
}
validateInteger("num", -2147483647, 2147483647, "num", "num 范围 -2147483647~2147483647");
validateString("start_code", 1, 20, "start_code", "start_code 长度 1~20");
validateString("current_code", 0, 20, "current_code", "current_code 长度 0~20");
validateString("create_time", 0, 19, "create_time", "create_time 长度 0~19");
validateString("change_time", 0, 19, "change_time", "change_time 长度 0~19");
validateInteger("receive_user_id", 1, 2147483647, "receive_user_id", "receive_user_id 范围 1~2147483647");
validateString("receive_user_name", 1, 255, "receive_user_name", "receive_user_name 长度 1~255");
validateInteger("supermarket_id", 1, 2147483647, "supermarket_id", "supermarket_id 范围 1~2147483647");

View File

@ -145,6 +145,17 @@
<version>2.4.2</version>
</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>
<!-- 避免控制台输出如下提示信息:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
项目中实际上用不到这个 jar 包,本项目用不上这个依赖

View File

@ -72,6 +72,7 @@ public class CellAddresses {
static {
// addrMap.put("serial", serial);
addrMap.put("qrcode", qrcode);
addrMap.put("datatimePrint", datetimePrint);
addrMap.put("clientName", clientName);
addrMap.put("clientTaxId", clientTaxId);

View File

@ -1,13 +1,16 @@
package com.cowr.local.ssjygl.devicectrl.printer;
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 com.jfinal.kit.PathKit;
import com.jfinal.log.Log;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
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;
@ -15,99 +18,128 @@ import java.util.Map;
import java.util.Set;
public class ExcelHelper {
static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
public static Workbook genExcel(Map<String, Object> model, File tplFile) throws IOException {
long st = System.currentTimeMillis();
Workbook workbook = XSSFWorkbookFactory.create(tplFile);
System.out.println("读取模板耗时:" + ( System.currentTimeMillis() - st ));
Sheet sheet = workbook.getSheetAt(0);
private static Log log = Log.getLog(ExcelHelper.class);
static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Set<Map.Entry<String, CellAddress>> entrySet = CellAddresses.addrMap.entrySet();
for (Map.Entry<String, CellAddress> entry : entrySet) {
Object val = model.get(entry.getKey());
if (val == null) {
continue;
public static Workbook genExcel(Map<String, Object> model, File tplFile) {
FileInputStream is = null;
try {
long st = System.currentTimeMillis();
is = new FileInputStream(tplFile);
Workbook workbook = XSSFWorkbookFactory.create(is);
log.debug("读取模板耗时:" + (System.currentTimeMillis() - st));
Sheet sheet = workbook.getSheetAt(0);
Set<Map.Entry<String, CellAddress>> entrySet = CellAddresses.addrMap.entrySet();
for (Map.Entry<String, CellAddress> entry : entrySet) {
Object val = model.get(entry.getKey());
if (val == null) {
continue;
}
CellAddress addr = entry.getValue();
if ("qrcode".equals(entry.getKey())) {
Drawing patriarch = sheet.createDrawingPatriarch();
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 2, 4);
anchor.setAnchorType(ClientAnchor.AnchorType.byId(2));
patriarch.createPicture(anchor, workbook.addPicture(QRcodeZxingUtil.generateQRcodeByte(val.toString(), 200, "png"), XSSFWorkbook.PICTURE_TYPE_PNG));
} else {
getCell(getRow(sheet, addr.getRow()), addr.getColumn()).setCellValue(val.toString());
}
}
String now = sdf.format(new Date());
getCell(getRow(sheet, CellAddresses.datetimePrint.getRow()), CellAddresses.datetimePrint.getColumn()).setCellValue(now);
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);
}
}
CellAddress addr = entry.getValue();
getCell(getRow(sheet, addr.getRow()), addr.getColumn()).setCellValue(val.toString());
}
String now = sdf.format(new Date());
getCell(getRow(sheet, CellAddresses.datetimePrint.getRow()), CellAddresses.datetimePrint.getColumn()).setCellValue(now);
return workbook;
return null;
}
public static Row getRow(Sheet sheet, int i){
public static Row getRow(Sheet sheet, int i) {
Row row = sheet.getRow(i);
if(row == null){
if (row == null) {
row = sheet.createRow(i);
}
return row;
}
public static Cell getCell(Row row, int i){
public static Cell getCell(Row row, int i) {
Cell cell = row.getCell(i);
if(cell == null){
if (cell == null) {
cell = row.createCell(i);
}
return cell;
}
public class Model {
public class Model {
//二维码
private String qrcode;
private String qrcode;
//单号
private String serial ;
private String serial;
//开票时间
private String datetimePrint;
private String datetimePrint;
//客户名称
private String clientName;
private String clientName;
//客户纳税人识别号
private String clientTaxId;
private String clientTaxId;
//客户地址、电话
private String clientContact;
private String clientContact;
//客户开户行及账号
private String clientBankInfo;
private String clientBankInfo;
//运输公司名称及车牌号
private String haulerName;
private String haulerName;
//运输公司纳税人识别号
private String haulerTaxId;
private String haulerTaxId;
//运输公司地址、电话
private String haulerContact;
private String haulerContact;
//运输公司开户行及账号
private String haulerBankInfo;
private String haulerBankInfo;
//起点
private String origin;
private String origin;
//终点
private String dest;
private String dest;
//品名
private String goodsName;
private String goodsName;
//净重
private String goodsNetWeight;
private String goodsNetWeight;
//运输距离
private String transDistance;
private String transDistance;
//商品单价
private String priceGoods;
private String priceGoods;
//商品总价小写
private String priceGoodsTotal;
private String priceGoodsTotal;
//商品总价大写
private String priceGoodsTotalUpper;
private String priceGoodsTotalUpper;
//运输单价
private String priceTrans;
private String priceTrans;
//运输总价小写
private String priceTransTotal;
private String priceTransTotal;
//运输总价大写
private String priceTransTotalUpper;
private String priceTransTotalUpper;
//销售方
private String vendor;
private String vendor;
//销售方纳税人识别号
private String vendorTaxId;
private String vendorTaxId;
//备注
private String remark;
private String remark;
}
}

View File

@ -0,0 +1,190 @@
package com.cowr.local.ssjygl.devicectrl.printer;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.jfinal.log.Log;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.file.Path;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
public class QRcodeZxingUtil {
private static Log log = Log.getLog(QRcodeZxingUtil.class);
/**
*
*/
public static DateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
/**
*
*/
public static final int QRCODE_SIZE = 300;
/**
*
*/
public static final String CONTENT = "http://blog.csdn.net/magi1201";
/**
*
*
* @param content
* @param width
* @param height
* @param picFormat jpg/png
*/
public static void generateQRcodePic(String content, int width, int height, String picFormat) {
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 1);
try {
// 构造二维字节矩阵
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
// 构造文件目录,若目录不存在,则创建目录
String fileDir = "C:\\lisai\\DEV_ENV" + File.separator + "image" + File.separator + sf.format(new Date());
if (!new File(fileDir).exists()) {
new File(fileDir).mkdirs();
}
Path file = new File(fileDir + File.separator + "qrcode." + picFormat).toPath();
// 将二位字节矩阵按照指定图片格式,写入指定文件目录,生成二维码图片
MatrixToImageWriter.writeToPath(bitMatrix, picFormat, file);
} catch (WriterException | IOException e) {
e.printStackTrace();
}
}
/**
*
*
* @param content
* @param width
* @param picFormat
*/
public static byte[] generateQRcodeByte(String content, int width, String picFormat) {
byte[] codeBytes = null;
try {
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
hints.put(EncodeHintType.MARGIN, 0); //去掉白色边框,极度重要,否则二维码周围的白边会很宽
// 构造二维字节矩阵,将二位字节矩阵渲染为二维缓存图片
QRCodeWriter writer = new QRCodeWriter();
BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, width, width, hints);
BufferedImage image = toBufferedImage(bitMatrix);
// 定义输出流,将二维缓存图片写到指定输出流
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(image, picFormat, out);
// 将输出流转换为字节数组
codeBytes = out.toByteArray();
} catch (WriterException | IOException e) {
log.error(e.getMessage(), e);
}
return codeBytes;
}
/**
*
*
* @param matrix
* @return
*/
public static BufferedImage toBufferedImage(BitMatrix matrix) {
int width = matrix.getWidth();
int height = matrix.getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
int onColor = 0xFF000000;
int offColor = 0xFFFFFFFF;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
image.setRGB(x, y, matrix.get(x, y) ? onColor : offColor);
}
}
return image;
}
/**
*
*
* @param filepath
*/
public static void readQRcode(String filepath) {
MultiFormatReader multiFormatReader = new MultiFormatReader();
File file = new File(filepath);
// 图片缓冲
BufferedImage image = null;
// 二进制比特图
BinaryBitmap binaryBitmap = null;
// 二维码结果
Result result = null;
try {
image = ImageIO.read(file);
binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));
result = multiFormatReader.decode(binaryBitmap);
} catch (IOException | NotFoundException e1) {
e1.printStackTrace();
}
System.out.println("读取二维码: " + result.toString());
System.out.println("二维码格式: " + result.getBarcodeFormat());
System.out.println("二维码内容: " + result.getText());
}
/**
* main
*
* @param args
*/
public static void main(String[] args) {
// 生成二维码,直接写到本地
generateQRcodePic(CONTENT, QRCODE_SIZE, QRCODE_SIZE, "jpg");
// 测试二维码信息解析
String filepath = "C:\\lisai\\DEV_ENV" + File.separator + "image" + File.separator + sf.format(new Date())
+ File.separator + "qrcode.jpg";
readQRcode(filepath);
// 生成二维码,返回字节数组
String path = "C:\\lisai\\DEV_ENV" + File.separator + "image" + File.separator + sf.format(new Date());
File pathDir = new File(path);
if (!pathDir.exists()) {
pathDir.mkdirs();
}
File pathFile = new File(path + File.separator + "qrcodeByte.jpg");
byte[] fileIo = generateQRcodeByte(CONTENT, QRCODE_SIZE, "jpg");
try {
OutputStream os = new FileOutputStream(pathFile);
os.write(fileIo);
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,9 @@
package com.cowr.local.ssjygl.invoice.log;
import com.cowr.local.ssjygl.base.BaseSyncService;
import com.jfinal.log.Log;
public class InvoiceLogSyncService extends BaseSyncService {
private static Log log = Log.getLog(InvoiceLogSyncService.class);
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
}

View File

@ -86,7 +86,7 @@ public class Config extends JFinalConfig {
public static String getRootPath() {
return PathKit.getWebRootPath()
.substring(0, PathKit.getWebRootPath().indexOf(File.separator + "ssjygl-xsx-local")) +
File.separator + "ssjygl-local";
File.separator + "ssjygl-xsx-local";
}
private class ClientThread extends Thread {

View File

@ -205,7 +205,7 @@ public class OrderService {
remark = "转运订单:" + sn;
if(order.get("source_weight") != null ){
if (order.get("source_weight") != null) {
remark += String.format("\n底单重量%.2f", order.getBigDecimal("source_weight"));
}
@ -248,9 +248,9 @@ public class OrderService {
vendor = CacheData.print_vendor; // 销售方名称
vendorTaxId = CacheData.print_vendorTaxId; // 销售方纳税人识别号
if(order.get("old_sn") != null){
if (order.get("old_sn") != null) {
remark = "外销订单:" + StrUtil.getRecordStr(order, "old_sn");
}else{
} else {
remark = "外销订单:" + StrUtil.getRecordStr(order, "sn");
}
@ -299,13 +299,13 @@ public class OrderService {
origin = purchase.getName(); // 运输起点
dest = supermarket.getName(); // 运输终点
if(order.get("old_sn") != null){
if (order.get("old_sn") != null) {
remark = "采购订单:" + StrUtil.getRecordStr(order, "old_sn");
}else{
} else {
remark = "采购订单:" + StrUtil.getRecordStr(order, "sn");
}
if(order.get("source_weight") != null ){
if (order.get("source_weight") != null) {
remark += String.format("\n底单重量%.2f", order.getBigDecimal("source_weight"));
}
@ -315,7 +315,7 @@ public class OrderService {
out.put("goodsTareWeight", goodsTareWeight);
out.put("goodsGrossWeight", goodsGrossWeight);
out.put("qrcode", "");
out.put("qrcode", sn);
out.put("serial", sn);
out.put("datetimePrint", sdf.get().format(new Date()));
out.put("clientName", clientName);
@ -361,6 +361,12 @@ public class OrderService {
try {
wb = ExcelHelper.genExcel(data, new File(PathKit.getRootClassPath() + "/tpl.xlsx"));
if (wb == null) {
log.error("获取 Workbook 失败");
return null;
}
log.debug("生成文件耗时1%s", System.currentTimeMillis() - st);
File out = new File(String.format("%s%s%s-%d.xlsx",

View File

@ -53,6 +53,15 @@ public class SysuserController extends Controller {
renderJson(SysuserSyncService.me.findByPk(model));
}
@Clear(AuthInterceptor.class)
public void testlogin() {
String name = get("name", "").trim();
String phone = get("phone", "").trim();
String password = get("password", "");
renderJson(SysuserSyncService.me.login(name, phone, password));
}
@Clear(AuthInterceptor.class)
public void login(){
String name = get("name", "").trim();

View File

@ -1,12 +1,12 @@
# mysql
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION;
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=ssjy_xsx
password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=ssjy_xsx
#password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=root
#password=Local_1
jdbcUrl=jdbc:mysql://192.168.1.119:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=root
password=Local_1
# redis
redis.basekey =ssjcgl_xsx_dev

View File

@ -29,42 +29,6 @@ public class InvoiceLogController extends Controller {
renderJson(InvoiceLogService.me.checkExistsByPk(model));
}
/**
* invoice_log - 使
*/
@Before(InvoiceLogValidator.class)
public void save(){
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
renderJson(InvoiceLogSyncService.me.save(model));
}
/**
* invoice_log - 使
*/
@Before(InvoiceLogPKValidator.class)
public void del(){
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
renderJson(InvoiceLogSyncService.me.delete(model));
}
/**
* invoice_log - 使
*/
@Before(InvoiceLogPKValidator.class)
public void restore(){
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
renderJson(InvoiceLogSyncService.me.restore(model));
}
/**
* invoice_log - 使
*/
@Before(InvoiceLogValidator.class)
public void edit(){
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
renderJson(InvoiceLogSyncService.me.update(model));
}
/**
* invoice_log - 使
*/

View File

@ -2,8 +2,10 @@ package com.cowr.service.ssjygl.invoice.receive;
import com.cowr.common.view.Result;
import com.cowr.model.InvoiceReceive;
import com.cowr.model.Supermarket;
import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.base.BaseSyncService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
public class InvoiceReceiveSyncService extends BaseSyncService {
@ -11,7 +13,21 @@ public class InvoiceReceiveSyncService extends BaseSyncService {
public static InvoiceReceiveSyncService me = new InvoiceReceiveSyncService();
public Result save(InvoiceReceive receive, Sysuser user){
Sysuser receive_user = Sysuser.dao.findById(receive.getReceiveUserId());
return null;
if(receive_user == null){
return Result.failed("未找到关联用户信息");
}
receive.setReceiveUserName(receive_user.getName());
Supermarket supermarket = Supermarket.dao.findById(receive.getSupermarketId());
if(supermarket == null){
return Result.failed("未找到对应超市信息");
}
receive.setId(StrKit.getRandomUUID());
return super.save(receive, user);
}
}

View File

@ -111,6 +111,18 @@ public class SysuserController extends Controller {
Integer entity_id = getInt("entity_id");
renderJson(Result.object(SysuserSyncService.me.find(pp, name, phone, del, type, entity_id)));
}
/**
* sysuser
*/
public void list() {
PageParam pp = getBean(PageParam.class, "", true);
String name = get("name", "");
String phone = get("phone", "");
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
Integer type = getInt("type");
Integer entity_id = getInt("entity_id");
renderJson(Result.object(SysuserSyncService.me.list(name, phone, del, type, entity_id)));
}
/**
* sysuser

View File

@ -634,4 +634,52 @@ public class SysuserSyncService extends BaseSyncService {
return Db.paginate(pp.getPage(), pp.getSize(), "select * ", sqlbuf.toString(), paraList.toArray());
}
public List<Record> list(String name, String phone, Integer del, Integer type, Integer entity_id) {
StringBuilder sqlbuf = new StringBuilder();
sqlbuf.append(" from (\n");
sqlbuf.append("select \n");
sqlbuf.append(" u.id, u.phone, u.name, u.type, u.role, u.del\n");
sqlbuf.append(" , case when u.type = 4 then d.trans_co_id else u.entity_id end entity_id\n");
sqlbuf.append(" , case when u.type = 1 then s.name end supermarket_name \n");
sqlbuf.append(" , case when u.type = 2 then t.name when u.type = 4 then t2.name end trans_co_name \n");
sqlbuf.append(" , case when u.type = 3 then c.name end customer_name\n");
sqlbuf.append(" , case when u.type = 4 then d.id end driver_id\n");
sqlbuf.append(" from sysuser u \n");
sqlbuf.append(" left join supermarket s on u.entity_id = s.id \n");
sqlbuf.append(" left join transport_company t on u.entity_id = t.id \n");
sqlbuf.append(" left join driver d on u.entity_id = d.id\n");
sqlbuf.append(" left join transport_company t2 on d.trans_co_id = t2.id \n");
sqlbuf.append(" left join customer c on u.entity_id = c.id\n");
sqlbuf.append(") a\n");
sqlbuf.append("where 1 = 1");
List<Object> paraList = new ArrayList<>();
if (StrKit.notBlank(name)) {
sqlbuf.append(" and a.name like ? \n");
paraList.add("%" + name + "%");
}
if (StrKit.notBlank(phone)) {
sqlbuf.append(" and a.phone like ? \n");
paraList.add("%" + phone + "%");
}
if (del != null && (del == Const.LOGIC_DEL_VALID || del == Const.LOGIC_DEL_INVALID)) {
sqlbuf.append(" and a.del = ? \n");
paraList.add(del);
}
if (type != null && type > 0) {
sqlbuf.append(" and a.type = ? \n");
paraList.add(type);
}
if (entity_id != null && entity_id > 0) {
sqlbuf.append(" and a.entity_id = ? \n");
paraList.add(entity_id);
}
return Db.find("select * " + sqlbuf.toString(), paraList.toArray());
}
}

View File

@ -1,12 +1,12 @@
# mysql
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=ssjy_xsx
password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=ssjy_xsx
#password=Ssjy_xs_890
# mysql
#jdbcUrl=jdbc:mysql://192.168.1.165:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=root
#password=Local_1
jdbcUrl=jdbc:mysql://192.168.1.165:3306/ssjy_xsx_service_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=root
password=Local_1
# redis
redis.basekey=ssjcgl_xsx_dev