diff --git a/api/app/lib/models/workorder.js b/api/app/lib/models/workorder.js
new file mode 100644
index 0000000..0881e6e
--- /dev/null
+++ b/api/app/lib/models/workorder.js
@@ -0,0 +1,103 @@
+/* eslint-disable*/
+
+'use strict';
+
+module.exports = dc => {
+ const DataTypes = dc.ORM;
+ const sequelize = dc.orm;
+ const Workorder = sequelize.define("workorder", {
+ id: {
+ type: DataTypes.INTEGER,
+ allowNull: false,
+ defaultValue: null,
+ comment: null,
+ primaryKey: true,
+ field: "id",
+ autoIncrement: true,
+ unique: "workorder_id_uindex"
+ },
+ storyId: {
+ type: DataTypes.INTEGER,
+ allowNull: false,
+ defaultValue: null,
+ comment: "项企工作流的 history_id 实例id",
+ primaryKey: false,
+ field: "story_id",
+ autoIncrement: false,
+ unique: "workorder_story_id_uindex"
+ },
+ pomsProjectId: {
+ type: DataTypes.INTEGER,
+ allowNull: true,
+ defaultValue: null,
+ comment: "运维的项目的id",
+ primaryKey: false,
+ field: "poms_project_id",
+ autoIncrement: false,
+ references: {
+ key: "id",
+ model: "projectCorrelation"
+ }
+ },
+ expectTime: {
+ type: DataTypes.DATE,
+ allowNull: true,
+ defaultValue: null,
+ comment: "期望解决时间",
+ primaryKey: false,
+ field: "expect_time",
+ autoIncrement: false
+ },
+ createTime: {
+ type: DataTypes.DATE,
+ allowNull: true,
+ defaultValue: null,
+ comment: "创建时间",
+ primaryKey: false,
+ field: "create_time",
+ autoIncrement: false
+ },
+ completeTime: {
+ type: DataTypes.DATE,
+ allowNull: true,
+ defaultValue: null,
+ comment: "解决时间",
+ primaryKey: false,
+ field: "complete_time",
+ autoIncrement: false
+ },
+ state: {
+ type: DataTypes.STRING,
+ allowNull: true,
+ defaultValue: null,
+ comment: "状态",
+ primaryKey: false,
+ field: "state",
+ autoIncrement: false
+ },
+ problemType: {
+ type: DataTypes.STRING,
+ allowNull: true,
+ defaultValue: null,
+ comment: "问题类型",
+ primaryKey: false,
+ field: "problem_type",
+ autoIncrement: false
+ },
+ solution: {
+ type: DataTypes.STRING,
+ allowNull: true,
+ defaultValue: null,
+ comment: "解决方案",
+ primaryKey: false,
+ field: "solution",
+ autoIncrement: false
+ }
+ }, {
+ tableName: "workorder",
+ comment: "",
+ indexes: []
+ });
+ dc.models.Workorder = Workorder;
+ return Workorder;
+};
\ No newline at end of file
diff --git a/api/app/lib/schedule/workorder_statistics.js b/api/app/lib/schedule/workorder_statistics.js
index 50e27fd..34a6141 100644
--- a/api/app/lib/schedule/workorder_statistics.js
+++ b/api/app/lib/schedule/workorder_statistics.js
@@ -6,29 +6,33 @@ let isDev = false
module.exports = function (app, opts) {
const workorderStatistics = app.fs.scheduleInit(
{
- interval: '24 */1 * * * *',
+ interval: '24 0 */1 * * *', // 与 sql 相关 谨慎改动
immediate: isDev,
proRun: !isDev,
disabled: true
},
+
async () => {
try {
const { models, ORM: sequelize } = app.fs.dc
- const { apMergeDeVeAnxinProjectId = '' } = opts
const { clickHouse } = app.fs
const { database: camWorkflow } = clickHouse.camWorkflow.opts.config
const { parseProcessData } = app.fs.utils
- const attendanceRes = await clickHouse.pepEmis.query(
+ const existWorkorderCount = await models.Workorder.count()
+
+ const formRes = await clickHouse.pepEmis.query(
`
SELECT
story.id AS historyId,
story.apply_user AS pepUserId,
story.form_data AS formData,
story.submit_form_data AS submitFormData,
+ story.create_at AS createAt,
fform.form_schema AS formSchema,
fprocess.name AS processName,
procin.state_ AS state,
+ procin.end_time_ AS endTime,
fform.id AS formId,
fversion.id AS versionId,
fgroup.name AS groupName
@@ -44,13 +48,65 @@ module.exports = function (app, opts) {
ON fgroup.id = fprocess.group_id
AND fgroup.name = '运维中台表单'
INNER JOIN ${camWorkflow}.act_hi_procinst AS procin
- ON procin.id_ = story.procinst_id
- ${existOvertimeCount || existVacateCount ?
- `WHERE story.create_at > '2023-03-16 00:00:00'`
- : ''}
+ ON procin.id_ = story.procinst_id
+ ${existWorkorderCount ?
+ // 25小时之内完成的 或 3个月内未完成的
+ `
+ WHERE
+ (
+ procin.end_time_ IS NOT NULL
+ AND
+ procin.end_time_ > '${moment().subtract(25, 'hours').format('YYYY-MM-DD HH:mm:ss')}'
+ )
+ OR
+ (
+ procin.end_time_ IS NULL
+ AND
+ story.create_at > '${moment().subtract(3, 'months').format('YYYY-MM-DD HH:mm:ss')}'
+ )
+ `
+ :
+ ''
+ }
`
+
).toPromise()
+ for (let f of formRes) {
+ const parseData = parseProcessData({
+ formSchema: JSON.parse(f.formSchema),
+ formData: JSON.parse(f.formData)
+ })
+ const existRes = await models.Workorder.findOne({
+ where: {
+ storyId: f.historyId,
+ }
+ })
+ if (existRes) {
+ await models.Workorder.update({
+ completeTime: f.endTime || null,
+ state: f.state,
+ problemType: parseData.problemType.value,
+ solution: parseData.solution.value
+ }, {
+ where: {
+ storyId: f.historyId,
+ }
+ })
+ } else {
+ const newRes = await models.Workorder.create({
+ storyId: f.historyId,
+ pomsProjectId: parseData.pomsProjectId.value || null,
+ expectTime: parseData.expectTime.value || null,
+ createTime: f.createAt || null,
+ completeTime: f.endTime || null,
+ state: f.state,
+ problemType: parseData.problemType.value || null,
+ solution: parseData.solution.value || null
+ })
+ }
+ }
+
} catch (error) {
console.error(error);
}
diff --git a/api/app/lib/utils/parseProcessData.js b/api/app/lib/utils/parseProcessData.js
index 22a2f99..f4a958b 100644
--- a/api/app/lib/utils/parseProcessData.js
+++ b/api/app/lib/utils/parseProcessData.js
@@ -93,6 +93,12 @@ module.exports = function (app, opts) {
},
expectTime: {
keyWord: '期望完成时间'
+ },
+ problemType: {
+ keyWord: '问题类型',
+ },
+ solution: {
+ keyWord: '解决方案'
}
}) => {
let needData = JSON.parse(JSON.stringify(pomsNeedData))
diff --git a/api/config.js b/api/config.js
index 5640487..d00c5ce 100644
--- a/api/config.js
+++ b/api/config.js
@@ -252,10 +252,10 @@ const product = {
name: 'iot',
db: CLICKHOUST_IOT
},
- // {
- // name: 'camWorkflow',
- // db: CLICKHOUST_CAM_WORKFLOW
- // },
+ {
+ name: 'camWorkflow',
+ db: CLICKHOUST_CAM_WORKFLOW
+ },
]
}
}
diff --git a/api/sequelize-automate.config.js b/api/sequelize-automate.config.js
index 0b063a4..8012e75 100644
--- a/api/sequelize-automate.config.js
+++ b/api/sequelize-automate.config.js
@@ -6,6 +6,13 @@ module.exports = {
password: '123',
dialect: 'postgres',
host: '10.8.30.32',
+
+ // database: 'POMS',
+ // username: 'FashionAdmin',
+ // password: '123456',
+ // dialect: 'postgres',
+ // host: '10.8.30.156',
+
port: 5432,
define: {
underscored: false,
@@ -26,7 +33,7 @@ module.exports = {
dir: './app/lib/models', // 指定输出 models 文件的目录
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
- tables: ['alarm_push_config'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
+ tables: ['workorder'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
ignorePrefix: [], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面
diff --git a/script/0.28/schema/1.create_workorder.sql b/script/0.28/schema/1.create_workorder.sql
new file mode 100644
index 0000000..cc19610
--- /dev/null
+++ b/script/0.28/schema/1.create_workorder.sql
@@ -0,0 +1,41 @@
+create table if not exists workorder
+(
+ id serial not null
+ constraint workorder_pk
+ primary key,
+ story_id integer not null,
+ poms_project_id integer
+ constraint workorder_project_correlation_id_fk
+ references project_correlation,
+ expect_time timestamp with time zone,
+ create_time timestamp with time zone,
+ complete_time timestamp with time zone,
+ state varchar(64),
+ problem_type varchar(128),
+ solution varchar(128)
+);
+
+comment on table workorder is '工单信息 定时任务采集自项企工作流';
+
+comment on column workorder.story_id is '项企工作流的 history_id 实例id';
+
+comment on column workorder.poms_project_id is '运维的项目的id';
+
+comment on column workorder.expect_time is '期望解决时间';
+
+comment on column workorder.create_time is '创建时间';
+
+comment on column workorder.complete_time is '解决时间';
+
+comment on column workorder.state is '状态';
+
+comment on column workorder.problem_type is '问题类型';
+
+comment on column workorder.solution is '解决方案';
+
+create unique index if not exists workorder_id_uindex
+ on workorder (id);
+
+create unique index if not exists workorder_story_id_uindex
+ on workorder (story_id);
+
diff --git a/web/client/src/sections/problem/components/tableData.jsx b/web/client/src/sections/problem/components/tableData.jsx
index eacbfd6..c07b746 100644
--- a/web/client/src/sections/problem/components/tableData.jsx
+++ b/web/client/src/sections/problem/components/tableData.jsx
@@ -17,7 +17,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
const [checkAll, setCheckAll] = useState(true) //查询
const api = useRef();
const search = useRef({
- state: '', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', statusId: '',
+ state: 'new', keywordTarget: '', keyword: '', kindId: '', groupUnitId: '', statusId: '',
errType: '', confirmState: '', onlineState: '', sustainTimeStart: '', sustainTimeEnd: ''
})
const kindName = useRef()
@@ -285,6 +285,7 @@ const TableData = ({ route, dispatch, actions, collectData, setSetup, exhibition
field={v.field}
key={v.field}
maxLength="10"
+ initValue={v.field == 'state' ? 'new' : undefined}
style={{ width: 116, marginRight: 16, color: "#F9F9F9", }}
placeholder="全部"
filter
diff --git a/web/client/src/sections/problem/containers/dataAlarm.jsx b/web/client/src/sections/problem/containers/dataAlarm.jsx
index dbf8214..fbbe8f2 100644
--- a/web/client/src/sections/problem/containers/dataAlarm.jsx
+++ b/web/client/src/sections/problem/containers/dataAlarm.jsx
@@ -318,15 +318,16 @@ const DataAlarm = (props) => {
:
}
- {route && ['dataLnterrupt', 'dataAbnormal', 'strategyHit', 'deviceAbnormal'].includes(route) ? <>
-
- {route == 'deviceAbnormal' ? "" : }
- >
+ {route && ['dataLnterrupt', 'dataAbnormal', 'strategyHit', 'deviceAbnormal'].includes(route) ?
+ <>
+ {/* */}
+ {route == 'deviceAbnormal' ? "" : }
+ >
: route == 'videoAbnormal' ? <>
-
+ {/* */}