123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691 |
- 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<String, Object> cacheSCmap = CacheSearchCondition.cacheSCmap(request, "jdjc");
- Specification<JdjcEntity> spec = new Specification<JdjcEntity>() {
- // 查询条件
- @Override
- public Predicate toPredicate(Root<JdjcEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
- List<Predicate> list = new ArrayList<Predicate>();
- 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<String> in = cb.in(root.get("szgq").get("id").as(String.class));
- @SuppressWarnings("unchecked")
- List<String> gqlist = (List<String>) 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<JdjcEntity> list = query.findAll(spec, toPageRequest(page), JdjcEntity.class);
- List<JdjcVo> voList = new ArrayList<JdjcVo>();
- 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<TaskInfoEntity> 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<JdjcfjEntity> 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<TaskInfoEntity> 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<JdjcfjEntity> zgfjlist = jdjcfjService.findByJdjcid(id, "1");
- if (zgfjlist != null && zgfjlist.size() > 0) {
- model.addAttribute("zgfjlist", zgfjlist);
- }
- List<JdjcfjEntity> 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<MultipartFile> 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;
- }
- }
|