Browse Source

pepProjectId 可空

dev
巴林闲侠 2 years ago
parent
commit
073e0c0d50
  1. 3
      api/app/lib/controllers/project/bind.js
  2. 30
      api/app/lib/controllers/project/index.js
  3. 2
      api/app/lib/models/project_correlation.js
  4. 2
      api/app/lib/routes/alarm/index.js
  5. 2
      script/0.0.3/2.alter_table_project_correlation.sql

3
api/app/lib/controllers/project/bind.js

@ -98,6 +98,7 @@ async function bindAnxin2pep (ctx) {
return curUrl == curForUrlArr.join('://')
})
if (existSameApp) {
// 有重复的将已有信息解除锁定并更新
updateAppData.push({
id: existSameApp.id,
name: a.name,
@ -107,6 +108,7 @@ async function bindAnxin2pep (ctx) {
})
existSameApp.addAgain = true
} else {
// 没有就创建
createAppData.push({
name: a.name,
url: a.url,
@ -114,6 +116,7 @@ async function bindAnxin2pep (ctx) {
lock: false,
})
}
// 筛选剩余的已有信息并将之锁定
lockAppData = existApp.filter(esa => !esa.addAgain).map(esa => {
return {
id: esa.id,

30
api/app/lib/controllers/project/index.js

@ -61,9 +61,35 @@ async function pomsProject (ctx) {
}
}
const pepProjectRes = pepProjectIds.size ?
await clickHouse.projectManage.query(`SELECT id, project_name FROM t_pim_project WHERE id IN (${[...pepProjectIds].join(',')})`).toPromise() :
await clickHouse.projectManage.query(
`
SELECT
t_pim_project.id AS id,
t_pim_project.project_name AS project_name,
t_pim_project_construction.construction_status_id AS construction_status_id
FROM t_pim_project
LEFT JOIN t_pim_project_construction
ON t_pim_project.id = t_pim_project_construction.project_id
WHERE id IN (${[...pepProjectIds].join(',')})
`
// `
// SELECT
// t_pim_project.id AS id,
// t_pim_project.project_name AS project_name,
// t_pim_project_construction.construction_status_id AS construction_status_id,
// t_project_state.construction_status AS construction_status
// FROM t_pim_project
// LEFT JOIN t_pim_project_construction
// ON t_pim_project.id = t_pim_project_construction.project_id
// LEFT JOIN t_project_state
// ON t_pim_project_construction.construction_status_id = t_project_state.id
// WHERE id IN (${[...pepProjectIds].join(',')})
// `
).toPromise() :
[]
const anxinProjectRes = anxinProjectIds.size ?
await clickHouse.anxinyun.query(`SELECT id,"name" FROM t_project WHERE id IN (${[...anxinProjectIds].join(',')})`).toPromise() :
[]
@ -72,6 +98,8 @@ async function pomsProject (ctx) {
for (let p of proRes.rows) {
const corPro = pepProjectRes.find(pp => pp.id == p.pepProjectId)
p.dataValues.pepProjectName = corPro.project_name
p.dataValues.constructionStatusId = corPro.construction_status_id
p.dataValues.constructionStatus = 'xxx'//'corPro.construction_status'
let nextAnxinProject = anxinProjectRes.filter(ap => p.anxinProjectId.includes(ap.id))
p.dataValues.anxinProject = nextAnxinProject
delete p.dataValues.anxinProjectId

2
api/app/lib/models/project_correlation.js

@ -53,7 +53,7 @@ module.exports = dc => {
},
pepProjectId: {
type: DataTypes.INTEGER,
allowNull: false,
allowNull: true,
defaultValue: null,
comment: null,
primaryKey: false,

2
api/app/lib/routes/alarm/index.js

@ -23,4 +23,6 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['POST/alarm/application/api_confirm'] = { content: '确认应用接口/元素错误信息', visible: true };
router.post('/alarm/application/api_confirm', application.confirmApiError);
//
};

2
script/0.0.3/2.alter_table_project_correlation.sql

@ -5,3 +5,5 @@ alter table project_correlation
alter table project_correlation
add del bool default false;
alter table project_correlation alter column pep_project_id drop not null;
Loading…
Cancel
Save