package com.xt.jygl.ggfwxxgl.jdjc.ctl; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder.In; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import cache.CacheSearchCondition; import com.fasterxml.jackson.core.JsonProcessingException; import com.xt.jygl.accessory.entity.AccessoryEntity; import com.xt.jygl.accessory.service.AccessoryService; import com.xt.jygl.common.BaseWebCtl; import com.xt.jygl.common.Constants; import com.xt.jygl.common.GlobalData; import com.xt.jygl.common.Utils; import com.xt.jygl.ggfwxxgl.jdjc.entity.JdjcEntity; import com.xt.jygl.ggfwxxgl.jdjc.entity.JdjcfjEntity; import com.xt.jygl.ggfwxxgl.jdjc.service.JdjcService; import com.xt.jygl.ggfwxxgl.jdjc.service.JdjcfjService; import com.xt.jygl.ggfwxxgl.jdjc.vo.JdjcVo; import com.xt.jygl.gkjcxx.gk.entity.GkEntity; import com.xt.jygl.gkjcxx.gk.service.GkService; import com.xt.jygl.gkjcxx.gq.entity.GqEntity; import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.entity.GkjyrEntity; import com.xt.jygl.workflow.entity.TaskInfoEntity; import com.xt.jygl.workflow.service.TaskInfoService; import com.xtframe.core.anon.auth.RequiresPermissions; import com.xtframe.core.base.ctl.WebJsonResult; import com.xtframe.core.support.SecurityMgr; import com.xtframe.sec.code.entity.CodeEntity; import com.xtframe.sec.common.BaseEntity; import com.xtframe.sec.common.QueryService; import com.xtframe.sec.common.SimplePageRequest; import com.xtframe.sec.user.entity.UserEntity; import com.xtframe.sec.utils.SecUtils; import com.xtframe.util.StringUtils; @Controller @RequestMapping("/jdjc") public class JdjcCtl extends BaseWebCtl { @Autowired private SecurityMgr securityMgr; @Autowired private QueryService query; @Autowired private JdjcService jdjcService; @Autowired private GkService gkService; @Autowired private TaskInfoService taskInfoService; @Autowired private AccessoryService accessoryService; @Autowired private JdjcfjService jdjcfjService; @RequestMapping(value = "/main") @RequiresPermissions("jdjc:main") public String main(SimplePageRequest page, Model model, final HttpServletRequest request, final String ssjyr, final String szdid, final String szgkid, final String szgqid, final String menuid) throws JsonProcessingException { final Map cacheSCmap = CacheSearchCondition.cacheSCmap(request, "jdjc"); Specification spec = new Specification() { // 查询条件 @Override public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder cb) { List list = new ArrayList(); if (StringUtils.isNotEmpty(szdid)) { list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%")); } else if (isGET(request)) { String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szdid"); if (StringUtils.isNotEmpty(v)) { list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + v + "%")); } } if (StringUtils.isNotEmpty(szgkid)) { list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%")); } else if (isGET(request)) { String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgkid"); if (StringUtils.isNotEmpty(v)) { list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + v + "%")); } } if (StringUtils.isNotEmpty(szgqid)) { list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + szgqid + "%")); } else if (isGET(request)) { String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgqid"); if (StringUtils.isNotEmpty(v)) { list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + v + "%")); } } if (StringUtils.isNotEmpty(ssjyr)) { list.add(cb.like(root.get("gkjyr").get("gkjyr").as(String.class), "%" + ssjyr + "%")); } else if (isGET(request)) { String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "ssjyr"); if (StringUtils.isNotEmpty(v)) { list.add(cb.like(root.get("gkjyr").get("gkjyr").as(String.class), "%" + v + "%")); } } // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据 if (isJyr()) { list.add(cb.like(root.get("gkjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%")); } else { In in = cb.in(root.get("szgq").get("id").as(String.class)); @SuppressWarnings("unchecked") List gqlist = (List) Utils.getSession().getAttribute("gqList"); if (gqlist != null && gqlist.size() > 0) { for (int i = 0; i < gqlist.size(); i++) { in.value(gqlist.get(i)); } list.add(in); } } list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE)); list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY)); return cb.and(list.toArray(new Predicate[] {})); } }; if (page.getPage() < 1) { Object jdtxpage = CacheSearchCondition.cacheSCmapVal(cacheSCmap, "jdtxpage"); if (StringUtils.isEmpty(jdtxpage) || !org.apache.commons.lang.StringUtils.isNumeric(String.valueOf(jdtxpage))) { jdtxpage = "1"; } page.setPage(Integer.valueOf(String.valueOf(jdtxpage))); } Page list = query.findAll(spec, toPageRequest(page), JdjcEntity.class); List voList = new ArrayList(); for (JdjcEntity entity : list) { JdjcVo vo = new JdjcVo(); if (null != entity) { BeanUtils.copyProperties(entity, vo); if (entity.getRecordStatus() != 9) { if ((jdjcService.getTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) || jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) { List lists = taskInfoService.findByBusIdAndBusKeyAndRecordStatus(entity.getId(), JdjcEntity.PROCESS_DEFINITION_KEY); if (lists != null & lists.size() > 0) { TaskInfoEntity taskinfo = lists.get(0); if ("申请".equals(taskinfo.getCurrName())) { vo.setTaskState("TH"); } else { vo.setTaskState(Constants.IS_MY_TASK); } } } } vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : ""); vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : ""); vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : ""); vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : ""); vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : ""); vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : ""); vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : ""); voList.add(vo); } } if (isPOST(request)) { cacheSCmap.put("jdtxpage", page.getPage()); CacheSearchCondition.putCacheSCmap(request.getParameterMap(), cacheSCmap); } model.addAttribute("list", voList); model.addAttribute("menuid", menuid); model.addAttribute("ssjyr", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "ssjyr")); model.addAttribute("szd", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szdid")); model.addAttribute("szgk", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgkid")); model.addAttribute("szgq", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgqid")); int flag = 0; if (GlobalData.CITY_CODE.length() > 3) { flag = 1; } model.addAttribute("flag", flag); // 翻页共通 putPageInfo(model, page, list); return "ggfwxxgl/jdjc/jdjcmain"; } @RequestMapping(value = "/delete") @ResponseBody @RequiresPermissions("jdjc:delete") public WebJsonResult delete(Model model, String id) { WebJsonResult wr = success(); try { jdjcService.logicDelete(id); } catch (Exception e) { wr.setSuccess(false); wr.setMessage("删除失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/save") @ResponseBody public WebJsonResult save(Model model, JdjcEntity code, String flowflag, String szdid, String szgkid, String accid, String szgqid, String jyrid) { // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段 // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查 WebJsonResult wr = success(); if (StringUtils.isEmpty(szdid)) { wr.setSuccess(false); wr.setMessage("请选择所在地"); return wr; } if (StringUtils.isEmpty(szgkid)) { wr.setSuccess(false); wr.setMessage("请选择所在港口"); return wr; } if (StringUtils.isEmpty(szgqid)) { wr.setSuccess(false); wr.setMessage("请选择所在港区"); return wr; } if (StringUtils.isEmpty(jyrid)) { wr.setSuccess(false); wr.setMessage("请选择被督查单位"); return wr; } JdjcEntity entity = new JdjcEntity(); try { if (!StringUtils.isEmpty(code.getId())) { // 修改 entity = jdjcService.findOne(code.getId()); entity.setBdcdwcjry(code.getBdcdwcjry()); entity.setBdcdwfzr(code.getBdcdwfzr()); entity.setCjdcry(code.getCjdcry()); entity.setYhmc(code.getYhmc()); entity.setZgcsyq(code.getZgcsyq()); entity.setZgqx(code.getZgqx()); entity.setZgsm(code.getZgsm()); if (!StringUtils.isEmpty(code.getFlowflag())) { entity.setFlowflag(code.getFlowflag()); // 1为下发 entity.setBtnflag("0"); } entity = jdjcService.save(entity); } else { CodeEntity szd = new CodeEntity(szdid); code.setSzd(szd); GkEntity szgk = new GkEntity(); szgk.setId(szgkid); code.setSzgk(szgk); GqEntity szgq = new GqEntity(); szgq.setId(szgqid); code.setSzgq(szgq); GkjyrEntity ssjyr = new GkjyrEntity(); ssjyr.setId(jyrid); code.setGkjyr(ssjyr); if (GlobalData.CITY_CODE.length() > 3) { code.setBtnflag("0"); code.setFlowflag("0"); } else { code.setBtnflag("1"); if (StringUtils.isEmpty(code.getFlowflag())) { code.setFlowflag("0"); } } entity = jdjcService.save(code); } if (!StringUtils.isEmpty(accid)) { // 关联附件 String[] ssids = accid.split(","); for (String ssid : ssids) { JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid); if (jdjcfj != null) { jdjcfj.setJdtxid(entity.getId()); jdjcfjService.save(jdjcfj); } } } } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/savexf") @ResponseBody public WebJsonResult savexf(Model model, JdjcEntity code, String flowflag, String szdid, String szgkid, String accid, String szgqid, String jyrid) { // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段 // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查 WebJsonResult wr = success(); if (StringUtils.isEmpty(szdid)) { wr.setSuccess(false); wr.setMessage("请选择所在地"); return wr; } if (StringUtils.isEmpty(szgkid)) { wr.setSuccess(false); wr.setMessage("请选择所在港口"); return wr; } if (StringUtils.isEmpty(szgqid)) { wr.setSuccess(false); wr.setMessage("请选择所在港区"); return wr; } if (StringUtils.isEmpty(jyrid)) { wr.setSuccess(false); wr.setMessage("请选择被督查单位"); return wr; } JdjcEntity entity = new JdjcEntity(); try { if (!StringUtils.isEmpty(code.getId())) { // 修改 entity = jdjcService.findOne(code.getId()); entity.setBdcdwcjry(code.getBdcdwcjry()); entity.setBdcdwfzr(code.getBdcdwfzr()); entity.setCjdcry(code.getCjdcry()); entity.setYhmc(code.getYhmc()); entity.setZgcsyq(code.getZgcsyq()); entity.setZgqx(code.getZgqx()); entity.setZgsm(code.getZgsm()); entity.setFlowflag("1"); // 1为下发 entity.setBtnflag("0"); entity = jdjcService.save(entity); } else { CodeEntity szd = new CodeEntity(szdid); code.setSzd(szd); GkEntity szgk = new GkEntity(); szgk.setId(szgkid); code.setSzgk(szgk); GqEntity szgq = new GqEntity(); szgq.setId(szgqid); code.setSzgq(szgq); GkjyrEntity ssjyr = new GkjyrEntity(); ssjyr.setId(jyrid); code.setGkjyr(ssjyr); if (Constants.GROUP_CODE_SZD.length() > 3) { code.setBtnflag("0"); code.setFlowflag("0"); } else { code.setBtnflag("1"); code.setFlowflag("1"); } entity = jdjcService.save(code); } if (!StringUtils.isEmpty(accid)) { // 关联附件 String[] ssids = accid.split(","); for (String ssid : ssids) { JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid); if (jdjcfj != null) { jdjcfj.setJdtxid(entity.getId()); jdjcfjService.save(jdjcfj); } } } } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/submit") @ResponseBody public WebJsonResult submit(Model model, JdjcEntity code, String accid, String szdid, String szgkid, String szgqid, String jyrid) { // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段 // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查 WebJsonResult wr = success(); if (StringUtils.isEmpty(szdid)) { wr.setSuccess(false); wr.setMessage("请选择所在地"); return wr; } if (StringUtils.isEmpty(szgkid)) { wr.setSuccess(false); wr.setMessage("请选择所在港口"); return wr; } if (StringUtils.isEmpty(szgqid)) { wr.setSuccess(false); wr.setMessage("请选择所在港区"); return wr; } if (StringUtils.isEmpty(jyrid)) { wr.setSuccess(false); wr.setMessage("请选择被督查单位"); return wr; } JdjcEntity entity = new JdjcEntity(); try { if (!StringUtils.isEmpty(code.getId())) { // 修改 entity = jdjcService.findOne(code.getId()); entity.setBdcdwcjry(code.getBdcdwcjry()); entity.setBdcdwfzr(code.getBdcdwfzr()); entity.setCjdcry(code.getCjdcry()); entity.setYhmc(code.getYhmc()); entity.setZgcsyq(code.getZgcsyq()); entity.setZgqx(code.getZgqx()); entity.setZgsm(code.getZgsm()); if (GlobalData.CITY_CODE.length() > 3) { code.setBtnflag("0"); } code.setFlowflag("2"); entity = jdjcService.submit(entity); } else { CodeEntity szd = new CodeEntity(szdid); code.setSzd(szd); GkEntity szgk = new GkEntity(); szgk.setId(szgkid); code.setSzgk(szgk); GqEntity szgq = new GqEntity(); szgq.setId(szgqid); code.setSzgq(szgq); GkjyrEntity ssjyr = new GkjyrEntity(); ssjyr.setId(jyrid); code.setGkjyr(ssjyr); if (GlobalData.CITY_CODE.length() > 3) { code.setBtnflag("0"); } code.setFlowflag("2"); entity = jdjcService.submit(code); } if (!StringUtils.isEmpty(accid)) { // 关联附件 String[] ssids = accid.split(","); for (String ssid : ssids) { JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid); if (jdjcfj != null) { jdjcfj.setJdtxid(entity.getId()); jdjcfjService.save(jdjcfj); } } } } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/submitAudit") @ResponseBody public WebJsonResult submitAudit(JdjcEntity code, String accid) { WebJsonResult wr = success(); JdjcEntity entity = new JdjcEntity(); try { if (!StringUtils.isEmpty(code.getId())) { entity = jdjcService.findOne(code.getId()); entity.setBdcdwcjry(code.getBdcdwcjry()); entity.setBdcdwfzr(code.getBdcdwfzr()); entity.setCjdcry(code.getCjdcry()); entity.setYhmc(code.getYhmc()); entity.setZgcsyq(code.getZgcsyq()); entity.setZgqx(code.getZgqx()); entity.setZgsm(code.getZgsm()); entity = jdjcService.save(entity); } if (!StringUtils.isEmpty(accid)) { // 关联附件 String[] ssids = accid.split(","); for (String ssid : ssids) { JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid); if (jdjcfj != null) { jdjcfj.setJdtxid(entity.getId()); jdjcfjService.save(jdjcfj); } } } } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } try { if (jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), code.getId()) != null) { jdjcService.claim(code.getId(), SecUtils.getCurrUser().getId().toString()); } jdjcService.changeAudit(null, entity, true); } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/audit") @ResponseBody public WebJsonResult audit(String shyj, String id, boolean flag, String accid) { WebJsonResult wr = success(); JdjcEntity entity = jdjcService.findOne(id); if (!StringUtils.isEmpty(accid)) { // 关联附件 String[] ssids = accid.split(","); for (String ssid : ssids) { JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid); if (jdjcfj != null) { jdjcfj.setJdtxid(entity.getId()); jdjcfjService.save(jdjcfj); } } } try { if (jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), id) != null) { jdjcService.claim(id, SecUtils.getCurrUser().getId().toString()); } jdjcService.changeAudit(shyj, entity, flag); } catch (Exception e) { wr.setSuccess(false); wr.setMessage("操作失败!"); e.printStackTrace(); } return wr; } @RequestMapping(value = "/edit") public String edit(Model model, String id, String flag) { model.addAttribute("flag", flag); JdjcEntity entity = jdjcService.findOne(id); JdjcVo vo = new JdjcVo(); BeanUtils.copyProperties(entity, vo); vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : ""); vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : ""); vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : ""); vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : ""); vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : ""); model.addAttribute("record", vo); List list = jdjcfjService.findByJdjcid(id, "1"); if (list != null && list.size() > 0) { model.addAttribute("fjlist", list); } return "ggfwxxgl/jdjc/jdjcedit"; } @RequestMapping(value = "/view") @RequiresPermissions("jdjc:main") public String view(Model model, String id, String flag, String opflag) { model.addAttribute("flag", flag); JdjcEntity entity = jdjcService.findOne(id); JdjcVo vo = new JdjcVo(); BeanUtils.copyProperties(entity, vo); vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : ""); vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : ""); vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : ""); vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : ""); vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : ""); vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : ""); vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : ""); vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : ""); vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : ""); vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : ""); vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : ""); vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : ""); vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : ""); vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : ""); vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : ""); model.addAttribute("record", vo); List lists = taskInfoService.findByBusIdAndBusKeyAndRecordStatus(id, JdjcEntity.PROCESS_DEFINITION_KEY); if (lists != null & lists.size() > 0) { TaskInfoEntity taskinfo = lists.get(0); if ("年度审核材料".equals(taskinfo.getCurrName())) { opflag = "1"; } else if ("年度审核批准".equals(taskinfo.getCurrName())) { opflag = "2"; } else if ("".equals(taskinfo.getCurrName())) { opflag = "3"; } model.addAttribute("opflag", opflag); } if (isJyr()) { model.addAttribute("jyrFlag", "1"); } List zgfjlist = jdjcfjService.findByJdjcid(id, "1"); if (zgfjlist != null && zgfjlist.size() > 0) { model.addAttribute("zgfjlist", zgfjlist); } List zghfjlist = jdjcfjService.findByJdjcid(id, "0"); if (zghfjlist != null && zghfjlist.size() > 0) { model.addAttribute("zghfjlist", zghfjlist); } return "ggfwxxgl/jdjc/jdjcview"; } @RequestMapping(value = "/add") @RequiresPermissions("jdjc:add") public String add(Model model) { UserEntity user = securityMgr.getCurrUser(); model.addAttribute("user", user); SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd"); Date today = new Date(); model.addAttribute("sqrq", dateTimeFormat.format(today)); int btnflag = 0; if (GlobalData.CITY_CODE.length() > 3) { btnflag = 1; } model.addAttribute("btnflag", btnflag); return "ggfwxxgl/jdjc/jdjcadd"; } // 保存附件 @RequestMapping(value = "/saveFile") @ResponseBody public WebJsonResult saveFile(@RequestParam("file") List file, String fjFlag, Model model, HttpServletRequest request, HttpServletResponse response) { WebJsonResult wr = success(); if (file != null && file.size() > 0) { JdjcfjEntity fjEntity = new JdjcfjEntity(); for (int i = 0; i < file.size(); i++) { MultipartFile f = file.get(i); if (f.getSize() > 0) { AccessoryEntity acc = accessoryService.saveFile(f, "jdtx"); if (acc != null) { fjEntity.setFjid(acc.getId()); fjEntity.setFjmc(acc.getName()); fjEntity.setType(fjFlag); fjEntity = jdjcfjService.save(fjEntity); break; } } } wr.setAttr("acc", fjEntity); } else { wr.setSuccess(false); wr.setMessage("请上传附件或上传的文件不能为空文件!"); } return wr; } @RequestMapping(value = "/delFile") @ResponseBody public WebJsonResult delFile(String accid, Model model) { WebJsonResult wr = success(); try { JdjcfjEntity entity = jdjcfjService.findOne(accid); if (entity != null) { AccessoryEntity acc = accessoryService.findOne(entity.getFjid()); if (acc != null) { accessoryService.delete(acc); if (entity != null) { String path = acc.getFilepath() + acc.getFilename(); File file = new File(path); if (file.isFile() && file.exists()) { file.delete(); } } } jdjcfjService.delete(entity); } } catch (Exception e) { wr.setSuccess(false); } return wr; } }