|
@@ -425,15 +425,16 @@ function deleteByBill(user_id,datas,callback) {
|
|
|
|
|
|
|
|
|
function deleteByID(datas,callback){
|
|
|
- ration_glj.deleteOne(datas.query,(err,result)=>{
|
|
|
- if(err){
|
|
|
- callback(err,'');
|
|
|
+ deleteAndUpdateState(datas).then(function (result) {
|
|
|
+ if(result.err){
|
|
|
+ callback(result.err,'');
|
|
|
}else {
|
|
|
let returndata ={
|
|
|
moduleName:'ration_glj',
|
|
|
data:{
|
|
|
updateTpye:commonConsts.UT_DELETE,
|
|
|
query:datas.query,
|
|
|
+ adjustState:result.adjustState
|
|
|
}
|
|
|
}
|
|
|
callback(null,returndata)
|
|
@@ -441,6 +442,20 @@ function deleteByID(datas,callback){
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+async function deleteAndUpdateState(datas) {
|
|
|
+ let result={
|
|
|
+ err:null
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ await ration_glj.deleteOne(datas.query);
|
|
|
+ let stateResult = await glj_calculate_facade.calculateQuantity({projectID:datas.query.projectID,rationID:datas.doc.rationID});
|
|
|
+ result.adjustState=stateResult.adjustState;
|
|
|
+ }catch (err){
|
|
|
+ result.err=err;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
function startingTask(processName){
|
|
|
return function(asyncCallBack){
|
|
|
var result = {
|
|
@@ -634,14 +649,18 @@ async function addGLJ(rgList) {
|
|
|
newRecodes.push(createNewRecord(g));
|
|
|
}
|
|
|
await ration_glj.insertMany(newRecodes);
|
|
|
+
|
|
|
+ let stateResult = await glj_calculate_facade.calculateQuantity({projectID:rgList[0].projectID,rationID:rgList[0].rationID});
|
|
|
let result={
|
|
|
newRecodes:newRecodes,
|
|
|
- showData:rgList
|
|
|
+ showData:rgList,
|
|
|
+ adjustState:stateResult.adjustState
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
async function replaceGLJ(data) {
|
|
|
+ let rdata={};
|
|
|
let projectGljModel = new GLJListModel();
|
|
|
let result = await projectGljModel.addList(getGLJSearchInfo(data));
|
|
|
data.marketPrice=result.unit_price.market_price;
|
|
@@ -650,9 +669,13 @@ async function replaceGLJ(data) {
|
|
|
data.projectGLJID=result.id;
|
|
|
data.isEstimate=result.is_evaluate;
|
|
|
let updateResult=await ration_glj.findOneAndUpdate({ID:data.ID,projectID:data.projectID},data);
|
|
|
- return data
|
|
|
+ let stateResult = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID});
|
|
|
+ rdata.data=data;
|
|
|
+ rdata.adjustState=stateResult.adjustState;
|
|
|
+ return rdata;
|
|
|
}
|
|
|
async function mReplaceGLJ(data) {
|
|
|
+ let mresult={};
|
|
|
let projectGljModel = new GLJListModel();
|
|
|
let result = await projectGljModel.addList(getGLJSearchInfo(data.doc));
|
|
|
data.doc.marketPrice=result.unit_price.market_price;
|
|
@@ -660,11 +683,26 @@ async function mReplaceGLJ(data) {
|
|
|
data.doc.basePrice=result.unit_price.base_price;
|
|
|
data.doc.projectGLJID=result.id;
|
|
|
data.doc.isEstimate=result.is_evaluate;
|
|
|
+ let rationList=await ration_glj.distinct('rationID',data.query);
|
|
|
let updateResult=await ration_glj.update(data.query,data.doc,{multi: true});
|
|
|
- console.log(updateResult);
|
|
|
- return data
|
|
|
+ let stateList= await changAdjustState(data,rationList);
|
|
|
+ mresult.data=data;
|
|
|
+ mresult.stateList=stateList;
|
|
|
+ return mresult
|
|
|
}
|
|
|
|
|
|
+async function changAdjustState(data,rationList) {
|
|
|
+ let stateList=[];
|
|
|
+ for(let r of rationList){
|
|
|
+ let stateResult = await glj_calculate_facade.calculateQuantity({projectID:data.query.projectID,rationID:r});
|
|
|
+ stateList.push({rationID:r,adjustState:stateResult.adjustState});
|
|
|
+ }
|
|
|
+ return stateList;
|
|
|
+}
|
|
|
+
|
|
|
+async function testError() {
|
|
|
+ throw new Error('test Error');
|
|
|
+}
|
|
|
|
|
|
function getData(projectID, callback) {
|
|
|
ration_glj.find({'projectID':projectID},(err,datas)=>{
|