修复了模型开发和服务开发不能修改月份和年份的问题
This commit is contained in:
parent
8c8f3a09f9
commit
527e455e4b
Binary file not shown.
@ -5,62 +5,96 @@
|
||||
#include "DDSInterfaceGen.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;
|
||||
// 1. 从数据库获取接口数据
|
||||
AllInterfaceData interfaceData = GetInterfaceData::getInterfaceData(tableName, errorMsgStr);
|
||||
g_interfaceData = GetInterfaceData::getInterfaceData(g_tableName, errorMsgStr);
|
||||
if (!errorMsgStr.empty()) {
|
||||
memcpy((void *)errorMsg, errorMsgStr.c_str(), errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, errorMsgStr.c_str(), g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. 创建构型目录
|
||||
bool ret = GenIDL::createConfigDirectory(configName);
|
||||
bool XNInterfaceGen_Step3_CreateConfigDir()
|
||||
{
|
||||
bool ret = GenIDL::createConfigDirectory(g_configName);
|
||||
if (!ret) {
|
||||
memcpy((void *)errorMsg, "Create config directory failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "Create config directory failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. 生成IDL文件
|
||||
ret = GenIDL::generateIDL(interfaceData);
|
||||
bool XNInterfaceGen_Step4_GenerateIDL()
|
||||
{
|
||||
bool ret = GenIDL::generateIDL(g_interfaceData);
|
||||
if (!ret) {
|
||||
memcpy((void *)errorMsg, "Generate IDL failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "Generate IDL failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4. 生成FastDDS代码
|
||||
ret = FastDDSGen::generateFastDDSCode(GenIDL::getIDLFilePath());
|
||||
bool XNInterfaceGen_Step5_GenerateFastDDS()
|
||||
{
|
||||
bool ret = FastDDSGen::generateFastDDSCode(GenIDL::getIDLFilePath());
|
||||
if (!ret) {
|
||||
memcpy((void *)errorMsg, "Generate FastDDS code failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "Generate FastDDS code failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 5. 生成DDS接口
|
||||
bool XNInterfaceGen_Step6_GenerateDDSInterface()
|
||||
{
|
||||
DDSInterfaceGen ddsInterfaceGen(GenIDL::getIDLFilePath());
|
||||
ret = ddsInterfaceGen.generateDDSInterface(interfaceData);
|
||||
bool ret = ddsInterfaceGen.generateDDSInterface(g_interfaceData);
|
||||
if (!ret) {
|
||||
memcpy((void *)errorMsg, "Generate DDS interface failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "Generate DDS interface failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 6. 生成CMakeLists.txt文件
|
||||
ret = CMakeListsGen::generateCMakeLists(interfaceData, GenIDL::getIDLFilePath(), configName);
|
||||
bool XNInterfaceGen_Step7_GenerateCMakeLists()
|
||||
{
|
||||
bool ret =
|
||||
CMakeListsGen::generateCMakeLists(g_interfaceData, GenIDL::getIDLFilePath(), g_configName);
|
||||
if (!ret) {
|
||||
memcpy((void *)errorMsg, "Generate CMakeLists.txt failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "Generate CMakeLists.txt failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 7. 执行CMake编译和安装
|
||||
bool XNInterfaceGen_Step8_BuildAndInstall()
|
||||
{
|
||||
std::string idlDirPath = fs::path(GenIDL::getIDLFilePath()).parent_path().string();
|
||||
std::string buildCmd =
|
||||
"cd " + idlDirPath + " && mkdir -p build && cd build && cmake .. && make && make install";
|
||||
int buildRet = system(buildCmd.c_str());
|
||||
if (buildRet != 0) {
|
||||
memcpy((void *)errorMsg, "CMake build or install failed", errorMsgSize);
|
||||
return -1;
|
||||
memcpy(g_errorMsg, "CMake build or install failed", g_errorMsgSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
@ -2,9 +2,26 @@
|
||||
#define XN_INTERFACE_GEN_SERVER_H
|
||||
|
||||
#include "XNInterfaceGenServer_global.h"
|
||||
#include "PublicDefine.h"
|
||||
|
||||
extern "C" XNIGS_EXPORT int XNInterfaceGen(const char *tableName, const int tableNameSize,
|
||||
// 全局变量声明
|
||||
extern std::string g_tableName;
|
||||
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
|
||||
|
@ -1394,12 +1394,56 @@ class ModelDevelopment extends HTMLElement {
|
||||
const selectedYear = parseInt(calendarYear.value);
|
||||
const selectedMonth = parseInt(calendarMonth.value);
|
||||
|
||||
// 关闭当前对话框
|
||||
closeModal();
|
||||
|
||||
// 更新日期参数并重新显示对话框
|
||||
// 更新当前日期
|
||||
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);
|
||||
|
@ -1466,12 +1466,56 @@ class ServiceDevelopment extends HTMLElement {
|
||||
const selectedYear = parseInt(calendarYear.value);
|
||||
const selectedMonth = parseInt(calendarMonth.value);
|
||||
|
||||
// 关闭当前对话框
|
||||
closeModal();
|
||||
|
||||
// 更新日期参数并重新显示对话框
|
||||
// 更新当前日期
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user