Browse Source

1、优化能耗分析

dev
mh 8 months ago
parent
commit
0127b2122f
  1. 4
      user-service/src/main/java/com/mh/user/job/DealDataJob.java
  2. 2
      user-service/src/main/java/com/mh/user/mapper/DealDataMapper.java
  3. 2
      user-service/src/main/java/com/mh/user/mapper/provider/SysLogProvider.java
  4. 4
      user-service/src/main/java/com/mh/user/sqlmapper/SysLogMapper.xml
  5. 67
      user-service/src/main/java/com/mh/user/utils/ExchangeStringUtil.java

4
user-service/src/main/java/com/mh/user/job/DealDataJob.java

@ -48,7 +48,7 @@ public class DealDataJob {
String curDate = sdf1.format(date);
String name = dealDataService.customName();
if (name != null
&& (name.contains(Constant.CUSTOM_NAME_HUAXIA) || name.contains(Constant.CUSTOM_NAME_GUANGSHANG))) {
&& (name.contains(Constant.CUSTOM_NAME_HUAXIA))) {
dealDataService.proEnergy2(curDate);
} else {
dealDataService.proEnergy(curDate); //yyyy-MM-dd HH:00:00
@ -146,7 +146,7 @@ public class DealDataJob {
String curDate = sdf1.format(date);
String name = dealDataService.customName();
if (name != null
&& (name.contains(Constant.CUSTOM_NAME_HUAXIA) || name.contains(Constant.CUSTOM_NAME_GUANGSHANG))) {
&& (name.contains(Constant.CUSTOM_NAME_HUAXIA))) {
dealDataService.proEnergySum2(curDate);
} else {
dealDataService.proEnergySum(curDate);

2
user-service/src/main/java/com/mh/user/mapper/DealDataMapper.java

@ -68,7 +68,7 @@ public interface DealDataMapper {
void deleteDataHistory();
//查询学校名称
@Select("select customName from SysParam ")
@Select("select top 1 customName from SysParam ")
String customName();
//判断网关在线状态

2
user-service/src/main/java/com/mh/user/mapper/provider/SysLogProvider.java

@ -5,7 +5,7 @@ public class SysLogProvider {
public String findLogs(String userName, int page, int limit){
StringBuffer sql = new StringBuffer("");
sql.append("select * from (" +
" select *,ROW_NUMBER() over(order by id) as rn from sys_log " +
" select *,ROW_NUMBER() over(order by create_time desc) as rn from sys_log " +
" where 1=1 ");
if (userName != null && !userName.equals("")){
sql.append(" AND user_name = #{userName} ");

4
user-service/src/main/java/com/mh/user/sqlmapper/SysLogMapper.xml

@ -198,13 +198,13 @@
<select id="findPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from sys_log
from sys_log order by create_time desc
</select>
<select id="findPageByUserName" parameterType="java.lang.String" resultMap="BaseResultMap">
<bind name="pattern" value="'%' + _parameter.userName + '%'" />
select
<include refid="Base_Column_List" />
from sys_log
where user_name like #{pattern}
where user_name like #{pattern} order by create_time desc
</select>
</mapper>

67
user-service/src/main/java/com/mh/user/utils/ExchangeStringUtil.java

@ -22,19 +22,35 @@ import java.util.regex.Pattern;
*/
public class ExchangeStringUtil {
// public static void main(String args[]){
//// byte[] result = hexStrToBinaryStr("686868");
//// for (byte a :
//// result) {
//// System.out.println(a);
//// }
//// String str = "/192.168.1.252:30000";
//// String tempStr = str.replace("30000","40000");
//// String tempStr = str.substring(str.indexOf("/") + 1, str.lastIndexOf(":"));
// Double tempStr=parseHex4("FD00");
// System.out.println(tempStr);
//
// }
public static void main(String args[]){
String s = floatToHex(12555.45F);
System.out.println(s);
System.out.println(hexToLong("0000006C"));
System.out.println(longToHex(317751L));
}
/**
* 长整型转16进制
* @param value
* @return
*/
public static String longToHex(long value) {
String hexString = Long.toHexString(value);
while (hexString.length() < 8) {
hexString = "0" + hexString;
}
return hexString;
}
/**
* 16进制转长整型
* @param hexString
* @return
*/
public static long hexToLong(String hexString) {
return Long.parseLong(hexString, 16); // 将16进制字符串解析为长整型
}
//十六进制转正负数十进制
public static double parseHex4(String num) {
@ -1194,4 +1210,29 @@ public class ExchangeStringUtil {
return (flagValue);
}
/**
* 浮点转16进制
* @param value
* @return
*/
public static String floatToHex(float value) {
int intValue = Float.floatToIntBits(value) & 0xFFFFFFFF;
String hexString = Integer.toHexString(intValue);
while (hexString.length() < 8) {
hexString = "0" + hexString;
}
return hexString;
}
/**
* 16进制转浮点
* @param hexString
* @return
*/
public static float hexToFloat(String hexString) {
int intBits = Integer.parseInt(hexString, 16); // 将16进制字符串解析为整数
return Float.intBitsToFloat(intBits); // 将整数值转换为浮点数
}
}

Loading…
Cancel
Save