schangxiang@126.com
2025-09-09 3d8966ba2c81e7e0365c8b123e861d18ee4f94f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import BaseService from "../baseService";
import { BaseEmptyEquipmentReturn } from "../../entity/outbound/sale/baseEmptyEquipmentReturn";
import { BaseConsignor } from "../../entity/basicInfo/consignor/baseConsignor";
import { BaseStorage } from "../../entity/basicInfo/base/baseStorage";
 
/**
 * 财务管理
 */
export default class emptyEquipmentReturnService extends BaseService {
  //#region 添加保存前事件
  /**
   * 添加保存后事件
   */
  public async onAddSaveAfter(t: BaseEmptyEquipmentReturn, isAdd: boolean) {
    this.info.result = true;
    // 只有在添加时才增加流水
    if (isAdd) {
      // 获得最后一条流水
      let lastEmpty = await this.dbRead.findOne(BaseEmptyEquipmentReturn, {
        where: {
          emptyEquipmentReturn_Id: t.emptyEquipmentReturn_Id
        }
      });
      var baseConsignor = await this.dbRead.findOne(BaseConsignor, {
        where: {
          consignorName: "广州西门子"
        }
      });
      var baseStorage = await this.dbRead.findOne(BaseStorage, {
        where: {
          storageName: "立体库"
        }
      });
      if (baseStorage) {
        lastEmpty.storage_Id = baseStorage.storage_Id;
        lastEmpty.storageName = baseStorage.storageName;
      }
      if (baseStorage) {
        lastEmpty.consignor_Id = baseConsignor.consignor_Id;
        lastEmpty.consignorCode = baseConsignor.consignorCode;
        lastEmpty.consignorName = baseConsignor.consignorName;
      }
      lastEmpty.statusText = "新建";
 
      lastEmpty.orderType = "空器具回库";
      await this.dbWrite.save(lastEmpty);
    }
    return this.info;
  }
  //#endregion
}