You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.5 KiB

package com.eco.plugin.xx.jlyhsjtb.function;
import com.eco.plugin.xx.jlyhsjtb.config.PluginSimpleConfig;
import com.eco.plugin.xx.jlyhsjtb.controller.ControllerSelf;
import com.eco.plugin.xx.jlyhsjtb.utils.DateUtilSelf;
import com.eco.plugin.xx.jlyhsjtb.utils.FtpUtils;
import com.eco.plugin.xx.jlyhsjtb.utils.IOUtils;
import com.fr.json.JSONArray;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.script.AbstractFunction;
import java.io.File;
import java.util.Date;
@FunctionRecorder
public class AuthFunction extends AbstractFunction {
@Override
public Object run(Object[] objects) {
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
checkUser(psc);
checkOrg(psc);
return "success";
}
private void checkUser(PluginSimpleConfig psc) {
String tody = DateUtilSelf.DateToString(new Date(),"yyyyMMdd");
String url = psc.getFtpurl()+"/"+tody;
String checkFileName = "IAMJ_USER_"+tody+".ok";
File checkFile = FtpUtils.downloadFromLinux(psc.getFtphost(),psc.getFtpport(),psc.getFtpuser(),psc.getFtppsd(),url,checkFileName);
if(checkFile != null && checkFile.exists()){
String dataFileName = "IAMJ_USER_"+tody+".dat";
File dataFile = FtpUtils.downloadFromLinux(psc.getFtphost(),psc.getFtpport(),psc.getFtpuser(),psc.getFtppsd(),url,dataFileName);
String jsonStr = IOUtils.readTxtFile(dataFile);
JSONArray datas = new JSONArray("["+jsonStr+"]");
for(int i=0;i<datas.length();i++){
ControllerSelf.operateUser(datas.getJSONObject(i));
}
}
}
private void checkOrg(PluginSimpleConfig psc) {
String tody = DateUtilSelf.DateToString(new Date(),"yyyyMMdd");
String url = psc.getFtpurl()+"/"+tody;
String checkFileName = "IAMJ_ORG_"+tody+".ok";
File checkFile = FtpUtils.downloadFromLinux(psc.getFtphost(),psc.getFtpport(),psc.getFtpuser(),psc.getFtppsd(),url,checkFileName);
if(checkFile != null && checkFile.exists()){
String dataFileName = "IAMJ_ORG_"+tody+".dat";
File dataFile = FtpUtils.downloadFromLinux(psc.getFtphost(),psc.getFtpport(),psc.getFtpuser(),psc.getFtppsd(),url,dataFileName);
String jsonStr = IOUtils.readTxtFile(dataFile);
JSONArray datas = new JSONArray("["+jsonStr+"]");
for(int i=0;i<datas.length();i++){
ControllerSelf.operateOrg(datas.getJSONObject(i));
}
}
}
}