dev
parent
b66a75d3a7
commit
c75a52025d
|
|
@ -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}安排车辆前去运输。");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -22,7 +22,9 @@ public class ExcelHelper {
|
|||
public static Workbook genExcel(Map<String, Object> model, File tplFile) {
|
||||
FileInputStream is = null;
|
||||
try {
|
||||
long st = System.currentTimeMillis();
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -143,16 +143,16 @@ public class LocalOrderService {
|
|||
|
||||
if (ret) {
|
||||
// if (req_receipt == 1) {
|
||||
try {
|
||||
printdata.set("first_weight", transport.getFirstWeight());
|
||||
printdata.set("second_weight", transport.getSecondWeight());
|
||||
try {
|
||||
printdata.set("first_weight", transport.getFirstWeight());
|
||||
printdata.set("second_weight", transport.getSecondWeight());
|
||||
|
||||
Config.deviceThread.print(printerId, getPrintFile(printdata));
|
||||
out.set("print", true);
|
||||
} catch (Exception e) {
|
||||
out.set("print", "打印指令发送失败");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
Config.deviceThread.print(printerId, getPrintFile(printdata));
|
||||
out.set("print", true);
|
||||
} catch (Exception e) {
|
||||
out.set("print", "打印指令发送失败");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
// }
|
||||
|
||||
try {
|
||||
|
|
@ -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 {
|
||||
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) {
|
||||
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.
Binary file not shown.
|
|
@ -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);
|
||||
|
|
@ -122,7 +133,7 @@ public class SmsService {
|
|||
smslog.setRelateId(ordercluster.getId().toString());
|
||||
|
||||
smslog.save();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -130,16 +141,16 @@ public class SmsService {
|
|||
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");
|
||||
|
||||
log.debug("检查 %s 短信发送状态", logs.size());
|
||||
|
||||
long st = System.currentTimeMillis();
|
||||
|
||||
for(SmsLog smslog : logs){
|
||||
for (SmsLog smslog : logs) {
|
||||
try {
|
||||
if(st - smslog.getCreateTime().getTime() > 24 * 60 * 60 * 1000){
|
||||
if (st - smslog.getCreateTime().getTime() > 24 * 60 * 60 * 1000) {
|
||||
smslog.setSendstatus(2);
|
||||
smslog.update();
|
||||
log.debug("发送给 %s 的短信超时", smslog.getPhone());
|
||||
|
|
@ -152,7 +163,7 @@ public class SmsService {
|
|||
JSONObject ret = JSONObject.parseObject(response);
|
||||
|
||||
if ("OK".equals(ret.getString("Code"))) {
|
||||
if(ret.getInteger("TotalCount") == 0){
|
||||
if (ret.getInteger("TotalCount") == 0) {
|
||||
log.debug("还未处理完成,没有查询到发送结果");
|
||||
continue;
|
||||
}
|
||||
|
|
@ -164,18 +175,18 @@ public class SmsService {
|
|||
smslog.setSenddate(detail.getDate("SendDate"));
|
||||
smslog.setSendstatus(detail.getIntValue("SendStatus"));
|
||||
|
||||
if(smslog.getSendcontent() != null){
|
||||
if (smslog.getSendcontent() != null) {
|
||||
int len = smslog.getSendcontent().length();
|
||||
if(len <= 70){
|
||||
if (len <= 70) {
|
||||
smslog.setBillNum(1);
|
||||
}else{
|
||||
smslog.setBillNum((int) Math.ceil(len/67.0));
|
||||
} else {
|
||||
smslog.setBillNum((int) Math.ceil(len / 67.0));
|
||||
}
|
||||
}
|
||||
|
||||
smslog.update();
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue