修改占位费和增加报文解析
This commit is contained in:
parent
bb085e8d7a
commit
f547f03e3f
@ -47,8 +47,64 @@ public class AnalyzeTheMessage extends BaseController {
|
|||||||
return analyzeTheMessageService.getRateModelRequestLogic(content);
|
return analyzeTheMessageService.getRateModelRequestLogic(content);
|
||||||
case "0A":
|
case "0A":
|
||||||
return analyzeTheMessageService.getReplyRateModelRequestLogic(content);
|
return analyzeTheMessageService.getReplyRateModelRequestLogic(content);
|
||||||
|
case "13":
|
||||||
|
return analyzeTheMessageService.getRealtimeDataLogic(content);
|
||||||
|
case "15":
|
||||||
|
return analyzeTheMessageService.getBmsChargingHandshakeDataLogic(content);
|
||||||
|
case "17":
|
||||||
|
return analyzeTheMessageService.getBmsChargingConfigDataLogic(content);
|
||||||
|
case "19":
|
||||||
|
return analyzeTheMessageService.getBmsChargingCompletedDataLogic(content);
|
||||||
|
case "1B":
|
||||||
|
return analyzeTheMessageService.getBmsErrorDataLogic(content);
|
||||||
|
case "1D":
|
||||||
|
return analyzeTheMessageService.getBmsInterruptDataLogic(content);
|
||||||
|
case "21":
|
||||||
|
return analyzeTheMessageService.getBmsChargerInterruptDataLogic(content);
|
||||||
|
case "23":
|
||||||
|
return analyzeTheMessageService.getBmsReqChargerOutputDataLogic(content);
|
||||||
|
case "25":
|
||||||
|
return analyzeTheMessageService.getBmsChargingDataLogic(content);
|
||||||
|
case "31":
|
||||||
|
return analyzeTheMessageService.getPileStartChargingDataLogic(content);
|
||||||
|
case "32":
|
||||||
|
return analyzeTheMessageService.getReplyPileStartChargingDataLogic(content);
|
||||||
|
case "33":
|
||||||
|
return analyzeTheMessageService.getRemoteStartReplyDataLogic(content);
|
||||||
|
case "38":
|
||||||
|
return analyzeTheMessageService.getReplyRemoteStartReplyDataLogic(content);
|
||||||
|
case "35":
|
||||||
|
return analyzeTheMessageService.getRemoteStopReplyDataLogic(content);
|
||||||
|
case "36":
|
||||||
|
return analyzeTheMessageService.getReplyRemoteStopReplyDataLogic(content);
|
||||||
|
case "3B":
|
||||||
|
return analyzeTheMessageService.getOrderDataLogic(content);
|
||||||
|
case "40":
|
||||||
|
return analyzeTheMessageService.getReplyOrderDataLogic(content);
|
||||||
|
case "41":
|
||||||
|
return analyzeTheMessageService.getBalanceUpdateReplyDataLogic(content);
|
||||||
|
case "42":
|
||||||
|
return analyzeTheMessageService.getReplyBalanceUpdateReplyDataLogic(content);
|
||||||
|
case "51":
|
||||||
|
return analyzeTheMessageService.getPileConfigReplyDataLogic(content);
|
||||||
|
case "52":
|
||||||
|
return analyzeTheMessageService.getReplyPileConfigReplyDataLogic(content);
|
||||||
|
case "55":
|
||||||
|
return analyzeTheMessageService.getPileTimeConfigReplyDataLogic(content);
|
||||||
|
case "56":
|
||||||
|
return analyzeTheMessageService.getReplyPileTimeConfigReplyDataLogic(content);
|
||||||
|
case "57":
|
||||||
|
return analyzeTheMessageService.getRateModelConfigReplyDataLogic(content);
|
||||||
|
case "58":
|
||||||
|
return analyzeTheMessageService.getReplyRateModelConfigReplyDataLogic(content);
|
||||||
|
case "91":
|
||||||
|
return analyzeTheMessageService.getRemoteRebootReplyDataLogic(content);
|
||||||
|
case "92":
|
||||||
|
return analyzeTheMessageService.getReplyRemoteRebootReplyDataLogic(content);
|
||||||
|
case "93":
|
||||||
|
return analyzeTheMessageService.getRemoteUpgradeReplyDataLogic(content);
|
||||||
|
case "94":
|
||||||
|
return analyzeTheMessageService.getRemoteUpgradeDataLogic(content);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return R.fail("请输入正确的报文");
|
return R.fail("请输入正确的报文");
|
||||||
|
|||||||
@ -24,4 +24,63 @@ public interface IAnalyzeTheMessageService {
|
|||||||
R getRateModelRequestLogic(String content);
|
R getRateModelRequestLogic(String content);
|
||||||
|
|
||||||
R getReplyRateModelRequestLogic(String content);
|
R getReplyRateModelRequestLogic(String content);
|
||||||
|
|
||||||
|
R getRealtimeDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsChargingHandshakeDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsChargingConfigDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsChargingCompletedDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsErrorDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsInterruptDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsChargerInterruptDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsReqChargerOutputDataLogic(String content);
|
||||||
|
|
||||||
|
R getBmsChargingDataLogic(String content);
|
||||||
|
|
||||||
|
R getPileStartChargingDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyPileStartChargingDataLogic(String content);
|
||||||
|
|
||||||
|
R getRemoteStartReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyRemoteStartReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getRemoteStopReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyRemoteStopReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getOrderDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyOrderDataLogic(String content);
|
||||||
|
|
||||||
|
R getBalanceUpdateReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyBalanceUpdateReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getPileConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyPileConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getPileTimeConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyPileTimeConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getRateModelConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyRateModelConfigReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getRemoteRebootReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getReplyRemoteRebootReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getRemoteUpgradeReplyDataLogic(String content);
|
||||||
|
|
||||||
|
R getRemoteUpgradeDataLogic(String content);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,246 @@
|
|||||||
|
package com.xhpc.card.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateField;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.xhpc.pp.utils.HexUtils;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
|
||||||
|
|
||||||
|
public class CP56Time2a {
|
||||||
|
|
||||||
|
public static final String DATE_FORMAT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
public static Date cp56toDate(String hex) {
|
||||||
|
|
||||||
|
byte[] bytes = HexUtils.toBytes(hex);
|
||||||
|
int milliseconds = HexUtils.reverseHexInt(hex.substring(0, 4));
|
||||||
|
int minutes = bytes[2] & 0x3f;
|
||||||
|
int hours = bytes[3] & 0x1f;
|
||||||
|
int days = bytes[4] & 0x1f;
|
||||||
|
int months = bytes[5] & 0x0f;
|
||||||
|
int years = bytes[6] & 0x7f;
|
||||||
|
DateTime dt = new DateTime();
|
||||||
|
dt.setField(DateField.MILLISECOND, 0);
|
||||||
|
dt.setField(DateField.SECOND, milliseconds / 1000);
|
||||||
|
dt.setField(DateField.MINUTE, minutes);
|
||||||
|
dt.setField(DateField.HOUR_OF_DAY, hours);
|
||||||
|
dt.setField(DateField.MONTH, months - 1);
|
||||||
|
dt.setField(DateField.DAY_OF_MONTH, days);
|
||||||
|
dt.setField(DateField.YEAR, years + 2000);
|
||||||
|
return dt.toCalendar().getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String cp56toDateStr(String hex) {
|
||||||
|
|
||||||
|
Date date = cp56toDate(hex);
|
||||||
|
return DateTime.of(date).toString(DATE_FORMAT_DATE_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String cp56toDateTSStr(String hex) {
|
||||||
|
|
||||||
|
byte[] bytes = hex.getBytes();
|
||||||
|
int[] infoElements = new int[bytes.length];
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
infoElements[i] = bytes[i];
|
||||||
|
}
|
||||||
|
return TimeScale(infoElements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toCp56Hex(Date d) {
|
||||||
|
|
||||||
|
byte[] result = new byte[7];
|
||||||
|
Calendar date = Calendar.getInstance();
|
||||||
|
date.setTime(d);
|
||||||
|
String milliSecond = String.format("%04X", (date.get(Calendar.SECOND) * 1000));
|
||||||
|
String reversehilo = milliSecond.substring(2, 4).concat(milliSecond.substring(0, 2));
|
||||||
|
result[0] = (byte) date.get(Calendar.MINUTE);
|
||||||
|
result[1] = (byte) (date.get(Calendar.HOUR_OF_DAY));
|
||||||
|
result[2] = (byte) (date.get(Calendar.DAY_OF_MONTH));
|
||||||
|
result[3] = (byte) (date.get(Calendar.MONTH) + 1);
|
||||||
|
result[4] = (byte) (date.get(Calendar.YEAR) % 100);
|
||||||
|
return reversehilo.concat(HexUtils.toHex(result)).substring(0, 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String decode(byte[] b) {
|
||||||
|
|
||||||
|
int year = b[6] & 0x7F;
|
||||||
|
int month = b[5] & 0x0F;
|
||||||
|
int day = b[4] & 0x1F;
|
||||||
|
int week = (b[4] & 0xE0) / 32;
|
||||||
|
// int week = (b[4] & 0xE0) >> 5;
|
||||||
|
int hour = b[3] & 0x1F;
|
||||||
|
int minute = b[2] & 0x3F;
|
||||||
|
int second = (b[1] << 8) + b[0];
|
||||||
|
String str = "20" + year + "-"
|
||||||
|
+ String.format("%02d", month) + "-"
|
||||||
|
+ String.format("%02d", day) + "T"
|
||||||
|
+ String.format("%02d", hour) + ":"
|
||||||
|
+ String.format("%02d", minute) + ":"
|
||||||
|
+ String.format("%02d", second / 1000) + "."
|
||||||
|
+ String.format("%03d", second % 1000);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String encode(Date date) {
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String milliSecond = String.format("%04X", (calendar.get(Calendar.SECOND) * 1000) + calendar.get(Calendar.MILLISECOND));
|
||||||
|
builder.append(milliSecond, 2, 4);
|
||||||
|
builder.append(milliSecond, 0, 2);
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.MINUTE) & 0x3F));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.HOUR_OF_DAY) & 0x1F));
|
||||||
|
int week = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
|
if (week == Calendar.SUNDAY)
|
||||||
|
week = 7;
|
||||||
|
else week--;
|
||||||
|
builder.append(String.format("%02X", (week << 5) + (calendar.get(Calendar.DAY_OF_MONTH) & 0x1F)));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.MONTH) + 1));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.YEAR) - 2000));
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时标CP56Time2a解析
|
||||||
|
*
|
||||||
|
* @param b 时标CP56Time2a(长度为7 的int数组)
|
||||||
|
* @return 解析结果
|
||||||
|
*/
|
||||||
|
public static String TimeScale(int[] b) {
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
int year = b[6] & 0x7F;
|
||||||
|
int month = b[5] & 0x0F;
|
||||||
|
int day = b[4] & 0x1F;
|
||||||
|
int week = (b[4] & 0xE0) / 32;
|
||||||
|
int hour = b[3] & 0x1F;
|
||||||
|
int minute = b[2] & 0x3F;
|
||||||
|
int second = (b[1] << 8) + b[0];
|
||||||
|
result.append("20");
|
||||||
|
result.append(year).append("-");
|
||||||
|
result.append(String.format("%02d", month)).append("-");
|
||||||
|
result.append(String.format("%02d", day)).append(" ");
|
||||||
|
result.append(hour).append(":").append(minute).append(":");
|
||||||
|
result.append(second / 1000 + "." + second % 1000);
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String TimeScale(byte[] bytes) {
|
||||||
|
|
||||||
|
int[] b = new int[bytes.length];
|
||||||
|
for (int i = 0; i < bytes.length; i++) {
|
||||||
|
b[i] = bytes[i];
|
||||||
|
}
|
||||||
|
return TimeScale(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间转16进制字符串
|
||||||
|
*/
|
||||||
|
public static String date2HStr(Date date) {
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String milliSecond = String.format("%04X", (calendar.get(Calendar.SECOND) * 1000) + calendar.get(Calendar.MILLISECOND));
|
||||||
|
builder.append(milliSecond, 2, 4);
|
||||||
|
builder.append(milliSecond, 0, 2);
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.MINUTE) & 0x3F));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.HOUR_OF_DAY) & 0x1F));
|
||||||
|
int week = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
|
if (week == Calendar.SUNDAY)
|
||||||
|
week = 7;
|
||||||
|
else week--;
|
||||||
|
builder.append(String.format("%02X", (week << 5) + (calendar.get(Calendar.DAY_OF_MONTH) & 0x1F)));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.MONTH) + 1));
|
||||||
|
builder.append(String.format("%02X", calendar.get(Calendar.YEAR) - 2000));
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Date toDate(byte[] bytes) {
|
||||||
|
|
||||||
|
int milliseconds1 = bytes[0] < 0 ? 256 + bytes[0] : bytes[0];
|
||||||
|
int milliseconds2 = bytes[1] < 0 ? 256 + bytes[1] : bytes[1];
|
||||||
|
int milliseconds = milliseconds1 + milliseconds2 * 256;
|
||||||
|
// 位于 0011 1111
|
||||||
|
int minutes = bytes[2] & 0x3f;
|
||||||
|
// 位于 0001 1111
|
||||||
|
int hours = bytes[3] & 0x1f;
|
||||||
|
// 位于 0000 1111
|
||||||
|
int days = bytes[4] & 0x0f;
|
||||||
|
// 位于 0001 1111
|
||||||
|
int months = bytes[5] & 0x0f;
|
||||||
|
// 位于 0111 1111
|
||||||
|
int years = bytes[6] & 0x7f;
|
||||||
|
final Calendar aTime = Calendar.getInstance();
|
||||||
|
aTime.set(Calendar.MILLISECOND, milliseconds);
|
||||||
|
aTime.set(Calendar.MINUTE, minutes);
|
||||||
|
aTime.set(Calendar.HOUR_OF_DAY, hours);
|
||||||
|
aTime.set(Calendar.DAY_OF_MONTH, days);
|
||||||
|
aTime.set(Calendar.MONTH, months);
|
||||||
|
aTime.set(Calendar.YEAR, years + 2000);
|
||||||
|
return aTime.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] toBytes(Date aDate) {
|
||||||
|
|
||||||
|
byte[] result = new byte[7];
|
||||||
|
final Calendar aTime = Calendar.getInstance();
|
||||||
|
aTime.setTime(aDate);
|
||||||
|
final int milliseconds = aTime.get(Calendar.MILLISECOND);
|
||||||
|
result[0] = (byte) (milliseconds % 256);
|
||||||
|
result[1] = (byte) (milliseconds / 256);
|
||||||
|
result[2] = (byte) aTime.get(Calendar.MINUTE);
|
||||||
|
result[3] = (byte) aTime.get(Calendar.HOUR_OF_DAY);
|
||||||
|
result[4] = (byte) aTime.get(Calendar.DAY_OF_MONTH);
|
||||||
|
result[5] = (byte) aTime.get(Calendar.MONTH);
|
||||||
|
result[6] = (byte) (aTime.get(Calendar.YEAR) % 100);
|
||||||
|
System.out.println("Year->" + aTime.get(Calendar.YEAR));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getCP56time2a(String hex) {
|
||||||
|
|
||||||
|
return "20" + String.format("%02d", Integer.parseInt(hex.substring(12, 14), 16)) + "-"
|
||||||
|
+ String.format("%02d", Integer.parseInt(hex.substring(10, 12), 16)) + "-"
|
||||||
|
+ String.format("%02d", Integer.parseInt(hex.substring(8, 10), 16)) + "T"
|
||||||
|
+ String.format("%02d", Integer.parseInt(hex.substring(6, 8), 16)) + ":"
|
||||||
|
+ String.format("%02d", Integer.parseInt(hex.substring(4, 6), 16)) + ":"
|
||||||
|
+ String.format("%02d", Integer.parseInt(hex.substring(2, 4) + "" + hex.substring(0, 2), 16) / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws InterruptedException {
|
||||||
|
// Date time = Calendar.getInstance().getTime();
|
||||||
|
// System.out.println(String.format("--未编码--: %s", time));
|
||||||
|
// String hex = toCp56Hex(time);
|
||||||
|
// System.out.println("--编码1--:" + hex);
|
||||||
|
// System.out.println(HexUtils.toBinaryString("90E223133D0416"));
|
||||||
|
System.out.println("--下达1--:" + DateUtil.format(cp56toDate("E880380D170518"), NORM_DATETIME_FORMATTER));
|
||||||
|
System.out.println("--下达2--:" + DateUtil.format(cp56toDate("A50F3A0D170518"), NORM_DATETIME_FORMATTER));
|
||||||
|
// System.out.println("toCp56Hex = " + toCp56Hex(cp56toDate("C05D0D171F0116")));
|
||||||
|
//// System.out.println("--下达2--:" + DateUtil.format(cp56toDate(""), NORM_DATETIME_FORMAT));
|
||||||
|
// String dateStr = "2017-03-01 22:33:23";
|
||||||
|
// Date date = DateUtil.parse(dateStr);
|
||||||
|
// Date newDate = DateUtil.offset(date, DateField.DAY_OF_MONTH, 2);
|
||||||
|
// System.out.println("--变为--:" + newDate.toString());
|
||||||
|
// System.out.println("sudo date " + newDate.getTime());
|
||||||
|
// System.out.println("--D0073211110815--:" + DateUtil.format(cp56toDate("D0073211110815"), NORM_DATETIME_FORMAT));
|
||||||
|
// System.out.println("--A85B3411110815--:" + DateUtil.format(cp56toDate("A85B3411110815"), NORM_DATETIME_FORMAT));
|
||||||
|
// String encode = encode(time);
|
||||||
|
// System.out.println(String.format("--编码2--:%s", encode));
|
||||||
|
// System.out.println("--解码2--:" + decode(HexUtils.toBytes(encode)));
|
||||||
|
|
||||||
|
String s = cp56toDateStr("81461009200A18");
|
||||||
|
|
||||||
|
System.out.println("-111-变为--:" + s);
|
||||||
|
|
||||||
|
String s1 = cp56toDateStr("1AB42D09200A18");
|
||||||
|
|
||||||
|
System.out.println("-111-变为--:" + s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -164,6 +164,7 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I
|
|||||||
xhpcTimingChargingModel.setChargingStationId(chargingStationId);
|
xhpcTimingChargingModel.setChargingStationId(chargingStationId);
|
||||||
xhpcTimingChargingModel.setPhone(xhpcTimingChargingModelDto.getPhone());
|
xhpcTimingChargingModel.setPhone(xhpcTimingChargingModelDto.getPhone());
|
||||||
|
|
||||||
|
if(xhpcTimingChargingModelDto.getChargingPileIds()!=null){
|
||||||
Integer[] chargingPileIds = xhpcTimingChargingModelDto.getChargingPileIds();
|
Integer[] chargingPileIds = xhpcTimingChargingModelDto.getChargingPileIds();
|
||||||
String PileIds ="";
|
String PileIds ="";
|
||||||
for (int i = 0; i <chargingPileIds.length ; i++) {
|
for (int i = 0; i <chargingPileIds.length ; i++) {
|
||||||
@ -176,6 +177,9 @@ public class XhpcTimingChargingModelServiceImpl extends BaseService implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhpcTimingChargingModel.setPileIds(PileIds);
|
xhpcTimingChargingModel.setPileIds(PileIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(xhpcTimingChargingModelDto.getTimingChargingModelId() !=null){
|
if(xhpcTimingChargingModelDto.getTimingChargingModelId() !=null){
|
||||||
xhpcTimingChargingModel.setTimingChargingModelId(xhpcTimingChargingModelDto.getTimingChargingModelId());
|
xhpcTimingChargingModel.setTimingChargingModelId(xhpcTimingChargingModelDto.getTimingChargingModelId());
|
||||||
|
|||||||
@ -159,7 +159,10 @@
|
|||||||
remark,
|
remark,
|
||||||
</if>
|
</if>
|
||||||
<if test="null != phone and '' != phone">
|
<if test="null != phone and '' != phone">
|
||||||
phone
|
phone,
|
||||||
|
</if>
|
||||||
|
<if test="null != pileIds and '' != pileIds">
|
||||||
|
pile_ids,
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
@ -197,7 +200,10 @@
|
|||||||
#{remark},
|
#{remark},
|
||||||
</if>
|
</if>
|
||||||
<if test="null != phone and '' != phone">
|
<if test="null != phone and '' != phone">
|
||||||
#{phone}
|
#{phone},
|
||||||
|
</if>
|
||||||
|
<if test="null != pileIds and '' != pileIds">
|
||||||
|
#{pileIds},
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|||||||
@ -245,5 +245,13 @@ public class BmsReqChargerOutputDataLogic implements ServiceLogic {
|
|||||||
double current = BMSCurrentParser.parseBmsCurrent(bmsData,400);
|
double current = BMSCurrentParser.parseBmsCurrent(bmsData,400);
|
||||||
System.out.println("BMS电流需求: " + current + " A");
|
System.out.println("BMS电流需求: " + current + " A");
|
||||||
|
|
||||||
|
|
||||||
|
int t1 = HexUtils.reverseHexInt("B014");//电桩电流输出值
|
||||||
|
System.out.println("BMS电压: " + t1 + " v");
|
||||||
|
|
||||||
|
|
||||||
|
String bmsData1 = "8409"; // 从BMS获取的实际数据
|
||||||
|
double current1 = BMSCurrentParser.parseBmsCurrent(bmsData1,400);
|
||||||
|
System.out.println("BMS电流需求: " + current1 + " A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,12 +8,23 @@ import com.xhpc.common.redis.service.RedisService;
|
|||||||
import com.xhpc.common.security.service.TokenService;
|
import com.xhpc.common.security.service.TokenService;
|
||||||
import com.xhpc.common.util.DateUtil;
|
import com.xhpc.common.util.DateUtil;
|
||||||
import com.xhpc.common.util.UserTypeUtil;
|
import com.xhpc.common.util.UserTypeUtil;
|
||||||
|
import com.xhpc.user.constant.InvoiceMapHistoryOrderStatusConst;
|
||||||
import com.xhpc.user.domain.*;
|
import com.xhpc.user.domain.*;
|
||||||
|
import com.xhpc.user.mapper.XhpcHistoryOrderMapper;
|
||||||
|
import com.xhpc.user.pojo.XhpcInvoiceMapHistoryOrder;
|
||||||
import com.xhpc.user.service.XhpcInvoiceService;
|
import com.xhpc.user.service.XhpcInvoiceService;
|
||||||
import com.xhpc.system.api.model.LoginUser;
|
import com.xhpc.system.api.model.LoginUser;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序的InvoiceController
|
* 小程序的InvoiceController
|
||||||
@ -33,6 +44,9 @@ public class XhpcInvoiceApiController extends BaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
RedisService redisService;
|
RedisService redisService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
XhpcHistoryOrderMapper xhpcHistoryOrderMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户显示小红点,即查询用户有几个未读的已开发票
|
* 查询用户显示小红点,即查询用户有几个未读的已开发票
|
||||||
*
|
*
|
||||||
@ -154,4 +168,6 @@ public class XhpcInvoiceApiController extends BaseController {
|
|||||||
return AjaxResult.success(titleResponse);
|
return AjaxResult.success(titleResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public interface XhpcHistoryOrderMapper {
|
|||||||
|
|
||||||
List<Map<String, Object>> countOperatorOnHistoryOrderIds(@Param("historyOrderIds")List<Integer> historyOrderIds);
|
List<Map<String, Object>> countOperatorOnHistoryOrderIds(@Param("historyOrderIds")List<Integer> historyOrderIds);
|
||||||
|
|
||||||
List<Map<String, Object>> findHistoryOrderIds(@Param("historyOrderIds")List<Integer> historyOrderIds,@Param("operatorId")Long operatorId);
|
List<Map<String, Object>> findHistoryOrderIds(@Param("historyOrderIds")List<Integer> historyOrderIds,@Param("operatorId")String operatorId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,7 +167,7 @@ public class XhpcInvoice implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 充电订单运营商id
|
* 充电订单运营商id
|
||||||
*/
|
*/
|
||||||
private Long orderOperatorId;
|
private String orderOperatorId;
|
||||||
/**
|
/**
|
||||||
* 开票运营商id
|
* 开票运营商id
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -35,9 +35,11 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -590,6 +592,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
xhpcInvoice.setCreatorType(saveInvoiceInfoRequest.getCreatorType());
|
xhpcInvoice.setCreatorType(saveInvoiceInfoRequest.getCreatorType());
|
||||||
xhpcInvoice.setCreator(saveInvoiceInfoRequest.getCreator());
|
xhpcInvoice.setCreator(saveInvoiceInfoRequest.getCreator());
|
||||||
xhpcInvoice.setCreateTime(DateUtils.parseDate(saveInvoiceInfoRequest.getCreateTime()));
|
xhpcInvoice.setCreateTime(DateUtils.parseDate(saveInvoiceInfoRequest.getCreateTime()));
|
||||||
|
|
||||||
xhpcInvoice.setStatus(0);
|
xhpcInvoice.setStatus(0);
|
||||||
xhpcInvoice.setInvoiceStatus(saveInvoiceInfoRequest.getInvoiceStatus());
|
xhpcInvoice.setInvoiceStatus(saveInvoiceInfoRequest.getInvoiceStatus());
|
||||||
xhpcInvoiceMapper.insertSelectiveAndReturnId(xhpcInvoice);
|
xhpcInvoiceMapper.insertSelectiveAndReturnId(xhpcInvoice);
|
||||||
@ -666,12 +669,56 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> operatorIdList = xhpcHistoryOrderMapper.countOperatorOnHistoryOrderIds(historyOrderIds);
|
List<Map<String, Object>> operatorIdList = xhpcHistoryOrderMapper.countOperatorOnHistoryOrderIds(historyOrderIds);
|
||||||
//该变量是用来计算内部存储的历史订单金额是否与传入的一致
|
|
||||||
double totalActPrice = 0;
|
List<Map<String, Object>> list =new ArrayList<>();
|
||||||
|
String operatorNames ="";
|
||||||
|
String operatorIds ="";
|
||||||
for (int i = 0; i <operatorIdList.size() ; i++) {
|
for (int i = 0; i <operatorIdList.size() ; i++) {
|
||||||
Map<String, Object> stringObjectMap = operatorIdList.get(i);
|
Map<String, Object> stringObjectMap = operatorIdList.get(i);
|
||||||
Long operatorId = Long.valueOf(stringObjectMap.get("operatorId").toString());
|
Map<String, Object> map =new HashMap<>();
|
||||||
|
String operatorId = stringObjectMap.get("operatorId").toString();
|
||||||
|
int invoiceType = Integer.parseInt(stringObjectMap.get("invoiceType").toString());
|
||||||
|
String operatorName = stringObjectMap.get("operatorName").toString();
|
||||||
|
if(i==0){
|
||||||
|
if(invoiceType==1){
|
||||||
|
operatorNames = operatorName;
|
||||||
|
operatorIds = operatorId;
|
||||||
|
}else{
|
||||||
|
map.put("operatorId",stringObjectMap.get("operatorId"));
|
||||||
|
map.put("invoiceType",invoiceType);
|
||||||
|
map.put("operatorName",operatorName);
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(invoiceType==1){
|
||||||
|
operatorNames = operatorNames+","+operatorName;
|
||||||
|
operatorIds = operatorIds+","+operatorId;
|
||||||
|
}else{
|
||||||
|
map.put("operatorId",stringObjectMap.get("operatorId"));
|
||||||
|
map.put("invoiceType",invoiceType);
|
||||||
|
map.put("operatorName",operatorName);
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!"".equals(operatorNames)){
|
||||||
|
Map<String, Object> map =new HashMap<>();
|
||||||
|
map.put("operatorId",operatorIds);
|
||||||
|
map.put("invoiceType",1);
|
||||||
|
map.put("operatorName",operatorNames);
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//该变量是用来计算内部存储的历史订单金额是否与传入的一致
|
||||||
|
double totalActPrice = 0;
|
||||||
|
for (int i = 0; i <list.size() ; i++) {
|
||||||
|
Map<String, Object> stringObjectMap = list.get(i);
|
||||||
|
String operatorId = stringObjectMap.get("operatorId").toString();
|
||||||
|
Integer invoiceType = Integer.valueOf(stringObjectMap.get("operatorId").toString());
|
||||||
|
String operatorName = stringObjectMap.get("operatorName").toString();
|
||||||
//将该发票记录放入数据库生成发票记录,除了所包含的历史订单的总电费,总服务费
|
//将该发票记录放入数据库生成发票记录,除了所包含的历史订单的总电费,总服务费
|
||||||
XhpcInvoice xhpcInvoice = new XhpcInvoice();
|
XhpcInvoice xhpcInvoice = new XhpcInvoice();
|
||||||
xhpcInvoice.setReceiveEmail(saveInvoiceInfoRequest.getReceiveEmail());
|
xhpcInvoice.setReceiveEmail(saveInvoiceInfoRequest.getReceiveEmail());
|
||||||
@ -717,7 +764,17 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
xhpcInvoiceMapHistoryOrder.setServicePriceTotal(BigDecimal.valueOf(new BigDecimal(map.get("servicePriceTotal").toString()).doubleValue() - new BigDecimal(map.get("promotionDiscount").toString()).doubleValue()));
|
xhpcInvoiceMapHistoryOrder.setServicePriceTotal(BigDecimal.valueOf(new BigDecimal(map.get("servicePriceTotal").toString()).doubleValue() - new BigDecimal(map.get("promotionDiscount").toString()).doubleValue()));
|
||||||
xhpcInvoiceMapHistoryOrder.setPromotionDiscount(new BigDecimal(map.get("promotionDiscount").toString()));
|
xhpcInvoiceMapHistoryOrder.setPromotionDiscount(new BigDecimal(map.get("promotionDiscount").toString()));
|
||||||
xhpcInvoiceMapHistoryOrder.setHistoryActPrice(new BigDecimal(map.get("actPrice").toString()));
|
xhpcInvoiceMapHistoryOrder.setHistoryActPrice(new BigDecimal(map.get("actPrice").toString()));
|
||||||
xhpcInvoiceMapHistoryOrder.setCreateTime(cn.hutool.core.date.DateUtil.parse(map.get("createTime").toString()));
|
|
||||||
|
if(map.get("createTime").toString().length()==16){
|
||||||
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.parse(map.get("createTime").toString(), dateTimeFormatter);
|
||||||
|
xhpcInvoiceMapHistoryOrder.setCreateTime(Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
}else if(map.get("createTime").toString().length()==19){
|
||||||
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.parse(map.get("createTime").toString(), dateTimeFormatter);
|
||||||
|
xhpcInvoiceMapHistoryOrder.setCreateTime(Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()));
|
||||||
|
}
|
||||||
|
|
||||||
xhpcInvoiceMapHistoryOrder.setChargingMode(map.get("chargingMode").toString());
|
xhpcInvoiceMapHistoryOrder.setChargingMode(map.get("chargingMode").toString());
|
||||||
xhpcInvoiceMapHistoryOrder.setChargingStationId(Long.valueOf(map.get("chargingStationId").toString()));
|
xhpcInvoiceMapHistoryOrder.setChargingStationId(Long.valueOf(map.get("chargingStationId").toString()));
|
||||||
xhpcInvoiceMapHistoryOrder.setTerminalId(Long.valueOf(map.get("terminalId").toString()));
|
xhpcInvoiceMapHistoryOrder.setTerminalId(Long.valueOf(map.get("terminalId").toString()));
|
||||||
@ -731,8 +788,15 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
xhpcInvoice.setInvoiceOrderEletricTotalMoney(BigDecimal.valueOf(totalPowerPrice));
|
xhpcInvoice.setInvoiceOrderEletricTotalMoney(BigDecimal.valueOf(totalPowerPrice));
|
||||||
xhpcInvoice.setInvoiceOrderServiceTotalMoney(BigDecimal.valueOf(totalServicePrice));
|
xhpcInvoice.setInvoiceOrderServiceTotalMoney(BigDecimal.valueOf(totalServicePrice));
|
||||||
xhpcInvoice.setInvoiceMoney(BigDecimal.valueOf(totalPowerPrice).add(BigDecimal.valueOf(totalServicePrice)));
|
xhpcInvoice.setInvoiceMoney(BigDecimal.valueOf(totalPowerPrice).add(BigDecimal.valueOf(totalServicePrice)));
|
||||||
|
if(invoiceType==1){
|
||||||
xhpcInvoice.setOrderOperatorId(operatorId);
|
xhpcInvoice.setOrderOperatorId(operatorId);
|
||||||
xhpcInvoice.setInvoiceOperatorId(operatorId);
|
xhpcInvoice.setInvoiceOperatorId(1L);
|
||||||
|
xhpcInvoice.setInvoiceOperatorName(operatorName);
|
||||||
|
}else{
|
||||||
|
xhpcInvoice.setOrderOperatorId(operatorId);
|
||||||
|
xhpcInvoice.setInvoiceOperatorId(Long.valueOf(operatorId));
|
||||||
|
xhpcInvoice.setInvoiceOperatorName(operatorName);
|
||||||
|
}
|
||||||
xhpcInvoiceMapper.updateElectricAndServiceById(xhpcInvoice);
|
xhpcInvoiceMapper.updateElectricAndServiceById(xhpcInvoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,5 +1010,9 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("2024-01-02T12:11".length());
|
||||||
|
System.out.println("2024-01-02T12:11:00".length());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,7 +169,9 @@
|
|||||||
|
|
||||||
<select id="countOperatorOnHistoryOrderIds" resultType="map">
|
<select id="countOperatorOnHistoryOrderIds" resultType="map">
|
||||||
select
|
select
|
||||||
xo.operator_id operatorId
|
xo.operator_id operatorId,
|
||||||
|
xo.name as operatorName,
|
||||||
|
xo.invoice_type invoiceType
|
||||||
FROM
|
FROM
|
||||||
xhpc_history_order xho
|
xhpc_history_order xho
|
||||||
left join xhpc_charging_station xcs on xho.charging_station_id = xcs.charging_station_id
|
left join xhpc_charging_station xcs on xho.charging_station_id = xcs.charging_station_id
|
||||||
@ -216,7 +218,7 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
<if test="operatorId !=null">
|
<if test="operatorId !=null">
|
||||||
and xo.operator_id=#{operatorId}
|
and FIND_IN_SET(CAST(xo.operator_id AS CHAR),#{operatorId})
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user