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

1138 lines
53 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/**
* @use入职管理-待报道-同步nc入职人员基本信息--其他
* @author 刘浩
*
* 其他人员入职同步NCC
* 8
*/
package com.weaver.seconddev.sxjg.esb;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.ebuilder.common.exception.BusinessException;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.eteams.file.client.file.FileData;
import com.weaver.file.ud.api.FileDownloadService;
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfig;
import com.weaver.seconddev.sxjg.config.EbDbDataSourceConfigResp;
import com.weaver.seconddev.sxjg.util.NccApiUtil;
import com.weaver.seconddev.sxjg.util.NccResultUtil;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.io.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("esb_applypositiontonccqt_howe")
public class ApplyPositionToNccQt implements EsbServerlessRpcRemoteInterface {
private static final Logger log = LoggerFactory.getLogger(ApplyPositionToNccQt.class);
private JdbcTemplate jdbcTemplate = new JdbcTemplate(EbDbDataSourceConfig.dbDataSource());
private JdbcTemplate jdbcTemplateresp = new JdbcTemplate(EbDbDataSourceConfigResp.dbDataSource());
private String b1;
private String b2;
private String b3;
private String b4;
private String b5;
private String b6;
private String b7;
private String b8;
private String b9;
private String b10;
private String b11;
public ApplyPositionToNccQt() {
PropertiesConfiguration p = null;
try {
p = new PropertiesConfiguration();
p.setEncoding("utf-8");
p.setFileName("config/nccconfig.properties");
p.load();
this.b1 = p.getString("sxjgncc.b1");
this.b2 = p.getString("sxjgncc.b2");
this.b3 = p.getString("sxjgncc.b3");
this.b4 = p.getString("sxjgncc.b4");
this.b5 = p.getString("sxjgncc.b5");
this.b6 = p.getString("sxjgncc.b6");
this.b7 = p.getString("sxjgncc.b7");
this.b8 = p.getString("sxjgncc.b8");
this.b9 = p.getString("sxjgncc.b9");
this.b10 = p.getString("sxjgncc.b10");
this.b11 = p.getString("sxjgncc.b11");
}catch (ConfigurationException e) {
throw new BusinessException("获取sxjg.properties配置文件失败", e);
}
}
@Autowired
private FileDownloadService fileDownloadService;
@Override
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
Map<String, Object> finresult = new HashMap<>();
finresult.put("code",200);
String rzid = (String) params.get("rzid");//姓名
String name = (String) params.get("name");//姓名
String idtype = (String) params.get("idtype");//证件类型
String id = (String) params.get("id");//证件号码
String pk_org = (String) params.get("pk_org");//所属组织
String sex = (String) params.get("sex");
String birthdate = (String) params.get("birthdate");
String nativeplace = (String) params.get("nativeplace");
String characterrpr = (String) params.get("characterrpr");
String nationality = (String) params.get("nationality");
String polity = (String) params.get("polity");
String health = (String) params.get("health");
String marital = (String) params.get("marital");
String joinworkdate = (String) params.get("joinworkdate");
String mobile = (String) params.get("mobile");
String email = (String) params.get("email");
String bloodtype = (String) params.get("bloodtype");
String usedname = (String) params.get("usedname");
String fileaddress = (String) params.get("fileaddress");
String glbdef6 = (String) params.get("glbdef6");
// String partyname = (String) params.get("partyname");
// String partydate = (String) params.get("partydate");
// String partyunit = (String) params.get("partyunit");
// String partypsn = (String) params.get("partypsn");
// String partyduedate = (String) params.get("partyduedate");
// String glbdef1 = (String) params.get("glbdef1");
String pk_org_work = (String) params.get("pk_org_work");
String pk_psncl_work = (String) params.get("pk_psncl_work");
String pk_dept_work = (String) params.get("pk_dept_work");
String pk_post_work = (String) params.get("pk_post_work");
String pk_postseries_work = (String) params.get("pk_postseries_work");
String pk_job_work = (String) params.get("pk_job_work");
String pk_jobgrade_work = (String) params.get("pk_jobgrade_work");
String begindate_work = (String) params.get("begindate_work");
String collectid = (String) params.get("collectid");
String ygxs = (String)params.get("ygxs");
String rdtrq = (String)params.get("rdtrq");//入党团日期
if (collectid == null || collectid.length() == 0) {
finresult.put("code",500);
finresult.put("msg","当前人员并未进行信息采集");
return WeaResult.success(finresult);
}
String sql = "select ncc_pk from ft_ncczjlx where ncc_name = '"+idtype+"'";
Map<String, Object> srrr = jdbcTemplateresp.queryForMap(sql);
String idtypePk =(String) srrr.get("ncc_pk");
JSONObject result = new JSONObject();
JSONArray data = new JSONArray();
JSONArray bd_psndoc = new JSONArray();//人员基本信息
JSONObject bd_psndoc_obj = new JSONObject();
JSONArray hi_psnorg = new JSONArray();//组织关系
JSONObject hi_psnorg_obj = new JSONObject();
JSONArray hi_psnjob = new JSONArray();//工作记录
JSONObject hi_psnjob_obj = new JSONObject();
bd_psndoc_obj.put("name", name);
bd_psndoc_obj.put("idtype", idtype);
bd_psndoc_obj.put("id", id);
bd_psndoc_obj.put("pk_org", pk_org);
sex = "male".equals(sex) ? "1" : "2";
bd_psndoc_obj.put("sex", sex);
bd_psndoc_obj.put("birthdate", data10str(birthdate));
bd_psndoc_obj.put("nativeplace", nativeplace);
bd_psndoc_obj.put("characterrpr", characterrpr);
bd_psndoc_obj.put("nationality", nationality);
bd_psndoc_obj.put("polity", polity);
bd_psndoc_obj.put("health", health);
bd_psndoc_obj.put("marital", marital);
bd_psndoc_obj.put("joinworkdate", data10str(joinworkdate));
bd_psndoc_obj.put("mobile", mobile);
bd_psndoc_obj.put("email", email);
bd_psndoc_obj.put("bloodtype", bloodtype);
bd_psndoc_obj.put("usedname", usedname);
bd_psndoc_obj.put("fileaddress", fileaddress);
bd_psndoc_obj.put("glbdef6", glbdef6);
bd_psndoc_obj.put("joinpolitydate",rdtrq);
bd_psndoc.add(bd_psndoc_obj);
hi_psnorg_obj.put("begindate", data10str(begindate_work));
if(ygxs.contains("其他")) {
hi_psnorg_obj.put("indocflag", "Y");
}else {
hi_psnorg_obj.put("indocflag", "N");
}
hi_psnorg.add(hi_psnorg_obj);
hi_psnjob_obj.put("pk_org", pk_org_work);
hi_psnjob_obj.put("pk_psncl", pk_psncl_work);
hi_psnjob_obj.put("pk_dept", pk_dept_work);
hi_psnjob_obj.put("pk_post", pk_post_work);
hi_psnjob_obj.put("pk_postseries", pk_postseries_work);
hi_psnjob_obj.put("pk_job", pk_job_work);
hi_psnjob_obj.put("pk_jobgrade", pk_jobgrade_work);
hi_psnjob_obj.put("begindate", data10str(begindate_work));
hi_psnjob.add(hi_psnjob_obj);
JSONArray hi_psndoc_work = getWorkRecord(collectid);
JSONArray hi_psndoc_edu = getEduInfoRecord(collectid);
JSONArray hi_psndoc_family = getFamilyInfoRecord(collectid);
JSONArray hi_psndoc_linkman =getJjchatInfoRecord(collectid);
JSONArray hi_psndoc_title = getPsTitleInfoRecord(collectid);
JSONArray hi_psndoc_nationdyty = getNationdutInfoRecord(collectid);
JSONArray hi_psndoc_glbdef1 = getGlbdef1InfoRecord(collectid);
JSONArray hi_psndoc_part = getPartInfoRecord(collectid);
JSONArray hi_psndoc_enc =getEncInfoRecord(collectid);
JSONArray hi_psndoc_glbdef3 =getGlbdef3InfoRecord(collectid);
JSONArray hi_psndoc_glbdef2 =getGlbdef2InfoRecord(collectid);
// JSONArray hi_psndoc_partylog = new JSONArray();
// JSONObject hi_psndoc_partylog_obj = new JSONObject();
// hi_psndoc_partylog_obj.put("partyname",partyname);
// hi_psndoc_partylog_obj.put("partydate",data10str(partydate));
// hi_psndoc_partylog_obj.put("partyunit",partyunit);
// hi_psndoc_partylog_obj.put("partypsn",partypsn);
// hi_psndoc_partylog_obj.put("partyduedate",data10str(partyduedate));
// hi_psndoc_partylog_obj.put("glbdef1",glbdef1);
// hi_psndoc_partylog.add(hi_psndoc_partylog_obj);
JSONObject x1 = new JSONObject();
x1.put("bd_psndoc",bd_psndoc);
x1.put("hi_psnorg",hi_psnorg);
x1.put("hi_psnjob",hi_psnjob);
x1.put("hi_psndoc_work",hi_psndoc_work);
x1.put("hi_psndoc_edu",hi_psndoc_edu);
x1.put("hi_psndoc_family",hi_psndoc_family);
x1.put("hi_psndoc_linkman",hi_psndoc_linkman);
x1.put("hi_psndoc_title",hi_psndoc_title);
x1.put("hi_psndoc_nationdyty",hi_psndoc_nationdyty);
x1.put("hi_psndoc_glbdef1",hi_psndoc_glbdef1);
// x1.put("hi_psndoc_part",hi_psndoc_part);
x1.put("hi_psndoc_enc",hi_psndoc_enc);
x1.put("hi_psndoc_glbdef3",hi_psndoc_glbdef3);
x1.put("hi_psndoc_glbdef2",hi_psndoc_glbdef2);
x1.put("hi_psndoc_partylog",hi_psndoc_part);
data.add(x1);
result.put("data",data);
try {
NccApiUtil nccApiUtil = new NccApiUtil();
nccApiUtil.init();
String token = nccApiUtil.getToken();
String url = nccApiUtil.getBaseUrl()+"nccloud/api/hrhi/openAPI/personnelSync/entry";
String rs11 = nccApiUtil.doJsonPost(url,token,result.toJSONString());
NccResultUtil rs = new NccResultUtil(rs11);
if(rs.getResult()) {
//传附件
log.error("howec:::::::传附件");
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("id",id);
jsonObject2.put("idtype",idtypePk);
JSONArray r11 = getFjByCollectId(collectid);
if(r11.size() == 0) {
sql = "update uf_rcrt_entry_manage_qtry set entry_status = '1' where id = "+rzid;
jdbcTemplate.execute(sql);
return WeaResult.success(finresult);
}
jsonObject2.put("data",r11);
nccApiUtil = new NccApiUtil();
nccApiUtil.init();
token = nccApiUtil.getToken();
url = nccApiUtil.getBaseUrl()+"nccloud/api/hrhi/openAPI/attachment/upload";
rs11 = nccApiUtil.doJsonPost(url,token,jsonObject2.toJSONString());
rs = new NccResultUtil(rs11);
if(rs.getResult()){
//更新入职状态未已入职
sql = "update uf_rcrt_entry_manage_qtry set entry_status = '1' where id = "+rzid;
jdbcTemplate.execute(sql);
return WeaResult.success(finresult);
}else {
//更新附件同步异常
sql = "update uf_rcrt_entry_manage_qtry set fjtbsfyc = '2' where id = "+rzid;
jdbcTemplate.execute(sql);
finresult.put("code",500);
finresult.put("msg",rs.getDescription());
return WeaResult.success(finresult);
}
}else {
finresult.put("code",500);
finresult.put("msg",rs.getDescription());
return WeaResult.success(finresult);
}
}catch (Exception e){
e.printStackTrace();
finresult.put("code",500);
finresult.put("msg",e.getMessage());
log.error("howec:::::::::1:"+e.getMessage());
return WeaResult.success(finresult);
}
}
//获取履历记录数组 表:b2
private JSONArray getWorkRecord(String collectid) {
JSONArray hi_psndoc_work = new JSONArray();
String sql = "select id,start_date,end_date,company,workdept,workjob,job_name,memo from "+b2+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_work_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null) {
rs1.put(key,"");
}
});
String start_date = (String) rs1.get("start_date");
String end_date = (String) rs1.get("end_date");
String company = (String) rs1.get("company");
String workdept = (String) rs1.get("workdept");
String workjob = (String) rs1.get("workjob");
String job_name = (String) rs1.get("job_name");
String memo = (String) rs1.get("memo");
hi_psndoc_work_obj.put("begindate", start_date);
hi_psndoc_work_obj.put("workcorp", company);
hi_psndoc_work_obj.put("enddate", end_date);
hi_psndoc_work_obj.put("workdept", workdept);
hi_psndoc_work_obj.put("workjob", workjob);
hi_psndoc_work_obj.put("workpost", job_name);
hi_psndoc_work_obj.put("memo", memo);
hi_psndoc_work.add(hi_psndoc_work_obj);
}
}
return hi_psndoc_work;
}
//获取学历信息数组b1
private JSONArray getEduInfoRecord(String collectid) {
JSONArray hi_psndoc_edu = new JSONArray();
String sql = "select data_start,data_end,education,dnxl,school_name,emp_major,xz,xxfs,xw,xwsyrq,xwsydw,xlzsbh,xwzsbh,zgxl from "+b1+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_edu_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!key.equals("zgxl"))) {
rs1.put(key,"");
}
});
String data_start = (String) rs1.get("data_start");
String data_end = (String) rs1.get("data_end");
String education = (String) rs1.get("education");
String dnxl = (String) rs1.get("dnxl");
String school_name = (String) rs1.get("school_name");
String emp_major = (String) rs1.get("emp_major");
String xz = (String) rs1.get("xz");
String xxfs = (String) rs1.get("xxfs");
String xw = (String) rs1.get("xw");
String xwsyrq = (String) rs1.get("xwsyrq");
String xwsydw = (String) rs1.get("xwsydw");
String xlzsbh = (String) rs1.get("xlzsbh");
String xwzsbh = (String) rs1.get("xwzsbh");
String zgxl = "N";
if(rs1.get("zgxl") != null) {
long zgxl1 = (long) rs1.get("zgxl");
zgxl = zgxl1 == 1l ? "Y" : "N";
}
List<String>ids = new ArrayList<>();
ids.add(education);
ids.add(dnxl);
ids.add(xxfs);
ids.add(xw);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_edu_obj.put("begindate",data_start);
hi_psndoc_edu_obj.put("education",rsmap.get(education));
hi_psndoc_edu_obj.put("enddate",data_end);
hi_psndoc_edu_obj.put("school",school_name);
hi_psndoc_edu_obj.put("major",emp_major);
hi_psndoc_edu_obj.put("edusystem",xz);
hi_psndoc_edu_obj.put("studymode",rsmap.get(xxfs));
hi_psndoc_edu_obj.put("pk_degree",rsmap.get(xw));
hi_psndoc_edu_obj.put("degreedate",xwsyrq);
hi_psndoc_edu_obj.put("degreeunit",xwsydw);
hi_psndoc_edu_obj.put("educationctifcode",xlzsbh);
hi_psndoc_edu_obj.put("certifcode",xwzsbh);
hi_psndoc_edu_obj.put("lasteducation",zgxl);
hi_psndoc_edu_obj.put("glbdef1",rsmap.get(dnxl));
hi_psndoc_edu.add(hi_psndoc_edu_obj);
}
}
return hi_psndoc_edu;
}
//家庭信息数组b4
private JSONArray getFamilyInfoRecord(String collectid) {
JSONArray hi_psndoc_family = new JSONArray();
String sql = "select ybrgx,jtcyxm,sfzh,csrq,gzdw,zw,lxdh,zzmm,xl from "+b4+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_family_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null) {
rs1.put(key,"");
}
});
String ybrgx = (String) rs1.get("ybrgx");
String jtcyxm = (String) rs1.get("jtcyxm");
String sfzh = (String) rs1.get("sfzh");
String csrq = (String) rs1.get("csrq");
String gzdw = (String) rs1.get("gzdw");
String zw = (String) rs1.get("zw");
String lxdh = (String) rs1.get("lxdh");
String zzmm = (String) rs1.get("zzmm");
String xl = (String) rs1.get("xl");
List<String>ids = new ArrayList<>();
ids.add(ybrgx);
ids.add(zzmm);
ids.add(xl);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_family_obj.put("mem_relation",rsmap.get(ybrgx));
hi_psndoc_family_obj.put("mem_name",jtcyxm);
hi_psndoc_family_obj.put("mem_birthday",csrq);
hi_psndoc_family_obj.put("mem_corp",gzdw);
hi_psndoc_family_obj.put("mem_job",zw);
hi_psndoc_family_obj.put("relaphone",lxdh);
hi_psndoc_family_obj.put("politics",rsmap.get(zzmm));
hi_psndoc_family_obj.put("glbdef1",rsmap.get(xl));
hi_psndoc_family_obj.put("glbdef2",sfzh);
hi_psndoc_family.add(hi_psndoc_family_obj);
}
}
return hi_psndoc_family;
}
//紧急联系人 b3
private JSONArray getJjchatInfoRecord(String collectid) {
JSONArray hi_psndoc_linkman = new JSONArray();
String sql = "select linkman,mobile from "+b3+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_linkman_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null) {
rs1.put(key,"");
}
});
String linkman = (String) rs1.get("linkman");
String mobile = (String) rs1.get("mobile");
hi_psndoc_linkman_obj.put("linkman",linkman);
hi_psndoc_linkman_obj.put("mobile",mobile);
hi_psndoc_linkman.add(hi_psndoc_linkman_obj);
}
}
return hi_psndoc_linkman;
}
//hi_psndoc_title 职称信息 b5
private JSONArray getPsTitleInfoRecord(String collectid) {
JSONArray hi_psndoc_title = new JSONArray();
String sql = "select hdzc,pdrq,zcdj,zymc,pdjg,zsbh,zgzc,fzsj,pzwh from "+b5+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_title_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"zgzc".equals(key))) {
rs1.put(key,"");
}
});
String hdzc = (String) rs1.get("hdzc");
String pdrq = (String) rs1.get("pdrq");
String zcdj = (String) rs1.get("zcdj");
String zymc = (String) rs1.get("zymc");
String pdjg = (String) rs1.get("pdjg");
String zsbh = (String) rs1.get("zsbh");
String zgzc1 = "N";
String fzsj = (String) rs1.get("fzsj");
String pzwh = (String) rs1.get("pzwh");
if(rs1.get("zgzc")!=null) {
long zgzc = (long) rs1.get("zgzc");
zgzc1 = zgzc == 0l ? "N":"Y";
}
List<String>ids = new ArrayList<>();
ids.add(hdzc);
ids.add(zcdj);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_title_obj.put("begindate",pdrq);
hi_psndoc_title_obj.put("pk_techposttitle",rsmap.get(hdzc));
hi_psndoc_title_obj.put("titlerank",rsmap.get(zcdj));
hi_psndoc_title_obj.put("assorg",pdjg);
hi_psndoc_title_obj.put("certifcode",zsbh);
hi_psndoc_title_obj.put("tiptop_flag",zgzc1);
hi_psndoc_title_obj.put("glbdef1",zymc);
hi_psndoc_title_obj.put("glbdef5",pzwh);
hi_psndoc_title_obj.put("glbdef2",fzsj);
hi_psndoc_title.add(hi_psndoc_title_obj);
}
}
return hi_psndoc_title;
}
//hi_psndoc_nationdyty 获取职称资格 b6
private JSONArray getNationdutInfoRecord(String collectid) {
JSONArray hi_psndoc_nationdyty = new JSONArray();
String sql = "select zyzgdj,zygz,zsbh,pdjg,hdrq,zgzyzg from "+b6+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_nationdyty_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"zgzyzg".equals(key))) {
rs1.put(key,"");
}
});
String zyzgdj = (String) rs1.get("zyzgdj");
String zygz = (String) rs1.get("zygz");
String zsbh = (String) rs1.get("zsbh");
String pdjg = (String) rs1.get("pdjg");
String hdrq = (String) rs1.get("hdrq");
String zgzyzg1 = "N";
if(rs1.get("zgzyzg")!=null) {
long zgzyzg = (long) rs1.get("zgzyzg");
zgzyzg1 = zgzyzg == 0l ? "N":"Y";
}
List<String>ids = new ArrayList<>();
ids.add(zyzgdj);
ids.add(zygz);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_nationdyty_obj.put("workdate",hdrq);
hi_psndoc_nationdyty_obj.put("certificatenum",zsbh);
hi_psndoc_nationdyty_obj.put("worklevel",rsmap.get(zyzgdj));
hi_psndoc_nationdyty_obj.put("occuptype",rsmap.get(zygz));
hi_psndoc_nationdyty_obj.put("workunitname",pdjg);
hi_psndoc_nationdyty_obj.put("istop",zgzyzg1);
hi_psndoc_nationdyty.add(hi_psndoc_nationdyty_obj);
}
}
return hi_psndoc_nationdyty;
}
//hi_psndoc_glbdef1 获取职业资格注册 b7
private JSONArray getGlbdef1InfoRecord(String collectid) {
JSONArray hi_psndoc_glbdef1 = new JSONArray();
String sql = "select zyzgmc,zyzgmcjzy,zyzgzsbh,zgzpzrq,zcbh,sfbqyzc,zgzjzrq,zxyzyjmc,zxyjzrq,zxezyjmc,zxejzrq,zxszyjmc,zxsjzrq,zxsizyjmc,zxsijzrq,zxwzyjmc,zxwjzrq,bz from "+b7+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_glbdef1_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"sfbqyzc".equals(key))) {
rs1.put(key,"");
}
});
String zyzgmc = (String) rs1.get("zyzgmc");//职业资格名称
String zyzgmcjzy = (String) rs1.get("zyzgmcjzy");//职业资格名称及专业
String zyzgzsbh = (String) rs1.get("zyzgzsbh");//职业资格证书编号
String zgzpzrq = (String) rs1.get("zgzpzrq");//格证批准日期
String zcbh = (String) rs1.get("zcbh");// 注册编号
long sfbqyzc1 = 0l;
if(rs1.get("sfbqyzc") != null) {
sfbqyzc1 = (long) rs1.get("sfbqyzc");//是否本企业注册
}
String zgzjzrq = (String) rs1.get("zgzjzrq");//资格证截止日期
String zxyzyjmc = (String) rs1.get("zxyzyjmc");//增项一专业及名称
String zxyjzrq = (String) rs1.get("zxyjzrq");//增项一截止日期
String zxezyjmc = (String) rs1.get("zxezyjmc");//增项二专业及名称
String zxejzrq = (String) rs1.get("zxejzrq");//增项二截止日期
String zxszyjmc = (String) rs1.get("zxszyjmc");//增项三专业及名称
String zxsjzrq = (String) rs1.get("zxsjzrq");//增项三截止日期
String zxsizyjmc = (String) rs1.get("zxsizyjmc");// 增项四专业及名称
String zxsijzrq = (String) rs1.get("zxsijzrq");//项四截止日期
String zxwzyjmc = (String) rs1.get("zxwzyjmc");// 增项五专业及名称
String zxwjzrq = (String) rs1.get("zxwjzrq");// 增项五截止日期
String bz = (String) rs1.get("bz");//备注
List<String>ids = new ArrayList<>();
ids.add(zyzgmc);
ids.add(zyzgmcjzy);
ids.add(zxyzyjmc);
ids.add(zxezyjmc);
ids.add(zxszyjmc);
ids.add(zxsizyjmc);
ids.add(zxwzyjmc);
Map<String,String> rsmap = getNameById(ids);
String sfbqyzc = sfbqyzc1 == 0l ? "N":"Y";
hi_psndoc_glbdef1_obj.put("glbdef1",rsmap.get(zyzgmc));//职业资格名称
hi_psndoc_glbdef1_obj.put("glbdef2",rsmap.get(zyzgmcjzy));//职业资格名称及专业
hi_psndoc_glbdef1_obj.put("glbdef3",zyzgzsbh);//职业资格证书编号
hi_psndoc_glbdef1_obj.put("glbdef4",zgzpzrq);//资格证批准日期
hi_psndoc_glbdef1_obj.put("glbdef5",zcbh);//注册编号
hi_psndoc_glbdef1_obj.put("glbdef6",sfbqyzc);//是否本企业注册
hi_psndoc_glbdef1_obj.put("glbdef7",zgzjzrq);//注册证书有效时间
hi_psndoc_glbdef1_obj.put("glbdef8",rsmap.get(zxyzyjmc));//增项一专业及名称
hi_psndoc_glbdef1_obj.put("glbdef9",zxyjzrq);//增项一截止日期
hi_psndoc_glbdef1_obj.put("glbdef10",rsmap.get(zxezyjmc));//增项二专业及名称
hi_psndoc_glbdef1_obj.put("glbdef11",zxejzrq);//增项二截止日期
hi_psndoc_glbdef1_obj.put("glbdef12",rsmap.get(zxszyjmc));//增项三专业及名称
hi_psndoc_glbdef1_obj.put("glbdef13",zxsjzrq);//增项三截止日期
hi_psndoc_glbdef1_obj.put("glbdef14",rsmap.get(zxsizyjmc));//增项四专业及名称
hi_psndoc_glbdef1_obj.put("glbdef15",zxsijzrq);//增项四截止日期
hi_psndoc_glbdef1_obj.put("glbdef16",rsmap.get(zxwzyjmc));//增项五专业及名称
hi_psndoc_glbdef1_obj.put("glbdef17",zxwjzrq);//增项五截止日期
hi_psndoc_glbdef1_obj.put("glbdef19",bz);//备注
hi_psndoc_glbdef1.add(hi_psndoc_glbdef1_obj);
}
}
return hi_psndoc_glbdef1;
}
//hi_psndoc_part 获取参加党派记 b11
private JSONArray getPartInfoRecord(String collectid) {
JSONArray hi_psndoc_part = new JSONArray();
String sql = "select partyname,partydate,partyunit,partypsn,zzsj,bz from "+b11+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_part_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"sfbqyzc".equals(key))) {
rs1.put(key,"");
}
});
String partyname = (String) rs1.get("partyname");
String partydate = (String) rs1.get("partydate");
String partyunit = (String) rs1.get("partyunit");
String partypsn = (String) rs1.get("partypsn");
String zzsj = (String) rs1.get("zzsj");
String bz = (String) rs1.get("bz");
List<String>ids = new ArrayList<>();
ids.add(partyname);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_part_obj.put("partyname",rsmap.get(partyname));
hi_psndoc_part_obj.put("partydate",partydate);
hi_psndoc_part_obj.put("partyunit",partyunit);
hi_psndoc_part_obj.put("partypsn",partypsn);
hi_psndoc_part_obj.put("partyduedate",zzsj);//转正时间
hi_psndoc_part_obj.put("glbdef1",bz);//备注
hi_psndoc_part.add(hi_psndoc_part_obj);
}
}
return hi_psndoc_part;
}
//hi_psndoc_enc 获取奖励情况记录 b10
private JSONArray getEncInfoRecord(String collectid) {
JSONArray hi_psndoc_enc = new JSONArray();
String sql = "select jlrq,jllx,jljg,jlcs,jlsy,jllb from "+b10+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_enc_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"sfbqyzc".equals(key))) {
rs1.put(key,"");
}
});
String jlrq = (String) rs1.get("jlrq");
String jllx = (String) rs1.get("jllx");
String jljg = (String) rs1.get("jljg");
String jlcs = (String) rs1.get("jlcs");
String jlsy = (String) rs1.get("jlsy");
String jllb = (String) rs1.get("jllb");
List<String>ids = new ArrayList<>();
ids.add(jllb);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_enc_obj.put("encourdate",jlrq);
hi_psndoc_enc_obj.put("encourtype",jllx);
hi_psndoc_enc_obj.put("encourorg",jljg);
hi_psndoc_enc_obj.put("encourmeas",jlcs);
hi_psndoc_enc_obj.put("encourmatter",jlsy);
hi_psndoc_enc_obj.put("glbdef1",rsmap.get(jllb));
hi_psndoc_enc.add(hi_psndoc_enc_obj);
}
}
return hi_psndoc_enc;
}
//hi_psndoc_glbdef3 安全生产考核证 b9
private JSONArray getGlbdef3InfoRecord(String collectid) {
JSONArray hi_psndoc_glbdef3 = new JSONArray();
String sql = "select aqsckhzmc,fzsj,zsbh,yxq,bz from "+b9+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_glbdef3_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"sfbqyzc".equals(key))) {
rs1.put(key,"");
}
});
String aqsckhzmc = (String) rs1.get("aqsckhzmc");
String fzsj = (String) rs1.get("fzsj");
String zsbh = (String) rs1.get("zsbh");
String yxq = (String) rs1.get("yxq");
String bz = (String) rs1.get("bz");
List<String>ids = new ArrayList<>();
ids.add(aqsckhzmc);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_glbdef3_obj.put("glbdef1",rsmap.get(aqsckhzmc));
hi_psndoc_glbdef3_obj.put("glbdef2",fzsj);
hi_psndoc_glbdef3_obj.put("glbdef3",yxq);
hi_psndoc_glbdef3_obj.put("glbdef4",zsbh);
hi_psndoc_glbdef3_obj.put("glbdef5",bz);
hi_psndoc_glbdef3.add(hi_psndoc_glbdef3_obj);
}
}
return hi_psndoc_glbdef3;
}
//hi_psndoc_glbdef2 岗位证书 b8
private JSONArray getGlbdef2InfoRecord(String collectid) {
JSONArray hi_psndoc_glbdef2 = new JSONArray();
String sql = "select gwzsmc,zsbh,zsqdsj,zsfjsj,bz from "+b8+" where is_delete = '0' and form_data_id = '" + collectid + "'";
List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
if (CollectionUtil.isNotEmpty(rs)) {
for (int i = 0; i < rs.size(); i++) {
JSONObject hi_psndoc_glbdef2_obj = new JSONObject();
Map<String, Object> rs1 = rs.get(i);
rs1.forEach((key, value) -> {
if(value == null && (!"sfbqyzc".equals(key))) {
rs1.put(key,"");
}
});
String gwzsmc = (String) rs1.get("gwzsmc");
String zsbh = (String) rs1.get("zsbh");
String zsqdsj = (String) rs1.get("zsqdsj");
String zsfjsj = (String) rs1.get("zsfjsj");
String bz = (String) rs1.get("bz");
List<String>ids = new ArrayList<>();
ids.add(gwzsmc);
Map<String,String> rsmap = getNameById(ids);
hi_psndoc_glbdef2_obj.put("glbdef1",rsmap.get(gwzsmc));
hi_psndoc_glbdef2_obj.put("glbdef2",zsbh);
hi_psndoc_glbdef2_obj.put("glbdef3",zsqdsj);
hi_psndoc_glbdef2_obj.put("glbdef4",zsfjsj);
hi_psndoc_glbdef2_obj.put("glbdef5",bz);
hi_psndoc_glbdef2.add(hi_psndoc_glbdef2_obj);
}
}
return hi_psndoc_glbdef2;
}
/**
* 根据id获取名称
*/
private Map<String,String> getNameById(List<String> ids2) {
List<String>ids = new ArrayList<>();
if(CollectionUtil.isNotEmpty(ids2)) {
for(String f : ids2) {
if(f.length()>0) {
ids.add(f);
}
}
}
Map<String,String> result = new HashMap<>();
String s1 = ids.stream().collect(Collectors.joining(","));
for(int i = 0;i<ids.size();i++) {
String s = ids.get(i);
result.put(s,"");//初始化
}
String sql = "select id,ncc_name from ft_nccda where id in ("+s1+")";
List<Map<String, Object>> rs = jdbcTemplateresp.queryForList(sql);
for(int x = 0;x<rs.size();x++) {
Map<String, Object> map = rs.get(x);
BigDecimal id = (BigDecimal)map.get("id");
String ncc_name = (String)map.get("ncc_name");
result.put(id.toString(),ncc_name);
}
return result;
}
private static String data10str(String s) {
if(s.length()>10 && s.contains("-")) {
String f = s.substring(0,10);
return f;
}else {
return s;
}
}
private JSONArray getFjByCollectId(String collectid) {
JSONArray array1 = new JSONArray();
String sql = "select dyxlxlzxwz,dexlxlzxwz,dsxlxlzxwz,dsixlxlzxwz,gwz,zcz,zyzgz,aqsckhz,jqmgzp,sfzzp from uf_rcrt_entry_collect_qtry where id = "+collectid;
Map<String, Object> map = jdbcTemplate.queryForMap(sql);
String dyxlxlzxwz = map.get("dyxlxlzxwz") == null ? "0" : (String)map.get("dyxlxlzxwz");
String dexlxlzxwz = map.get("dexlxlzxwz") == null ? "0" : (String)map.get("dexlxlzxwz");
String dsxlxlzxwz = map.get("dsxlxlzxwz") == null ? "0" : (String)map.get("dsxlxlzxwz");
String dsixlxlzxwz = map.get("dsixlxlzxwz") == null ? "0" : (String)map.get("dsixlxlzxwz");
String gwz = map.get("gwz") == null ? "0" : (String)map.get("gwz");
String zcz = map.get("zcz") == null ? "0" : (String)map.get("zcz");
String zyzgz = map.get("zyzgz") == null ? "0" : (String)map.get("zyzgz");
String aqsckhz = map.get("aqsckhz") == null ? "0" : (String)map.get("aqsckhz");
String sfzzp = map.get("sfzzp") == null ? "0" : (String)map.get("sfzzp");
String jqmgzp = map.get("jqmgzp") == null ? "0" : (String)map.get("jqmgzp");
List<FileData> file1 = getDxDt(dyxlxlzxwz);//第一学历学历证学位证
List<FileData> file2 =getDxDt(dexlxlzxwz);//第二学历学历证学位证
List<FileData> file3 = getDxDt(dsxlxlzxwz);//第三学历学历证学位证
List<FileData> file4 = getDxDt(dsixlxlzxwz);//第四学历学历证学位证
List<FileData> file5 = getDxDt(gwz);//岗位证
List<FileData> file6 = getDxDt(zcz);//职称证
List<FileData> file7 = getDxDt(zyzgz);//执业资格证
List<FileData> file8 = getDxDt(aqsckhz);//安全生产考核证
List<FileData> file9 = getDxDt(sfzzp);//身份证
List<FileData> file10 = getDxDt(jqmgzp);//近期免冠照片
if(CollectionUtil.isNotEmpty(file1)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","第一学历学历证学位证");
JSONArray json1 = new JSONArray();
for(FileData f : file1) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
log.error("name::::::"+name1);
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file2)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","第二学历学历证学位证");
JSONArray json1 = new JSONArray();
for(FileData f : file2) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file3)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","第三学历学历证学位证");
JSONArray json1 = new JSONArray();
for(FileData f : file3) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file4)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","第四学历学历证学位证");
JSONArray json1 = new JSONArray();
for(FileData f : file4) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file5)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","岗位证");
JSONArray json1 = new JSONArray();
for(FileData f : file5) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file6)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","职称证");
JSONArray json1 = new JSONArray();
for(FileData f : file6) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file7)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","执业资格证");
JSONArray json1 = new JSONArray();
for(FileData f : file7) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file8)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","安全生产考核证");
JSONArray json1 = new JSONArray();
for(FileData f : file8) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file9)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","身份证");
JSONArray json1 = new JSONArray();
for(FileData f : file9) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
if(CollectionUtil.isNotEmpty(file10)) {
JSONObject rs1 = new JSONObject();
rs1.put("file_name","近期免冠照片");
JSONArray json1 = new JSONArray();
for(FileData f : file10) {
JSONObject r1 = new JSONObject();
String filename = "";
String name1 = f.getFileObj().getName();
if(name1.contains(".")) {
String names[] = name1.split("\\.");
filename = names[names.length-1];
}
if(filename.length() > 0) {
r1.put("file_type",filename.toLowerCase());
}else{
r1.put("file_type",f.getFileObj().getType());
}
log.error("howec:::::::::xxxxx21:"+f.getFileObj().getName());
log.error("howec:::::::::xxxxx1:"+f.getFileObj().getType());
log.error("howec:::::::::xxxxx2:"+f.getLoadUrl());
InputStream stream1 = f.getInputStream();
byte[] a = getByteData(stream1);
r1.put("filebytes",a);
json1.add(r1);
}
rs1.put("filebytes_array",json1);
array1.add(rs1);
}
return array1;
}
private byte[] getByteData(InputStream stream){
byte[] binaryData;
try{
// 创建字节数组输出流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// 定义缓冲区大小(根据需要调整)
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = stream.read(buffer)) != -1) {
// 写入到字节数组输出流
baos.write(buffer, 0, bytesRead);
}
// 获取转换后的二进制数据
binaryData = baos.toByteArray();
// 关闭输入流和输出流
stream.close();
baos.close();
return binaryData;
} catch (Exception e) {
e.printStackTrace();
log.error("下载输出文件流失败");
} finally {
try {
if(stream != null){
stream.close();
}
} catch (Exception e) {
log.error("inputStream 关闭资源失败", e);
}
}
return null;
}
private List<FileData> getDxDt(String id) {
List<FileData> rs = new ArrayList<>();
try {
if(!"0".equals(id)) {
String ids[] = id.split(",");
for(String s1 : ids) {
log.error("11111111111111111");
FileData file1 = fileDownloadService.downloadFile(Long.parseLong(s1));
if(file1.getFileObj()!=null && file1.getInputStream()!=null) {
log.error("222222222222");
rs.add(file1);
}
}
}
}catch (Exception e){
e.printStackTrace();
log.error("获取附件错误:"+e.getMessage());
}
return rs;
}
}