Преглед изворни кода

bug-fix:
1. 修改了一部分bug

eyes4 пре 5 месеци
родитељ
комит
f4e2e1255c

+ 45 - 13
pmr-biz-manager/bpmn/立项流程.bpmn

@@ -206,7 +206,7 @@
       <bpmn2:signalEventDefinition id="SignalEventDefinition_0y27jk5" signalRef="Signal_0828f9d" />
     </bpmn2:intermediateThrowEvent>
     <bpmn2:sequenceFlow id="Flow_1t45qnv" sourceRef="task_modify" targetRef="task_request" />
-    <bpmn2:sequenceFlow id="Flow_0nzbvpg" sourceRef="Event_catch_withdraw" targetRef="task_modify">
+    <bpmn2:sequenceFlow id="Flow_0nzbvpg" sourceRef="Event_catch_withdraw" targetRef="Activity_1ga5o6o">
       <bpmn2:extensionElements>
         <camunda:properties>
           <camunda:property name="prj_phase" value="new" />
@@ -224,9 +224,9 @@
     </bpmn2:sequenceFlow>
     <bpmn2:manualTask id="task_modify" name="修改项目信息">
       <bpmn2:extensionElements />
-      <bpmn2:incoming>Flow_0nzbvpg</bpmn2:incoming>
       <bpmn2:incoming>Flow_01n3edp</bpmn2:incoming>
       <bpmn2:incoming>Flow_0sb2avy</bpmn2:incoming>
+      <bpmn2:incoming>Flow_0ipuk5f</bpmn2:incoming>
       <bpmn2:outgoing>Flow_1t45qnv</bpmn2:outgoing>
     </bpmn2:manualTask>
     <bpmn2:endEvent id="Event_end">
@@ -293,8 +293,12 @@ this.environment.services.get_handlers('project_checker').then((handlers) =&gt;
       <bpmn2:outgoing>Flow_0sb2avy</bpmn2:outgoing>
       <bpmn2:script>try{
 let files = this.environment.output.task_request.files;
+if (files) {
+      this.environment.services.place_on_files(files, "立项驳回").then(()=&gt; next());  
+} else {
+        next();
+}
 
-this.environment.services.place_on_files(files, "立项驳回").then(()=&gt; next());
 } catch(e){
 this.environment.Logger('work').error(e); 
 next();      
@@ -306,10 +310,30 @@ next();
       <bpmn2:outgoing>Flow_0if8for</bpmn2:outgoing>
       <bpmn2:script>try{
 let files = this.environment.output.task_request.files;
+if (files) {
+       this.environment.services.place_on_files(files, "立项通过", "project_set_up").then(()=&gt; next()); 
+} else {
+        next();
+}
 
-this.environment.services.place_on_files(files, "立项通过", "project_set_up").then(()=&gt; next());
 }catch(e){
 next();
+}</bpmn2:script>
+    </bpmn2:scriptTask>
+    <bpmn2:sequenceFlow id="Flow_0ipuk5f" sourceRef="Activity_1ga5o6o" targetRef="task_modify" />
+    <bpmn2:scriptTask id="Activity_1ga5o6o" name="归档撤回的立项文件" scriptFormat="JavaScript">
+      <bpmn2:incoming>Flow_0nzbvpg</bpmn2:incoming>
+      <bpmn2:outgoing>Flow_0ipuk5f</bpmn2:outgoing>
+      <bpmn2:script>try{
+let files = this.environment.output.task_request.files;
+if (files) {
+    this.environment.services.place_on_files(files, "主动撤回").then(()=&gt; next());
+} else {
+        next();
+}
+} catch(e){
+this.environment.Logger('work').error(e); 
+next();      
 }</bpmn2:script>
     </bpmn2:scriptTask>
   </bpmn2:process>
@@ -337,12 +361,6 @@ next();
         <dc:Bounds x="870" y="80" width="100" height="80" />
         <bpmndi:BPMNLabel />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape id="Event_0mceau4_di" bpmnElement="Event_throw_withdraw">
-        <dc:Bounds x="1032" y="102" width="36" height="36" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="1028" y="78" width="44" height="14" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_0tntlum_di" bpmnElement="event_throw_approved">
         <dc:Bounds x="1242" y="302" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -384,6 +402,16 @@ next();
       <bpmndi:BPMNShape id="Activity_04s4p12_di" bpmnElement="Activity_10dmh6u">
         <dc:Bounds x="1310" y="280" width="100" height="80" />
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Event_0mceau4_di" bpmnElement="Event_throw_withdraw">
+        <dc:Bounds x="1112" y="102" width="36" height="36" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1108" y="78" width="44" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="Activity_1k1mf96_di" bpmnElement="Activity_1ga5o6o">
+        <dc:Bounds x="770" y="400" width="100" height="80" />
+        <bpmndi:BPMNLabel />
+      </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="Event_06bs6js_di" bpmnElement="event_catch_approved">
         <dc:Bounds x="912" y="142" width="36" height="36" />
         <bpmndi:BPMNLabel>
@@ -424,7 +452,7 @@ next();
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_0tj9nd6_di" bpmnElement="Flow_0tj9nd6">
         <di:waypoint x="970" y="120" />
-        <di:waypoint x="1032" y="120" />
+        <di:waypoint x="1112" y="120" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_02taytj_di" bpmnElement="Flow_02taytj">
         <di:waypoint x="1278" y="320" />
@@ -445,7 +473,7 @@ next();
       <bpmndi:BPMNEdge id="Flow_0nzbvpg_di" bpmnElement="Flow_0nzbvpg">
         <di:waypoint x="938" y="378" />
         <di:waypoint x="938" y="440" />
-        <di:waypoint x="590" y="440" />
+        <di:waypoint x="870" y="440" />
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="Flow_06cxzjx_di" bpmnElement="Flow_06cxzjx">
         <di:waypoint x="1140" y="428" />
@@ -497,6 +525,10 @@ next();
         <di:waypoint x="1410" y="320" />
         <di:waypoint x="1442" y="320" />
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="Flow_0ipuk5f_di" bpmnElement="Flow_0ipuk5f">
+        <di:waypoint x="770" y="440" />
+        <di:waypoint x="590" y="440" />
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
-</bpmn2:definitions>
+</bpmn2:definitions>

+ 0 - 8
pmr-biz-manager/src/app.ts

@@ -318,12 +318,4 @@ new ServiceApp().start(new MyRouter('@src/routes', guards), Models).then(async (
         });
     });
 
-
-    schedule.scheduleJob('0 * * * *', async function () {
-        FlowEngine.case_engine_map.forEach((value, key) => {
-            console.log(key);
-            // console.log(value);
-        });
-    });
-
 });

+ 1 - 1
pmr-biz-manager/src/routes/api/prj/contract/get_list.ts

@@ -96,7 +96,7 @@ function get_list(json: IRequest, params: IMethodParams, cached_data: ICachedDat
                 replacements.customer_name = `%${data.customer_name}%`;
             }
             if (data.handler_id !== undefined) {
-                condition += ` and customer.handler_id = :handler_id `;
+                condition += ` and customer.id = :handler_id `;
                 replacements.handler_id = data.handler_id;
             }
 

+ 2 - 2
pmr-biz-manager/src/routes/api/prj/doc/archive.ts

@@ -11,7 +11,7 @@ interface IData {
     /**
      * 是否归档
      */
-    archived: boolean;
+    archive: boolean;
 }
 
 
@@ -26,7 +26,7 @@ function archive(json: IRequest, params: IMethodParams, cached_data: ICachedData
             if (!await is_project_document_archivable(cached_data.user_id, file.prj_id)) {
                 return reject(Resp.gen_err(Resp.Forbidden, '您没有权限对此项目的文档进行归档,请确认您是项目负责人或特权人员。'));
             }
-            await PrjFile.update({archived: data.archived}, {where: {id: data.id}, returning: false});
+            await PrjFile.update({archived: data.archive}, {where: {id: data.id}, returning: false});
             resolve({});
         } catch (e) {
             reject(Resp.throw_err(e));

+ 2 - 1
pmr-biz-manager/src/routes/api/prj/info/modify.ts

@@ -164,6 +164,7 @@ function modify(content: IRequest, params: IMethodParams, cached_data: ICachedDa
                         transaction: t,
                         returning: true
                     });
+
                 await BpmnWork.update({assigned_to: data.leader_id},
                     {
                         where: {prj_id: prj.id, task_id: {[Op.is]: null}, status: {[Op.lt]: WorkItemStatus.completed}},
@@ -262,6 +263,7 @@ function modify(content: IRequest, params: IMethodParams, cached_data: ICachedDa
                     transaction: t,
                     replacements: {prj_id: data.id}
                 });
+
                 if (!record || record.length === 0) {
                     throw Resp.gen_err(Resp.ResourceNotFound, '项目已被其他用户删除。');
                 }
@@ -325,7 +327,6 @@ function modify(content: IRequest, params: IMethodParams, cached_data: ICachedDa
                 }
             }, cached_data, t);
 
-
             await t.commit();
             resolve(result);
         } catch (e) {

+ 1 - 1
pmr-biz-manager/src/routes/api/prj/outcome/detail.ts

@@ -106,7 +106,7 @@ function detail(json: IRequest, params: IMethodParams, cached_data: ICachedData)
                     outcome.status, 
                     task.handler_id, handler.name as handler_name, 
                     outcome.creator_id, creator.name as creator_name,
-                    TO_CHAR(outcome.plan_time, 'yyyy-MM-dd HH24') as plan_time,
+                    TO_CHAR(outcome.plan_time, 'yyyy-MM-dd') as plan_time,
                     TO_CHAR(outcome.updated_at, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as updated_at,
                     TO_CHAR(outcome.created_at, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as created_at,
                     TO_CHAR(outcome.completed_at, 'yyyy-MM-dd HH24' || ':' || 'MI' || ':' || 'ss') as completed_at,

+ 4 - 0
pmr-biz-manager/src/routes/api/prj/outcome/remove.ts

@@ -130,6 +130,10 @@ function statusGuard(json: IRequest, cached_data: ICachedData): Promise<void> {
             return reject(Resp.gen_err(Resp.InvalidFlow, '当前任务阶段不允许删除交付物。'));
         }
 
+        if (!data.draft && task.status >= TaskStatus.doing) {
+            return reject(Resp.gen_err(Resp.InvalidFlow, '当前任务阶段不允许删除交付物。'));
+        }
+
 
         resolve();
     });

+ 1 - 0
pmr-biz-manager/src/routes/api/prj/plan/modify_task.ts

@@ -17,6 +17,7 @@ import {
     if_project_task_manageable_in_current_phase,
     is_project_task_modifiable
 } from "@src/utils/prj_premission_helper";
+import {PrjTaskOutcomeDraft} from "@core-models/PrjTaskOutcomeDraft";
 
 interface IData {
     /**

+ 5 - 1
pmr-biz-manager/src/routes/api/prj/plan/remove_task.ts

@@ -62,6 +62,9 @@ function statusGuard(json: IRequest, cached_data: ICachedData): Promise<void> {
         let result = await if_project_task_manageable_in_current_phase(data.draft, prj_info.id, prj_info.phase_id, '删除任务');
         if (!result.manageable)
             return reject(result.error);
+        if (data.draft === false && (prj_info.phase_id === 'doing' || prj_info.phase_id === 'reject_plan_alt')) {
+            return reject(Resp.gen_err(Resp.InvalidFlow, '不允许直接删除计划,请在计划草稿中删除后提交审核。'));
+        }
         // let phase = await PrjPhaseDefine.findOne({where: {id: prj_info.phase_id}, raw: true});
         // if (!phase) return reject(Resp.gen_err(Resp.ResourceNotFound, '项目状态信息出错,id: ' + prj_info.id));
         // if (phase.order_index < 20) return reject(Resp.gen_err(Resp.InvalidFlow, '需要先对项目进行立项,立项后才可制订计划。'));
@@ -102,10 +105,11 @@ async function remove(json: IRequest, params: IMethodParams, cached_data: ICache
                 await model.destroy({where: {id: data.task_id}, transaction: t});
             } else {
                 await PrjTaskOutcomeDraft.update({change_marker: ChangeMarker.deleted}, {
-                    where: {id: data.task_id},
+                    where: {task_id: data.task_id},
                     transaction: t,
                     returning: false
                 });
+                await PrjPlanTaskDraft.update({change_marker: ChangeMarker.deleted}, {where: {id: data.task_id}, transaction: t});
             }
 
             /// 如果计划任务是草稿,且还没有生成计划变更任务,则生成任务

+ 29 - 6
pmr-biz-manager/src/routes/api/prj/week_report/modify.ts

@@ -4,6 +4,8 @@ import {WhereOptions} from "sequelize";
 import {Resp} from "@util/Resp";
 import {PrjWeekReport} from "@core-models/PrjWeekReport";
 import dayjs from "dayjs";
+import {PrjFile} from "@core-models/PrjFile";
+import {Logger} from "@util/Logger";
 
 
 interface IData {
@@ -38,7 +40,7 @@ function statusGuard(json: IRequest, cached_data: ICachedData): Promise<void> {
         let report = await PrjWeekReport.findOne({where: {id: data.id}, raw: true});
         if (!report) return reject(Resp.gen_err(Resp.ResourceNotFound));
         if (report.reporter_id !== user) return reject(Resp.gen_err(Resp.Forbidden, '只允许修改自己的周报。'));
-        if (report.year !== dayjs().year() || report.month !== dayjs().month() || report.week !== dayjs().week()){
+        if (report.year !== dayjs().year() || report.week !== dayjs().week()){
             return reject(Resp.gen_err(Resp.InvalidFlow, '只允许修改本周的周报。'));
         }
         if (report.status > 0 ) return reject(Resp.gen_err(Resp.InvalidFlow, '周报已提交,不允许修改,在未审阅前可撤回后再修改。'));
@@ -59,11 +61,32 @@ async function before_respond(content: IRequest, params: IMethodParams, cached_d
         "end_to": "YYYY-MM-DD"
     })));
 
-    // let data = <IData>content.data;
-    // if (!data.attachments) return result;
-    // for (let attachment of data.attachments) {
-    //     await PrjFile.update({dependent_id: data.id}, {where: {id: attachment}})
-    // }
+    let t = await PrjFile.sequelize!.transaction();
+    let data = <IData>content.data;
+    try {
+        await PrjFile.update({dependent_id: null}, {
+            where: {
+                category_id: 'week_report',
+                dependent_id: data.id
+            },
+            returning: false,
+            transaction: t
+        });
+        if (data.attachments)  {
+            for (let attachment of data.attachments) {
+                await PrjFile.update({dependent_id: data.id}, {
+                    where: {id: attachment},
+                    returning: false,
+                    transaction: t
+                });
+            }
+        }
+        await t.commit()
+    } catch (e) {
+        Logger.error(e);
+        await t.rollback();
+    }
+
     return result;
 }
 

+ 1 - 0
pmr-biz-manager/src/routes/api/prj/work/submit.ts

@@ -39,6 +39,7 @@ function submit(json: IRequest, params: IMethodParams, cached_data: ICachedData)
                             let item = work.form.schema.properties[key];
                             if (item.type === 'upload') {
                                 let files = data.form_data[key];
+                                if (!files) continue;
                                 for (let file of files) {
                                     // await PrjFile.update({dependent_id: work.id}, {where: {associate_work_id: work.id}});
                                     await PrjFile.update({dependent_id: work.id}, {where: {id: file.id}});

+ 1 - 0
pmr-biz-manager/src/utils/prj_logger.ts

@@ -59,6 +59,7 @@ export class PrjLogger {
     static gen_modified_content(name: string, old_value: string, new_value?: string): string {
         if (!new_value) return '';
         if (old_value === new_value) return '';
+        if (!old_value) old_value = '';
         // 如果字符长度超过32字节,则只显示前32字节,加上...
         if (old_value.length > 32) old_value = old_value.substring(0, 32) + '...';
         if (new_value.length > 32) new_value = new_value.substring(0, 32) + '...';

+ 6 - 0
pmr-biz-manager/src/utils/prj_premission_helper.ts

@@ -234,6 +234,12 @@ export async function if_project_task_manageable_in_current_phase(draft: boolean
         result.error = Resp.gen_err(Resp.InvalidFlow, `当前项目处于计划变更审核过程中,不允许${action}。`);
         return result;
     }
+
+    if (!draft && phase.order_index === 70) {
+        result.error = Resp.gen_err(Resp.InvalidFlow, `项目执行中,不允许直接${action},请先在草稿中${action}后再提交计划变更审核。`);
+        return result;
+    }
+
     if (phase.order_index === 80) {
         result.error = Resp.gen_err(Resp.InvalidFlow, `项目验收中,不允许${action}。`);
         return result;