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_CACHENAME = "mian"; // redis 默认 cache 对象别名
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象 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; public static Map<String, String> SMS_TEMP_MAP;
static { static {
SMS_TEMP_MAP = new HashMap<>(); 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

@ -22,7 +22,9 @@ public class ExcelHelper {
public static Workbook genExcel(Map<String, Object> model, File tplFile) { public static Workbook genExcel(Map<String, Object> model, File tplFile) {
FileInputStream is = null; FileInputStream is = null;
try { try {
long st = System.currentTimeMillis(); long st = System.currentTimeMillis();
Map<String, CellAddress> addrMap;
CellAddress datetimePrint;
is = new FileInputStream(tplFile); is = new FileInputStream(tplFile);
@ -30,7 +32,15 @@ public class ExcelHelper {
log.debug("读取模板耗时:" + (System.currentTimeMillis() - st)); log.debug("读取模板耗时:" + (System.currentTimeMillis() - st));
Sheet sheet = workbook.getSheetAt(0); 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) { for (Map.Entry<String, CellAddress> entry : entrySet) {
Object val = model.get(entry.getKey()); Object val = model.get(entry.getKey());
if (val == null) { if (val == null) {
@ -38,18 +48,19 @@ public class ExcelHelper {
} }
CellAddress addr = entry.getValue(); CellAddress addr = entry.getValue();
if ("qrcode".equals(entry.getKey())) { // // 插入二维码
Drawing patriarch = sheet.createDrawingPatriarch(); // if ("qrcode".equals(entry.getKey())) {
XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 2, 4); // Drawing patriarch = sheet.createDrawingPatriarch();
anchor.setAnchorType(ClientAnchor.AnchorType.byId(2)); // XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, 1, 1, 2, 4);
patriarch.createPicture(anchor, workbook.addPicture(QRcodeZxingUtil.generateQRcodeByte(val.toString(), 200, "png"), XSSFWorkbook.PICTURE_TYPE_PNG)); // anchor.setAnchorType(ClientAnchor.AnchorType.byId(2));
} else { // 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()); getCell(getRow(sheet, addr.getRow()), addr.getColumn()).setCellValue(val.toString());
} // }
} }
String now = sdf.format(new Date()); 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; return workbook;
} catch (Exception e) { } catch (Exception e) {

View File

@ -11,7 +11,7 @@ public class JsdCellAddresses {
// 开票时间 // 开票时间
public static final CellAddress datetimePrint = makeCellAddress("o8"); 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"); 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 remark = makeCellAddress("m20");
// 开票人 // 开票人
public static final CellAddress drawer = makeCellAddress("l24"); public static final CellAddress drawer = makeCellAddress("e24");
// 车牌号 // 车牌号
public static final CellAddress truckLicense = makeCellAddress("m11"); public static final CellAddress truckLicense = makeCellAddress("m11");

View File

@ -143,16 +143,16 @@ public class LocalOrderService {
if (ret) { if (ret) {
// if (req_receipt == 1) { // if (req_receipt == 1) {
try { try {
printdata.set("first_weight", transport.getFirstWeight()); printdata.set("first_weight", transport.getFirstWeight());
printdata.set("second_weight", transport.getSecondWeight()); printdata.set("second_weight", transport.getSecondWeight());
Config.deviceThread.print(printerId, getPrintFile(printdata)); Config.deviceThread.print(printerId, getPrintFile(printdata));
out.set("print", true); out.set("print", true);
} catch (Exception e) { } catch (Exception e) {
out.set("print", "打印指令发送失败"); out.set("print", "打印指令发送失败");
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
// } // }
try { try {
@ -440,6 +440,7 @@ public class LocalOrderService {
// 开票类型,从订单信息中获取 // 开票类型,从订单信息中获取
// 订单中的开票类型在结算时,从客户信息中获取 // 订单中的开票类型在结算时,从客户信息中获取
// 2020-09-08 目前只有 order_temp 中有 invoice_type 字段
// 2020-09-28 开专票的单位,先临时开具结算单 // 2020-09-28 开专票的单位,先临时开具结算单
// 2020-09-28 在拿到印刷版的结算单前,需要在空白纸上打印完整的结算单信息 // 2020-09-28 在拿到印刷版的结算单前,需要在空白纸上打印完整的结算单信息
out.put("invoice_type", StrUtil.getRecordStr(order, "invoice_type")); out.put("invoice_type", StrUtil.getRecordStr(order, "invoice_type"));
@ -460,7 +461,13 @@ public class LocalOrderService {
Workbook wb = null; Workbook wb = null;
try { try {
wb = ExcelHelper.genExcel(data, new File(PathKit.getRootClassPath() + "/tpl.xlsx")); 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) { if (wb == null) {
log.error("获取 Workbook 失败"); log.error("获取 Workbook 失败");
@ -560,13 +567,4 @@ public class LocalOrderService {
return Result.success("打印指令已发送"); 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; 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(); JSONObject obj = new JSONObject();
obj.put("supermarket_name", supermarket.getName()); 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())); obj.put("weight", String.format("%.2f", ordercluster.getTotalWeight()));
String content = null; String content = null;
@ -86,11 +96,12 @@ public class SmsService {
for (Sysuser sysuser : users) { for (Sysuser sysuser : users) {
try { try {
String phone = sysuser.getPhone(); // String phone = sysuser.getPhone();
String phone = "13627293906";
log.debug("给 %s 发送短信", phone); 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); log.debug(response);
JSONObject ret = JSONObject.parseObject(response); JSONObject ret = JSONObject.parseObject(response);
@ -122,7 +133,7 @@ public class SmsService {
smslog.setRelateId(ordercluster.getId().toString()); smslog.setRelateId(ordercluster.getId().toString());
smslog.save(); smslog.save();
}catch (Exception e){ } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }
@ -130,16 +141,16 @@ public class SmsService {
return false; return false;
} }
public void checkSendStatus(){ public void checkSendStatus() {
List<SmsLog> logs = SmsLog.dao.find("select * from sms_log t where t.code = 'OK' and t.sendstatus < 2 limit 500"); List<SmsLog> logs = SmsLog.dao.find("select * from sms_log t where t.code = 'OK' and t.sendstatus < 2 limit 500");
log.debug("检查 %s 短信发送状态", logs.size()); log.debug("检查 %s 短信发送状态", logs.size());
long st = System.currentTimeMillis(); long st = System.currentTimeMillis();
for(SmsLog smslog : logs){ for (SmsLog smslog : logs) {
try { try {
if(st - smslog.getCreateTime().getTime() > 24 * 60 * 60 * 1000){ if (st - smslog.getCreateTime().getTime() > 24 * 60 * 60 * 1000) {
smslog.setSendstatus(2); smslog.setSendstatus(2);
smslog.update(); smslog.update();
log.debug("发送给 %s 的短信超时", smslog.getPhone()); log.debug("发送给 %s 的短信超时", smslog.getPhone());
@ -152,7 +163,7 @@ public class SmsService {
JSONObject ret = JSONObject.parseObject(response); JSONObject ret = JSONObject.parseObject(response);
if ("OK".equals(ret.getString("Code"))) { if ("OK".equals(ret.getString("Code"))) {
if(ret.getInteger("TotalCount") == 0){ if (ret.getInteger("TotalCount") == 0) {
log.debug("还未处理完成,没有查询到发送结果"); log.debug("还未处理完成,没有查询到发送结果");
continue; continue;
} }
@ -164,18 +175,18 @@ public class SmsService {
smslog.setSenddate(detail.getDate("SendDate")); smslog.setSenddate(detail.getDate("SendDate"));
smslog.setSendstatus(detail.getIntValue("SendStatus")); smslog.setSendstatus(detail.getIntValue("SendStatus"));
if(smslog.getSendcontent() != null){ if (smslog.getSendcontent() != null) {
int len = smslog.getSendcontent().length(); int len = smslog.getSendcontent().length();
if(len <= 70){ if (len <= 70) {
smslog.setBillNum(1); smslog.setBillNum(1);
}else{ } else {
smslog.setBillNum((int) Math.ceil(len/67.0)); smslog.setBillNum((int) Math.ceil(len / 67.0));
} }
} }
smslog.update(); smslog.update();
} }
}catch (Exception e){ } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} }