|
@@ -590,13 +590,13 @@ async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes
|
|
|
let rkey = getIndex(ration_glj);
|
|
|
let pglj = projectGLJMap[rkey];
|
|
|
let subList = [];
|
|
|
- setUnitPrice(pglj,unitPriceMap);
|
|
|
+ await setUnitPrice(pglj,unitPriceMap);
|
|
|
if(existMixRatioMap[rkey]){//如果有组成物
|
|
|
for(let m of existMixRatioMap[rkey]){
|
|
|
let mpglj = projectGLJMap[getIndex(m)]
|
|
|
if(mpglj){
|
|
|
let cglj = _.clone(mpglj);
|
|
|
- setUnitPrice(cglj,unitPriceMap);
|
|
|
+ await setUnitPrice(cglj,unitPriceMap);
|
|
|
cglj.ratio_data = m;
|
|
|
subList.push(cglj);
|
|
|
}else{
|
|
@@ -617,13 +617,44 @@ async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes
|
|
|
|
|
|
|
|
|
|
|
|
- function setUnitPrice(p,unitPriceMap){
|
|
|
- p.unit_price = unitPriceMap[getIndex(p)];
|
|
|
+ async function setUnitPrice(p,unitPriceMap){
|
|
|
+ let unitPrice = unitPriceMap[getIndex(p)];
|
|
|
+ if(unitPrice){
|
|
|
+ p.unit_price = unitPrice;
|
|
|
+ }else{
|
|
|
+ unitPrice = newPriceDataFromPGlj(p,unitPriceFileId);
|
|
|
+ await unitPriceModel.insertMany([unitPrice]);
|
|
|
+ p.unit_price =unitPrice
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+function newPriceDataFromPGlj(np,unitPriceFileId){
|
|
|
+ let insertData = {
|
|
|
+ code: np.code,
|
|
|
+ base_price: np.base_price,
|
|
|
+ market_price: np.market_price,
|
|
|
+ unit_price_file_id: unitPriceFileId,
|
|
|
+ name: np.name,
|
|
|
+ taxRate:np.taxRate,
|
|
|
+ specs:np.specs?np.specs:'',
|
|
|
+ original_code:np.original_code,
|
|
|
+ unit:np.unit?np.unit:'',
|
|
|
+ type: np.type,
|
|
|
+ short_name: np.shortName !== undefined ? np.shortName : '',
|
|
|
+ glj_id: np.glj_id,
|
|
|
+ is_add:0,
|
|
|
+ grossWeightCoe:np.grossWeightCoe,
|
|
|
+ purchaseStorageRate:np.purchaseStorageRate,
|
|
|
+ offSiteTransportLossRate:np.offSiteTransportLossRate,
|
|
|
+ handlingLossRate:np.handlingLossRate
|
|
|
+ };
|
|
|
+ if(np.from=='cpt') insertData.is_add=1;//如果是来自补充工料机,则都添加新增标记
|
|
|
+ if(insertData.code != insertData.original_code) insertData.is_add=1;//添加的时候如果是复制整块来的,可能在源项目中是新增的工料机,这里也要添上(暂时可能还用不到)
|
|
|
+ return insertData;
|
|
|
+}
|
|
|
|
|
|
async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
|
|
|
let unitPriceMap = {};
|
|
@@ -636,8 +667,8 @@ async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
|
|
|
for(let np of newProjectGLJList){
|
|
|
let pkey = getIndex(np);
|
|
|
if(unitPriceMap[pkey]) continue;
|
|
|
-
|
|
|
- let insertData = {
|
|
|
+ let insertData = newPriceDataFromPGlj(np,unitPriceFileId)
|
|
|
+ /* let insertData = {
|
|
|
code: np.code,
|
|
|
base_price: np.base_price,
|
|
|
market_price: np.market_price,
|
|
@@ -657,7 +688,7 @@ async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
|
|
|
handlingLossRate:np.handlingLossRate
|
|
|
};
|
|
|
if(np.from=='cpt') insertData.is_add=1;//如果是来自补充工料机,则都添加新增标记
|
|
|
- if(insertData.code != insertData.original_code) insertData.is_add=1;//添加的时候如果是复制整块来的,可能在源项目中是新增的工料机,这里也要添上(暂时可能还用不到)
|
|
|
+ if(insertData.code != insertData.original_code) insertData.is_add=1;//添加的时候如果是复制整块来的,可能在源项目中是新增的工料机,这里也要添上(暂时可能还用不到) */
|
|
|
newUnitPriceList.push(insertData);
|
|
|
unitPriceMap[pkey] = insertData;
|
|
|
}
|