1.数据完整性列表筛选条件调整
2.管理员新增装置自动生成装置名称
This commit is contained in:
@@ -798,6 +798,20 @@ public class DeviceController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "findMaxDeviceName", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String findMaxDeviceName(HttpServletRequest request, Long gdIndex) {
|
||||
String result;
|
||||
try {
|
||||
result = manaDevice.findMaxDeviceName(gdIndex);
|
||||
userLog.getLog("查询当前供电公司下面最大的设备名称", "成功", result, LogTypeEnum.SYSTEM.toString(), 0);
|
||||
} catch (Exception e) {
|
||||
result = null;
|
||||
userLog.getLog("查询当前供电公司下面最大的设备名称", "失败", result, LogTypeEnum.SYSTEM.toString(), 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "addDevice", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public HttpResult addDevice(HttpServletRequest request, HttpSession session, String devName, Long gdIndex,
|
||||
|
||||
@@ -123,4 +123,6 @@ public interface ManaDeviceService {
|
||||
*/
|
||||
int addMonitor(String monitorId);
|
||||
|
||||
String findMaxDeviceName(Long gdIndex);
|
||||
|
||||
}
|
||||
|
||||
@@ -2488,4 +2488,31 @@ public class ManaDeviceServiceImpl implements ManaDeviceService {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findMaxDeviceName(Long gdIndex) {
|
||||
String name = deviceMapper.findMaxDeviceName(gdIndex);
|
||||
return incrementString(name);
|
||||
}
|
||||
|
||||
public String incrementString(String str) {
|
||||
// 查找最后一个非数字字符的位置
|
||||
int lastIndex = str.length() - 1;
|
||||
while (lastIndex >= 0 && Character.isDigit(str.charAt(lastIndex))) {
|
||||
lastIndex--;
|
||||
}
|
||||
// 如果没有找到非数字字符,说明整个字符串都是数字
|
||||
if (lastIndex == -1) {
|
||||
// 直接将字符串转换为整数,递增,再转回字符串
|
||||
return String.valueOf(Long.parseLong(str) + 1);
|
||||
}
|
||||
// 提取出数字部分
|
||||
String numberPart = str.substring(lastIndex + 1);
|
||||
// 将数字部分转换为整数,递增,再转回字符串
|
||||
long number = Long.parseLong(numberPart) + 1;
|
||||
String incrementedNumberPart = String.format("%0" + numberPart.length() + "d", number);
|
||||
// 将递增后的数字部分拼接到原字符串的非数字部分
|
||||
return str.substring(0, lastIndex + 1) + incrementedNumberPart;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,4 +171,8 @@ FROM
|
||||
WHERE
|
||||
a.dev_index = #{devIndex}
|
||||
</select>
|
||||
|
||||
<select id="findMaxDeviceName" resultType="String">
|
||||
SELECT MAX(NAME) FROM PQ_DEVICE WHERE GD_INDEX = #{gdIndex}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -49,6 +49,20 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$("html").css("height", "100px");
|
||||
|
||||
//获取默认装置名称
|
||||
var gdIndex = $("#gdIndex").val();
|
||||
$.ajax({
|
||||
url: '/pqs9900/device/findMaxDeviceName',
|
||||
type: 'POST',
|
||||
dataType: "text",
|
||||
data: {
|
||||
gdIndex: gdIndex
|
||||
},
|
||||
success: function (data) {
|
||||
$('#devName').val(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
|
||||
Reference in New Issue
Block a user