From 10b1577c86bd45cba5abb3b1445f4b5e3fc32216 Mon Sep 17 00:00:00 2001 From: sriramv Date: Mon, 2 May 2022 15:58:45 +0530 Subject: [PATCH 1/4] GWM --- app/controllers/salespd.controller.js | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js index 71a81a6..d970f5e 100644 --- a/app/controllers/salespd.controller.js +++ b/app/controllers/salespd.controller.js @@ -21,26 +21,26 @@ exports.SectionList = async (req, res) => section_name_obj = { section1_key : "GeneralSection" , section1_name : "General Section" , - section2_key : "FundRequirement", - section2_name : "Fund Requirement", - section3_key : "DetailsOfKeyShareHolder", - section3_name : "Details Of Key ShareHolder", - section4_key : "BreifOfBusiness", - section4_name : "Breif Of Business", - section5_key : "FinancialInformation", - section5_name : "Financial Information", - section6_key : "PropertyInformation", - section6_name : "Property Information", + section2_key : "FundRequirements", + section2_name : "Fund Requirements", + section3_key : "DetailsOfKeyShareHolders", + section3_name : "Details Of Key Share Holders", + section4_key : "BreifOfBusinesses", + section4_name : "Breif Of Businesses", + section5_key : "FinancialInformations", + section5_name : "Financial Informations", + section6_key : "PropertyInformations", + section6_name : "Property Informations", section7_key : "FinalRemarks", section7_name : "Final Remarks", section8_key : "OfficerDetails", section8_name : "Officer Details", - section9_key : "Photograph", - section9_name : "Photograph", - section10_key : "InstitutionDetail", - section10_name : "Institution Detail", - section11_key : "ProductInformation", - section11_name : "Product Information", + section9_key : "Photographs", + section9_name : "Photographs", + section10_key : "InstitutionDetails", + section10_name : "Institution Details", + section11_key : "ProductInformations", + section11_name : "Product Informations", }; if(data.length > 0) From c197af3f9412cf11a69970733364a8892ba00261 Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 4 May 2022 11:43:07 +0530 Subject: [PATCH 2/4] pullsalesPDAPI:GWM --- app/controllers/salespd.controller.js | 22 ++++++++ app/routes/routes.js | 77 +++++++++++++++++++++++++-- 2 files changed, 96 insertions(+), 3 deletions(-) diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js index d970f5e..66e2f7d 100644 --- a/app/controllers/salespd.controller.js +++ b/app/controllers/salespd.controller.js @@ -4,6 +4,28 @@ const ApiCallHelper = require('../services/apicallhelper.js'); +exports.PullSalesPdData = async (req, res) => +{ + try + { + res.send({'status':200,'message':"success",'data':data}); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); + } //end of try catch + +}; +exports.PullSalesPdPhotographsData = async (req, res) => +{ + try + { + res.send({'status':200,'message':"success",'data':data}); + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); + } //end of try catch + +}; //GeneralSection data List Api exports.SectionList = async (req, res) => { diff --git a/app/routes/routes.js b/app/routes/routes.js index fc66311..5942da7 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -9,7 +9,6 @@ module.exports = app => { - /** * @swagger * /api/demo: @@ -26,8 +25,80 @@ module.exports = app => { router.get('/salespd',Mycontroller.SalesPd) - - +/** +* @swagger +* definitions: +* PullSalesPdData: +* type: object +* properties: +* pdid: +* type: integer +* description: pdid +* example: 6646 +* product: +* type: string +* description: product +* example: LFMP +* data: +* type: string +* description: json string +* example: +*/ +/** +* @swagger +* /api/PullSalesPdData: +* post: +* summary: Pull SalesPd Data +* description: Pull SalesPd Data +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/PullSalesPdData' +* responses: +* 200: +* description: success +* 500: +* description: failed +*/ + router.post("/PullSalesPdData", SalesPdController.PullSalesPdData); + /** +* @swagger +* definitions: +* PullSalesPdPhotographsData: +* type: object +* properties: +* pdid: +* type: integer +* description: pdid +* example: 6646 +* product: +* type: string +* description: product +* example: LFMP +* data: +* type: string +* description: json string +* example: +*/ +/** +* @swagger +* /api/PullSalesPdPhotographsData: +* post: +* summary: Pull SalesPd Photographs Data +* description: Pull SalesPd Photographs Data +* requestBody: +* content: +* application/json: +* schema: +* $ref: '#/definitions/PullSalesPdPhotographsData' +* responses: +* 200: +* description: success +* 500: +* description: failed +*/ + router.post("/PullSalesPdPhotographsData", SalesPdController.PullSalesPdPhotographsData); //GeneralSection List Api /** * @swagger From 854bff90a638cfaa55c02cbe8fcec82181174bca Mon Sep 17 00:00:00 2001 From: sriramv Date: Wed, 4 May 2022 13:09:04 +0530 Subject: [PATCH 3/4] GWM --- app/models/GeneralSection.js | 1 + app/models/Photograph.js | 10 +++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/models/GeneralSection.js b/app/models/GeneralSection.js index 909231d..4700682 100644 --- a/app/models/GeneralSection.js +++ b/app/models/GeneralSection.js @@ -12,6 +12,7 @@ module.exports = (sequelize, DataTypes) => { autoIncrement : true, primaryKey: true }, + ref_no: { type: DataTypes.INTEGER }, losid: { type: DataTypes.STRING }, application_id: { type: DataTypes.STRING }, main_loan_applicant: { type: DataTypes.STRING }, diff --git a/app/models/Photograph.js b/app/models/Photograph.js index b314c8b..2e0927a 100644 --- a/app/models/Photograph.js +++ b/app/models/Photograph.js @@ -7,13 +7,9 @@ module.exports = (sequelize, DataTypes) => { Photograph.init( { pd_id: { type: DataTypes.INTEGER }, - selfie_with_person_met: { type: DataTypes.STRING }, - hospital_building: { type: DataTypes.STRING }, - approach_to_pd_location: { type: DataTypes.STRING }, - name_board_seen: { type: DataTypes.STRING }, - stock_image: { type: DataTypes.STRING }, - workplace_interior_image: { type: DataTypes.STRING }, - institute_interior: { type: DataTypes.STRING }, + ref_no: { type: DataTypes.INTEGER }, + img: { type: DataTypes.STRING }, + img_name: { type: DataTypes.STRING }, createdby: { type: DataTypes.INTEGER }, updatedby: { type: DataTypes.INTEGER } From ef58d2c32086591230b7d76dbe8a280746a3dea4 Mon Sep 17 00:00:00 2001 From: sriramv Date: Thu, 5 May 2022 18:17:56 +0530 Subject: [PATCH 4/4] GWM --- app/controllers/salespd.controller.js | 209 ++++++++++++++++++++++++-- app/models/BreifOfBusiness.js | 8 +- app/models/GeneralSection.js | 4 +- app/routes/routes.js | 27 +++- 4 files changed, 232 insertions(+), 16 deletions(-) diff --git a/app/controllers/salespd.controller.js b/app/controllers/salespd.controller.js index 66e2f7d..8808718 100644 --- a/app/controllers/salespd.controller.js +++ b/app/controllers/salespd.controller.js @@ -1,6 +1,7 @@ -const { sequelize, GeneralSection , BreifOfBusiness , DetailsOfKeyShareHolder , FinalRemarks , FinancialInformation , FundRequirement , InstitutionDetail , OfficerDetails , Photograph , ProductInformation , PropertyInformation} = require('../models') +const { sequelize, GeneralSection , BriefOfBusiness , DetailsOfKeyShareHolder , FinalRemarks , FinancialInformation , FundRequirement , InstitutionDetail , OfficerDetails , Photograph , ProductInformation , PropertyInformation} = require('../models') const { logMsg } = require('../services/logger.js'); const ApiCallHelper = require('../services/apicallhelper.js'); +const request = require('request'); @@ -8,24 +9,181 @@ exports.PullSalesPdData = async (req, res) => { try { - res.send({'status':200,'message':"success",'data':data}); + + const tempData =JSON.parse(JSON.stringify(req.body.data)); + + var count = 0; + var generalSectionData = [ ]; + var storeId = [ ]; + const len = Object.keys(tempData).length - 1; + for (const [keys, values] of Object.entries(tempData)) { + count++; + console.log(values); + if (Array.isArray(values) == true ) + { + values.forEach(async(values) => { + if (keys == 'section1') { + Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno}); + await GeneralSection.create( values ) + .then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);}) + .catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); }); + storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }}); + }; + if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id); }); }; + if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section5') { + Object.assign(values, { pd_id: storeId.pd_id }); + Object.assign(values, values[0]); + await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id);}); }; + // if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); }; + // if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); }; + }); + } + else + { + if (keys == 'section1') { + Object.assign(values, { ref_no: req.body.pdid , product :req.body.product , case_no :req.body.caseno}); + await GeneralSection.create( values ) + .then((successData)=>{logMsg.info("GeneralSection insert success ,PdId= "+successData.dataValues.pd_id);}) + .catch((err)=>{ logMsg.info("GeneralSection insert failed ,PdId(ref_no)= "+req.body.pdid); }); + + storeId = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }}); + }; + if (keys == 'section2') { Object.assign(values, { pd_id: storeId.pd_id }); await FundRequirement.create( values ).then((successData)=>{logMsg.info("FundRequirement insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FundRequirement insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section3') { Object.assign(values, { pd_id: storeId.pd_id }); await DetailsOfKeyShareHolder.create( values).then((successData)=>{logMsg.info("DetailsOfKeyShareHolder insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("DetailsOfKeyShareHolder insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section4') { Object.assign(values, { pd_id: storeId.pd_id }); await BriefOfBusiness.create( values).then((successData)=>{logMsg.info("BreifOfBusiness insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("BreifOfBusiness insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section5') { + Object.assign(values, { pd_id: storeId.pd_id }); + Object.assign(values, values[0]); + await FinancialInformation.create( values).then((successData)=>{logMsg.info("FinancialInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinancialInformation insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section6') { Object.assign(values, { pd_id: storeId.pd_id }); await PropertyInformation.create( values).then((successData)=>{logMsg.info("PropertyInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("PropertyInformation insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section7') { Object.assign(values, { pd_id: storeId.pd_id }); await FinalRemarks.create( values).then((successData)=>{logMsg.info("FinalRemarks insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("FinalRemarks insert failed ,PdId= "+storeId.pd_id);}); }; + if (keys == 'section8') { Object.assign(values, { pd_id: storeId.pd_id }); await OfficerDetails.create( values).then((successData)=>{logMsg.info("OfficerDetails insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("OfficerDetails insert failed ,PdId= "+storeId.pd_id);}); }; + // if (keys == 'section10') { Object.assign(values, { pd_id: storeId.pd_id }); await InstitutionDetail.create( values).then((successData)=>{logMsg.info("InstitutionDetail insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("InstitutionDetail insert failed ,PdId= "+storeId.pd_id);}); }; + // if (keys == 'section11') { Object.assign(values, { pd_id: storeId.pd_id }); await ProductInformation.create( values).then((successData)=>{logMsg.info("ProductInformation insert success ,PdId= "+storeId.pd_id);}).catch((err)=>{ logMsg.info("ProductInformation insert failed ,PdId= "+storeId.pd_id);}); }; + } + if (len == count - 1 ) + { + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No Data"}); + }, 1000); + + } + } + } catch(err) { res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); } //end of try catch }; + + exports.PullSalesPdPhotographsData = async (req, res) => { try { - res.send({'status':200,'message':"success",'data':data}); + GeneralSectionData = await GeneralSection.findOne({ where : { ref_no : req.body.pdid , is_active : 1 }}); + PdId = GeneralSectionData.dataValues.pd_id; + + const Photographdata =req.body.data; + + for(const value of Photographdata) + { + Object.assign(value, { pd_id: PdId }); + await Photograph.create( value) + .then((successData)=>{logMsg.info("Photograph insert success ,PdId= "+PdId);}) + .catch((err)=>{ logMsg.info("Photograph insert failed ,PdId= "+PdId);}); + }; + setTimeout(() => { + res.send({'status':200,'message':"success",'data':"No data"}); + }, 1000); + } catch(err) { res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); } //end of try catch }; + +exports.DownloadPdReport = async (req, res) => +{ + try + { + pd_id = req.query.ref_no; + DownloadPdReportUrl = process.env.PD_REPORT_URL; + url = DownloadPdReportUrl+"getSalesPDReportforCETApp?sales_pd_id="+pd_id; + + + request({ + url: url, + method: "GET" + + }, function (error, response, body) { console.log(body); + if (body != undefined) { + data = JSON.parse(body); + if ( data.status == 200) { + + link = data.records; + res.send({'status':200,'message':"success",'data':link}); + }else{ + res.send({'status':404,'message':"failed",'data':"No data"}); + } + } + }); + + + + } catch(err) { + res.send({'status':404,message: err.message || "Some error occurred while retrieving data." ,'data': "No data" }); + } //end of try catch + +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //GeneralSection data List Api exports.SectionList = async (req, res) => { @@ -37,7 +195,7 @@ exports.SectionList = async (req, res) => if(MainApplicantDetails.status == 200) { GeneralSection.findAll({ where:{losid:req.query.losid,main_loan_applicant:MainApplicantDetails.data.name,is_active : 1}, - include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: FinancialInformation }, {model: FinalRemarks }, {model: BreifOfBusiness }, {model: PropertyInformation }, {model: OfficerDetails }, {model: Photograph }, {model: InstitutionDetail }, {model: ProductInformation }] }) + include: [ {model: FundRequirement }, {model: DetailsOfKeyShareHolder }, {model: FinancialInformation }, {model: FinalRemarks }, {model: BriefOfBusiness }, {model: PropertyInformation }, {model: OfficerDetails }, {model: Photograph }] }) .then(data => { section_name_obj = { @@ -47,8 +205,8 @@ exports.SectionList = async (req, res) => section2_name : "Fund Requirements", section3_key : "DetailsOfKeyShareHolders", section3_name : "Details Of Key Share Holders", - section4_key : "BreifOfBusinesses", - section4_name : "Breif Of Businesses", + section4_key : "BriefOfBusinesses", + section4_name : "Brief Of Businesses", section5_key : "FinancialInformations", section5_name : "Financial Informations", section6_key : "PropertyInformations", @@ -59,10 +217,10 @@ exports.SectionList = async (req, res) => section8_name : "Officer Details", section9_key : "Photographs", section9_name : "Photographs", - section10_key : "InstitutionDetails", - section10_name : "Institution Details", - section11_key : "ProductInformations", - section11_name : "Product Informations", + // section10_key : "InstitutionDetails", + // section10_name : "Institution Details", + // section11_key : "ProductInformations", + // section11_name : "Product Informations", }; if(data.length > 0) @@ -92,6 +250,37 @@ exports.SectionList = async (req, res) => }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //BreifOfBusiness data List Api exports.BreifOfBusinessList = async (req, res) => { diff --git a/app/models/BreifOfBusiness.js b/app/models/BreifOfBusiness.js index ba5f06b..7277a67 100644 --- a/app/models/BreifOfBusiness.js +++ b/app/models/BreifOfBusiness.js @@ -1,10 +1,10 @@ 'use strict' const { Model } = require('sequelize') module.exports = (sequelize, DataTypes) => { - class BreifOfBusiness extends Model { + class BriefOfBusiness extends Model { } - BreifOfBusiness.init( + BriefOfBusiness.init( { pd_id: { type: DataTypes.INTEGER }, nature_of_business : { type: DataTypes.STRING }, @@ -18,9 +18,9 @@ module.exports = (sequelize, DataTypes) => { { sequelize, tableName: 'sales_brief_of_the_business_or_service', - modelName: 'BreifOfBusiness', + modelName: 'BriefOfBusiness', } ) - return BreifOfBusiness + return BriefOfBusiness } \ No newline at end of file diff --git a/app/models/GeneralSection.js b/app/models/GeneralSection.js index 4700682..67cd458 100644 --- a/app/models/GeneralSection.js +++ b/app/models/GeneralSection.js @@ -13,6 +13,8 @@ module.exports = (sequelize, DataTypes) => { primaryKey: true }, ref_no: { type: DataTypes.INTEGER }, + product: { type: DataTypes.STRING }, + case_no: { type: DataTypes.STRING }, losid: { type: DataTypes.STRING }, application_id: { type: DataTypes.STRING }, main_loan_applicant: { type: DataTypes.STRING }, @@ -52,7 +54,7 @@ module.exports = (sequelize, DataTypes) => { foreignKey: 'pd_id', sourceKey : 'pd_id' }); - GeneralSection.hasMany(models.BreifOfBusiness, { + GeneralSection.hasMany(models.BriefOfBusiness, { foreignKey: 'pd_id', sourceKey : 'pd_id' }); diff --git a/app/routes/routes.js b/app/routes/routes.js index 5942da7..d1f3139 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -22,7 +22,7 @@ module.exports = app => { router.get("/demo", Mycontroller.Welcome); - router.get('/salespd',Mycontroller.SalesPd) + /** @@ -39,6 +39,10 @@ module.exports = app => { * type: string * description: product * example: LFMP +* caseno: +* type: string +* description: +* example: MW53315 * data: * type: string * description: json string @@ -99,6 +103,27 @@ module.exports = app => { * description: failed */ router.post("/PullSalesPdPhotographsData", SalesPdController.PullSalesPdPhotographsData); + +/** +* @swagger +* /api/DownloadPdReport: +* get: +* summary: Download Pd Report as pdf file +* description: Download Pd Report as pdf file +* parameters: +* - in: query +* name: ref_no +* schema: +* type: integer +* required: true +* example: 614 +* responses: +* 200: +* description: success +*/ +router.get("/DownloadPdReport", SalesPdController.DownloadPdReport); + + //GeneralSection List Api /** * @swagger