import BaseController from "../baseController";
|
import { TMSWayBill } from "../../entity/express/tms/tmsWayBill";
|
import { TMSPortTemplate } from "../../entity/express/tms/tmsPortTemplate";
|
import { BasePrintTemplate } from "../../entity/sys/print/basePrintTemplate";
|
import { TMSSortingPanelLog } from "../../entity/express/panel/tmsSortingPanelLog";
|
import { Post } from "egg-shell-decorators";
|
|
/**
|
* 组板操作
|
*/
|
export default class PanelController extends BaseController {
|
//#region PC组板
|
/// <summary>
|
/// 校验并生产PC组板
|
/// </summary>
|
/// <returns></returns>
|
@Post()
|
public async checkPCPanel() {
|
try {
|
//#region 校验信息
|
if (!this.body.wayBillCode) {
|
this.info.result = false;
|
this.info.msg = "运单编号不能为空";
|
this.ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
|
// 运单信息
|
let waybill = await this.dbRead.findOne(TMSWayBill, {
|
wayBillCode: this.body.wayBillCode
|
});
|
if (waybill == null) {
|
this.info.msg = "运单号不存在";
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
|
if (this.body.port_Id > 0 && waybill.port_Id != this.body.port_Id) {
|
this.info.msg = "当前运单号和选择口岸不匹配!";
|
this.info.result = false;
|
this.ctx.body = this.info;
|
return;
|
}
|
|
//#region 获取快递模板Id
|
let template = await this.dbRead.findOne(TMSPortTemplate, {
|
portName: waybill.portName,
|
expressCorp_Id: waybill.expressCorp_Id
|
});
|
if (template == null) {
|
this.info.result = false;
|
this.info.msg = "口岸未设置快递模板";
|
this.ctx.body = this.info;
|
return;
|
}
|
|
let btemp = await this.dbRead.findOne(BasePrintTemplate, {
|
printTemplate_Id: template.faceBillTemplateID
|
});
|
if (btemp == null) {
|
this.info.result = false;
|
this.info.msg = "快递模板不存在";
|
this.ctx.body = this.info;
|
return;
|
}
|
//#endregion
|
|
this.info = await this.ctx.service.tms.sortingHelper.checkRule(this.body.wayBillCode, "PC组板");
|
//模块ID
|
this.info.dynamic = btemp.menu_Id;
|
if (this.info.result) {
|
let wayBillInfo: TMSWayBill = this.info.data as TMSWayBill;
|
if (wayBillInfo.printNum != null) {
|
wayBillInfo.printNum += 1;
|
} else {
|
wayBillInfo.printNum = 1;
|
}
|
wayBillInfo.abnormalReason = this.info.msg;
|
await this.dbWrite.update(TMSWayBill, wayBillInfo.wayBill_Id, {
|
printNum: ++wayBillInfo.printNum,
|
abnormalReason: this.info.msg
|
});
|
|
//添加运单追踪记录
|
this.ctx.service.tms.wayBillHelper.setStatusHistory(
|
wayBillInfo,
|
"流水线组板",
|
wayBillInfo.orderStatus,
|
"出库扫描完毕,等待发往机场"
|
);
|
let log = new TMSSortingPanelLog();
|
log.wayBillCode = wayBillInfo.wayBillCode;
|
log.wayBillWeight = wayBillInfo.weight;
|
log.message = wayBillInfo.abnormalReason;
|
log.planDropOffPort = wayBillInfo.planDropOffPort;
|
log.actualDropOffPort = wayBillInfo.actualDropOffPort;
|
log.userProduct_Id = 1007;
|
log.userProductCode = "100000001";
|
log.userProductAlias = "WmsSaaS云仓系统";
|
log.platUser_Id = 1;
|
log.platCorpName = "澳德";
|
log.platUserCode = "PT20180001";
|
await this.dbWrite.save(log);
|
} else {
|
if (this.info.data != null) {
|
let wayBillInfo: TMSWayBill = this.info.data as TMSWayBill;
|
if (wayBillInfo.printNum != null) {
|
wayBillInfo.printNum += 1;
|
} else {
|
wayBillInfo.printNum = 1;
|
}
|
wayBillInfo.abnormalReason = this.info.msg;
|
await this.dbWrite.update(TMSWayBill, wayBillInfo.wayBill_Id, {
|
printNum: ++wayBillInfo.printNum,
|
abnormalReason: this.info.msg
|
});
|
this.ctx.service.tms.wayBillHelper.setStatusHistory(
|
wayBillInfo,
|
"PC组板",
|
wayBillInfo.orderStatus + wayBillInfo.abnormalReason
|
); //添加运单追踪记录
|
let log = new TMSSortingPanelLog();
|
log.wayBillCode = wayBillInfo.wayBillCode;
|
log.wayBillWeight = wayBillInfo.weight;
|
log.message = wayBillInfo.abnormalReason;
|
log.planDropOffPort = wayBillInfo.planDropOffPort;
|
log.actualDropOffPort = wayBillInfo.actualDropOffPort;
|
log.userProduct_Id = 1007;
|
log.userProductCode = "100000001";
|
log.userProductAlias = "WmsSaaS云仓系统";
|
log.platUser_Id = 1;
|
log.platCorpName = "澳德";
|
log.platUserCode = "PT20180001";
|
await this.dbWrite.save(log);
|
}
|
}
|
} catch (ex) {
|
this.info.result = false;
|
this.info.msg = ex.message;
|
}
|
this.ctx.body = this.info;
|
}
|
//#endregion
|
}
|