public String execute() throws Exception {
TSysDepartment depart = dao.findBySid(TSysDepartment.class, getCurrentUser().getFrybm());
/*
* List<String> drug =
* Arrays.asList("化学药品检验检测中心","藏药检验检测中心","中药检验检测中心","药品包装材料检验检测中心");
* List<String> hzdrug = Arrays.asList("化妆品检验检测中心"); List<String> ylqx =
* Arrays.asList("医疗器械检验检测中心","药品包装材料检验检测中心"); List<String> all =
* Arrays.asList("业务保障部","院部","药理与卫生学检验检测评价中心","质量技术部");
*/
String drug="化学药品检验检测中心,藏药检验检测中心,中药检验检测中心,药品包装材料检验检测中心";
String hzdrug="化妆品检验检测中心";
String ylqx="医疗器械检验检测中心,药品包装材料检验检测中心";
String all="业务保障部,院部,药理与卫生学检验检测评价中心,质量技术部";
String viewModule = "";
String nn = "";
String ksmc=depart.getFdepmc();
if(all.contains(ksmc)) {
nn="医疗器械";
viewModule+="医疗器械化妆品药品";
}
if(ylqx.contains(ksmc)) {
nn="医疗器械";
viewModule+="医疗器械";
}
if(drug.contains(ksmc)) {
nn = "药品";
viewModule+="药品";
}
if(hzdrug.contains(ksmc)) {
nn= "化妆品";
viewModule+="化妆品";
}
if(Util.isEmpty(nn)) {
nn="医疗器械";
}
if(StringUtils.isEmpty(nodename)) {
nodename = nn;
}
ActionContext.getContext().put("viewModule", viewModule);
if(!Util.isEmpty(download)){
page.setPageSize(10000000);
page.setPageNo(1);
//dao.queryPage1(page, getNodename());
}else{
if(Util.isEmpty(isNotSetdefaultValue)) {
page.getCondition().put("nf", Calendar.getInstance().get(Calendar.YEAR)+"");
}
dao.queryPage(page, getNodename(),null);
}
if (!Util.isEmpty(download)) {
if("ypsc".equals(download)) {
page.getCondition().put("lccb_jymdxl","省级药品抽检");
}
if("scxm".equals(download)||"scjbxx".equals(download)) {
page.getCondition().put("lccb_jymdxl","省级医疗器械抽检");
}
dao.queryPagedc(page, getNodename());
list = page.getDataRows();
YlqxSubject newqx = new YlqxSubject() ;
String[] gds;
String[] jgs;
String agent = getRequest().getHeader("User-Agent");
String filename = Util.getDownloadFileName(getNodename(), agent);
getResponse().setContentType("application/vnd.ms-excel");
getResponse().setHeader("Content-disposition",
"attachment;filename=" + filename + ".xls");
if(download.equals("xm")||download.equals("scxm")||download.equals("scjbxx")){
long l1 = System.currentTimeMillis();
if("药品".equals(nodename)) {
List<Map<String,Object>> makeList = new ArrayList<Map<String,Object>>();
List<Map<String,Object>> dataResult = new ArrayList(list);
List<String> uids = ListTools.extractValueByMapKey(dataResult, "lccb_jianpUID");
if(uids.isEmpty()) return "ypxm";
List<DrugSubject> subjects = (List<DrugSubject>) dao.findResultByListLimit("from DrugSubject where lcs_jianpUID in (:param) order by lcs_snum", uids,1000);
List<TSysPerson> persons = dao.findAll(TSysPerson.class);
for(Map basic:list){
String uid = (String) basic.get("lccb_jianpUID");
List<DrugSubject> subject=ListTools.match(subjects, "lcs_jianpUID", uid);
if(subject.isEmpty()) makeList.add(basic);
for (DrugSubject s : subject) {
Map temp = new HashMap(basic);
temp.put("lcs_snum", s.getLcs_snum());
temp.put("lcs_jydl", s.getLcs_jydl());
temp.put("lcs_jyxm", s.getLcs_jyxm());
temp.put("lcs_bzgd", s.getLcs_bzgd());
temp.put("lcs_jyjg", s.getLcs_jyjg());
temp.put("lcs_jyjl", s.getLcs_jyjl());
temp.put("lcs_jyry", s.getLcs_jyry());
temp.put("lcs_jyks",s.getLcs_jyks());
String lcs_sfzj = s.getLcs_sfzj();
List<TSysPerson> fuhrs = new ArrayList<TSysPerson>();
if("主检".equals(lcs_sfzj) && !Util.isEmpty(basic.get("lccb_zjfhrid"))) {
fuhrs = ListTools.match(persons, "fsid", (String)basic.get("lccb_zjfhrid"));
}else if("协1".equals(lcs_sfzj)&& !Util.isEmpty(basic.get("lccb_xj1fhrid"))) {
fuhrs = ListTools.match(persons, "fsid", (String)basic.get("lccb_xj1fhrid"));
}else if("协2".equals(lcs_sfzj)&& !Util.isEmpty(basic.get("lccb_xj2fhrid"))) {
fuhrs = ListTools.match(persons, "fsid", (String)basic.get("lccb_xj2fhrid"));
}else if("协3".equals(lcs_sfzj)&& !Util.isEmpty(basic.get("lccb_xj3fhrid"))) {
fuhrs = ListTools.match(persons, "fsid", (String)basic.get("lccb_xj3fhrid"));
}
temp.put("lcs_fuhr", fuhrs.isEmpty()?"":fuhrs.get(0).getFrymc());//校对者
temp.put("lcs_pf", s.getLcs_pf());//工作量
makeList.add(temp);
}
}
page.setDataRows(makeList);
return "ypxm";
}else if("医疗器械".equals(nodename)) {
for(Map basic:list){
String uid = (String) basic.get("lccb_jianpUID");
List<YlqxSubject> subject=dao.findByProperty(YlqxSubject.class, "lcs_jianpUID", uid,"lcs_snum");
basic.put("sujects", subject);
String zzjl = (String) basic.get("lccb_zzjl");
String s="";
String jyjl="";
if(!Util.isEmpty(zzjl)) {
for(YlqxSubject ss:subject) {
jyjl=ss.getLcs_jyjl();
if(!Util.isEmpty(jyjl)&&jyjl.indexOf("不")!=-1) {
if(!jyjl.equals("不适用")) {
s=s+ss.getLcs_jyxm()+",";
}
}
}
}
if(!Util.isEmpty(s)) {
basic.put("bhgxm", s.substring(0,s.length()-1));
}
}
if("scxm".equals(download)) {
return "scqxxm";
}else if("scjbxx".equals(download)){
return "scjbxx";
}else {
return "qxxm";
}
}
return null;
}
List<Map<String,Object>> makeList = new ArrayList<Map<String,Object>>();
List<Map<String,Object>> dataResult = new ArrayList(list);
for(Map basic:list){
String uid = (String) basic.get("lccb_jianpUID");
String zzjl = (String) basic.get("lccb_zzjl");
if("药品".equals(nodename)) {
List<DrugSubject> subject=dao.findByProperty(DrugSubject.class, "lcs_jianpUID", uid,"lcs_snum");
if(!Util.isEmpty(zzjl)&&zzjl.indexOf("不")!= -1&&!zzjl.equals("不适用")) {
String ss="";
for (DrugSubject s : subject) {
if(s.getLcs_jyjl().indexOf("不")!= -1&&s.getLcs_jyjl()!="不适用") {
if(!Util.isEmpty(s.getLcs_jyxm())) {
ss+=s.getLcs_jyxm()+";";
}else {
ss+=s.getLcs_jydl()+";";
}
}
}
basic.put("jyxms", ss);
ss="";
}else{
basic.put("jyxms","/");
}
}else if("医疗器械".equals(nodename)) {
List<YlqxSubject> subjects=dao.findByProperty(YlqxSubject.class, "lcs_jianpUID", uid,"lcs_snum");
if(!Util.isEmpty(zzjl)&&zzjl.indexOf("不")!= -1&&!zzjl.equals("不适用")) {
String ss="";
for (YlqxSubject s : subjects) {
if(s.getLcs_jyjl().indexOf("不")!= -1&&s.getLcs_jyjl()!="不适用") {
if(!Util.isEmpty(s.getLcs_jyxm())) {
ss+=s.getLcs_jyxm()+";";
}else {
ss+=s.getLcs_jydl()+";";
}
}
}
basic.put("jyxms", ss);
ss="";
}else{
basic.put("jyxms","/");
}
}
}
page.setDataRows(list);
if("药品".equals(nodename) || "医疗器械".equals(nodename)) {
this.ylqxCxtjcldc();//统计数据处理
}
if("ypsc".equals(download)) {
return "xls1";
}else {
return "xls";
}
}else if(!Util.isEmpty(downloadname)){
/*String agent = getRequest().getHeader("User-Agent");
String filename = Util.getDownloadFileName(getNodename(), agent);
getResponse().setContentType("application/vnd.ms-excel");
getResponse().setHeader("Content-disposition",
"attachment;filename=" + filename + ".xls");*/
ServletContext servletcontext=ServletActionContext.getRequest().getSession().getServletContext();
List<List<Map<String, Object>>> datas=new ArrayList();
page.setPageSize(999999);
page.setSortColumn("lccb_chouyjpzbh");
dao.queryPage(page, getNodename(),ids);
datas.add(page.getDataRows());
dao.queryPage1(page, getNodename(),ids);
datas.add(page.getDataRows());
ExcelUtil.DynamicOperateExcelUtils(servletcontext.getRealPath("mould/国抽化妆品数据上传模板.xlsx"),new String[]{"化妆品样品信息","化妆品检验项目"}, datas);
//return "xls1";
return null;
} else {
this.ylqxCxtjcl();//统计数据处理
List<TSysDepartment> jyks = dao.findByProperty(TSysDepartment.class, "fisjyjg", "是");
ActionContext.getContext().put("jyks", jyks);
//获取检验目的大类,检验目的小类
Tools.cxtjJymddlAndXl(dao.findAll(TreeFields.class),nodename);
return SUCCESS;
}
}