| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- 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<WarehouseEntity> 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<String> 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<ClothingApplyDetailEntity> 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<ClothingApplyDetailEntity> 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<String> 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<ClothingApplyDetailEntity> 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<String, Object> 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<ClothingApplyDetailEntity> 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<BigDecimal> 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<ClothingApplyEntity> list=this.clothingApplyService.getListByCriteriaQuery(cq, false);
- List<ClothingApplyPage> pageList=new ArrayList<ClothingApplyPage>();
- 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<ClothingApplyDetailEntity> 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<String, MultipartFile> fileMap = multipartRequest.getFileMap();
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
- MultipartFile file = entity.getValue();// 获取上传文件对象
- ImportParams params = new ImportParams();
- params.setTitleRows(2);
- params.setHeadRows(2);
- params.setNeedSave(true);
- try {
- List<ClothingApplyPage> 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<ClothingApplyEntity> list() {
- List<ClothingApplyEntity> 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<ConstraintViolation<ClothingApplyPage>> failures = validator.validate(clothingApplyPage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- List<ClothingApplyDetailEntity> 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<ConstraintViolation<ClothingApplyPage>> failures = validator.validate(clothingApplyPage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- List<ClothingApplyDetailEntity> 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, Object>();
- String startdate = "";
- String lastdate = "";
- if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(clothingid)){
- try{
- List<ClothingUserEntity> 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<String, Object> 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<ClothingApplyDetailEntity> 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<BigDecimal> 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);
- }
- }
|