package cn.com.lzt.clothing.apply.controller; import cn.com.lzt.clothing.apply.entity.ClothingApplyEntity; import cn.com.lzt.clothing.apply.page.ClothingApplyPage; import cn.com.lzt.clothing.apply.service.ClothingApplyServiceI; import cn.com.lzt.clothing.applydetail.entity.ClothingApplyDetailEntity; import cn.com.lzt.clothing.user.entity.ClothingUserEntity; import cn.com.lzt.common.controller.BaseLztController; import cn.com.lzt.common.util.DictUtil; import cn.com.lzt.common.util.LztUtil; import cn.com.lzt.common.util.UserUtil; import cn.com.lzt.common.view.JsonDataModelAndView; import cn.com.lzt.useractiviti.data.util.ActivitiPdfExport; import cn.com.lzt.useractiviti.data.util.ActivitiTools; import cn.com.lzt.warehouse.entity.WarehouseEntity; import cn.com.lzt.workflow.service.WorkflowServiceI; import com.lowagie.text.pdf.PdfPTable; import com.xcgl.weixin.entity.WXAjaxJson; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.jeecgframework.core.beanvalidator.BeanValidators; import org.jeecgframework.core.common.exception.BusinessException; import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery; import org.jeecgframework.core.common.model.json.AjaxJson; import org.jeecgframework.core.common.model.json.DataGrid; import org.jeecgframework.core.constant.Globals; import org.jeecgframework.core.util.*; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants; import org.jeecgframework.tag.core.easyui.TagUtil; import org.jeecgframework.web.system.pojo.base.TSDepart; import org.jeecgframework.web.system.pojo.base.TSUser; import org.jeecgframework.web.system.service.SystemService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.util.UriComponentsBuilder; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.ConstraintViolation; import javax.validation.Validator; import java.io.IOException; import java.math.BigDecimal; import java.net.URI; import java.util.*; /** * @Title: Controller * @Description: 服装申请 * @author onlineGenerator * @date 2019-10-10 09:26:47 * @version V1.0 * */ @Controller @RequestMapping("/clothingApplyController") public class ClothingApplyController extends BaseLztController { /** * Logger for this class */ private static final Logger logger = Logger.getLogger(ClothingApplyController.class); @Autowired private ClothingApplyServiceI clothingApplyService; @Autowired private SystemService systemService; @Autowired private Validator validator; @Autowired WorkflowServiceI workflowService ; /** * 服装申请列表 页面跳转 * * @return */ @RequestMapping(params = "list") public ModelAndView list(HttpServletRequest request) { String userid = ResourceUtil.getSessionUser().getId(); String hql1 = "from WarehouseEntity where responsiblePerson=? "; List warehouseList = systemService.findHql(hql1, userid); if (warehouseList.size() > 1) request.setAttribute("isMultiWarehouse", "1"); else request.setAttribute("isMultiWarehouse", "0"); return new ModelAndView("cn/com/lzt/clothing/apply/clothingApplyList"); } @RequestMapping(params = "listQry") public ModelAndView listQry(HttpServletRequest request) { return new ModelAndView("cn/com/lzt/clothing/apply/clothingApplyQryList"); } /** * easyui AJAX请求数据 * * @param request * @param response * @param dataGrid */ @RequestMapping(params = "datagrid") public void datagrid(ClothingApplyEntity clothingApply,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { CriteriaQuery cq = new CriteriaQuery(ClothingApplyEntity.class, dataGrid); TSUser user = ResourceUtil.getSessionUser(); boolean isproject = UserUtil.isProjectUser(user.getId()); if(isproject) { String sql_wh = "select distinct id from t_b_warehouse ware " + " where ware.responsible_person = '"+ user.getId()+"'"; List wh_ids = systemService.findListbySql(sql_wh); if(wh_ids != null && wh_ids.size()>0) { cq.in("warehouseid",wh_ids.toArray(new String[]{})); }else { //没有仓库,则查不出数据 cq.eq("warehouseid", "1"); } } if(StringUtils.isNotEmpty(clothingApply.getWarehousename())) { cq.like("warehousename", "%"+clothingApply.getWarehousename()+"%"); clothingApply.setWarehousename(null); } //查询条件组装器 org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, clothingApply); cq.add(); this.clothingApplyService.getDataGridReturn(cq, true); TagUtil.datagrid(response, dataGrid); } /** * 删除服装申请 * * @return */ @RequestMapping(params = "doDel") @ResponseBody public AjaxJson doDel(ClothingApplyEntity clothingApply, HttpServletRequest request) { AjaxJson j = new AjaxJson(); clothingApply = systemService.getEntity(ClothingApplyEntity.class, clothingApply.getId()); String message = "服装申请删除成功"; try{ clothingApplyService.delMain(clothingApply); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); }catch(Exception e){ e.printStackTrace(); message = "服装申请删除失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } @RequestMapping(params = "doGrant") @ResponseBody public AjaxJson doGrant(String ids, HttpServletRequest request) { AjaxJson j = new AjaxJson(); String message = "服装发放成功"; try{ String[] idList = ids.split(","); for (String id : idList) { ClothingApplyEntity clothingApply = systemService.getEntity(ClothingApplyEntity.class, id); clothingApply.setGrantstatus("1"); systemService.saveOrUpdate(clothingApply); } systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); }catch(Exception e){ e.printStackTrace(); message = "服装发放失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } /** * 批量删除服装申请 * * @return */ @RequestMapping(params = "doBatchDel") @ResponseBody public AjaxJson doBatchDel(String ids,HttpServletRequest request){ AjaxJson j = new AjaxJson(); String message = "服装申请删除成功"; try{ for(String id:ids.split(",")){ ClothingApplyEntity clothingApply = systemService.getEntity(ClothingApplyEntity.class, id ); clothingApplyService.delMain(clothingApply); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); } }catch(Exception e){ e.printStackTrace(); message = "服装申请删除失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } /** * 添加服装申请 * * @return */ @RequestMapping(params = "doAdd") @ResponseBody public AjaxJson doAdd(ClothingApplyEntity clothingApply,ClothingApplyPage clothingApplyPage, HttpServletRequest request) { List clothingApplyDetailList = clothingApplyPage.getClothingApplyDetailList(); AjaxJson j = new AjaxJson(); String message = "添加成功"; try{ clothingApply.setGrantstatus("0"); clothingApplyService.addMain(clothingApply, clothingApplyDetailList); systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO); }catch(Exception e){ e.printStackTrace(); message = "服装申请添加失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } /** * 更新服装申请 * * @return */ @RequestMapping(params = "doUpdate") @ResponseBody public AjaxJson doUpdate(ClothingApplyEntity clothingApply,ClothingApplyPage clothingApplyPage, HttpServletRequest request) { List clothingApplyDetailList = clothingApplyPage.getClothingApplyDetailList(); AjaxJson j = new AjaxJson(); String message = "更新成功"; try{ clothingApplyService.updateMain(clothingApply, clothingApplyDetailList); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); }catch(Exception e){ e.printStackTrace(); message = "更新服装申请失败"; throw new BusinessException(e.getMessage()); } j.setMsg(message); return j; } /** * 服装申请新增页面跳转 * * @return */ @RequestMapping(params = "goAdd") public ModelAndView goAdd(ClothingApplyEntity clothingApply, HttpServletRequest req) { String warehouseid = req.getParameter("warehouseid"); TSUser user = ResourceUtil.getSessionUser(); if(StringUtils.isEmpty(warehouseid)) { String sql_wh = "select distinct id from t_b_warehouse ware " + " where ware.responsible_person = '"+ user.getId()+"'"; List wh_ids = systemService.findListbySql(sql_wh); if(wh_ids.size() == 0) { req.setAttribute("ex", new BusinessException("登录人没有库管员权限,不能办理物料领用业务,请联系管理员。")); return new ModelAndView("common/error"); }else { warehouseid = wh_ids.get(0); } } clothingApply = new ClothingApplyEntity(); WarehouseEntity wh = systemService.get(WarehouseEntity.class, warehouseid); TSDepart dept = systemService.get(TSDepart.class, wh.getProjectId()); clothingApply.setWarehouseid(wh.getId()); clothingApply.setWarehousename(wh.getWarehouseName()); clothingApply.setDepartid(wh.getProjectId()); clothingApply.setProjectid(dept.getProjectid()); clothingApply.setApplydate(DateUtils.date_sdf.format(new Date())); req.setAttribute("clothingApplyPage", clothingApply); return new ModelAndView("cn/com/lzt/clothing/apply/clothingApply-add"); } /** * 服装申请编辑页面跳转 * * @return */ @RequestMapping(params = "goUpdate") public ModelAndView goUpdate(ClothingApplyEntity clothingApply, HttpServletRequest req) { if (StringUtil.isNotEmpty(clothingApply.getId())) { clothingApply = clothingApplyService.getEntity(ClothingApplyEntity.class, clothingApply.getId()); req.setAttribute("clothingApplyPage", clothingApply); } return new ModelAndView("cn/com/lzt/clothing/apply/clothingApply-update"); } @RequestMapping(params = "goUpdateMobile") public ModelAndView goUpdateMobile(ClothingApplyEntity clothingApply, HttpServletRequest req) { if (StringUtil.isNotEmpty(clothingApply.getId())) { clothingApply = clothingApplyService.getEntity(ClothingApplyEntity.class, clothingApply.getId()); String hql0 = "from ClothingApplyDetailEntity where 1 = 1 AND aPPLYID =? "; List clothingApplyDetailEntityList = systemService.findHql(hql0,clothingApply.getId()); double quantity = 0; for (ClothingApplyDetailEntity detail : clothingApplyDetailEntityList) { quantity += detail.getQuantity(); } req.setAttribute("totalquantity", quantity); req.setAttribute("entity", clothingApply); } Map data = LztUtil.copyReqAttributes(new String[]{ "totalquantity", "entity"}); return new JsonDataModelAndView(WXAjaxJson.success(data)); } /** * 加载明细列表[服装申请明细] * * @return */ @RequestMapping(params = "clothingApplyDetailList") public ModelAndView clothingApplyDetailList(ClothingApplyEntity clothingApply, HttpServletRequest req) { //=================================================================================== //获取参数 Object id0 = clothingApply.getId(); //=================================================================================== //查询-服装申请明细 String hql0 = "from ClothingApplyDetailEntity where 1 = 1 AND aPPLYID =? "; try{ List clothingApplyDetailEntityList = systemService.findHql(hql0,id0); for (ClothingApplyDetailEntity detail : clothingApplyDetailEntityList) { String sql = "select sum(quantity) quantity from t_b_clothing_user where userid = '" +detail.getUserid()+"' and clothingid = '"+detail.getClothingid()+"'"; List quantity = systemService.findListbySql(sql); if(quantity != null && quantity.size() > 0 && quantity.get(0) != null) { detail.setQuantityexist(quantity.get(0).intValue()); }else { detail.setQuantityexist(0); } } req.setAttribute("clothingApplyDetailList", clothingApplyDetailEntityList); }catch(Exception e){ logger.info(e.getMessage()); } return new ModelAndView("cn/com/lzt/clothing/applydetail/clothingApplyDetailList"); } /** * 导出excel * * @param request * @param response */ @RequestMapping(params = "exportXls") public String exportXls(ClothingApplyEntity clothingApply,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid,ModelMap map) { CriteriaQuery cq = new CriteriaQuery(ClothingApplyEntity.class, dataGrid); //查询条件组装器 org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, clothingApply); try{ //自定义追加查询条件 }catch (Exception e) { throw new BusinessException(e.getMessage()); } cq.add(); List list=this.clothingApplyService.getListByCriteriaQuery(cq, false); List pageList=new ArrayList(); if(list!=null&&list.size()>0){ for(ClothingApplyEntity entity:list){ try{ ClothingApplyPage page=new ClothingApplyPage(); MyBeanUtils.copyBeanNotNull2Bean(entity,page); Object id0 = entity.getId(); String hql0 = "from ClothingApplyDetailEntity where 1 = 1 AND aPPLYID =? "; List clothingApplyDetailEntityList = systemService.findHql(hql0,id0); page.setClothingApplyDetailList(clothingApplyDetailEntityList); pageList.add(page); }catch(Exception e){ logger.info(e.getMessage()); } } } map.put(NormalExcelConstants.FILE_NAME,"服装申请"); map.put(NormalExcelConstants.CLASS,ClothingApplyPage.class); map.put(NormalExcelConstants.PARAMS,new ExportParams("服装申请列表", "导出人:Jeecg", "导出信息")); map.put(NormalExcelConstants.DATA_LIST,pageList); return NormalExcelConstants.JEECG_EXCEL_VIEW; } /** * 通过excel导入数据 * @param request * @param * @return */ @RequestMapping(params = "importExcel", method = RequestMethod.POST) @ResponseBody public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) { AjaxJson j = new AjaxJson(); MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map fileMap = multipartRequest.getFileMap(); for (Map.Entry entity : fileMap.entrySet()) { MultipartFile file = entity.getValue();// 获取上传文件对象 ImportParams params = new ImportParams(); params.setTitleRows(2); params.setHeadRows(2); params.setNeedSave(true); try { List list = ExcelImportUtil.importExcel(file.getInputStream(), ClothingApplyPage.class, params); ClothingApplyEntity entity1=null; for (ClothingApplyPage page : list) { entity1=new ClothingApplyEntity(); MyBeanUtils.copyBeanNotNull2Bean(page,entity1); clothingApplyService.addMain(entity1, page.getClothingApplyDetailList()); } j.setMsg("文件导入成功!"); } catch (Exception e) { j.setMsg("文件导入失败!"); logger.error(ExceptionUtil.getExceptionMessage(e)); }finally{ try { file.getInputStream().close(); } catch (IOException e) { e.printStackTrace(); } } } return j; } /** * 导出excel 使模板 */ @RequestMapping(params = "exportXlsByT") public String exportXlsByT(ModelMap map) { map.put(NormalExcelConstants.FILE_NAME,"服装申请"); map.put(NormalExcelConstants.CLASS,ClothingApplyPage.class); map.put(NormalExcelConstants.PARAMS,new ExportParams("服装申请列表", "导出人:"+ ResourceUtil.getSessionUser().getRealName(), "导出信息")); map.put(NormalExcelConstants.DATA_LIST,new ArrayList()); return NormalExcelConstants.JEECG_EXCEL_VIEW; } /** * 导入功能跳转 * * @return */ @RequestMapping(params = "upload") public ModelAndView upload(HttpServletRequest req) { req.setAttribute("controller_name", "clothingApplyController"); return new ModelAndView("common/upload/pub_excel_upload"); } @RequestMapping(method = RequestMethod.GET) @ResponseBody public List list() { List listClothingApplys=clothingApplyService.getList(ClothingApplyEntity.class); return listClothingApplys; } @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity get(@PathVariable("id") String id) { ClothingApplyEntity task = clothingApplyService.get(ClothingApplyEntity.class, id); if (task == null) { return new ResponseEntity(HttpStatus.NOT_FOUND); } return new ResponseEntity(task, HttpStatus.OK); } @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResponseEntity create(@RequestBody ClothingApplyPage clothingApplyPage, UriComponentsBuilder uriBuilder) { //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. Set> failures = validator.validate(clothingApplyPage); if (!failures.isEmpty()) { return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); } //保存 List clothingApplyDetailList = clothingApplyPage.getClothingApplyDetailList(); ClothingApplyEntity clothingApply = new ClothingApplyEntity(); try{ MyBeanUtils.copyBeanNotNull2Bean(clothingApply,clothingApplyPage); }catch(Exception e){ logger.info(e.getMessage()); } clothingApplyService.addMain(clothingApply, clothingApplyDetailList); //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. String id = clothingApplyPage.getId(); URI uri = uriBuilder.path("/rest/clothingApplyController/" + id).build().toUri(); HttpHeaders headers = new HttpHeaders(); headers.setLocation(uri); return new ResponseEntity(headers, HttpStatus.CREATED); } @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity update(@RequestBody ClothingApplyPage clothingApplyPage) { //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. Set> failures = validator.validate(clothingApplyPage); if (!failures.isEmpty()) { return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); } //保存 List clothingApplyDetailList = clothingApplyPage.getClothingApplyDetailList(); ClothingApplyEntity clothingApply = new ClothingApplyEntity(); try{ MyBeanUtils.copyBeanNotNull2Bean(clothingApply,clothingApplyPage); }catch(Exception e){ logger.info(e.getMessage()); } clothingApplyService.updateMain(clothingApply, clothingApplyDetailList); //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码. return new ResponseEntity(HttpStatus.NO_CONTENT); } @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.NO_CONTENT) public void delete(@PathVariable("id") String id) { ClothingApplyEntity clothingApply = clothingApplyService.get(ClothingApplyEntity.class, id); clothingApplyService.delMain(clothingApply); } @SuppressWarnings({ "unchecked", "rawtypes" }) @RequestMapping(params = "getClothingUserInfo", method = RequestMethod.POST) @ResponseBody public Object getClothingUserInfo(String userid,String clothingid){ Map reJson = new HashMap(); String startdate = ""; String lastdate = ""; if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(clothingid)){ try{ List cuList = systemService.findHql( " From ClothingUserEntity where userid =? and clothingid =? order by createDate desc", userid,clothingid); if(cuList.size() > 0) { startdate = DateUtils.date_sdf.format(cuList.get(0).getStartdate()); lastdate = DateUtils.date_sdf.format(cuList.get(0).getCreateDate()); } }catch (Exception e) { reJson.put("status", "fail"); logger.info(e.getMessage()); return reJson; } reJson.put("status", "success"); reJson.put("startdate", startdate); reJson.put("lastdate", lastdate); }else{ reJson.put("status", "fail"); reJson.put("msg", "员工、服装信息未找到,查询不到启用日期、上次申领日期"); } return reJson; } @RequestMapping(params = "goView") public ModelAndView goView(ClothingApplyEntity clothingApply, HttpServletRequest request) { String taskId = request.getParameter("taskId"); //【我发起的流程】-【详情】中查看业务数据时,只看单据信息,不预览审批流程 if(StringUtils.isEmpty(taskId)) { clothingApply = clothingApplyService.getEntity(ClothingApplyEntity.class, clothingApply.getId()); request.setAttribute("clothingApplyPage", clothingApply); request.setAttribute("viewFlag", "1"); return new ModelAndView("cn/com/lzt/clothing/apply/clothingApply-update"); } // if(StringUtils.isNotEmpty(request.getParameter("flag"))){ // //驳回重填表单 // request.setAttribute("url", "contractController.do?goUpdate&return=1&id="+workflowService.getBpmDataId(taskId)); // }else { // request.setAttribute("url", "contractController.do?goUpdate&load=detail&audit=1&id="+workflowService.getBpmDataId(taskId)); // } request.setAttribute("url", "clothingApplyController.do?goUpdate&load=detail&id="+workflowService.getBpmDataId(taskId)); Map taskDetails = workflowService.getTaskDetails(taskId); request.setAttribute("busititle", "服装申领详细信息"); request.setAttribute("id", workflowService.getBpmDataId(taskId)); request.setAttribute("bpmLogList", taskDetails.get("bpmLogList")); request.setAttribute("taskId", taskDetails.get("taskId")); request.setAttribute("taskName", taskDetails.get("taskName")); request.setAttribute("task", taskDetails.get("task")); request.setAttribute("transitionList", taskDetails.get("transitionList")); request.setAttribute("nextCodeCount", taskDetails.get("nextCodeCount")); request.setAttribute("bpmLogListCount", taskDetails.get("bpmLogListCount")); request.setAttribute("bpmLogNewList", taskDetails.get("bpmLogNewList")); request.setAttribute("bpmLogNewListCount", taskDetails.get("bpmLogNewListCount")); request.setAttribute("histListNode", taskDetails.get("histListNode")); request.setAttribute("histListSize", taskDetails.get("histListSize")); request.setAttribute("turnbackTaskId", taskDetails.get("turnbackTaskId")); request.setAttribute("height", "750px"); return new ModelAndView("cn/com/lzt/workflow/task-option"); } @RequestMapping(params="exportDetailPdf4Mobile") public void exportDetailPdf4Mobile(@RequestParam("procInstId") String procInstId, HttpServletResponse response){ ActivitiTools tools = ActivitiTools.getInstance(procInstId,true); tools.setTitle("服装申领明细"); tools.setProcInstId(null); ActivitiPdfExport pdfExport = tools.getPdfExport(); String id = tools.getBusId(); ClothingApplyEntity clothingApply = clothingApplyService.getEntity(ClothingApplyEntity.class, id); String hql0 = "from ClothingApplyDetailEntity where 1 = 1 AND aPPLYID =? "; List clothingApplyDetailEntityList = systemService.findHql(hql0,clothingApply.getId()); double quantity = 0; for (ClothingApplyDetailEntity detail : clothingApplyDetailEntityList) { quantity += detail.getQuantity(); } BigDecimal totalMoney = clothingApply.getTotalMoney(); pdfExport.table() .cell("领料点",clothingApply.getWarehousename()) .cell("申请日期",clothingApply.getApplydate()) .cell("申请总数",String.valueOf(quantity)) .cell("总金额",totalMoney==null?"":totalMoney.toPlainString()); try{ pdfExport.cell(""); PdfPTable detailTableHeader = pdfExport.createTable(12); detailTableHeader.setWidthPercentage(100); pdfExport.cell(detailTableHeader, "员工姓名", false); pdfExport.cell(detailTableHeader, "服装名称", false); pdfExport.cell(detailTableHeader, "服装类型", false); pdfExport.cell(detailTableHeader, "入职日期", false); pdfExport.cell(detailTableHeader, "上次申领日期", false); pdfExport.cell(detailTableHeader, "启用日期", false); pdfExport.cell(detailTableHeader, "申请原因", false); pdfExport.cell(detailTableHeader, "单价", false); pdfExport.cell(detailTableHeader, "申请数量", false); pdfExport.cell(detailTableHeader, "金额", false); pdfExport.cell(detailTableHeader, "已有数量", false); pdfExport.cell(detailTableHeader, "尺寸", false); pdfExport.cell(detailTableHeader); int i = 0; for(ClothingApplyDetailEntity detailEntity:clothingApplyDetailEntityList){ String sql = "select sum(quantity) quantity from t_b_clothing_user where userid = '" +detailEntity.getUserid()+"' and clothingid = '"+detailEntity.getClothingid()+"'"; List quantityList = systemService.findListbySql(sql); if(quantityList != null && quantityList.size() > 0 && quantityList.get(0) != null) { detailEntity.setQuantityexist(quantityList.get(0).intValue()); }else { detailEntity.setQuantityexist(0); } i++; PdfPTable detailTable = pdfExport.createTable(12); BigDecimal price = detailEntity.getPrice(); BigDecimal money = detailEntity.getMoney(); pdfExport.cell(detailTable,detailEntity.getRealname(),false); pdfExport.cell(detailTable, detailEntity.getClothingname(), false); pdfExport.cell(detailTable, DictUtil.formatToTypeName(detailEntity.getType(),"clothingtype") , false); pdfExport.cell(detailTable, DateUtils.formatDate(detailEntity.getEntrydate(),"yyyy-MM-dd"), false); pdfExport.cell(detailTable, DateUtils.formatDate(detailEntity.getLastdate(),"yyyy-MM-dd"), false); pdfExport.cell(detailTable, DateUtils.formatDate(detailEntity.getStartdate(),"yyyy-MM-dd"), false); pdfExport.cell(detailTable, DictUtil.formatToTypeName(detailEntity.getApplyreason(),"applyreason"), false); pdfExport.cell(detailTable, price ==null?"":price.toPlainString(), false); pdfExport.cell(detailTable, String.valueOf(detailEntity.getQuantity()), false); pdfExport.cell(detailTable, money ==null?"":money.toPlainString(), false); pdfExport.cell(detailTable, String.valueOf(detailEntity.getQuantityexist()), false); pdfExport.cell(detailTable, String.valueOf(detailEntity.getSize()), false); pdfExport.cell("明细"+i,true); pdfExport.cell(detailTable); } }catch(Exception e){ e.printStackTrace(); logger.info(e.getMessage()); } tools.exportToResponse(response); } }