|
@@ -1,5 +1,6 @@
|
|
|
package com.xt.jygl.gkjygl.cghzyxxgl.dcsb.ctl;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
@@ -12,7 +13,9 @@ import javax.persistence.criteria.CriteriaBuilder.In;
|
|
|
import javax.persistence.criteria.CriteriaQuery;
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
import javax.persistence.criteria.Root;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import org.activiti.engine.ActivitiException;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -366,7 +369,206 @@ public class DcsbCtl extends BaseWebCtl {
|
|
|
putPageInfo(model, page, list);
|
|
|
return "gkjygl/cghzyxxgl/dcsb/dcsbmain";
|
|
|
}
|
|
|
+ //导出
|
|
|
+ @RequestMapping(value="/exportExcelAll")
|
|
|
+ @ResponseBody
|
|
|
+ public String exportExcelAll(HttpServletResponse response,SimplePageRequest page, Model model, final String gkjyr, final String szdid, final String szgkid, final String szgqid, final String zypmc, final String bh, final String hwzl, final String shzt, final String menuid, final Date zysjq, final String dydlid, final Date zysjz, final HttpServletRequest request) throws JsonProcessingException {
|
|
|
+ final Map<String, Object> cacheSCmap = CacheSearchCondition.cacheSCmap(request, "dcsb");
|
|
|
+ // 查询条件
|
|
|
+ Specification<DcsbEntity> spec = new Specification<DcsbEntity>() {
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<DcsbEntity> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
|
|
|
+ List<Predicate> list = new ArrayList<Predicate>();
|
|
|
+ if (StringUtils.isNotEmpty(gkjyr)) {
|
|
|
+ list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + gkjyr + "%"));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "gkjyr");
|
|
|
+ if (StringUtils.isNotEmpty(v)) {
|
|
|
+ list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + v + "%"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(zypmc)) {
|
|
|
+ list.add(cb.like(root.get("zypmc").as(String.class), "%" + zypmc + "%"));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "zypmc");
|
|
|
+ if (StringUtils.isNotEmpty(v)) {
|
|
|
+ list.add(cb.like(root.get("zypmc").as(String.class), "%" + v + "%"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(dydlid)) {
|
|
|
+ list.add(cb.equal(root.get("hwzl").get("id").as(String.class), dydlid));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, "id", "hwzl", "dydlid");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(shzt)) {
|
|
|
+ list.add(cb.like(root.get("shzt").as(String.class), "%" + shzt + "%"));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "shzt");
|
|
|
+ if (StringUtils.isNotEmpty(v)) {
|
|
|
+ list.add(cb.like(root.get("shzt").as(String.class), "%" + v + "%"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (null != zysjq && !"".equals(zysjq)) {
|
|
|
+ list.add(cb.greaterThanOrEqualTo(root.get("zysjq").as(Date.class), zysjq));
|
|
|
+ /*
|
|
|
+ * if (StringUtils.isNotEmpty(new
|
|
|
+ * SimpleDateFormat("yyyy-MM-dd").format(zysjq))) { } else
|
|
|
+ * if (isGET(request)) { String v = (String)
|
|
|
+ * CacheSearchCondition.cacheSCmapVal(cacheSCmap, "zysjq");
|
|
|
+ * if (StringUtils.isNotEmpty(new
|
|
|
+ * SimpleDateFormat("yyyy-MM-dd").format(v))) {
|
|
|
+ * list.add(cb.equal(root.get("zysjq").as(Date.class), v));
|
|
|
+ * } }
|
|
|
+ */
|
|
|
+ } else {
|
|
|
+ String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "zysjq");
|
|
|
+ if (!StringUtils.isEmpty(v)) {
|
|
|
+ try {
|
|
|
+ Date d = new SimpleDateFormat("yyyy-MM-dd").parse(v);
|
|
|
+ list.add(cb.greaterThanOrEqualTo(root.get("zysjq").as(Date.class), d));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null != zysjz && !"".equals(zysjz)) {
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("zysjz").as(Date.class), zysjz));
|
|
|
+ /*
|
|
|
+ * if (StringUtils.isNotEmpty(new
|
|
|
+ * SimpleDateFormat("yyyy-MM-dd").format(zysjz))) { } else
|
|
|
+ * if (isGET(request)) { String v = (String)
|
|
|
+ * CacheSearchCondition.cacheSCmapVal(cacheSCmap, "zysjz");
|
|
|
+ * if (StringUtils.isNotEmpty(v)) {
|
|
|
+ * list.add(cb.lessThanOrEqualTo
|
|
|
+ * (root.get("zysjz").as(Date.class), new
|
|
|
+ * SimpleDateFormat("yyyy-MM-dd").parse(v))); } }
|
|
|
+ */
|
|
|
+ } else {
|
|
|
+ String v = (String) CacheSearchCondition.cacheSCmapVal(cacheSCmap, "zysjz");
|
|
|
+ if (!StringUtils.isEmpty(v)) {
|
|
|
+ try {
|
|
|
+ Date d = new SimpleDateFormat("yyyy-MM-dd").parse(v);
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("zysjz").as(Date.class), d));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
|
|
|
+ if (isJyr()) {
|
|
|
+ list.add(cb.like(root.get("ssjyr").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_VALID));
|
|
|
+ }
|
|
|
+ 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[] {}));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ String user1 = (String) Utils.getSession().getAttribute("userpre");
|
|
|
+ String user2 = SecUtils.getCurrUser().getId();
|
|
|
+ if (user2 != null) {
|
|
|
+ if (!user2.equals(user1)) {
|
|
|
+ SearchCondition.dcsbpage = 1;
|
|
|
+ SearchCondition.dcsbjyr = "";
|
|
|
+ SearchCondition.dcsbszd = "";
|
|
|
+ SearchCondition.dcsbszgk = "";
|
|
|
+ SearchCondition.dcsbszgq = "";
|
|
|
+ SearchCondition.dcsbzypmc = "";
|
|
|
+ SearchCondition.dcsbhwzl = "";
|
|
|
+ SearchCondition.dcsbshzt = "";
|
|
|
+ SearchCondition.dcsbzysjq = null;
|
|
|
+ SearchCondition.dcsbzysjz = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Utils.getSession().setAttribute("userpre", user2);
|
|
|
|
|
|
+
|
|
|
+ List<DcsbEntity> list = query.findAll(spec,DcsbEntity.class);
|
|
|
+ List<DcsbVo> voList = new ArrayList<DcsbVo>();
|
|
|
+ for (DcsbEntity entity : list) {
|
|
|
+ DcsbVo vo = new DcsbVo();
|
|
|
+ if (entity != null) {
|
|
|
+ BeanUtils.copyProperties(entity, vo);
|
|
|
+ vo.setSsjyr(entity.getSsjyr() != null ? entity.getSsjyr().getGkjyr() : "");
|
|
|
+ vo.setSzgk(entity.getSzgk() != null ? entity.getSzgk().getGkmc() : "");
|
|
|
+ vo.setSzgq(entity.getSzgq() != null ? entity.getSzgq().getGqmc() : "");
|
|
|
+ if (entity.getShzt() != null) {
|
|
|
+ vo.setShztzw(securityMgr.codeService().findOne(entity.getShzt()).getText());
|
|
|
+ }
|
|
|
+ if (entity.getHwzl() != null) {
|
|
|
+ vo.setHwzlzw(securityMgr.codeService().findOne(entity.getHwzl().getId()).getText());
|
|
|
+ }
|
|
|
+ if ((dcsbService.getTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) || dcsbService.getCandidateTaskByUserAndBusKey(SecUtils.getCurrUser().getId().toString(), entity.getId().toString()) != null) {
|
|
|
+ List<TaskInfoEntity> lists = taskInfoService.findByBusIdAndBusKeyAndRecordStatus(entity.getId(), DcsbEntity.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);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.setContentType("application/binary;charset=iso-8859-1");
|
|
|
+ try {
|
|
|
+ ServletOutputStream outputStream = response.getOutputStream();
|
|
|
+ String fileName = new String(("港口单船作业申报").getBytes(), "iso-8859-1");
|
|
|
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".xlsx");// 组装附件名称和格式
|
|
|
+ dcsbService.exportExcelAll(voList, outputStream);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
// 货物种类
|
|
|
@RequestMapping(value = "/selectHwzl")
|
|
|
@ResponseBody
|
|
@@ -503,7 +705,7 @@ public class DcsbCtl extends BaseWebCtl {
|
|
|
|
|
|
return "gkjygl/cghzyxxgl/dcsb/dcsbedit";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 保存
|
|
|
@RequestMapping(value = "/save")
|
|
|
@ResponseBody
|