|
@@ -15,13 +15,20 @@ var buildUrl = 'https://yun.smartcost.com.cn/cld';
|
|
|
* modelsTable 数据表对象
|
|
|
* parameter 设置传的参数
|
|
|
*/
|
|
|
-var getPage= async function(modelsTable,where,currentPage,pageSize,parameter){
|
|
|
- var totalCount=await modelsTable.count();
|
|
|
+var getPage= async function(modelsTable,where,currentPage,pageSize,parameter,totalCount){
|
|
|
+
|
|
|
+ if(!hash.isExistence(totalCount)){
|
|
|
+ if(hash.isExistence(where)){
|
|
|
+ totalCount=await modelsTable.count({where});
|
|
|
+ }else{
|
|
|
+ totalCount=await modelsTable.count();
|
|
|
+ }
|
|
|
+ }
|
|
|
currentPage=parseInt(currentPage);
|
|
|
- if(hash.isExistence(where)){
|
|
|
- totalCount=await modelsTable.count({where});
|
|
|
+ var total =0;
|
|
|
+ if(totalCount!=0){
|
|
|
+ total = Math.trunc ( totalCount / pageSize );
|
|
|
}
|
|
|
- var total = Math.trunc ( totalCount / pageSize );
|
|
|
var totalPage = (totalCount % pageSize) == 0 ? total : total + 1;
|
|
|
|
|
|
var page={
|
|
@@ -42,18 +49,104 @@ var cloudService={
|
|
|
* compilation_id 编办ID
|
|
|
*/
|
|
|
getCuringList: async function(compilation_id,page=1){
|
|
|
-
|
|
|
+
|
|
|
//获得远程养护用户
|
|
|
- //数据组合
|
|
|
+ //分页数据
|
|
|
+ var limit=12;
|
|
|
+ var offset=0;
|
|
|
+ if(page!=1){
|
|
|
+ var pg=page-1;
|
|
|
+ offset=pg*limit;
|
|
|
+ }
|
|
|
+ var url= curingUrl+'/getCompilationList';
|
|
|
+ var curingCloudList={}; //await curlRequest(url);
|
|
|
+
|
|
|
+ //console.log(curingCloudList);
|
|
|
+
|
|
|
+ //组合数据以获得本地扩展数据
|
|
|
+ var mobile=[];
|
|
|
+ curingCloudList.forEach(function(v,i){
|
|
|
+ mobile.push(v.mobile);
|
|
|
+ });
|
|
|
+ //获得指定数据
|
|
|
+ var option={
|
|
|
+ where: {
|
|
|
+ mobile: {
|
|
|
+ [Op.or]: [mobile]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ raw:true,
|
|
|
+ };
|
|
|
+ if(hash.isExistence(compilation_id)){
|
|
|
+ option.where={compilation_id: compilation_id};
|
|
|
+ }
|
|
|
+ var curingList = await models.cloud_curing.findAll(option);
|
|
|
+ //组合同步云版数据
|
|
|
+ var falg=false;
|
|
|
+ curingCloudList.forEach(function(cclValue,cclKey){
|
|
|
+ curingCloudList[cclKey].client_id=0
|
|
|
+
|
|
|
+ falg=false;
|
|
|
+ curingList.forEach(function(clValue,clKey){
|
|
|
+ if(cclValue.mobile==clValue.mobile){
|
|
|
+ curingCloudList[cclKey].client_id=clValue.client_id;
|
|
|
+ falg=true;break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(falg){//新增本地扩展信息
|
|
|
+ sid=hash.hashDecode(STAFF.sid);
|
|
|
+ var obj = {
|
|
|
+ mobile: cclValue.mobile,
|
|
|
+ sso_id: cclValue.ssoid,
|
|
|
+ compilation_id: cclValue.compilationId,
|
|
|
+ curingCompany: cclValue.name,
|
|
|
+ sid: sid,
|
|
|
+ cid: STAFF.cid,
|
|
|
+ status: 2,
|
|
|
+ addtime: new Date().getTime(),
|
|
|
+ updateTotal: 1
|
|
|
+ };
|
|
|
+ var detail=await models.cloud_curing.create(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //数据组合--cld客户数据
|
|
|
var cid=[];
|
|
|
- curingList.forEach(function(v,i){
|
|
|
+ curingCloudList.forEach(function(v,i){
|
|
|
cid.push(v.client_id);
|
|
|
});
|
|
|
var attributes= ['cid', 'clientname', 'companyid', 'companyname'];
|
|
|
var clientList = await models.CLD_client.findAllInCid(cid,attributes);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ //组合页面需要展示的数据
|
|
|
+ curingCloudList.forEach(function(v,i){
|
|
|
+ curingCloudList[i].clientInfo={};
|
|
|
+ clientList.forEach(function(clientVal,clientI){
|
|
|
+ if(v.client_id==clientVal.cid){
|
|
|
+ curingCloudList[i].clientInfo=clientVal;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ curingCloudList[i].addtime=moment.unix(v.addtime).format('YYYY-MM-DD HH:mm');
|
|
|
+ curingCloudList[i].id=hash.hashEncode(v.id.toString());
|
|
|
+ curingCloudList[i].client_id=hash.hashEncode(v.client_id.toString());
|
|
|
+ curingCloudList[i].sso_id=v.sso_id;
|
|
|
+ });
|
|
|
+
|
|
|
+ var parameter='?compilation_id='+compilation_id;
|
|
|
+ //分页计算
|
|
|
+ var pageData = await getPage('','',page,limit,parameter,50);
|
|
|
+
|
|
|
+ return {curingList:curingCloudList,pageData:pageData};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//获得本地用户
|
|
|
var limit=12;
|
|
@@ -73,10 +166,17 @@ var cloudService={
|
|
|
|
|
|
var curingList = await models.cloud_curing.findAll(option);
|
|
|
var parameter='?compilation_id='+compilation_id;
|
|
|
+ //分页计算
|
|
|
var pageData = await getPage(models.cloud_curing,option.where,page,limit,parameter);
|
|
|
|
|
|
|
|
|
-
|
|
|
+ //数据组合--cld客户数据
|
|
|
+ var cid=[];
|
|
|
+ curingList.forEach(function(v,i){
|
|
|
+ cid.push(v.client_id);
|
|
|
+ });
|
|
|
+ var attributes= ['cid', 'clientname', 'companyid', 'companyname'];
|
|
|
+ var clientList = await models.CLD_client.findAllInCid(cid,attributes);
|
|
|
|
|
|
|
|
|
//组合页面需要展示的数据
|
|
@@ -241,7 +341,7 @@ var cloudService={
|
|
|
await models.cloud_curing.update(values,where);
|
|
|
id=curingDetail['id'];
|
|
|
}else{
|
|
|
- sid=hash.hashDecode(STAFF.sid);
|
|
|
+ cc
|
|
|
//获得登陆用户相关信息
|
|
|
var obj = {
|
|
|
mobile: data.mobile,
|