|  | @@ -0,0 +1,133 @@
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Created by zhang on 2019/3/18.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +import mongoose from "mongoose";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let Schema = mongoose.Schema;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +var rationAssItemSchema = mongoose.Schema({
 | 
	
		
			
				|  |  | +    name: String,
 | 
	
		
			
				|  |  | +    assistID: Number,
 | 
	
		
			
				|  |  | +    assistCode: String,
 | 
	
		
			
				|  |  | +    stdValue: Number,
 | 
	
		
			
				|  |  | +    actualValue:Number,
 | 
	
		
			
				|  |  | +    stepValue: String,
 | 
	
		
			
				|  |  | +    decimal: Number,
 | 
	
		
			
				|  |  | +    carryBit: String,
 | 
	
		
			
				|  |  | +    minValue: String,
 | 
	
		
			
				|  |  | +    maxValue: String,
 | 
	
		
			
				|  |  | +    paramName:String,//参数名称
 | 
	
		
			
				|  |  | +    param:String,//参数
 | 
	
		
			
				|  |  | +    thirdRationCode:String,//第三定额
 | 
	
		
			
				|  |  | +    isAdjust:Number,//0不调整,1调整
 | 
	
		
			
				|  |  | +    groupList:[Schema.Types.Mixed],//当有分组的时候用这个
 | 
	
		
			
				|  |  | +    assRation:Schema.Types.Mixed//存放对应的定额,材料计算时用到
 | 
	
		
			
				|  |  | +}, { _id: false });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +var ration_glj = new Schema({
 | 
	
		
			
				|  |  | +    ID:{type: String},
 | 
	
		
			
				|  |  | +    GLJID:Number,
 | 
	
		
			
				|  |  | +    repositoryId:Number,
 | 
	
		
			
				|  |  | +    rationID:String,
 | 
	
		
			
				|  |  | +    projectGLJID:Number,
 | 
	
		
			
				|  |  | +    name:String,
 | 
	
		
			
				|  |  | +    code:String,
 | 
	
		
			
				|  |  | +    //原始的编码
 | 
	
		
			
				|  |  | +    original_code: {type: String},
 | 
	
		
			
				|  |  | +    rcode:String,
 | 
	
		
			
				|  |  | +    //新结构,计录替换前的工料机信息,对于混凝土,替换,计算等问题处理,替换时保存旧数据的5大项信息
 | 
	
		
			
				|  |  | +    mIndexObj: Schema.Types.Mixed,
 | 
	
		
			
				|  |  | +    specs:String,
 | 
	
		
			
				|  |  | +    unit:String,
 | 
	
		
			
				|  |  | +    shortName:String,
 | 
	
		
			
				|  |  | +    type:Number,
 | 
	
		
			
				|  |  | +    // 机型
 | 
	
		
			
				|  |  | +    model: Number,
 | 
	
		
			
				|  |  | +    // 调整系数ID
 | 
	
		
			
				|  |  | +    adjCoe: Number,
 | 
	
		
			
				|  |  | +    quantity:String,
 | 
	
		
			
				|  |  | +    customQuantity:String,
 | 
	
		
			
				|  |  | +    rationItemQuantity:String,
 | 
	
		
			
				|  |  | +    tenderQuantity:String,//调整后消耗量
 | 
	
		
			
				|  |  | +    createType: {type: String,default:'normal'},//normal、add、replace  正常、添加工料机、替换工料机
 | 
	
		
			
				|  |  | +    from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
 | 
	
		
			
				|  |  | +},{versionKey:false,_id: false});
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let ration_schema = {
 | 
	
		
			
				|  |  | +    ID: {type: String},
 | 
	
		
			
				|  |  | +    projectID: Number,
 | 
	
		
			
				|  |  | +    code: String,
 | 
	
		
			
				|  |  | +    name: String,
 | 
	
		
			
				|  |  | +    unit: String,
 | 
	
		
			
				|  |  | +    quantity: String,
 | 
	
		
			
				|  |  | +    feeType:String,
 | 
	
		
			
				|  |  | +    caption:String,
 | 
	
		
			
				|  |  | +    libID:Number,
 | 
	
		
			
				|  |  | +    stdID:Number,
 | 
	
		
			
				|  |  | +    from:String,
 | 
	
		
			
				|  |  | +    rationAssList: [rationAssItemSchema]
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let freightSchema = {
 | 
	
		
			
				|  |  | +    ID:{type:String,index: true},
 | 
	
		
			
				|  |  | +    unit_price_file_id: Number,
 | 
	
		
			
				|  |  | +    connect_key: {type: String, index: true},// 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
 | 
	
		
			
				|  |  | +    start:String,//起讫地点
 | 
	
		
			
				|  |  | +    conveyance:String,//运输工具
 | 
	
		
			
				|  |  | +    unitFreight:String,//单位运价
 | 
	
		
			
				|  |  | +    kmDistance:String,//km运距
 | 
	
		
			
				|  |  | +    unitLoadingFee:String,//装卸费单价
 | 
	
		
			
				|  |  | +    loadingTimes:String,//装卸次数
 | 
	
		
			
				|  |  | +    otherFee:String,//其它费用
 | 
	
		
			
				|  |  | +    freightIncreaseRate:String,//运价增加率
 | 
	
		
			
				|  |  | +    weightCoe:String,//加权系数
 | 
	
		
			
				|  |  | +    rations:[ration_schema],
 | 
	
		
			
				|  |  | +    ration_gljs:[ration_glj],
 | 
	
		
			
				|  |  | +    calcType:String,//计算方式
 | 
	
		
			
				|  |  | +    materialType:String//材料类型
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +mongoose.model("freight_calc", new Schema(freightSchema, {versionKey: false, collection: "freight_calc"}));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let originalSchema = {
 | 
	
		
			
				|  |  | +    ID:{type:String,index: true},
 | 
	
		
			
				|  |  | +    unit_price_file_id: Number,
 | 
	
		
			
				|  |  | +    connect_key: {type: String, index: true},// 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
 | 
	
		
			
				|  |  | +    supplyLocation:String,//供应地点
 | 
	
		
			
				|  |  | +    supplyPrice:String,//供应价
 | 
	
		
			
				|  |  | +    coe:String,//加权系数
 | 
	
		
			
				|  |  | +    rations:[ration_schema],
 | 
	
		
			
				|  |  | +    ration_gljs:[ration_glj]
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +mongoose.model("original_calc", new Schema(originalSchema, {versionKey: false, collection: "original_calc"}));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let userfreightSchema = mongoose.Schema({
 | 
	
		
			
				|  |  | +    ID:String,
 | 
	
		
			
				|  |  | +    unit_price_file_id: Number,
 | 
	
		
			
				|  |  | +    connect_key: String,// 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
 | 
	
		
			
				|  |  | +    start:String,//起讫地点
 | 
	
		
			
				|  |  | +    conveyance:String,//运输工具
 | 
	
		
			
				|  |  | +    unitFreight:String,//单位运价
 | 
	
		
			
				|  |  | +    kmDistance:String,//km运距
 | 
	
		
			
				|  |  | +    unitLoadingFee:String,//装卸费单价
 | 
	
		
			
				|  |  | +    loadingTimes:String,//装卸次数
 | 
	
		
			
				|  |  | +    otherFee:String,//其它费用
 | 
	
		
			
				|  |  | +    freightIncreaseRate:String,//运价增加率
 | 
	
		
			
				|  |  | +    weightCoe:String,//加权系数
 | 
	
		
			
				|  |  | +    rations:[ration_schema],
 | 
	
		
			
				|  |  | +    ration_gljs:[ration_glj],
 | 
	
		
			
				|  |  | +    calcType:String,//计算方式
 | 
	
		
			
				|  |  | +    materialType:String//材料类型
 | 
	
		
			
				|  |  | +}, { _id: false });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +let user_freights = {
 | 
	
		
			
				|  |  | +    ID:{type:String,index: true},
 | 
	
		
			
				|  |  | +    userID:{type:String,index: true},
 | 
	
		
			
				|  |  | +    compilationID:{type:String,index: true},
 | 
	
		
			
				|  |  | +    rootProjectID:Number,
 | 
	
		
			
				|  |  | +    freight:userfreightSchema
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +mongoose.model("user_freights", new Schema(user_freights, {versionKey: false, collection: "user_freights"}));
 |