修复了模型开发和服务开发不能修改月份和年份的问题
This commit is contained in:
parent
8c8f3a09f9
commit
527e455e4b
Binary file not shown.
@ -5,62 +5,96 @@
|
|||||||
#include "DDSInterfaceGen.h"
|
#include "DDSInterfaceGen.h"
|
||||||
#include "CMakeListsGen.h"
|
#include "CMakeListsGen.h"
|
||||||
|
|
||||||
int XNInterfaceGen(const char *tableName, const int tableNameSize, const char *configName,
|
// 全局变量定义
|
||||||
const int configNameSize, const char *errorMsg, const int errorMsgSize)
|
std::string g_tableName;
|
||||||
|
std::string g_configName;
|
||||||
|
char *g_errorMsg;
|
||||||
|
int g_errorMsgSize;
|
||||||
|
AllInterfaceData g_interfaceData;
|
||||||
|
|
||||||
|
bool XNInterfaceGen_Step1_InitParams(const char *tableName, const int tableNameSize,
|
||||||
|
const char *configName, const int configNameSize,
|
||||||
|
const char *errorMsg, const int errorMsgSize)
|
||||||
|
{
|
||||||
|
g_tableName = std::string(tableName, tableNameSize);
|
||||||
|
g_configName = std::string(configName, configNameSize);
|
||||||
|
g_errorMsg = const_cast<char *>(errorMsg);
|
||||||
|
g_errorMsgSize = errorMsgSize;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool XNInterfaceGen_Step2_GetInterfaceData()
|
||||||
{
|
{
|
||||||
std::string errorMsgStr;
|
std::string errorMsgStr;
|
||||||
// 1. 从数据库获取接口数据
|
g_interfaceData = GetInterfaceData::getInterfaceData(g_tableName, errorMsgStr);
|
||||||
AllInterfaceData interfaceData = GetInterfaceData::getInterfaceData(tableName, errorMsgStr);
|
|
||||||
if (!errorMsgStr.empty()) {
|
if (!errorMsgStr.empty()) {
|
||||||
memcpy((void *)errorMsg, errorMsgStr.c_str(), errorMsgSize);
|
memcpy(g_errorMsg, errorMsgStr.c_str(), g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 创建构型目录
|
bool XNInterfaceGen_Step3_CreateConfigDir()
|
||||||
bool ret = GenIDL::createConfigDirectory(configName);
|
{
|
||||||
|
bool ret = GenIDL::createConfigDirectory(g_configName);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
memcpy((void *)errorMsg, "Create config directory failed", errorMsgSize);
|
memcpy(g_errorMsg, "Create config directory failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 生成IDL文件
|
bool XNInterfaceGen_Step4_GenerateIDL()
|
||||||
ret = GenIDL::generateIDL(interfaceData);
|
{
|
||||||
|
bool ret = GenIDL::generateIDL(g_interfaceData);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
memcpy((void *)errorMsg, "Generate IDL failed", errorMsgSize);
|
memcpy(g_errorMsg, "Generate IDL failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 生成FastDDS代码
|
bool XNInterfaceGen_Step5_GenerateFastDDS()
|
||||||
ret = FastDDSGen::generateFastDDSCode(GenIDL::getIDLFilePath());
|
{
|
||||||
|
bool ret = FastDDSGen::generateFastDDSCode(GenIDL::getIDLFilePath());
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
memcpy((void *)errorMsg, "Generate FastDDS code failed", errorMsgSize);
|
memcpy(g_errorMsg, "Generate FastDDS code failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 5. 生成DDS接口
|
bool XNInterfaceGen_Step6_GenerateDDSInterface()
|
||||||
|
{
|
||||||
DDSInterfaceGen ddsInterfaceGen(GenIDL::getIDLFilePath());
|
DDSInterfaceGen ddsInterfaceGen(GenIDL::getIDLFilePath());
|
||||||
ret = ddsInterfaceGen.generateDDSInterface(interfaceData);
|
bool ret = ddsInterfaceGen.generateDDSInterface(g_interfaceData);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
memcpy((void *)errorMsg, "Generate DDS interface failed", errorMsgSize);
|
memcpy(g_errorMsg, "Generate DDS interface failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 6. 生成CMakeLists.txt文件
|
bool XNInterfaceGen_Step7_GenerateCMakeLists()
|
||||||
ret = CMakeListsGen::generateCMakeLists(interfaceData, GenIDL::getIDLFilePath(), configName);
|
{
|
||||||
|
bool ret =
|
||||||
|
CMakeListsGen::generateCMakeLists(g_interfaceData, GenIDL::getIDLFilePath(), g_configName);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
memcpy((void *)errorMsg, "Generate CMakeLists.txt failed", errorMsgSize);
|
memcpy(g_errorMsg, "Generate CMakeLists.txt failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 7. 执行CMake编译和安装
|
bool XNInterfaceGen_Step8_BuildAndInstall()
|
||||||
|
{
|
||||||
std::string idlDirPath = fs::path(GenIDL::getIDLFilePath()).parent_path().string();
|
std::string idlDirPath = fs::path(GenIDL::getIDLFilePath()).parent_path().string();
|
||||||
std::string buildCmd =
|
std::string buildCmd =
|
||||||
"cd " + idlDirPath + " && mkdir -p build && cd build && cmake .. && make && make install";
|
"cd " + idlDirPath + " && mkdir -p build && cd build && cmake .. && make && make install";
|
||||||
int buildRet = system(buildCmd.c_str());
|
int buildRet = system(buildCmd.c_str());
|
||||||
if (buildRet != 0) {
|
if (buildRet != 0) {
|
||||||
memcpy((void *)errorMsg, "CMake build or install failed", errorMsgSize);
|
memcpy(g_errorMsg, "CMake build or install failed", g_errorMsgSize);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return 0;
|
|
||||||
}
|
}
|
@ -2,9 +2,26 @@
|
|||||||
#define XN_INTERFACE_GEN_SERVER_H
|
#define XN_INTERFACE_GEN_SERVER_H
|
||||||
|
|
||||||
#include "XNInterfaceGenServer_global.h"
|
#include "XNInterfaceGenServer_global.h"
|
||||||
|
#include "PublicDefine.h"
|
||||||
|
|
||||||
extern "C" XNIGS_EXPORT int XNInterfaceGen(const char *tableName, const int tableNameSize,
|
// 全局变量声明
|
||||||
const char *configName, const int configNameSize,
|
extern std::string g_tableName;
|
||||||
const char *errorMsg, const int errorMsgSize);
|
extern std::string g_configName;
|
||||||
|
extern char *g_errorMsg;
|
||||||
|
extern int g_errorMsgSize;
|
||||||
|
extern AllInterfaceData g_interfaceData;
|
||||||
|
|
||||||
|
// 步骤函数声明
|
||||||
|
extern "C" XNIGS_EXPORT bool
|
||||||
|
XNInterfaceGen_Step1_InitParams(const char *tableName, const int tableNameSize,
|
||||||
|
const char *configName, const int configNameSize,
|
||||||
|
const char *errorMsg, const int errorMsgSize);
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step2_GetInterfaceData();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step3_CreateConfigDir();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step4_GenerateIDL();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step5_GenerateFastDDS();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step6_GenerateDDSInterface();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step7_GenerateCMakeLists();
|
||||||
|
extern "C" XNIGS_EXPORT bool XNInterfaceGen_Step8_BuildAndInstall();
|
||||||
|
|
||||||
#endif // XN_INTERFACE_GEN_SERVER_H
|
#endif // XN_INTERFACE_GEN_SERVER_H
|
||||||
|
@ -1394,12 +1394,56 @@ class ModelDevelopment extends HTMLElement {
|
|||||||
const selectedYear = parseInt(calendarYear.value);
|
const selectedYear = parseInt(calendarYear.value);
|
||||||
const selectedMonth = parseInt(calendarMonth.value);
|
const selectedMonth = parseInt(calendarMonth.value);
|
||||||
|
|
||||||
// 关闭当前对话框
|
// 更新当前日期
|
||||||
closeModal();
|
|
||||||
|
|
||||||
// 更新日期参数并重新显示对话框
|
|
||||||
currentDate = new Date(selectedYear, selectedMonth, 1);
|
currentDate = new Date(selectedYear, selectedMonth, 1);
|
||||||
this.showDateTimeDialog(inputElement);
|
|
||||||
|
// 重新生成日历内容
|
||||||
|
const daysInMonth = new Date(selectedYear, selectedMonth + 1, 0).getDate();
|
||||||
|
const firstDay = new Date(selectedYear, selectedMonth, 1).getDay();
|
||||||
|
|
||||||
|
let calendarRows = '';
|
||||||
|
let dayCount = 1;
|
||||||
|
|
||||||
|
// 添加表头
|
||||||
|
calendarRows += '<tr>';
|
||||||
|
['日', '一', '二', '三', '四', '五', '六'].forEach(dayName => {
|
||||||
|
calendarRows += `<th>${dayName}</th>`;
|
||||||
|
});
|
||||||
|
calendarRows += '</tr>';
|
||||||
|
|
||||||
|
// 计算行数
|
||||||
|
const totalCells = firstDay + daysInMonth;
|
||||||
|
const rowCount = Math.ceil(totalCells / 7);
|
||||||
|
|
||||||
|
// 添加日期行
|
||||||
|
for (let i = 0; i < rowCount; i++) {
|
||||||
|
calendarRows += '<tr>';
|
||||||
|
for (let j = 0; j < 7; j++) {
|
||||||
|
if ((i === 0 && j < firstDay) || dayCount > daysInMonth) {
|
||||||
|
calendarRows += '<td></td>';
|
||||||
|
} else {
|
||||||
|
const isToday = dayCount === currentDate.getDate();
|
||||||
|
calendarRows += `<td class="calendar-day ${isToday ? 'selected' : ''}" data-day="${dayCount}">${dayCount}</td>`;
|
||||||
|
dayCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calendarRows += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新日历表格内容
|
||||||
|
const calendarTable = modal.querySelector('.calendar-table');
|
||||||
|
calendarTable.innerHTML = calendarRows;
|
||||||
|
|
||||||
|
// 重新绑定日期选择事件
|
||||||
|
const calendarDays = modal.querySelectorAll('.calendar-day');
|
||||||
|
calendarDays.forEach(cell => {
|
||||||
|
cell.addEventListener('click', (e) => {
|
||||||
|
// 移除所有选中状态
|
||||||
|
calendarDays.forEach(day => day.classList.remove('selected'));
|
||||||
|
// 添加新选中状态
|
||||||
|
e.target.classList.add('selected');
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
calendarMonth.addEventListener('change', updateCalendar);
|
calendarMonth.addEventListener('change', updateCalendar);
|
||||||
|
@ -1466,12 +1466,56 @@ class ServiceDevelopment extends HTMLElement {
|
|||||||
const selectedYear = parseInt(calendarYear.value);
|
const selectedYear = parseInt(calendarYear.value);
|
||||||
const selectedMonth = parseInt(calendarMonth.value);
|
const selectedMonth = parseInt(calendarMonth.value);
|
||||||
|
|
||||||
// 关闭当前对话框
|
// 更新当前日期
|
||||||
closeModal();
|
|
||||||
|
|
||||||
// 更新日期参数并重新显示对话框
|
|
||||||
currentDate = new Date(selectedYear, selectedMonth, 1);
|
currentDate = new Date(selectedYear, selectedMonth, 1);
|
||||||
this.showDateTimeDialog(inputElement);
|
|
||||||
|
// 重新生成日历内容
|
||||||
|
const daysInMonth = new Date(selectedYear, selectedMonth + 1, 0).getDate();
|
||||||
|
const firstDay = new Date(selectedYear, selectedMonth, 1).getDay();
|
||||||
|
|
||||||
|
let calendarRows = '';
|
||||||
|
let dayCount = 1;
|
||||||
|
|
||||||
|
// 添加表头
|
||||||
|
calendarRows += '<tr>';
|
||||||
|
['日', '一', '二', '三', '四', '五', '六'].forEach(dayName => {
|
||||||
|
calendarRows += `<th>${dayName}</th>`;
|
||||||
|
});
|
||||||
|
calendarRows += '</tr>';
|
||||||
|
|
||||||
|
// 计算行数
|
||||||
|
const totalCells = firstDay + daysInMonth;
|
||||||
|
const rowCount = Math.ceil(totalCells / 7);
|
||||||
|
|
||||||
|
// 添加日期行
|
||||||
|
for (let i = 0; i < rowCount; i++) {
|
||||||
|
calendarRows += '<tr>';
|
||||||
|
for (let j = 0; j < 7; j++) {
|
||||||
|
if ((i === 0 && j < firstDay) || dayCount > daysInMonth) {
|
||||||
|
calendarRows += '<td></td>';
|
||||||
|
} else {
|
||||||
|
const isToday = dayCount === currentDate.getDate();
|
||||||
|
calendarRows += `<td class="calendar-day ${isToday ? 'selected' : ''}" data-day="${dayCount}">${dayCount}</td>`;
|
||||||
|
dayCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calendarRows += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新日历表格内容
|
||||||
|
const calendarTable = modal.querySelector('.calendar-table');
|
||||||
|
calendarTable.innerHTML = calendarRows;
|
||||||
|
|
||||||
|
// 重新绑定日期选择事件
|
||||||
|
const calendarDays = modal.querySelectorAll('.calendar-day');
|
||||||
|
calendarDays.forEach(cell => {
|
||||||
|
cell.addEventListener('click', (e) => {
|
||||||
|
// 移除所有选中状态
|
||||||
|
calendarDays.forEach(day => day.classList.remove('selected'));
|
||||||
|
// 添加新选中状态
|
||||||
|
e.target.classList.add('selected');
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
calendarMonth.addEventListener('change', updateCalendar);
|
calendarMonth.addEventListener('change', updateCalendar);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user