JdjcCtl.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. package com.xt.jygl.ggfwxxgl.jdjc.ctl;
  2. import java.io.File;
  3. import java.text.SimpleDateFormat;
  4. import java.util.ArrayList;
  5. import java.util.Date;
  6. import java.util.List;
  7. import java.util.Map;
  8. import javax.persistence.criteria.CriteriaBuilder;
  9. import javax.persistence.criteria.CriteriaBuilder.In;
  10. import javax.persistence.criteria.CriteriaQuery;
  11. import javax.persistence.criteria.Predicate;
  12. import javax.persistence.criteria.Root;
  13. import javax.servlet.http.HttpServletRequest;
  14. import javax.servlet.http.HttpServletResponse;
  15. import org.springframework.beans.BeanUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.data.domain.Page;
  18. import org.springframework.data.jpa.domain.Specification;
  19. import org.springframework.stereotype.Controller;
  20. import org.springframework.ui.Model;
  21. import org.springframework.web.bind.annotation.RequestMapping;
  22. import org.springframework.web.bind.annotation.RequestParam;
  23. import org.springframework.web.bind.annotation.ResponseBody;
  24. import org.springframework.web.multipart.MultipartFile;
  25. import cache.CacheSearchCondition;
  26. import com.fasterxml.jackson.core.JsonProcessingException;
  27. import com.xt.jygl.accessory.entity.AccessoryEntity;
  28. import com.xt.jygl.accessory.service.AccessoryService;
  29. import com.xt.jygl.common.BaseWebCtl;
  30. import com.xt.jygl.common.Constants;
  31. import com.xt.jygl.common.GlobalData;
  32. import com.xt.jygl.common.Utils;
  33. import com.xt.jygl.ggfwxxgl.jdjc.entity.JdjcEntity;
  34. import com.xt.jygl.ggfwxxgl.jdjc.entity.JdjcfjEntity;
  35. import com.xt.jygl.ggfwxxgl.jdjc.service.JdjcService;
  36. import com.xt.jygl.ggfwxxgl.jdjc.service.JdjcfjService;
  37. import com.xt.jygl.ggfwxxgl.jdjc.vo.JdjcVo;
  38. import com.xt.jygl.gkjcxx.gk.entity.GkEntity;
  39. import com.xt.jygl.gkjcxx.gk.service.GkService;
  40. import com.xt.jygl.gkjcxx.gq.entity.GqEntity;
  41. import com.xt.jygl.gkjygl.gkjyr.jyrjbxx.entity.GkjyrEntity;
  42. import com.xt.jygl.workflow.entity.TaskInfoEntity;
  43. import com.xt.jygl.workflow.service.TaskInfoService;
  44. import com.xtframe.core.anon.auth.RequiresPermissions;
  45. import com.xtframe.core.base.ctl.WebJsonResult;
  46. import com.xtframe.core.support.SecurityMgr;
  47. import com.xtframe.sec.code.entity.CodeEntity;
  48. import com.xtframe.sec.common.BaseEntity;
  49. import com.xtframe.sec.common.QueryService;
  50. import com.xtframe.sec.common.SimplePageRequest;
  51. import com.xtframe.sec.user.entity.UserEntity;
  52. import com.xtframe.sec.utils.SecUtils;
  53. import com.xtframe.util.StringUtils;
  54. @Controller
  55. @RequestMapping("/jdjc")
  56. public class JdjcCtl extends BaseWebCtl {
  57. @Autowired
  58. private SecurityMgr securityMgr;
  59. @Autowired
  60. private QueryService query;
  61. @Autowired
  62. private JdjcService jdjcService;
  63. @Autowired
  64. private GkService gkService;
  65. @Autowired
  66. private TaskInfoService taskInfoService;
  67. @Autowired
  68. private AccessoryService accessoryService;
  69. @Autowired
  70. private JdjcfjService jdjcfjService;
  71. @RequestMapping(value = "/main")
  72. @RequiresPermissions("jdjc:main")
  73. 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 {
  74. final Map<String, Object> cacheSCmap = CacheSearchCondition.cacheSCmap(request, "jdjc");
  75. Specification<JdjcEntity> spec = new Specification<JdjcEntity>() {
  76. // 查询条件
  77. @Override
  78. public Predicate toPredicate(Root<JdjcEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
  79. List<Predicate> list = new ArrayList<Predicate>();
  80. if (StringUtils.isNotEmpty(szdid)) {
  81. list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + szdid + "%"));
  82. } else if (isGET(request)) {
  83. String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szdid");
  84. if (StringUtils.isNotEmpty(v)) {
  85. list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + v + "%"));
  86. }
  87. }
  88. if (StringUtils.isNotEmpty(szgkid)) {
  89. list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + szgkid + "%"));
  90. } else if (isGET(request)) {
  91. String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgkid");
  92. if (StringUtils.isNotEmpty(v)) {
  93. list.add(cb.like(root.get("szgk").get("id").as(String.class), "%" + v + "%"));
  94. }
  95. }
  96. if (StringUtils.isNotEmpty(szgqid)) {
  97. list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + szgqid + "%"));
  98. } else if (isGET(request)) {
  99. String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgqid");
  100. if (StringUtils.isNotEmpty(v)) {
  101. list.add(cb.like(root.get("szgq").get("id").as(String.class), "%" + v + "%"));
  102. }
  103. }
  104. if (StringUtils.isNotEmpty(ssjyr)) {
  105. list.add(cb.like(root.get("gkjyr").get("gkjyr").as(String.class), "%" + ssjyr + "%"));
  106. } else if (isGET(request)) {
  107. String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "ssjyr");
  108. if (StringUtils.isNotEmpty(v)) {
  109. list.add(cb.like(root.get("gkjyr").get("gkjyr").as(String.class), "%" + v + "%"));
  110. }
  111. }
  112. // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
  113. if (isJyr()) {
  114. list.add(cb.like(root.get("gkjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
  115. } else {
  116. In<String> in = cb.in(root.get("szgq").get("id").as(String.class));
  117. @SuppressWarnings("unchecked")
  118. List<String> gqlist = (List<String>) Utils.getSession().getAttribute("gqList");
  119. if (gqlist != null && gqlist.size() > 0) {
  120. for (int i = 0; i < gqlist.size(); i++) {
  121. in.value(gqlist.get(i));
  122. }
  123. list.add(in);
  124. }
  125. }
  126. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORD_STATE_DELETE));
  127. list.add(cb.notEqual(root.get("recordStatus").as(Integer.class), BaseEntity.RECORE_STATE_COPY));
  128. return cb.and(list.toArray(new Predicate[] {}));
  129. }
  130. };
  131. if (page.getPage() < 1) {
  132. Object jdtxpage = CacheSearchCondition.cacheSCmapVal(cacheSCmap, "jdtxpage");
  133. if (StringUtils.isEmpty(jdtxpage) || !org.apache.commons.lang.StringUtils.isNumeric(String.valueOf(jdtxpage))) {
  134. jdtxpage = "1";
  135. }
  136. page.setPage(Integer.valueOf(String.valueOf(jdtxpage)));
  137. }
  138. Page<JdjcEntity> list = query.findAll(spec, toPageRequest(page), JdjcEntity.class);
  139. List<JdjcVo> voList = new ArrayList<JdjcVo>();
  140. for (JdjcEntity entity : list) {
  141. JdjcVo vo = new JdjcVo();
  142. if (null != entity) {
  143. BeanUtils.copyProperties(entity, vo);
  144. if (entity.getRecordStatus() != 9) {
  145. if ((jdjcService.getTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) || jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) {
  146. List<TaskInfoEntity> lists = taskInfoService.findByBusIdAndBusKeyAndRecordStatus(entity.getId(), JdjcEntity.PROCESS_DEFINITION_KEY);
  147. if (lists != null & lists.size() > 0) {
  148. TaskInfoEntity taskinfo = lists.get(0);
  149. if ("申请".equals(taskinfo.getCurrName())) {
  150. vo.setTaskState("TH");
  151. } else {
  152. vo.setTaskState(Constants.IS_MY_TASK);
  153. }
  154. }
  155. }
  156. }
  157. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  158. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  159. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  160. vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  161. vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  162. vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : "");
  163. vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : "");
  164. voList.add(vo);
  165. }
  166. }
  167. if (isPOST(request)) {
  168. cacheSCmap.put("jdtxpage", page.getPage());
  169. CacheSearchCondition.putCacheSCmap(request.getParameterMap(), cacheSCmap);
  170. }
  171. model.addAttribute("list", voList);
  172. model.addAttribute("menuid", menuid);
  173. model.addAttribute("ssjyr", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "ssjyr"));
  174. model.addAttribute("szd", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szdid"));
  175. model.addAttribute("szgk", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgkid"));
  176. model.addAttribute("szgq", CacheSearchCondition.cacheSCmapVal(cacheSCmap, "szgqid"));
  177. int flag = 0;
  178. if (GlobalData.CITY_CODE.length() > 3) {
  179. flag = 1;
  180. }
  181. model.addAttribute("flag", flag);
  182. // 翻页共通
  183. putPageInfo(model, page, list);
  184. return "ggfwxxgl/jdjc/jdjcmain";
  185. }
  186. @RequestMapping(value = "/delete")
  187. @ResponseBody
  188. @RequiresPermissions("jdjc:delete")
  189. public WebJsonResult delete(Model model, String id) {
  190. WebJsonResult wr = success();
  191. try {
  192. jdjcService.logicDelete(id);
  193. } catch (Exception e) {
  194. wr.setSuccess(false);
  195. wr.setMessage("删除失败!");
  196. e.printStackTrace();
  197. }
  198. return wr;
  199. }
  200. @RequestMapping(value = "/save")
  201. @ResponseBody
  202. public WebJsonResult save(Model model, JdjcEntity code, String flowflag, String szdid, String szgkid, String accid, String szgqid, String jyrid) {
  203. // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段
  204. // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查
  205. WebJsonResult wr = success();
  206. if (StringUtils.isEmpty(szdid)) {
  207. wr.setSuccess(false);
  208. wr.setMessage("请选择所在地");
  209. return wr;
  210. }
  211. if (StringUtils.isEmpty(szgkid)) {
  212. wr.setSuccess(false);
  213. wr.setMessage("请选择所在港口");
  214. return wr;
  215. }
  216. if (StringUtils.isEmpty(szgqid)) {
  217. wr.setSuccess(false);
  218. wr.setMessage("请选择所在港区");
  219. return wr;
  220. }
  221. if (StringUtils.isEmpty(jyrid)) {
  222. wr.setSuccess(false);
  223. wr.setMessage("请选择被督查单位");
  224. return wr;
  225. }
  226. JdjcEntity entity = new JdjcEntity();
  227. try {
  228. if (!StringUtils.isEmpty(code.getId())) {
  229. // 修改
  230. entity = jdjcService.findOne(code.getId());
  231. entity.setBdcdwcjry(code.getBdcdwcjry());
  232. entity.setBdcdwfzr(code.getBdcdwfzr());
  233. entity.setCjdcry(code.getCjdcry());
  234. entity.setYhmc(code.getYhmc());
  235. entity.setZgcsyq(code.getZgcsyq());
  236. entity.setZgqx(code.getZgqx());
  237. entity.setZgsm(code.getZgsm());
  238. if (!StringUtils.isEmpty(code.getFlowflag())) {
  239. entity.setFlowflag(code.getFlowflag()); // 1为下发
  240. entity.setBtnflag("0");
  241. }
  242. entity = jdjcService.save(entity);
  243. } else {
  244. CodeEntity szd = new CodeEntity(szdid);
  245. code.setSzd(szd);
  246. GkEntity szgk = new GkEntity();
  247. szgk.setId(szgkid);
  248. code.setSzgk(szgk);
  249. GqEntity szgq = new GqEntity();
  250. szgq.setId(szgqid);
  251. code.setSzgq(szgq);
  252. GkjyrEntity ssjyr = new GkjyrEntity();
  253. ssjyr.setId(jyrid);
  254. code.setGkjyr(ssjyr);
  255. if (GlobalData.CITY_CODE.length() > 3) {
  256. code.setBtnflag("0");
  257. code.setFlowflag("0");
  258. } else {
  259. code.setBtnflag("1");
  260. if (StringUtils.isEmpty(code.getFlowflag())) {
  261. code.setFlowflag("0");
  262. }
  263. }
  264. entity = jdjcService.save(code);
  265. }
  266. if (!StringUtils.isEmpty(accid)) {
  267. // 关联附件
  268. String[] ssids = accid.split(",");
  269. for (String ssid : ssids) {
  270. JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid);
  271. if (jdjcfj != null) {
  272. jdjcfj.setJdtxid(entity.getId());
  273. jdjcfjService.save(jdjcfj);
  274. }
  275. }
  276. }
  277. } catch (Exception e) {
  278. wr.setSuccess(false);
  279. wr.setMessage("操作失败!");
  280. e.printStackTrace();
  281. }
  282. return wr;
  283. }
  284. @RequestMapping(value = "/savexf")
  285. @ResponseBody
  286. public WebJsonResult savexf(Model model, JdjcEntity code, String flowflag, String szdid, String szgkid, String accid, String szgqid, String jyrid) {
  287. // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段
  288. // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查
  289. WebJsonResult wr = success();
  290. if (StringUtils.isEmpty(szdid)) {
  291. wr.setSuccess(false);
  292. wr.setMessage("请选择所在地");
  293. return wr;
  294. }
  295. if (StringUtils.isEmpty(szgkid)) {
  296. wr.setSuccess(false);
  297. wr.setMessage("请选择所在港口");
  298. return wr;
  299. }
  300. if (StringUtils.isEmpty(szgqid)) {
  301. wr.setSuccess(false);
  302. wr.setMessage("请选择所在港区");
  303. return wr;
  304. }
  305. if (StringUtils.isEmpty(jyrid)) {
  306. wr.setSuccess(false);
  307. wr.setMessage("请选择被督查单位");
  308. return wr;
  309. }
  310. JdjcEntity entity = new JdjcEntity();
  311. try {
  312. if (!StringUtils.isEmpty(code.getId())) {
  313. // 修改
  314. entity = jdjcService.findOne(code.getId());
  315. entity.setBdcdwcjry(code.getBdcdwcjry());
  316. entity.setBdcdwfzr(code.getBdcdwfzr());
  317. entity.setCjdcry(code.getCjdcry());
  318. entity.setYhmc(code.getYhmc());
  319. entity.setZgcsyq(code.getZgcsyq());
  320. entity.setZgqx(code.getZgqx());
  321. entity.setZgsm(code.getZgsm());
  322. entity.setFlowflag("1"); // 1为下发
  323. entity.setBtnflag("0");
  324. entity = jdjcService.save(entity);
  325. } else {
  326. CodeEntity szd = new CodeEntity(szdid);
  327. code.setSzd(szd);
  328. GkEntity szgk = new GkEntity();
  329. szgk.setId(szgkid);
  330. code.setSzgk(szgk);
  331. GqEntity szgq = new GqEntity();
  332. szgq.setId(szgqid);
  333. code.setSzgq(szgq);
  334. GkjyrEntity ssjyr = new GkjyrEntity();
  335. ssjyr.setId(jyrid);
  336. code.setGkjyr(ssjyr);
  337. if (Constants.GROUP_CODE_SZD.length() > 3) {
  338. code.setBtnflag("0");
  339. code.setFlowflag("0");
  340. } else {
  341. code.setBtnflag("1");
  342. code.setFlowflag("1");
  343. }
  344. entity = jdjcService.save(code);
  345. }
  346. if (!StringUtils.isEmpty(accid)) {
  347. // 关联附件
  348. String[] ssids = accid.split(",");
  349. for (String ssid : ssids) {
  350. JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid);
  351. if (jdjcfj != null) {
  352. jdjcfj.setJdtxid(entity.getId());
  353. jdjcfjService.save(jdjcfj);
  354. }
  355. }
  356. }
  357. } catch (Exception e) {
  358. wr.setSuccess(false);
  359. wr.setMessage("操作失败!");
  360. e.printStackTrace();
  361. }
  362. return wr;
  363. }
  364. @RequestMapping(value = "/submit")
  365. @ResponseBody
  366. public WebJsonResult submit(Model model, JdjcEntity code, String accid, String szdid, String szgkid, String szgqid, String jyrid) {
  367. // how:如果是新增直接保存,如果更新,先取出数据库中记录,然后更新页面传过来的字段
  368. // why:这样的话一些在前台无需显示的字段保证不会丢失,同时一个个字段设置有助于bug排查
  369. WebJsonResult wr = success();
  370. if (StringUtils.isEmpty(szdid)) {
  371. wr.setSuccess(false);
  372. wr.setMessage("请选择所在地");
  373. return wr;
  374. }
  375. if (StringUtils.isEmpty(szgkid)) {
  376. wr.setSuccess(false);
  377. wr.setMessage("请选择所在港口");
  378. return wr;
  379. }
  380. if (StringUtils.isEmpty(szgqid)) {
  381. wr.setSuccess(false);
  382. wr.setMessage("请选择所在港区");
  383. return wr;
  384. }
  385. if (StringUtils.isEmpty(jyrid)) {
  386. wr.setSuccess(false);
  387. wr.setMessage("请选择被督查单位");
  388. return wr;
  389. }
  390. JdjcEntity entity = new JdjcEntity();
  391. try {
  392. if (!StringUtils.isEmpty(code.getId())) {
  393. // 修改
  394. entity = jdjcService.findOne(code.getId());
  395. entity.setBdcdwcjry(code.getBdcdwcjry());
  396. entity.setBdcdwfzr(code.getBdcdwfzr());
  397. entity.setCjdcry(code.getCjdcry());
  398. entity.setYhmc(code.getYhmc());
  399. entity.setZgcsyq(code.getZgcsyq());
  400. entity.setZgqx(code.getZgqx());
  401. entity.setZgsm(code.getZgsm());
  402. if (GlobalData.CITY_CODE.length() > 3) {
  403. code.setBtnflag("0");
  404. }
  405. code.setFlowflag("2");
  406. entity = jdjcService.submit(entity);
  407. } else {
  408. CodeEntity szd = new CodeEntity(szdid);
  409. code.setSzd(szd);
  410. GkEntity szgk = new GkEntity();
  411. szgk.setId(szgkid);
  412. code.setSzgk(szgk);
  413. GqEntity szgq = new GqEntity();
  414. szgq.setId(szgqid);
  415. code.setSzgq(szgq);
  416. GkjyrEntity ssjyr = new GkjyrEntity();
  417. ssjyr.setId(jyrid);
  418. code.setGkjyr(ssjyr);
  419. if (GlobalData.CITY_CODE.length() > 3) {
  420. code.setBtnflag("0");
  421. }
  422. code.setFlowflag("2");
  423. entity = jdjcService.submit(code);
  424. }
  425. if (!StringUtils.isEmpty(accid)) {
  426. // 关联附件
  427. String[] ssids = accid.split(",");
  428. for (String ssid : ssids) {
  429. JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid);
  430. if (jdjcfj != null) {
  431. jdjcfj.setJdtxid(entity.getId());
  432. jdjcfjService.save(jdjcfj);
  433. }
  434. }
  435. }
  436. } catch (Exception e) {
  437. wr.setSuccess(false);
  438. wr.setMessage("操作失败!");
  439. e.printStackTrace();
  440. }
  441. return wr;
  442. }
  443. @RequestMapping(value = "/submitAudit")
  444. @ResponseBody
  445. public WebJsonResult submitAudit(JdjcEntity code, String accid) {
  446. WebJsonResult wr = success();
  447. JdjcEntity entity = new JdjcEntity();
  448. try {
  449. if (!StringUtils.isEmpty(code.getId())) {
  450. entity = jdjcService.findOne(code.getId());
  451. entity.setBdcdwcjry(code.getBdcdwcjry());
  452. entity.setBdcdwfzr(code.getBdcdwfzr());
  453. entity.setCjdcry(code.getCjdcry());
  454. entity.setYhmc(code.getYhmc());
  455. entity.setZgcsyq(code.getZgcsyq());
  456. entity.setZgqx(code.getZgqx());
  457. entity.setZgsm(code.getZgsm());
  458. entity = jdjcService.save(entity);
  459. }
  460. if (!StringUtils.isEmpty(accid)) {
  461. // 关联附件
  462. String[] ssids = accid.split(",");
  463. for (String ssid : ssids) {
  464. JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid);
  465. if (jdjcfj != null) {
  466. jdjcfj.setJdtxid(entity.getId());
  467. jdjcfjService.save(jdjcfj);
  468. }
  469. }
  470. }
  471. } catch (Exception e) {
  472. wr.setSuccess(false);
  473. wr.setMessage("操作失败!");
  474. e.printStackTrace();
  475. }
  476. try {
  477. if (jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), code.getId()) != null) {
  478. jdjcService.claim(code.getId(), SecUtils.getCurrUser().getId().toString());
  479. }
  480. jdjcService.changeAudit(null, entity, true);
  481. } catch (Exception e) {
  482. wr.setSuccess(false);
  483. wr.setMessage("操作失败!");
  484. e.printStackTrace();
  485. }
  486. return wr;
  487. }
  488. @RequestMapping(value = "/audit")
  489. @ResponseBody
  490. public WebJsonResult audit(String shyj, String id, boolean flag, String accid) {
  491. WebJsonResult wr = success();
  492. JdjcEntity entity = jdjcService.findOne(id);
  493. if (!StringUtils.isEmpty(accid)) {
  494. // 关联附件
  495. String[] ssids = accid.split(",");
  496. for (String ssid : ssids) {
  497. JdjcfjEntity jdjcfj = jdjcfjService.findOne(ssid);
  498. if (jdjcfj != null) {
  499. jdjcfj.setJdtxid(entity.getId());
  500. jdjcfjService.save(jdjcfj);
  501. }
  502. }
  503. }
  504. try {
  505. if (jdjcService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), id) != null) {
  506. jdjcService.claim(id, SecUtils.getCurrUser().getId().toString());
  507. }
  508. jdjcService.changeAudit(shyj, entity, flag);
  509. } catch (Exception e) {
  510. wr.setSuccess(false);
  511. wr.setMessage("操作失败!");
  512. e.printStackTrace();
  513. }
  514. return wr;
  515. }
  516. @RequestMapping(value = "/edit")
  517. public String edit(Model model, String id, String flag) {
  518. model.addAttribute("flag", flag);
  519. JdjcEntity entity = jdjcService.findOne(id);
  520. JdjcVo vo = new JdjcVo();
  521. BeanUtils.copyProperties(entity, vo);
  522. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  523. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  524. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  525. vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : "");
  526. vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : "");
  527. model.addAttribute("record", vo);
  528. List<JdjcfjEntity> list = jdjcfjService.findByJdjcid(id, "1");
  529. if (list != null && list.size() > 0) {
  530. model.addAttribute("fjlist", list);
  531. }
  532. return "ggfwxxgl/jdjc/jdjcedit";
  533. }
  534. @RequestMapping(value = "/view")
  535. @RequiresPermissions("jdjc:main")
  536. public String view(Model model, String id, String flag, String opflag) {
  537. model.addAttribute("flag", flag);
  538. JdjcEntity entity = jdjcService.findOne(id);
  539. JdjcVo vo = new JdjcVo();
  540. BeanUtils.copyProperties(entity, vo);
  541. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  542. vo.setSzdzw(entity.getSzd() != null ? entity.getSzd().getText() : "");
  543. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  544. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  545. vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  546. vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  547. vo.setSzd(entity.getSzd() != null ? entity.getSzd().getId() : "");
  548. vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getId() : "");
  549. vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getId() : "");
  550. vo.setSzgkmc(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
  551. vo.setSzgqmc(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
  552. vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : "");
  553. vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : "");
  554. vo.setGkjyr(entity.getGkjyr() != null ? entity.getGkjyr().getId() : "");
  555. vo.setGkjyrmc(entity.getGkjyr() != null ? entity.getGkjyr().getGkjyr() : "");
  556. model.addAttribute("record", vo);
  557. List<TaskInfoEntity> lists = taskInfoService.findByBusIdAndBusKeyAndRecordStatus(id, JdjcEntity.PROCESS_DEFINITION_KEY);
  558. if (lists != null & lists.size() > 0) {
  559. TaskInfoEntity taskinfo = lists.get(0);
  560. if ("年度审核材料".equals(taskinfo.getCurrName())) {
  561. opflag = "1";
  562. } else if ("年度审核批准".equals(taskinfo.getCurrName())) {
  563. opflag = "2";
  564. } else if ("".equals(taskinfo.getCurrName())) {
  565. opflag = "3";
  566. }
  567. model.addAttribute("opflag", opflag);
  568. }
  569. if (isJyr()) {
  570. model.addAttribute("jyrFlag", "1");
  571. }
  572. List<JdjcfjEntity> zgfjlist = jdjcfjService.findByJdjcid(id, "1");
  573. if (zgfjlist != null && zgfjlist.size() > 0) {
  574. model.addAttribute("zgfjlist", zgfjlist);
  575. }
  576. List<JdjcfjEntity> zghfjlist = jdjcfjService.findByJdjcid(id, "0");
  577. if (zghfjlist != null && zghfjlist.size() > 0) {
  578. model.addAttribute("zghfjlist", zghfjlist);
  579. }
  580. return "ggfwxxgl/jdjc/jdjcview";
  581. }
  582. @RequestMapping(value = "/add")
  583. @RequiresPermissions("jdjc:add")
  584. public String add(Model model) {
  585. UserEntity user = securityMgr.getCurrUser();
  586. model.addAttribute("user", user);
  587. SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd");
  588. Date today = new Date();
  589. model.addAttribute("sqrq", dateTimeFormat.format(today));
  590. int btnflag = 0;
  591. if (GlobalData.CITY_CODE.length() > 3) {
  592. btnflag = 1;
  593. }
  594. model.addAttribute("btnflag", btnflag);
  595. return "ggfwxxgl/jdjc/jdjcadd";
  596. }
  597. // 保存附件
  598. @RequestMapping(value = "/saveFile")
  599. @ResponseBody
  600. public WebJsonResult saveFile(@RequestParam("file") List<MultipartFile> file, String fjFlag, Model model, HttpServletRequest request, HttpServletResponse response) {
  601. WebJsonResult wr = success();
  602. if (file != null && file.size() > 0) {
  603. JdjcfjEntity fjEntity = new JdjcfjEntity();
  604. for (int i = 0; i < file.size(); i++) {
  605. MultipartFile f = file.get(i);
  606. if (f.getSize() > 0) {
  607. AccessoryEntity acc = accessoryService.saveFile(f, "jdtx");
  608. if (acc != null) {
  609. fjEntity.setFjid(acc.getId());
  610. fjEntity.setFjmc(acc.getName());
  611. fjEntity.setType(fjFlag);
  612. fjEntity = jdjcfjService.save(fjEntity);
  613. break;
  614. }
  615. }
  616. }
  617. wr.setAttr("acc", fjEntity);
  618. } else {
  619. wr.setSuccess(false);
  620. wr.setMessage("请上传附件或上传的文件不能为空文件!");
  621. }
  622. return wr;
  623. }
  624. @RequestMapping(value = "/delFile")
  625. @ResponseBody
  626. public WebJsonResult delFile(String accid, Model model) {
  627. WebJsonResult wr = success();
  628. try {
  629. JdjcfjEntity entity = jdjcfjService.findOne(accid);
  630. if (entity != null) {
  631. AccessoryEntity acc = accessoryService.findOne(entity.getFjid());
  632. if (acc != null) {
  633. accessoryService.delete(acc);
  634. if (entity != null) {
  635. String path = acc.getFilepath() + acc.getFilename();
  636. File file = new File(path);
  637. if (file.isFile() && file.exists()) {
  638. file.delete();
  639. }
  640. }
  641. }
  642. jdjcfjService.delete(entity);
  643. }
  644. } catch (Exception e) {
  645. wr.setSuccess(false);
  646. }
  647. return wr;
  648. }
  649. }