lisai17@sina.com 2020-09-29 10:56:43 +08:00
parent b66a75d3a7
commit c75a52025d
8 changed files with 146 additions and 46 deletions

View File

@ -17,11 +17,11 @@ public class Const {
public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象
public static final String TEMP_CODE_PEIE = "SMS_200713899"; // 配额分配通知
public static final String TEMP_CODE_PEIE = "SMS_203717953"; // 配额分配通知
public static Map<String, String> SMS_TEMP_MAP;
static {
SMS_TEMP_MAP = new HashMap<>();
SMS_TEMP_MAP.put("SMS_200713899", "已经在${supermarket_name}分配了${weight}吨配额,请在${date}当天安排车辆前去运输。");
SMS_TEMP_MAP.put("SMS_200713899", "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
}
}

View File

@ -23,6 +23,8 @@ public class ExcelHelper {
FileInputStream is = null;
try {
long st = System.currentTimeMillis();
Map<String, CellAddress> addrMap;
CellAddress datetimePrint;
is = new FileInputStream(tplFile);
@ -30,7 +32,15 @@ public class ExcelHelper {
log.debug("读取模板耗时:" + (System.currentTimeMillis() - st));
Sheet sheet = workbook.getSheetAt(0);
Set<Map.Entry<String, CellAddress>> entrySet = CellAddresses.addrMap.entrySet();
if ("tpl_bill_full.xlsx".equals(tplFile.getName())) {
addrMap = JsdCellAddresses.addrMap;
datetimePrint = JsdCellAddresses.datetimePrint;
} else {
addrMap = CellAddresses.addrMap;
datetimePrint = CellAddresses.datetimePrint;
}
Set<Map.Entry<String, CellAddress>> entrySet = addrMap.entrySet();
for (Map.Entry<String, CellAddress> entry : entrySet) {
Object val = model.get(entry.getKey());
if (val == null) {
@ -38,18 +48,19 @@ public class ExcelHelper {
}
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 {
// // 插入二维码
// 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);
getCell(getRow(sheet, datetimePrint.getRow()), datetimePrint.getColumn()).setCellValue(now);
return workbook;
} catch (Exception e) {

View File

@ -11,7 +11,7 @@ public class JsdCellAddresses {
// 开票时间
public static final CellAddress datetimePrint = makeCellAddress("o8");
// 客户名称
public static final CellAddress clientName = makeCellAddress("e9");
public static final CellAddress clientName = makeCellAddress("c9");
// 净重
public static final CellAddress goodsNetWeight = makeCellAddress("g18");
@ -29,7 +29,7 @@ public class JsdCellAddresses {
// 备注
public static final CellAddress remark = makeCellAddress("m20");
// 开票人
public static final CellAddress drawer = makeCellAddress("l24");
public static final CellAddress drawer = makeCellAddress("e24");
// 车牌号
public static final CellAddress truckLicense = makeCellAddress("m11");

View File

@ -440,6 +440,7 @@ public class LocalOrderService {
// 开票类型,从订单信息中获取
// 订单中的开票类型在结算时,从客户信息中获取
// 2020-09-08 目前只有 order_temp 中有 invoice_type 字段
// 2020-09-28 开专票的单位,先临时开具结算单
// 2020-09-28 在拿到印刷版的结算单前,需要在空白纸上打印完整的结算单信息
out.put("invoice_type", StrUtil.getRecordStr(order, "invoice_type"));
@ -460,7 +461,13 @@ public class LocalOrderService {
Workbook wb = null;
try {
Object invoice_type = data.get("invoice_type"); // 可能是 null
if ("2".equals(invoice_type)) { // 2020-09-29 开专票的订单先用结算单模板
wb = ExcelHelper.genExcel(data, new File(PathKit.getRootClassPath() + "/tpl_bill_full.xlsx"));
} else { // 其他的用冠名发票
wb = ExcelHelper.genExcel(data, new File(PathKit.getRootClassPath() + "/tpl.xlsx"));
}
if (wb == null) {
log.error("获取 Workbook 失败");
@ -560,13 +567,4 @@ public class LocalOrderService {
return Result.success("打印指令已发送");
}
/**
*
*
* @return
*/
public boolean completeBocomm(String MerTranNo) {
return false;
}
}

Binary file not shown.

View File

@ -71,9 +71,19 @@ public class SmsService {
return false;
}
String date = DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime());
if (ordercluster.getTimeInterval() == 1) {
date += "当天7时~19时";
} else if (ordercluster.getTimeInterval() == 2) {
date += "上午7时~13时";
} else if (ordercluster.getTimeInterval() == 3) {
date += "下午13时~19时";
}
JSONObject obj = new JSONObject();
obj.put("supermarket_name", supermarket.getName());
obj.put("date", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
obj.put("date", date);
obj.put("weight", String.format("%.2f", ordercluster.getTotalWeight()));
String content = null;
@ -86,11 +96,12 @@ public class SmsService {
for (Sysuser sysuser : users) {
try {
String phone = sysuser.getPhone();
// String phone = sysuser.getPhone();
String phone = "13627293906";
log.debug("给 %s 发送短信", phone);
String response = this.aliyunsms.send("13688888888", Const.TEMP_CODE_PEIE, obj);
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_PEIE, obj);
log.debug(response);
JSONObject ret = JSONObject.parseObject(response);