Compare commits

...

2 Commits
main ... dev

@ -11,7 +11,6 @@ import weaver.docs.docs.ImageFileIdUpdate;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.filter.HttpRequestUtil;
import weaver.interfaces.schedule.BaseCronJob;
import java.io.*;
@ -25,8 +24,7 @@ import java.util.zip.ZipOutputStream;
public class ESiginsCronJob extends BaseCronJob {
@Override
public void execute() {
updateHrmSiginData();
}
public void updateHrmSiginData(){
@ -42,7 +40,7 @@ public class ESiginsCronJob extends BaseCronJob {
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String,String> map = null;
String hrmsql = " select id,loginid,subcompanyid1,workcode from hrmresource where status = 1 and departmentid in(29,30) " ;
String hrmsql = " select id,loginid,subcompanyid1,workcode from hrmresource where status = 1 " ;
bb.writeLog("hrmsql:"+hrmsql);
rs.executeQuery(hrmsql);
while (rs.next()){
@ -69,9 +67,13 @@ public class ESiginsCronJob extends BaseCronJob {
bb.writeLog("list:"+list.size());
ImageFileIdUpdate im = new ImageFileIdUpdate();
HttpRequestUtil HttpRequestUtil = new HttpRequestUtil();
String esignImage = "" ;
// data:image/gif;base64,base64编码的gif图片数据
// data:image/png;base64,base64编码的png图片数据
// data:image/jpeg;base64,base64编码的图片数据
// data:image/x-icon;base64,base64编码的icon图片数据
for(int i=0;i<list.size();i++)
{
Map<String,String> dataMap = list.get(i);
@ -79,19 +81,12 @@ public class ESiginsCronJob extends BaseCronJob {
String sysUserCode = dataMap.get("loginid");
String subcompanyid1 = dataMap.get("subcompanyid1");
String workcode = dataMap.get("workcode");
esiginsUrl += "/"+workcode+"/esigns";
String url = esiginsUrl+ "/"+workcode+"/esigns";
String auth = username + ":" + passwd;
String msg = doPostByAuth(esiginsUrl,"",auth);
try{
String msg = doPostByAuth(url,"",auth);
bb.writeLog("msg2 ==" + msg);
// data:image/gif;base64,base64编码的gif图片数据
// data:image/png;base64,base64编码的png图片数据
// data:image/jpeg;base64,base64编码的图片数据
// data:image/x-icon;base64,base64编码的icon图片数据
if(!"".equals(msg))
if(StringUtils.isNotEmpty(msg))
{
JSONObject jsonObject = JSONObject.parseObject(msg);
String resultCode = jsonObject.getString("resultCode");
@ -114,87 +109,78 @@ public class ESiginsCronJob extends BaseCronJob {
imagetype = "ico";
}
String imageFileType = "application/octet-stream";
String imageName = sysUserCode+"."+imagetype;
String imagefileused = "1";
String iszip = "1";
String secretLevel = "4";
String mainimagefile = "0";
int downloads = 0;
String ftpconfigid = "0";
String isaesencrypt = "0";
String comefrom = sysUserCode;
String marksize = "0";
String markdate = TimeUtil.getCurrentTimeString();
String sealtype = "1" ;
String isdefault = "1";
String filepath = ecology_app_root+"/filesystem/dzyz/"+sysUserCode ;
bb.writeLog("filepath:"+filepath);
File file = new File(filepath);
if(!file.exists()){
file.mkdirs();
}
long currentTime = System.currentTimeMillis();
String imagefilename = DigestUtils.md5Hex(sysUserCode); //MD5加密
//String imageFilePath = filepath+"/"+imagefilename+Util.null2String(currentTime);
String imageFilePath = filepath+"/"+imagefilename;
String image_File_Path = saveImageFile(esignImage,imageFilePath,imagetype);
bb.writeLog("image_File_Path:"+image_File_Path);
if(!"".equals(image_File_Path)){
if(!"".equals(image_File_Path))
{
File imageFile = new File(image_File_Path);
if(imageFile.exists())
{
String imagefilezippath = filepath+"/"+imagefilename+ ".zip";
String image_File_Zip_Path = saveImageFileZip(image_File_Path,imagefilezippath,imagefilename);
bb.writeLog("image_File_Zip_Path:"+image_File_Zip_Path);
if(!"".equals(image_File_Zip_Path)){
if(!"".equals(image_File_Zip_Path))
{
File imageFileZip = new File(image_File_Zip_Path);
if(imageFileZip.exists()){
if(imageFileZip.exists())
{
long filesize = imageFileZip.length();
bb.writeLog("filesize:"+filesize);
long d_filesize = 0 ;
String image_file_id = "" ;
String imgsql = " select imagefileid,filesize from imagefile where filerealpath = ?" ;
rs.executeQuery(imgsql,new Object[]{image_File_Path});
String imagefileid = "" ;
String oldfilerealpath = "" ;
String markid = "" ;
String sql =" select t.markid,t.imagefileid,k.filerealpath\n" +
" from DocSignature t\n" +
" left join imagefile k on k.imagefileid = t.imagefileid\n" +
" where t.isdefault = 1 and t.hrmresid= ?" ;
bb.writeLog("userid:"+userid);
rs.executeQuery(sql,new Object[]{userid});
bb.writeLog("sql:"+sql);
if(rs.next()){
image_file_id = Util.null2String(rs.getString("imagefileid"));
d_filesize = Long.parseLong(Util.null2String(rs.getString("imagefileid")));
oldfilerealpath = Util.null2String(rs.getString("filerealpath"));
imagefileid = Util.null2String(rs.getString("imagefileid"));
markid = Util.null2String(rs.getString("markid"));
}
bb.writeLog("d_filesize:"+d_filesize);
if(!"".equals(image_file_id)){
if(d_filesize != filesize)
{
int imagefileid = im.getImageFileNewId();
String sql = " INSERT INTO imagefile (IMAGEFILEID,IMAGEFILENAME, IMAGEFILETYPE, IMAGEFILEUSED, FILEREALPATH, ISZIP, FILESIZE, DOWNLOADS, FTPCONFIGID, ISAESENCRYPT, COMEFROM, mainimagefile, secretLevel) VALUES " +
" (?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
bb.writeLog("oldfilerealpath:"+oldfilerealpath);
boolean flag = rs.executeUpdate(sql,new Object[]{imagefileid,imageName,imageFileType,imagefileused,image_File_Zip_Path,iszip,filesize,downloads,ftpconfigid,isaesencrypt,comefrom,mainimagefile,secretLevel});
bb.writeLog("sql:"+sql);
if(flag){
sql = " update DocSignature set isdefault = 0 where hrmresid= ?" ;
boolean isUp = rs.executeUpdate(sql,new Object[]{userid});
bb.writeLog("sql:"+sql);
if(isUp){
sql = " insert into DocSignature(hrmresid, markname, marktype, markpath, marksize, markdate, subcompanyid, sealtype, isdefault, imagefileid)\n" +
" values(?,?,?,?,?,?,?,?,?,?)" ;
rs.executeUpdate(sql,new Object[]{userid,sysUserCode,"."+imagetype,image_File_Path,marksize,markdate,subcompanyid1,sealtype,isdefault,imagefileid});
if(StringUtils.isNotEmpty(markid) && StringUtils.isNotEmpty(imagefileid) && StringUtils.isNotEmpty(oldfilerealpath)){
String markdate = TimeUtil.getCurrentTimeString();
sql = " update DocSignature set MARKDATE = ? where MARKID= ?" ;
bb.writeLog("sql:"+sql);
rs.executeUpdate(sql,new Object[]{markdate,markid});
}else{
updateSignature(sysUserCode,imagetype,image_File_Zip_Path,filesize,image_File_Path,subcompanyid1,userid);
}
// if(StringUtils.isEmpty(oldfilerealpath) || StringUtils.isEmpty(imagefileid))
// {
//// File oldFileZip = new File(oldfilerealpath);
//// if(oldFileZip.exists()){
//// long oldfilesize = oldFileZip.length();
//// bb.writeLog("oldfilesize:"+oldfilesize);
////
//// if(oldfilesize != filesize)
//// {
//// updateSignature(sysUserCode,imagetype,image_File_Zip_Path,filesize,image_File_Path,subcompanyid1,userid);
//// }
//// }else{
//// updateSignature(sysUserCode,imagetype,image_File_Zip_Path,filesize,image_File_Path,subcompanyid1,userid);
//// }
// }
}
}
}else{
int imagefileid = im.getImageFileNewId();
String sql = " INSERT INTO imagefile (IMAGEFILEID,IMAGEFILENAME, IMAGEFILETYPE, IMAGEFILEUSED, FILEREALPATH, ISZIP, FILESIZE, DOWNLOADS, FTPCONFIGID, ISAESENCRYPT, COMEFROM, mainimagefile, secretLevel) VALUES " +
" (?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
boolean flag = rs.executeUpdate(sql,new Object[]{imagefileid,imageName,imageFileType,imagefileused,image_File_Zip_Path,iszip,filesize,downloads,ftpconfigid,isaesencrypt,comefrom,mainimagefile,secretLevel});
bb.writeLog("sql:"+sql);
if(flag){
sql = " insert into DocSignature(hrmresid, markname, marktype, markpath, marksize, markdate, subcompanyid, sealtype, isdefault, imagefileid)\n" +
" values(?,?,?,?,?,?,?,?,?,?)" ;
rs.executeUpdate(sql,new Object[]{userid,sysUserCode,"."+imagetype,image_File_Path,marksize,markdate,subcompanyid1,sealtype,isdefault,imagefileid});
bb.writeLog("sql:"+sql);
}
}
}
@ -202,11 +188,68 @@ public class ESiginsCronJob extends BaseCronJob {
}
}
}
}catch (Exception e){
bb.writeLog("e:"+e);
}
}
}
// int imagefileid = im.getImageFileNewId();
// sql = " INSERT INTO imagefile (IMAGEFILEID,IMAGEFILENAME, IMAGEFILETYPE, IMAGEFILEUSED, FILEREALPATH, ISZIP, FILESIZE, DOWNLOADS, FTPCONFIGID, ISAESENCRYPT, COMEFROM, mainimagefile, secretLevel) VALUES " +
// " (?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
//
// boolean flag = rs.executeUpdate(sql,new Object[]{imagefileid,imageName,imageFileType,imagefileused,image_File_Zip_Path,iszip,filesize,downloads,ftpconfigid,isaesencrypt,comefrom,mainimagefile,secretLevel});
// bb.writeLog("sql:"+sql);
// if(flag){
// sql = " update DocSignature set isdefault = 0 where hrmresid= ?" ;
// boolean isUp = rs.executeUpdate(sql,new Object[]{userid});
// bb.writeLog("sql:"+sql);
// if(isUp){
// sql = " insert into DocSignature(hrmresid, markname, marktype, markpath, marksize, markdate, subcompanyid, sealtype, isdefault, imagefileid)\n" +
// " values(?,?,?,?,?,?,?,?,?,?)" ;
// rs.executeUpdate(sql,new Object[]{userid,sysUserCode,"."+imagetype,image_File_Path,marksize,markdate,subcompanyid1,sealtype,isdefault,imagefileid});
// bb.writeLog("sql:"+sql);
// }
// }
public void updateSignature(String sysUserCode,String imagetype,String image_File_Zip_Path,long filesize,String image_File_Path,String subcompanyid1,String userid){
String imageFileType = "application/octet-stream";
String imageName = sysUserCode+"."+imagetype;
String imagefileused = "1";
String iszip = "1";
String secretLevel = "4";
String mainimagefile = "0";
int downloads = 0;
String ftpconfigid = "0";
String isaesencrypt = "0";
String comefrom = sysUserCode;
String marksize = "0";
String markdate = TimeUtil.getCurrentTimeString();
String sealtype = "1" ;
String isdefault = "1";
ImageFileIdUpdate im = new ImageFileIdUpdate();
RecordSet rs = new RecordSet();
BaseBean bb = new BaseBean();
int imagefileid = im.getImageFileNewId();
String sql = " INSERT INTO imagefile (IMAGEFILEID,IMAGEFILENAME, IMAGEFILETYPE, IMAGEFILEUSED, FILEREALPATH, ISZIP, FILESIZE, DOWNLOADS, FTPCONFIGID, ISAESENCRYPT, COMEFROM, mainimagefile, secretLevel) VALUES " +
" (?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
boolean flag = rs.executeUpdate(sql,new Object[]{imagefileid,imageName,imageFileType,imagefileused,image_File_Zip_Path,iszip,filesize,downloads,ftpconfigid,isaesencrypt,comefrom,mainimagefile,secretLevel});
bb.writeLog("sql:"+sql);
if(flag){
sql = " update DocSignature set isdefault = 0 where hrmresid= ?" ;
boolean isUp = rs.executeUpdate(sql,new Object[]{userid});
bb.writeLog("sql:"+sql);
if(isUp){
sql = " insert into DocSignature(hrmresid, markname, marktype, markpath, marksize, markdate, subcompanyid, sealtype, isdefault, imagefileid)\n" +
" values(?,?,?,?,?,?,?,?,?,?)" ;
rs.executeUpdate(sql,new Object[]{userid,sysUserCode,"."+imagetype,image_File_Path,marksize,markdate,subcompanyid1,sealtype,isdefault,imagefileid});
bb.writeLog("sql:"+sql);
}
}
}
@ -246,6 +289,9 @@ public class ESiginsCronJob extends BaseCronJob {
}
/***
*
* @param imagefilepath
@ -319,7 +365,7 @@ public class ESiginsCronJob extends BaseCronJob {
* @param dataJson
* @return
*/
public static String doPostByAuth(String esiginsUrl, String dataJson, String auth){
public String doPostByAuth(String esiginsUrl, String dataJson, String auth){
BaseBean bb = new BaseBean();
String authorization = "Basic "+new String(Base64.encode(auth));
@ -339,21 +385,25 @@ public class ESiginsCronJob extends BaseCronJob {
try {
Response response = client.newCall(request).execute();
bb.writeLog("response.code():"+response.code());
bb.writeLog("response.body():"+response.body().string());
//bb.writeLog("response.body():"+response.body().string());
msgData = response.body().string();
} catch (IOException e) {
e.printStackTrace();
bb.writeLog("e2:"+e);
}
bb.writeLog("msgData:"+msgData);
return msgData;
}
public static void main(String[] args) {
ESiginsCronJob ESiginsCronJob = new ESiginsCronJob();
String username = "admin";
String passwd = "Uportal_123";
String esiginsUrl = "http://172.16.25.133/portal-web/v1/esign/Forest/esigns" ;
String auth = username + ":" + passwd;
String msg = doPostByAuth(esiginsUrl,"",auth);
String msg = ESiginsCronJob.doPostByAuth(esiginsUrl,"",auth);
System.out.println(msg);
}

Loading…
Cancel
Save