|
@@ -16,6 +16,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|
|
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;
|
|
|
|
|
@@ -249,7 +250,149 @@ public class DcsbybbCtl extends BaseWebCtl {
|
|
|
putPageInfo(model, page, list);
|
|
|
return "gkjygl/cghzyxxgl/dcsbybb/dcsbybbmain";
|
|
|
}
|
|
|
+ //导出
|
|
|
+ @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 jcg, final String nwm, final String hwzl, final String menuid, final String zysjq, final String zysjz, final HttpServletRequest request,final String dydlid) throws JsonProcessingException{
|
|
|
+ final Map<String, Object> cacheSCmap = CacheSearchCondition.cacheSCmap(request,"dcsbybb");
|
|
|
+ // 查询条件
|
|
|
+ Specification<DcsbybbEntity> spec = new Specification<DcsbybbEntity>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Predicate toPredicate(Root<DcsbybbEntity> 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)) {
|
|
|
+ //list.add(cb.like(root.get("ssjyr").get("gkjyr").as(String.class), "%" + SearchCondition.ybbjyr + "%"));
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, "gkjyr","ssjyr","gkjyr");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(szdid)) {
|
|
|
+ list.add(cb.like(root.get("szd").get("id").as(String.class), szdid + "%"));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, "id","szd","szdid");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(szgkid)) {
|
|
|
+ list.add(cb.equal(root.get("szgk").get("id").as(String.class), szgkid));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, "id","szgk","szgkid");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(szgqid)) {
|
|
|
+ list.add(cb.equal(root.get("szgq").get("id").as(String.class), szgqid));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, "id","szgq","szgqid");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(jcg)) {
|
|
|
+ list.add(cb.equal(root.get("jcg").as(String.class), jcg));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, null,"jcg");
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(nwm)) {
|
|
|
+ list.add(cb.equal(root.get("nwm").as(String.class), nwm));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ CacheSearchCondition.predicateList(list, cacheSCmap, root, cb, null,"nwm");
|
|
|
+ }
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
|
+ Date date;
|
|
|
+ if (StringUtils.isNotEmpty(zysjq)) {
|
|
|
+ try {
|
|
|
+ date = sdf.parse(zysjq);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ date = null;
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ list.add(cb.greaterThanOrEqualTo(root.get("bgsj").as(Date.class), date));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ String val =(String)CacheSearchCondition.cacheSCmapVal(cacheSCmap,"zysjq");
|
|
|
+ if(StringUtils.isNotEmpty(val)){
|
|
|
+ try {
|
|
|
+ date = sdf.parse(val);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ date = null;
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ list.add(cb.greaterThanOrEqualTo(root.get("bgsj").as(Date.class),date));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(zysjz)) {
|
|
|
+ try {
|
|
|
+ date = sdf.parse(zysjz);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ date = null;
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("bgsj").as(Date.class), date));
|
|
|
+ } else if (isGET(request)) {
|
|
|
+ String val =(String)CacheSearchCondition.cacheSCmapVal(cacheSCmap,"zysjz");
|
|
|
+ if(StringUtils.isNotEmpty(val)){
|
|
|
+ try {
|
|
|
+ date = sdf.parse(val);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ date = null;
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ list.add(cb.lessThanOrEqualTo(root.get("bgsj").as(Date.class), date));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 经营人只能查看自己企业下的数据,非经营人只能查看自己所在地的数据
|
|
|
+ if (isJyr()) {
|
|
|
+ list.add(cb.like(root.get("ssjyr").get("id").as(String.class), "%" + getSsjyr().getId() + "%"));
|
|
|
+ } else {
|
|
|
+ list.add(cb.like(root.get("szd").get("id").as(String.class), "%" + SecUtils.getCurrUser().getSzd().getId() + "%"));
|
|
|
+ }
|
|
|
+ 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[] {}));
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
+
|
|
|
+ List<DcsbybbEntity> list = query.findAll(spec, DcsbybbEntity.class);
|
|
|
+ List<DcsbybbVo> voList = new ArrayList<DcsbybbVo>();
|
|
|
+ for (DcsbybbEntity entity : list) {
|
|
|
+ DcsbybbVo vo = new DcsbybbVo();
|
|
|
+ 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.getHwzl() != null) {
|
|
|
+ vo.setHwzlzw(securityMgr.codeService().findOne(entity.getHwzl().getId()).getText());
|
|
|
+ }
|
|
|
+ if (entity.getJcg() != null) {
|
|
|
+ vo.setJcg(securityMgr.codeService().findOne(entity.getJcg()).getText());
|
|
|
+ }
|
|
|
+ if (entity.getNwm() != null) {
|
|
|
+ vo.setNwm(securityMgr.codeService().findOne(entity.getNwm()).getText());
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(entity.getBgsj())){
|
|
|
+ SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM");
|
|
|
+ vo.setBgsj(dateTimeFormat.format(entity.getBgsj()));
|
|
|
+ }
|
|
|
+ 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");// 组装附件名称和格式
|
|
|
+ dcsbybbService.exportExcelAll(voList, outputStream);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
// 新增
|
|
|
@RequestMapping(value = "/add")
|
|
|
public String add(Model model) {
|