package cn.com.lzt.arrangeduty.controller; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.validation.ConstraintViolation; import javax.validation.Validator; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.poi.ss.usermodel.Workbook; import org.jeecgframework.core.beanvalidator.BeanValidators; import org.jeecgframework.core.common.controller.BaseController; import org.jeecgframework.core.common.exception.BusinessException; 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.ContextHolderUtils; import org.jeecgframework.core.util.DataUtils; import org.jeecgframework.core.util.ExceptionUtil; import org.jeecgframework.core.util.JeecgDataAutorUtils; import org.jeecgframework.core.util.MyBeanUtils; import org.jeecgframework.core.util.ResourceUtil; import org.jeecgframework.core.util.StringUtil; import org.jeecgframework.core.util.oConvertUtils; import org.jeecgframework.minidao.pojo.MiniDaoPage; import org.jeecgframework.poi.excel.ExcelExportUtil; 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.params.ExcelExportEntity; import org.jeecgframework.poi.excel.entity.vo.MapExcelConstants; import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants; import org.jeecgframework.tag.core.easyui.TagUtil; import org.jeecgframework.web.system.pojo.base.DictEntity; 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.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; 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 cn.com.lzt.arrangeduty.dao.ArrangeDutyMinidao; import cn.com.lzt.arrangeduty.dto.ArrangeDutyDto; import cn.com.lzt.arrangeduty.dto.MealsSubsidyDto; import cn.com.lzt.arrangeduty.dto.ProjectDepartDto; import cn.com.lzt.arrangeduty.entity.ArrangeDutyEntity; import cn.com.lzt.arrangeduty.service.ArrangeDutyServiceI; import cn.com.lzt.dialogDeal.service.DialogDealServiceI; import cn.com.lzt.mealssubsidy.entity.MealsSubsidyEntity; import cn.com.lzt.mealssubsidy.service.MealsSubsidyServiceI; import cn.com.lzt.projarrangedetail.projectarrangecommonmethod.ProjectArrangeCommonMethod; import cn.com.lzt.projarrangegeneral.service.ProjArrangeGeneralServiceI; import cn.com.lzt.projectpostdetail.service.ProjectPostDetailServiceI; import cn.com.lzt.useroptions.entity.TBusUserOptionsEntity; import cn.com.lzt.useroptions.service.TBusUserOptionsServiceI; /** * @Title: Controller * @Description: 班次表 * @author onlineGenerator * @date 2017-10-20 17:44:12 * @version V1.0 * */ @Controller @RequestMapping("/arrangeDutyController") public class ArrangeDutyController extends BaseController { /** * Logger for this class */ private static final Logger logger = Logger.getLogger(ArrangeDutyController.class); @Autowired private ArrangeDutyServiceI arrangeDutyService; @Autowired private ProjArrangeGeneralServiceI projArrangeGeneralService; @Autowired private SystemService systemService; @Autowired private Validator validator; @Autowired private ArrangeDutyMinidao arrangeDutyMinidao; @Autowired private ProjectPostDetailServiceI projectPostDetailService; @Autowired private TBusUserOptionsServiceI userOptionsService; //餐费补贴 @Autowired private MealsSubsidyServiceI mealsSubsidyService; /** * 项目信息获取 */ @Autowired DialogDealServiceI dialogDealServiceI; /** * 班次表列表 页面跳转 * * @return */ @RequestMapping(params = "list") public ModelAndView list(HttpServletRequest request) { HttpSession session = ContextHolderUtils.getSession(); TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER"); String departid = ""; String departname = ""; try { TBusUserOptionsEntity options = userOptionsService.getOptionsByUserID(tuser.getId(), Globals.USER_OPTIONS_TYPE_PROJECT, false); if(options != null) { departid = options.getOptionId(); departname = options.getOptionName(); } } catch (Exception e) { e.printStackTrace(); org.jeecgframework.core.util.LogUtil.error(e.getMessage()); } Calendar calendar = DataUtils.getCalendar(); calendar.add(Calendar.MONTH, -1); String yearmonth = DataUtils.formatDate(calendar, "yyyy-MM-dd"); request.setAttribute("maxdate", yearmonth); if (oConvertUtils.isNotEmpty(departid)) { request.setAttribute("departid", departid); request.setAttribute("departname", departname); } return new ModelAndView("cn/com/lzt/arrangeduty/arrangeDutyList"); } /** * 班次表列表 页面跳转 公司 * * @return */ @RequestMapping(params = "listAll") public ModelAndView listAll(HttpServletRequest request) { String departid = oConvertUtils.getString(request.getParameter("departid")); Calendar calendar = DataUtils.getCalendar(); calendar.add(Calendar.MONTH, -1); String yearmonth = DataUtils.formatDate(calendar, "yyyy-MM-dd"); request.setAttribute("maxdate", yearmonth); request.setAttribute("departid", departid); TSDepart depart = systemService.get(TSDepart.class, departid); if(depart != null) { request.setAttribute("departname", depart.getDepartname()); } return new ModelAndView("cn/com/lzt/arrangeduty/arrangeDutyAllList"); } /** * easyui AJAX请求数据 * * @param request * @param response * @param dataGrid * @param user */ @RequestMapping(params = "datagrid") public void datagrid(ArrangeDutyDto arrangeDutyDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { String myPId=arrangeDutyDto.getPid(); if(myPId!=null&&myPId.length()>0){ if(myPId.indexOf(",") == myPId.length()-1) { arrangeDutyDto.setPid(myPId.split(",")[0]); }else if(myPId.indexOf(",") < myPId.length()-1 && myPId.indexOf(",") >= 0) { arrangeDutyDto.setPid(myPId.split(",")[1]); }else { arrangeDutyDto.setPid(myPId); } }else { String queryParams = oConvertUtils.getString(request.getParameter("departid")); arrangeDutyDto.setPid(queryParams); } HttpSession session = ContextHolderUtils.getSession(); TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER"); try { if(arrangeDutyDto.getPid()!=null){ userOptionsService.saveUserOptions(tuser.getId(), arrangeDutyDto.getPid(), Globals.USER_OPTIONS_TYPE_PROJECT); }else { TBusUserOptionsEntity options = userOptionsService.getOptionsByUserID(tuser.getId(), Globals.USER_OPTIONS_TYPE_PROJECT, true); if(options != null) { arrangeDutyDto.setPid(options.getOptionId()); } } } catch (Exception e) { e.printStackTrace(); org.jeecgframework.core.util.LogUtil.error(e.getMessage()); } //根据当前登录用户id查询项目信息 List projectDepartDtoList=dialogDealServiceI.getProjectDepartByUserId(); List pidList=new ArrayList(); for (int i = 0; i < projectDepartDtoList.size(); i++) { pidList.add(projectDepartDtoList.get(i).getId()); } //根据用户所属项目和兼职项目查询,如果有查询条件,则只用条件查询 if(arrangeDutyDto.getPid()!=null&&arrangeDutyDto.getPid().length()>0){ List tempList=new ArrayList(); tempList.add(arrangeDutyDto.getPid()); pidList.retainAll(tempList); } arrangeDutyDto.setPidList(pidList); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); MiniDaoPage list = arrangeDutyService.getArrangeDutyDtoPage(arrangeDutyDto, dataGrid.getPage(), dataGrid.getRows(),authSql); for (int i = 0; i < list.getResults().size(); i++) { if(list.getResults().get(i)!=null){ if(list.getResults().get(i).getNormalworkStime()!=null &&list.getResults().get(i).getNormalworkStime().length()!=0 &&list.getResults().get(i).getNormalworkEtime()!=null &&list.getResults().get(i).getNormalworkEtime().length()!=0){ String normalWorkStime=list.getResults().get(i).getNormalworkStime()+"-"+list.getResults().get(i).getNormalworkEtime(); list.getResults().get(i).setNormalworkStime(normalWorkStime); } if(list.getResults().get(i).getOndutyStime()!=null &&list.getResults().get(i).getOndutyStime().length()!=0 &&list.getResults().get(i).getOndutyEtime()!=null &&list.getResults().get(i).getOndutyEtime().length()!=0){ String ondutyStime=list.getResults().get(i).getOndutyStime()+"-"+list.getResults().get(i).getOndutyEtime(); list.getResults().get(i).setOndutyStime(ondutyStime); } if(list.getResults().get(i).getTimeOutOvertimeStime()!=null &&list.getResults().get(i).getTimeOutOvertimeStime().length()!=0 &&list.getResults().get(i).getTimeOutOvertimeEtime()!=null &&list.getResults().get(i).getTimeOutOvertimeEtime().length()!=0){ String Overtime=list.getResults().get(i).getTimeOutOvertimeStime()+"-"+list.getResults().get(i).getTimeOutOvertimeEtime(); list.getResults().get(i).setTimeOutOvertimeStime(Overtime); } } } dataGrid.setTotal(list.getTotal()); dataGrid.setResults(list.getResults()); TagUtil.datagrid(response, dataGrid); } /** * easyui AJAX请求数据 * * @param request * @param response * @param dataGrid * @param user */ @RequestMapping(params = "datagridAll") public void datagridAll(ArrangeDutyDto arrangeDutyDto,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { String departid = oConvertUtils.getString(request.getParameter("departid")); String myPId=arrangeDutyDto.getPid(); if(myPId!=null&&myPId.length()>0){ if(myPId.indexOf(",") == myPId.length()-1) { arrangeDutyDto.setPid(myPId.split(",")[0]); }else if(myPId.indexOf(",") < myPId.length()-1 && myPId.indexOf(",") >= 0) { arrangeDutyDto.setPid(myPId.split(",")[1]); }else { arrangeDutyDto.setPid(myPId); } }else { arrangeDutyDto.setPid(departid); } String departname = oConvertUtils.getString(request.getParameter("departname")); // HttpSession session = ContextHolderUtils.getSession(); // TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER"); // try { // if(arrangeDutyDto.getPid()!=null){ // userOptionsService.saveUserOptions(tuser.getId(), arrangeDutyDto.getPid(), Globals.USER_OPTIONS_TYPE_PROJECT); // }else { // TBusUserOptionsEntity options = userOptionsService.getOptionsByUserID(tuser.getId(), Globals.USER_OPTIONS_TYPE_PROJECT, true); // if(options != null) { // arrangeDutyDto.setPid(options.getOptionId()); // } // } // } catch (Exception e) { // e.printStackTrace(); // org.jeecgframework.core.util.LogUtil.error(e.getMessage()); // } //根据当前登录用户id查询项目信息 // List projectDepartDtoList=dialogDealServiceI.getProjectDepartByUserId(); List pidList=new ArrayList(); // for (int i = 0; i < projectDepartDtoList.size(); i++) { // pidList.add(projectDepartDtoList.get(i).getId()); // } pidList.add(arrangeDutyDto.getPid()); //根据用户所属项目和兼职项目查询,如果有查询条件,则只用条件查询 if(arrangeDutyDto.getPid()!=null&&arrangeDutyDto.getPid().length()>0){ List tempList=new ArrayList(); tempList.add(arrangeDutyDto.getPid()); pidList.retainAll(tempList); } arrangeDutyDto.setPidList(pidList); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); MiniDaoPage list = arrangeDutyService.getArrangeDutyDtoPage(arrangeDutyDto, dataGrid.getPage(), dataGrid.getRows(),authSql); for (int i = 0; i < list.getResults().size(); i++) { if(list.getResults().get(i)!=null){ if(list.getResults().get(i).getNormalworkStime()!=null &&list.getResults().get(i).getNormalworkStime().length()!=0 &&list.getResults().get(i).getNormalworkEtime()!=null &&list.getResults().get(i).getNormalworkEtime().length()!=0){ String normalWorkStime=list.getResults().get(i).getNormalworkStime()+"-"+list.getResults().get(i).getNormalworkEtime(); list.getResults().get(i).setNormalworkStime(normalWorkStime); } if(list.getResults().get(i).getOndutyStime()!=null &&list.getResults().get(i).getOndutyStime().length()!=0 &&list.getResults().get(i).getOndutyEtime()!=null &&list.getResults().get(i).getOndutyEtime().length()!=0){ String ondutyStime=list.getResults().get(i).getOndutyStime()+"-"+list.getResults().get(i).getOndutyEtime(); list.getResults().get(i).setOndutyStime(ondutyStime); } if(list.getResults().get(i).getTimeOutOvertimeStime()!=null &&list.getResults().get(i).getTimeOutOvertimeStime().length()!=0 &&list.getResults().get(i).getTimeOutOvertimeEtime()!=null &&list.getResults().get(i).getTimeOutOvertimeEtime().length()!=0){ String Overtime=list.getResults().get(i).getTimeOutOvertimeStime()+"-"+list.getResults().get(i).getTimeOutOvertimeEtime(); list.getResults().get(i).setTimeOutOvertimeStime(Overtime); } } } request.setAttribute("departid", departid); request.setAttribute("departname", departname); dataGrid.setTotal(list.getTotal()); dataGrid.setResults(list.getResults()); TagUtil.datagrid(response, dataGrid); } /** * 删除班次表 * * @return */ @RequestMapping(params = "doDel") @ResponseBody public AjaxJson doDel(ArrangeDutyEntity arrangeDuty, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); arrangeDuty = systemService.getEntity(ArrangeDutyEntity.class, arrangeDuty.getId()); message = "班次删除成功"; try{ arrangeDutyService.delete(arrangeDuty); 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 = "doBatchDel") @ResponseBody public AjaxJson doBatchDel(String ids,HttpServletRequest request){ String message = null; AjaxJson j = new AjaxJson(); message = "班次删除成功"; try{ for(String id:ids.split(",")){ ArrangeDutyEntity arrangeDuty = systemService.getEntity(ArrangeDutyEntity.class, id ); arrangeDutyService.delete(arrangeDuty); 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; } /** * 添加班次表 * * @param ids * @return */ @RequestMapping(params = "doAdd") @ResponseBody public AjaxJson doAdd(ArrangeDutyEntity arrangeDuty, HttpServletRequest request) { // String strIp=request.getRemoteAddr(); // ProjectArrangeCommonMethod.writeVisitorIp("添加班次表"+strIp); String message = null; AjaxJson j = new AjaxJson(); message = "班次添加成功"; /*String myPId=arrangeDuty.getPid(); if(myPId!=null&&myPId.length()>0){ String[] pIdList=myPId.split(","); arrangeDuty.setPid(pIdList[0]); }*/ if(arrangeDuty.getPid()!=null&&arrangeDuty.getPid().length()>0){ arrangeDuty.setPid(arrangeDuty.getPid().split(",")[0]); } try{ arrangeDuty.setDeleteFlag(Globals.Delete_Normal.toString()); arrangeDuty.setStatus(Globals.Enabled_Status.toString()); if(arrangeDuty.getOndutyEtime()!=null&&arrangeDuty.getOndutyEtime().length()!=0 &&arrangeDuty.getOndutyStime()!=null&&arrangeDuty.getOndutyStime().length()!=0){ arrangeDuty.setOndutyWorkhours(ProjectArrangeCommonMethod.dealMinuteToHourFormat(arrangeDuty.getOndutyStime(),arrangeDuty.getOndutyEtime())); } arrangeDutyService.save(arrangeDuty); 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; } /** * 更新班次表 * * @param ids * @return */ @RequestMapping(params = "doUpdate") @ResponseBody public AjaxJson doUpdate(ArrangeDutyEntity arrangeDuty, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); message = "班次更新成功"; if(arrangeDuty.getPid()!=null&&arrangeDuty.getPid().length()>0){ arrangeDuty.setPid(arrangeDuty.getPid().split(",")[0]); } ArrangeDutyEntity t = arrangeDutyService.get(ArrangeDutyEntity.class, arrangeDuty.getId()); try { if(arrangeDuty.getOndutyEtime()!=null&&arrangeDuty.getOndutyEtime().length()!=0 &&arrangeDuty.getOndutyStime()!=null&&arrangeDuty.getOndutyStime().length()!=0){ arrangeDuty.setOndutyWorkhours(ProjectArrangeCommonMethod.dealMinuteToHourFormat(arrangeDuty.getOndutyStime(),arrangeDuty.getOndutyEtime())); } if(arrangeDuty.getNormalworkStime()==null){ t.setNormalworkStime(null); } if(arrangeDuty.getNormalworkEtime()==null){ t.setNormalworkEtime(null); } if(arrangeDuty.getDatumWorkhours()==null){ t.setDatumWorkhours(null); } if(arrangeDuty.getShiftWorkhours()==null){ t.setShiftWorkhours(null); } if(arrangeDuty.getTimeOutOvertimeHours()==null){ t.setTimeOutOvertimeHours(null); } if(arrangeDuty.getSpunchMinute()==null){ t.setSpunchMinute(null); } if(arrangeDuty.getEpunchMinute()==null){ t.setEpunchMinute(null); } MyBeanUtils.copyBeanNotNull2Bean(arrangeDuty, t); arrangeDutyService.saveOrUpdate(t); 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(ArrangeDutyEntity arrangeDuty, HttpServletRequest req) { if (StringUtil.isNotEmpty(arrangeDuty.getId())) { arrangeDuty = arrangeDutyService.getEntity(ArrangeDutyEntity.class, arrangeDuty.getId()); req.setAttribute("arrangeDutyPage", arrangeDuty); } return new ModelAndView("cn/com/lzt/arrangeduty/arrangeDuty-add"); } /** * 班次表编辑页面跳转 * * @return */ @RequestMapping(params = "goUpdate") public ModelAndView goUpdate(ArrangeDutyEntity arrangeDuty, HttpServletRequest req) { if (StringUtil.isNotEmpty(arrangeDuty.getId())) { arrangeDuty = arrangeDutyService.getEntity(ArrangeDutyEntity.class, arrangeDuty.getId()); /*if(arrangeDuty.getPid().length()>0&&arrangeDuty.getPid().indexOf(",")==-1){ arrangeDuty.setPid(arrangeDuty.getPid()+","); }*/ String pid = arrangeDuty.getPid(); if(pid != null) { TSDepart depart = systemService.get(TSDepart.class, pid); if(depart != null) { arrangeDuty.setDepartname(depart.getDepartname()); } } String mealid = arrangeDuty.getDutyMealid(); if(mealid != null) { MealsSubsidyEntity meal = systemService.get(MealsSubsidyEntity.class, mealid); if(meal != null) { arrangeDuty.setDutyMealName(meal.getSubsidyName()); } } req.setAttribute("arrangeDutyPage", arrangeDuty); } return new ModelAndView("cn/com/lzt/arrangeduty/arrangeDuty-update"); } /** * 班次表编辑页面跳转 * * @return */ @RequestMapping(params = "goUpdateAll") public ModelAndView goUpdateAll(ArrangeDutyEntity arrangeDuty, HttpServletRequest req) { if (StringUtil.isNotEmpty(arrangeDuty.getId())) { arrangeDuty = arrangeDutyService.getEntity(ArrangeDutyEntity.class, arrangeDuty.getId()); /*if(arrangeDuty.getPid().length()>0&&arrangeDuty.getPid().indexOf(",")==-1){ arrangeDuty.setPid(arrangeDuty.getPid()+","); }*/ String pid = arrangeDuty.getPid(); if(pid != null) { TSDepart depart = systemService.get(TSDepart.class, pid); if(depart != null) { arrangeDuty.setDepartname(depart.getDepartname()); } } String mealid = arrangeDuty.getDutyMealid(); if(mealid != null) { MealsSubsidyEntity meal = systemService.get(MealsSubsidyEntity.class, mealid); if(meal != null) { arrangeDuty.setDutyMealName(meal.getSubsidyName()); } } req.setAttribute("arrangeDutyPage", arrangeDuty); } return new ModelAndView("cn/com/lzt/arrangeduty/arrangeDutyAll-update"); } /** * 导入功能跳转 * * @return */ @RequestMapping(params = "upload") public ModelAndView upload(HttpServletRequest req) { req.setAttribute("controller_name","arrangeDutyController"); return new ModelAndView("common/upload/pub_excel_upload"); } /** * 导出excel * * @param request * @param response */ @RequestMapping(params = "exportXls") public String exportXls(ArrangeDutyDto arrangeDutyDto,HttpServletRequest request,HttpServletResponse response , DataGrid dataGrid,ModelMap modelMap) { //获取餐补名称 List mealsSubsidyList=systemService.queryDict("t_bus_meals_subsidy", "id", "subsidy_name"); Map mealsSubsidyMap=new HashMap(); for (int i = 0; i < mealsSubsidyList.size(); i++) { mealsSubsidyMap.put(mealsSubsidyList.get(i).getTypecode(), mealsSubsidyList.get(i).getTypename()); } /*//获取餐补名称 List mealsSubsidyList=systemService.queryDict("t_bus_meals_subsidy", "id", "subsidy_name"); Map mealsSubsidyMap=new HashMap(); for (int i = 0; i < mealsSubsidyList.size(); i++) { mealsSubsidyMap.put(mealsSubsidyList.get(i).getTypecode(), mealsSubsidyList.get(i).getTypename()); } //获取项目名称 List departList=systemService.queryDict("t_s_depart", "id", "departname"); Map departMap=new HashMap(); for (int i = 0; i < departList.size(); i++) { departMap.put(departList.get(i).getTypecode(), departList.get(i).getTypename()); } //获取班次类型 List dutyTypeList=systemService.queryDict(null, "dutyType", null); Map dutyTypeMap=new HashMap(); for (int i = 0; i < dutyTypeList.size(); i++) { dutyTypeMap.put(dutyTypeList.get(i).getTypecode(), dutyTypeList.get(i).getTypename()); } //标题 该list中用于存储标题的信息,每一个ExcelExportEntity 表示一列,根据List 的入栈顺序,由左至右,一次排序 List entityList = new ArrayList(); ExcelExportEntity head1=new ExcelExportEntity("班次名称", "dutyName", 15); entityList.add(head1); ExcelExportEntity head2=new ExcelExportEntity("班次类型", "dutyType", 15); entityList.add(head2); ExcelExportEntity head3=new ExcelExportEntity("项目", "pid", 15); entityList.add(head3); ExcelExportEntity head4=new ExcelExportEntity("正常工作时间", "normalworkStime", 15); entityList.add(head4); ExcelExportEntity head5=new ExcelExportEntity("开始打卡分钟数", "spunchMinute", 15); entityList.add(head5); ExcelExportEntity head6=new ExcelExportEntity("结束打卡分钟数", "epunchMinute", 15); entityList.add(head6); ExcelExportEntity head7=new ExcelExportEntity("基准工时(小时)", "datumWorkhours", 15); entityList.add(head7); ExcelExportEntity head8=new ExcelExportEntity("班次工时(小时)", "shiftWorkhours", 15); entityList.add(head8); ExcelExportEntity head9=new ExcelExportEntity("值班时间", "ondutyStime", 15); entityList.add(head9); ExcelExportEntity head10=new ExcelExportEntity("超时加班时间", "timeOutOvertimeStime", 15); entityList.add(head10); ExcelExportEntity head11=new ExcelExportEntity("超时加班时长(小时)", "timeOutOvertimeHours", 15); entityList.add(head11); ExcelExportEntity head12=new ExcelExportEntity("班次餐补", "dutyMealid", 15); entityList.add(head12); ExcelExportEntity head13=new ExcelExportEntity("备注", "remark", 15); entityList.add(head13); //组建数据集 List> dataResult = new ArrayList>(); //根据当前登录用户id查询项目信息 List projectDepartDtoList=dialogDealServiceI.getProjectDepartByUserId(); List pidList=new ArrayList(); for (int i = 0; i < projectDepartDtoList.size(); i++) { pidList.add(projectDepartDtoList.get(i).getId()); } //根据用户所属项目和兼职项目查询,如果有查询条件,则只用条件查询 if(arrangeDutyDto.getPid()!=null&&arrangeDutyDto.getPid().length()>0){ List tempList=new ArrayList(); tempList.add(arrangeDutyDto.getPid()); pidList.retainAll(tempList); } arrangeDutyDto.setPidList(pidList); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List arrangeDutyDtoList = arrangeDutyService.getArrangeDutyDtoNoPage(arrangeDutyDto,authSql); for (int i = 0; i < arrangeDutyDtoList.size(); i++) { Map map = new HashMap(); map.put("dutyName", arrangeDutyDtoList.get(i).getDutyName()); map.put("dutyType", arrangeDutyDtoList.get(i).getDutyType()); map.put("pid", departMap.get(arrangeDutyDtoList.get(i).getPid())); String normalWorkStime=""; if(arrangeDutyDtoList.get(i).getNormalworkStime()!=null &&arrangeDutyDtoList.get(i).getNormalworkStime().length()!=0 &&arrangeDutyDtoList.get(i).getNormalworkEtime()!=null &&arrangeDutyDtoList.get(i).getNormalworkEtime().length()!=0){ normalWorkStime=arrangeDutyDtoList.get(i).getNormalworkStime()+"-"+arrangeDutyDtoList.get(i).getNormalworkEtime(); } map.put("normalworkStime", normalWorkStime); map.put("spunchMinute", arrangeDutyDtoList.get(i).getSpunchMinute()); map.put("epunchMinute", arrangeDutyDtoList.get(i).getEpunchMinute()); map.put("datumWorkhours", arrangeDutyDtoList.get(i).getDatumWorkhours()); map.put("shiftWorkhours", arrangeDutyDtoList.get(i).getShiftWorkhours()); String ondutyStime=""; if(arrangeDutyDtoList.get(i).getOndutyStime()!=null &&arrangeDutyDtoList.get(i).getOndutyStime().length()!=0 &&arrangeDutyDtoList.get(i).getOndutyEtime()!=null &&arrangeDutyDtoList.get(i).getOndutyEtime().length()!=0){ ondutyStime=arrangeDutyDtoList.get(i).getOndutyStime()+"-"+arrangeDutyDtoList.get(i).getOndutyEtime(); } map.put("ondutyStime", ondutyStime); String timeOutOvertimeStime=""; if(arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeStime().length()!=0 &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime().length()!=0){ timeOutOvertimeStime=arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()+"-"+arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime(); } map.put("timeOutOvertimeStime", timeOutOvertimeStime); map.put("timeOutOvertimeHours", arrangeDutyDtoList.get(i).getTimeOutOvertimeHours()); List dutyMealidList=extractIdListByComma(arrangeDutyDtoList.get(i).getDutyMealid()); String dutyMealid=""; for (int k = 0; k < dutyMealidList.size(); k++) { for (int j = 0; j < mealsSubsidyList.size(); j++) { if(dutyMealidList.get(k).equals(mealsSubsidyList.get(j).getTypecode())){ if(dutyMealid.length()!=0){ dutyMealid+=","+mealsSubsidyList.get(j).getTypename(); }else{ dutyMealid=mealsSubsidyList.get(j).getTypename(); } break; } } } map.put("dutyMealid", dutyMealid); map.put("remark", arrangeDutyDtoList.get(i).getRemark()); dataResult.add(map); } modelMap.put(MapExcelConstants.ENTITY_LIST, entityList); modelMap.put(MapExcelConstants.MAP_LIST, dataResult); modelMap.put(NormalExcelConstants.FILE_NAME,"班次"); modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("班次列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导出信息")); return MapExcelConstants.JEECG_MAP_EXCEL_VIEW; */ /*CriteriaQuery cq = new CriteriaQuery(ArrangeDutyEntity.class, dataGrid); org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, arrangeDuty, request.getParameterMap()); List arrangeDutys = this.arrangeDutyService.getListByCriteriaQuery(cq,false); modelMap.put(NormalExcelConstants.FILE_NAME,"班次表"); modelMap.put(NormalExcelConstants.CLASS,ArrangeDutyEntity.class); modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("班次表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导出信息")); modelMap.put(NormalExcelConstants.DATA_LIST,arrangeDutys); return NormalExcelConstants.JEECG_EXCEL_VIEW;*/ // CriteriaQuery cq = new CriteriaQuery(ArrangeDutyEntity.class, dataGrid); // org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, arrangeDuty, request.getParameterMap()); // List arrangeDutys = this.arrangeDutyService.getListByCriteriaQuery(cq,false); //根据当前登录用户id查询项目信息 List projectDepartDtoList=dialogDealServiceI.getProjectDepartByUserId(); List pidList=new ArrayList(); for (int i = 0; i < projectDepartDtoList.size(); i++) { pidList.add(projectDepartDtoList.get(i).getId()); } //根据用户所属项目和兼职项目查询,如果有查询条件,则只用条件查询 if(arrangeDutyDto.getPid()!=null&&arrangeDutyDto.getPid().length()>0){ List tempList=new ArrayList(); String myPId = arrangeDutyDto.getPid(); if(myPId!=null&&myPId.length()>0){ if(myPId.indexOf(",") == myPId.length()-1) { tempList.add(myPId.split(",")[0]); }else if(myPId.indexOf(",") < myPId.length()-1 && myPId.indexOf(",") >= 0) { tempList.add(myPId.split(",")[1]); }else { tempList.add(myPId); } pidList.retainAll(tempList); } } arrangeDutyDto.setPidList(pidList); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List arrangeDutyDtoList = arrangeDutyService.getArrangeDutyDtoExport(arrangeDutyDto,authSql); for (int i = 0; i < arrangeDutyDtoList.size(); i++) { // Map map = new HashMap(); // map.put("dutyName", arrangeDutyDtoList.get(i).getDutyName()); // map.put("dutyType", arrangeDutyDtoList.get(i).getDutyType()); // map.put("pid", departMap.get(arrangeDutyDtoList.get(i).getPid())); String normalWorkStime=""; if(arrangeDutyDtoList.get(i).getNormalworkStime()!=null &&arrangeDutyDtoList.get(i).getNormalworkStime().length()!=0 &&arrangeDutyDtoList.get(i).getNormalworkEtime()!=null &&arrangeDutyDtoList.get(i).getNormalworkEtime().length()!=0){ normalWorkStime=arrangeDutyDtoList.get(i).getNormalworkStime()+"-"+arrangeDutyDtoList.get(i).getNormalworkEtime(); arrangeDutyDtoList.get(i).setNormalworkStime(normalWorkStime); } // map.put("normalworkStime", normalWorkStime); // // map.put("spunchMinute", arrangeDutyDtoList.get(i).getSpunchMinute()); // map.put("epunchMinute", arrangeDutyDtoList.get(i).getEpunchMinute()); // map.put("datumWorkhours", arrangeDutyDtoList.get(i).getDatumWorkhours()); // map.put("shiftWorkhours", arrangeDutyDtoList.get(i).getShiftWorkhours()); String ondutyStime=""; if(arrangeDutyDtoList.get(i).getOndutyStime()!=null &&arrangeDutyDtoList.get(i).getOndutyStime().length()!=0 &&arrangeDutyDtoList.get(i).getOndutyEtime()!=null &&arrangeDutyDtoList.get(i).getOndutyEtime().length()!=0){ ondutyStime=arrangeDutyDtoList.get(i).getOndutyStime()+"-"+arrangeDutyDtoList.get(i).getOndutyEtime(); arrangeDutyDtoList.get(i).setOndutyStime(ondutyStime); } // map.put("ondutyStime", ondutyStime); String timeOutOvertimeStime=""; if(arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeStime().length()!=0 &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime().length()!=0){ timeOutOvertimeStime=arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()+"-"+arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime(); arrangeDutyDtoList.get(i).setTimeOutOvertimeStime(timeOutOvertimeStime); } // map.put("timeOutOvertimeStime", timeOutOvertimeStime); // // map.put("timeOutOvertimeHours", arrangeDutyDtoList.get(i).getTimeOutOvertimeHours()); List dutyMealIdList=extractIdListByComma(arrangeDutyDtoList.get(i).getDutyMealid()); String dutyMealid=""; for (int k = 0; k < dutyMealIdList.size(); k++) { for (int j = 0; j < mealsSubsidyList.size(); j++) { if(dutyMealIdList.get(k).equals(mealsSubsidyList.get(j).getTypecode())){ if(dutyMealid.length()!=0){ dutyMealid+=","+mealsSubsidyList.get(j).getTypename(); }else{ dutyMealid=mealsSubsidyList.get(j).getTypename(); } break; } } } arrangeDutyDtoList.get(i).setDutyMealid(dutyMealid); // map.put("dutyMealid", dutyMealid); // map.put("remark", arrangeDutyDtoList.get(i).getRemark()); // // dataResult.add(map); } modelMap.put(NormalExcelConstants.FILE_NAME,"班次设定"); modelMap.put(NormalExcelConstants.CLASS,ArrangeDutyDto.class); modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("班次设定列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导出信息")); modelMap.put(NormalExcelConstants.DATA_LIST,arrangeDutyDtoList); return NormalExcelConstants.JEECG_EXCEL_VIEW; } /** * 导出excel * * @param request * @param response */ /*@RequestMapping(params = "exportXls") public void exportXls(ArrangeDutyDto arrangeDutyDto,HttpServletRequest request,HttpServletResponse response , DataGrid dataGrid ) { //获取餐补名称 List mealsSubsidyList=systemService.queryDict("t_bus_meals_subsidy", "id", "subsidy_name"); Map mealsSubsidyMap=new HashMap(); for (int i = 0; i < mealsSubsidyList.size(); i++) { mealsSubsidyMap.put(mealsSubsidyList.get(i).getTypecode(), mealsSubsidyList.get(i).getTypename()); } //获取项目名称 List departList=systemService.queryDict("t_s_depart", "id", "departname"); Map departMap=new HashMap(); for (int i = 0; i < departList.size(); i++) { departMap.put(departList.get(i).getTypecode(), departList.get(i).getTypename()); } //获取班次类型 List dutyTypeList=systemService.queryDict(null, "dutyType", null); Map dutyTypeMap=new HashMap(); for (int i = 0; i < dutyTypeList.size(); i++) { dutyTypeMap.put(dutyTypeList.get(i).getTypecode(), dutyTypeList.get(i).getTypename()); } //标题 该list中用于存储标题的信息,每一个ExcelExportEntity 表示一列,根据List 的入栈顺序,由左至右,一次排序 List entityList = new ArrayList(); ExcelExportEntity head1=new ExcelExportEntity("班次名称", "dutyName", 15); entityList.add(head1); ExcelExportEntity head2=new ExcelExportEntity("班次类型", "dutyType", 15); entityList.add(head2); ExcelExportEntity head3=new ExcelExportEntity("项目", "pid", 15); entityList.add(head3); ExcelExportEntity head4=new ExcelExportEntity("正常工作时间", "normalworkStime", 15); entityList.add(head4); ExcelExportEntity head5=new ExcelExportEntity("开始打卡分钟数", "spunchMinute", 15); entityList.add(head5); ExcelExportEntity head6=new ExcelExportEntity("结束打卡分钟数", "epunchMinute", 15); entityList.add(head6); ExcelExportEntity head7=new ExcelExportEntity("基准工时(小时)", "datumWorkhours", 15); entityList.add(head7); ExcelExportEntity head8=new ExcelExportEntity("班次工时(小时)", "shiftWorkhours", 15); entityList.add(head8); ExcelExportEntity head9=new ExcelExportEntity("值班时间", "ondutyStime", 15); entityList.add(head9); ExcelExportEntity head10=new ExcelExportEntity("超时加班时间", "timeOutOvertimeStime", 15); entityList.add(head10); ExcelExportEntity head11=new ExcelExportEntity("超时加班时长(小时)", "timeOutOvertimeHours", 15); entityList.add(head11); ExcelExportEntity head12=new ExcelExportEntity("班次餐补", "dutyMealid", 15); entityList.add(head12); ExcelExportEntity head13=new ExcelExportEntity("备注", "remark", 15); entityList.add(head13); //组建数据集 List> dataResult = new ArrayList>(); //根据当前登录用户id查询项目信息 List projectDepartDtoList=dialogDealServiceI.getProjectDepartByUserId(); List pidList=new ArrayList(); for (int i = 0; i < projectDepartDtoList.size(); i++) { pidList.add(projectDepartDtoList.get(i).getId()); } //根据用户所属项目和兼职项目查询,如果有查询条件,则只用条件查询 if(arrangeDutyDto.getPid()!=null&&arrangeDutyDto.getPid().length()>0){ List tempList=new ArrayList(); tempList.add(arrangeDutyDto.getPid()); pidList.retainAll(tempList); } arrangeDutyDto.setPidList(pidList); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List arrangeDutyDtoList = arrangeDutyService.getArrangeDutyDtoNoPage(arrangeDutyDto,authSql); for (int i = 0; i < arrangeDutyDtoList.size(); i++) { Map map = new HashMap(); map.put("dutyName", arrangeDutyDtoList.get(i).getDutyName()); map.put("dutyType", arrangeDutyDtoList.get(i).getDutyType()); map.put("pid", departMap.get(arrangeDutyDtoList.get(i).getPid())); String normalWorkStime=""; if(arrangeDutyDtoList.get(i).getNormalworkStime()!=null &&arrangeDutyDtoList.get(i).getNormalworkStime().length()!=0 &&arrangeDutyDtoList.get(i).getNormalworkEtime()!=null &&arrangeDutyDtoList.get(i).getNormalworkEtime().length()!=0){ normalWorkStime=arrangeDutyDtoList.get(i).getNormalworkStime()+"-"+arrangeDutyDtoList.get(i).getNormalworkEtime(); } map.put("normalworkStime", normalWorkStime); map.put("spunchMinute", arrangeDutyDtoList.get(i).getSpunchMinute()); map.put("epunchMinute", arrangeDutyDtoList.get(i).getEpunchMinute()); map.put("datumWorkhours", arrangeDutyDtoList.get(i).getDatumWorkhours()); map.put("shiftWorkhours", arrangeDutyDtoList.get(i).getShiftWorkhours()); String ondutyStime=""; if(arrangeDutyDtoList.get(i).getOndutyStime()!=null &&arrangeDutyDtoList.get(i).getOndutyStime().length()!=0 &&arrangeDutyDtoList.get(i).getOndutyEtime()!=null &&arrangeDutyDtoList.get(i).getOndutyEtime().length()!=0){ ondutyStime=arrangeDutyDtoList.get(i).getOndutyStime()+"-"+arrangeDutyDtoList.get(i).getOndutyEtime(); } map.put("ondutyStime", ondutyStime); String timeOutOvertimeStime=""; if(arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeStime().length()!=0 &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime()!=null &&arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime().length()!=0){ timeOutOvertimeStime=arrangeDutyDtoList.get(i).getTimeOutOvertimeStime()+"-"+arrangeDutyDtoList.get(i).getTimeOutOvertimeEtime(); } map.put("timeOutOvertimeStime", timeOutOvertimeStime); map.put("timeOutOvertimeHours", arrangeDutyDtoList.get(i).getTimeOutOvertimeHours()); List dutyMealidList=extractIdListByComma(arrangeDutyDtoList.get(i).getDutyMealid()); String dutyMealid=""; for (int k = 0; k < dutyMealidList.size(); k++) { for (int j = 0; j < mealsSubsidyList.size(); j++) { if(dutyMealidList.get(k).equals(mealsSubsidyList.get(j).getTypecode())){ if(dutyMealid.length()!=0){ dutyMealid+=","+mealsSubsidyList.get(j).getTypename(); }else{ dutyMealid=mealsSubsidyList.get(j).getTypename(); } break; } } } map.put("dutyMealid", dutyMealid); map.put("remark", arrangeDutyDtoList.get(i).getRemark()); dataResult.add(map); } //************ //获取项目名称 List departList1=systemService.queryDict("t_s_depart", "id", "departname"); Map departMap1=new HashMap(); for (int i = 0; i < departList1.size(); i++) { departMap1.put(departList1.get(i).getTypecode(), departList1.get(i).getTypename()); } //获取用户名称 List baseUserList=systemService.queryDict("t_s_base_user", "id", "realname"); Map baseUserMap=new HashMap(); for (int i = 0; i < baseUserList.size(); i++) { baseUserMap.put(baseUserList.get(i).getTypecode(), baseUserList.get(i).getTypename()); } //获取确认状态 List arrangeDutyStatusList=systemService.queryDict(null, "arrangeStatus", null); Map arrangeDutyStatusMap=new HashMap(); for (int i = 0; i < arrangeDutyStatusList.size(); i++) { arrangeDutyStatusMap.put(arrangeDutyStatusList.get(i).getTypecode(), arrangeDutyStatusList.get(i).getTypename()); } //标题 该list中用于存储标题的信息,每一个ExcelExportEntity 表示一列,根据List 的入栈顺序,由左至右,一次排序 List entityList1 = new ArrayList(); ExcelExportEntity head111=new ExcelExportEntity("月度", "yearmonth", 15); entityList1.add(head111); ExcelExportEntity head21=new ExcelExportEntity("项目名称", "pid", 15); entityList1.add(head21); ExcelExportEntity head31=new ExcelExportEntity("人数", "peopleQuantity", 15); entityList1.add(head31); ExcelExportEntity head41=new ExcelExportEntity("排班状态", "arrangeDutyStatus", 15); entityList1.add(head41); ExcelExportEntity head51=new ExcelExportEntity("上报人", "reporterId", 15); entityList1.add(head51); //组建数据集 List> dataResult1 = new ArrayList>(); String authSql1 = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); //查询项目排班详细表数据 List projArrangeGeneralDtolist = null; ProjArrangeGeneralDto projArrangeGeneralDto=new ProjArrangeGeneralDto(); try { projArrangeGeneralDtolist = projArrangeGeneralService.getProjArrangeGeneralDtoNoPage(projArrangeGeneralDto, authSql1); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error(ExceptionUtil.getExceptionMessage(e)); } for (int i = 0; i < projArrangeGeneralDtolist.size(); i++) { Map map = new HashMap(); map.put("yearmonth", projArrangeGeneralDtolist.get(i).getYearmonth()); map.put("pid", departMap1.get(projArrangeGeneralDtolist.get(i).getBelongUnitid())); map.put("peopleQuantity", projArrangeGeneralDtolist.get(i).getPeopleQuantity()); map.put("arrangeDutyStatus", arrangeDutyStatusMap.get(projArrangeGeneralDtolist.get(i).getArrangeDutyStatus())); map.put("reporterId", baseUserMap.get(projArrangeGeneralDtolist.get(i).getReporterId())); dataResult1.add(map); } //************ List> dataResult2 =dataResult; List> modelMapList=new ArrayList<>(); Map modelMap1= new HashMap<>(); modelMap1.put(MapExcelConstants.ENTITY_LIST, entityList); modelMap1.put(MapExcelConstants.MAP_LIST, dataResult); modelMap1.put(NormalExcelConstants.FILE_NAME,"班次"); modelMap1.put(NormalExcelConstants.PARAMS,new ExportParams("1班次列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导出信息")); modelMapList.add(modelMap1); Map modelMap2 = new HashMap(); modelMap2.put(MapExcelConstants.ENTITY_LIST, entityList1); modelMap2.put(MapExcelConstants.MAP_LIST, dataResult1); modelMap2.put(NormalExcelConstants.FILE_NAME,"班次asd"); modelMap2.put(NormalExcelConstants.PARAMS,new ExportParams("2班次列ddd表2", "导出cc人:"+ResourceUtil.getSessionUser().getRealName(), "导出信c息2")); modelMapList.add(modelMap2); Map modelMap3 = new HashMap(); modelMap3.put(MapExcelConstants.ENTITY_LIST, entityList1); modelMap3.put(MapExcelConstants.MAP_LIST, dataResult1); modelMap3.put(NormalExcelConstants.FILE_NAME,"班次asd"); modelMap3.put(NormalExcelConstants.PARAMS,new ExportParams("3班次列ddd表2", "导出cc人:"+ResourceUtil.getSessionUser().getRealName(), "导xxx出信c息2")); modelMapList.add(modelMap3); Map modelMap4= new HashMap<>(); modelMap4.put(MapExcelConstants.ENTITY_LIST, entityList); modelMap4.put(MapExcelConstants.MAP_LIST, dataResult); modelMap4.put(NormalExcelConstants.FILE_NAME,"班次"); modelMap4.put(NormalExcelConstants.PARAMS,new ExportParams("4班次列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导dcasdf出信息")); modelMapList.add(modelMap4); String codedFileName = "临时文件"+System.currentTimeMillis(); Workbook workbook = getWorkBook(modelMapList); if (workbook instanceof HSSFWorkbook) { codedFileName +=".xls"; } else { codedFileName +=".xlsx"; } try { if (isIE(request)) { codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8"); } else { codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1"); } response.setHeader("content-disposition", "attachment;filename=" + codedFileName); ServletOutputStream out = response.getOutputStream(); workbook.write(out); out.flush(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }*/ public static Workbook getWorkBook(List> list ) { Workbook workbook = null; for (int i = 0; i < list.size(); i++) { Map map = list.get(i); ExportParams exportParams = (ExportParams) map.get(MapExcelConstants.PARAMS); List entityList = (List) map.get(MapExcelConstants.ENTITY_LIST); List> resultData = (List>) map.get(MapExcelConstants.MAP_LIST); } for (int i = 0; i < list.size(); i++) { Map map = list.get(i); ExportParams exportParams = (ExportParams) map.get(MapExcelConstants.PARAMS); List entityList = (List) map.get(MapExcelConstants.ENTITY_LIST); List> resultData =(List>) map.get(MapExcelConstants.MAP_LIST); workbook = ExcelExportUtil.exportExcel( workbook, exportParams, entityList, resultData); } return workbook; } boolean isIE(HttpServletRequest request) { return (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 || request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0) ? true : false; } /** * 导出excel 使模板 * * @param request * @param response */ @RequestMapping(params = "exportXlsByT") public String exportXlsByT(ArrangeDutyEntity arrangeDuty,HttpServletRequest request,HttpServletResponse response , DataGrid dataGrid,ModelMap modelMap) { modelMap.put(NormalExcelConstants.FILE_NAME,"班次"); modelMap.put(NormalExcelConstants.CLASS,ArrangeDutyEntity.class); modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("班次列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(), "导出信息")); modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList()); return NormalExcelConstants.JEECG_EXCEL_VIEW; } @SuppressWarnings("unchecked") @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(1); params.setNeedSave(true); try { List listArrangeDutyEntitys = ExcelImportUtil.importExcel(file.getInputStream(),ArrangeDutyEntity.class,params); for (ArrangeDutyEntity arrangeDuty : listArrangeDutyEntitys) { arrangeDutyService.save(arrangeDuty); } j.setMsg("文件导入成功!"); } catch (Exception e) { j.setMsg("文件导入失败!"); logger.error(ExceptionUtil.getExceptionMessage(e)); }finally{ try { file.getInputStream().close(); } catch (IOException e) { e.printStackTrace(); } } } return j; } @RequestMapping(method = RequestMethod.GET) @ResponseBody public List list() { List listArrangeDutys=arrangeDutyService.getList(ArrangeDutyEntity.class); return listArrangeDutys; } @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity get(@PathVariable("id") String id) { ArrangeDutyEntity task = arrangeDutyService.get(ArrangeDutyEntity.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 ArrangeDutyEntity arrangeDuty, UriComponentsBuilder uriBuilder) { //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. Set> failures = validator.validate(arrangeDuty); if (!failures.isEmpty()) { return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); } //保存 try{ arrangeDutyService.save(arrangeDuty); } catch (Exception e) { e.printStackTrace(); return new ResponseEntity(HttpStatus.NO_CONTENT); } //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象. String id = arrangeDuty.getId(); URI uri = uriBuilder.path("/rest/arrangeDutyController/" + 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 ArrangeDutyEntity arrangeDuty) { //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息. Set> failures = validator.validate(arrangeDuty); if (!failures.isEmpty()) { return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST); } //保存 try{ arrangeDutyService.saveOrUpdate(arrangeDuty); } catch (Exception e) { e.printStackTrace(); return new ResponseEntity(HttpStatus.NO_CONTENT); } //按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) { arrangeDutyService.deleteEntityById(ArrangeDutyEntity.class, id); } /** * 逻辑删除班次表 * @author zbw * 2017-10-20 * @param wagestrategy * @param request * @return */ @RequestMapping(params = "logicDel") @ResponseBody public AjaxJson logicDel(ArrangeDutyEntity arrangeDutyEntity, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); arrangeDutyEntity = systemService.getEntity(ArrangeDutyEntity.class, arrangeDutyEntity.getId()); message = "班次删除成功"; try{ arrangeDutyEntity.setDeleteFlag(Globals.Delete_Forbidden.toString()); arrangeDutyService.logicDel(arrangeDutyEntity); systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); // wagestrategyService.delete(wagestrategy); // systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); }catch(Exception e){ j.setSuccess(false); e.printStackTrace(); message = "班次删除失败"; } j.setMsg(message); return j; } /** * 班次状态启用 * @author zbw * 2017-10-20 * @param id * @param request * @return */ @RequestMapping(params = "enable") @ResponseBody public AjaxJson enable(String id, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); message = "班次启用成功"; try{ ArrangeDutyEntity arrangeDutyEntity = arrangeDutyService.getEntity(ArrangeDutyEntity.class, id); arrangeDutyEntity.setStatus(Globals.Enabled_Status.toString()); arrangeDutyService.saveOrUpdate(arrangeDutyEntity); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); }catch(Exception e){ j.setSuccess(false); e.printStackTrace(); message = "班次启用失败"; } j.setMsg(message); return j; } /** * 班次状态停用 * @author zbw * 2017-10-20 * @param id * @param request * @return */ @RequestMapping(params = "disable") @ResponseBody public AjaxJson disable(String id, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); message = "班次停用成功"; try{ ArrangeDutyEntity arrangeDutyEntity = arrangeDutyService.getEntity(ArrangeDutyEntity.class, id); arrangeDutyEntity.setStatus(Globals.Disabled_Status.toString()); arrangeDutyService.saveOrUpdate(arrangeDutyEntity); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); }catch(Exception e){ j.setSuccess(false); e.printStackTrace(); message = "班次停用失败"; } j.setMsg(message); return j; } /** * 异步获取班次餐补名称 * @author zbw * 2017-10-31 * @param request * @param response * @return */ @RequestMapping(params = "getSubsidyName") @ResponseBody public AjaxJson getSubsidyName(HttpServletRequest request, HttpServletResponse response) { AjaxJson j = new AjaxJson(); String dutyMealid = request.getParameter("id"); if(dutyMealid.length()==0){ j.setMsg(""); return j; } //获取餐补名称 List mealsSubsidyList=systemService.queryDict("t_bus_meals_subsidy", "id", "subsidy_name"); List dutyMealidList=extractIdListByComma(dutyMealid); Map mealsSubsidyMap=new HashMap(); for (int i = 0; i < mealsSubsidyList.size(); i++) { mealsSubsidyMap.put(mealsSubsidyList.get(i).getTypecode(), mealsSubsidyList.get(i).getTypename()); } String subsidyName=""; for (int k = 0; k < dutyMealidList.size(); k++) { for (int l = 0; l < mealsSubsidyList.size(); l++) { if(dutyMealidList.get(k).equals(mealsSubsidyList.get(l).getTypecode())){ if(subsidyName.length()!=0){ subsidyName+=","+mealsSubsidyList.get(l).getTypename(); }else{ subsidyName=mealsSubsidyList.get(l).getTypename(); } break; } } } try { j.setMsg(subsidyName); } catch (Exception e) { e.printStackTrace(); throw new BusinessException(e.getMessage()); } return j; } /** * 异步获取项目名称 * @author zbw * 2017-10-20 * @param request * @param response * @return */ @RequestMapping(params = "getDName") @ResponseBody public AjaxJson getDName(HttpServletRequest request, HttpServletResponse response) { AjaxJson j = new AjaxJson(); String myPId = request.getParameter("id"); if(myPId!=null&&myPId.length()>0&&myPId.indexOf(",")!=-1){ String[] pIdList=myPId.split(","); myPId=pIdList[0]; } TSDepart tSDepart = systemService.getEntity(TSDepart.class, myPId); try { j.setMsg(tSDepart.getDepartname()); //systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); throw new BusinessException(e.getMessage()); } return j; } /** * 不用 * 异步获取项目名称 * @author zbw * 2017-10-20 * @param request * @param response * @return */ /*@RequestMapping(params = "getProjectPostName") @ResponseBody public AjaxJson getProjectPostName(HttpServletRequest request, HttpServletResponse response) { AjaxJson j = new AjaxJson(); String myPId = request.getParameter("id"); if(myPId!=null&&myPId.length()>0&&myPId.indexOf(",")!=-1){ String[] pIdList=myPId.split(","); myPId=pIdList[0]; } ProjectPostDetailDto projectPostDetailMiniDaoEntity=new ProjectPostDetailDto(); projectPostDetailMiniDaoEntity.setPid(myPId); DataGrid dataGrid=new DataGrid(); dataGrid.setField("id,ptjPostName,postid,ptjPostGeneralid,needNumber,remark,createName,createBy,createDate,updateName,updateBy,updateDate,sysOrgCode,sysCompanyCode,deleteFlag,"); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); MiniDaoPage list = arrangeDutyService.getProjectPostDetail(projectPostDetailMiniDaoEntity, dataGrid.getPage(), dataGrid.getRows(),authSql); Map myMap=new HashMap(); myMap.put("0", list); j.setAttributes(myMap); return j; }*/ /** * 异步验证班次名称; * @author zbw * 2018-1-10 * @param arrangeDutyEntity * @param request * @return */ @RequestMapping(params = "ajaxCheckShiftName") @ResponseBody public AjaxJson ajaxCheckShiftName(ArrangeDutyEntity arrangeDutyEntity, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); message = ""; StringBuffer hql = new StringBuffer(" from ArrangeDutyEntity t where t.deleteFlag = '0' and t.pid=? and t.dutyName=? "); List arrangeDutyEntityList = systemService.findHql(hql.toString(), arrangeDutyEntity.getPid().split(",")[0],arrangeDutyEntity.getDutyName()); if(arrangeDutyEntityList.size()!=0){ if(arrangeDutyEntity.getId()!=null&&arrangeDutyEntity.getId().length()!=0){ for (int i = 0; i < arrangeDutyEntityList.size(); i++) { if(!arrangeDutyEntityList.get(i).getId().equals(arrangeDutyEntity.getId())){ j.setSuccess(false); message="班次名称已存在"; break; } } }else{ j.setSuccess(false); message="班次名称已存在"; } } j.setMsg(message); return j; } /** * 班次餐补选择弹窗页面跳转路径 * @author zbw * 2017-10-31 * @param request * @return */ @RequestMapping(params = "dutyMealTable") public ModelAndView dutyMealTable(HttpServletRequest request) { //return new ModelAndView("cn/com/lzt/arrangeduty/dutyMealTable"); ModelAndView mv = new ModelAndView("cn/com/lzt/arrangeduty/dutyMealTable"); String ids = oConvertUtils.getString(request.getParameter("ids")); mv.addObject("ids", ids); String dutyType = oConvertUtils.getString(request.getParameter("dutyType")); mv.addObject("dutyType", dutyType); return mv; } /** * 班次餐补选择弹窗页面 * @author zbw * 2017-10-31 * @param mealsSubsidy * @param request * @param response * @param dataGrid */ @RequestMapping(params = "dutyMealdatagrid") public void dutyMealdatagrid(MealsSubsidyDto mealsSubsidyDto, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { String dutyType = oConvertUtils.getString(request.getParameter("dutyType")); mealsSubsidyDto.getSubsidyTypeList().add(Globals.SUBSIDY_TYPE_BCCB); // mealsSubsidyDto.getSubsidyTypeList().add(Globals.SUBSIDY_TYPE_ACGD); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); if(StringUtils.isEmpty(authSql)) { authSql = ""; } if(StringUtils.isNotEmpty(dutyType)) { if(dutyType.equals("riban11h")) { authSql +=" and shift_subsidy_type = 'riban' "; }else if(dutyType.equals("changban8h")){ authSql +=" and shift_subsidy_type = 'changban' "; }else if(dutyType.equals("zhiban")){ authSql +=" and shift_subsidy_type = 'zhiban' "; }else if(dutyType.equals("yeban11.5")){ authSql +=" and shift_subsidy_type in ('baibanjintiezao' ,'yebanjintiewan')"; }else if(dutyType.equals("jiaban")){ authSql +=" and shift_subsidy_type = '1' "; }else { authSql +=" and shift_subsidy_type = '"+dutyType+"' "; } }else { //不返回结果 authSql +=" and shift_subsidy_type = '1' "; } List mealsSubsidyDtoList = arrangeDutyService.getMealsSubsidySelect(mealsSubsidyDto, authSql); for (int i = 0; i < mealsSubsidyDtoList.size(); i++) { String strUnit=""; if(mealsSubsidyDtoList.get(i).getCalcuUnit().equals(Globals.CALCU_UNIT_dun)){ strUnit="元/顿"; }else if(mealsSubsidyDtoList.get(i).getCalcuUnit().equals(Globals.CALCU_UNIT_yue)){ strUnit="元/月"; }else if(mealsSubsidyDtoList.get(i).getCalcuUnit().equals(Globals.CALCU_UNIT_ci)){ strUnit="元/次"; } if(strUnit.length()!=0){ mealsSubsidyDtoList.get(i).setSubsidyMoneyAndUnit(mealsSubsidyDtoList.get(i).getSubsidyMoney().toString()+strUnit); }else{ mealsSubsidyDtoList.get(i).setSubsidyMoneyAndUnit(mealsSubsidyDtoList.get(i).getSubsidyMoney().toString()); } } dataGrid.setResults(mealsSubsidyDtoList); TagUtil.datagrid(response, dataGrid); //手动拼接班次餐补 /*if(arrangeDutyMinidaoDtoList.get(i).getDutyMealid()!=null&&arrangeDutyMinidaoDtoList.get(i).getDutyMealid().length()!=0){ String dutyMealid = arrangeDutyMinidaoDtoList.get(i).getDutyMealid(); List mealsSubsidyDtolist=getSubsidyInfo(dutyMealid); if(mealsSubsidyDtolist.size()>0){ String subsidyMoneyAndUnit=""; for (int j = 0; j < mealsSubsidyDtolist.size(); j++) { String strUnit=""; if(mealsSubsidyDtolist.get(j).getCalcuUnit().equals(Globals.CALCU_UNIT_dun)){ strUnit="元/顿"; }else if(mealsSubsidyDtolist.get(j).getCalcuUnit().equals(Globals.CALCU_UNIT_yue)){ strUnit="元/月"; }else if(mealsSubsidyDtolist.get(j).getCalcuUnit().equals(Globals.CALCU_UNIT_ci)){ strUnit="元/次"; } if(subsidyMoneyAndUnit.length()>0){ subsidyMoneyAndUnit+=","+mealsSubsidyDtolist.get(j).getSubsidyMoney()+strUnit; }else{ subsidyMoneyAndUnit=mealsSubsidyDtolist.get(j).getSubsidyMoney()+strUnit; } } arrangeDutyMinidaoDtoList.get(i).setSubsidyMoneyAndUnit(subsidyMoneyAndUnit); } }*/ /*String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List MealsSubsidyDtolist = arrangeDutyService.getMealsSubsidyByIdList( mealsSubsidyDto,authSql);*/ /*CriteriaQuery cq = new CriteriaQuery(MealsSubsidyEntity.class, dataGrid); //查询条件组装器 org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, mealsSubsidy, request.getParameterMap()); try{ //自定义追加查询条件 //班次设定页面添加根据班次餐补类型添加数据 cq.eq("subsidyType", "bancicanbu"); //cq.eq("subsidyName", "日班"); String[] status = new String[]{Globals.Enabled_Status.toString(), Globals.Disabled_Status.toString()}; cq.in("status", status); cq.eq("deleteFlag", Globals.Delete_Normal.toString()); }catch (Exception e) { throw new BusinessException(e.getMessage()); } cq.add(); this.mealsSubsidyService.getDataGridReturn(cq, true);*/ // TagUtil.datagrid(response, dataGrid); } /** * 项目选择弹窗页面跳转路径 * @author zbw * 2017-10-31 * @param request * @return */ /* @RequestMapping(params = "projectDepartTable") public ModelAndView projectDepartTable(HttpServletRequest request) { //return new ModelAndView("cn/com/lzt/arrangeduty/dutyMealTable"); ModelAndView mv = new ModelAndView("cn/com/lzt/arrangeduty/projectDepartTable"); String ids = oConvertUtils.getString(request.getParameter("ids")); mv.addObject("ids", ids); return mv; }*/ /** * 项目选择弹窗列表数据 * @author zbw * 2017-11-15 * @param projectDepartDto * @param request * @param response * @param dataGrid */ /* @RequestMapping(params = "projectDepartDatagrid") public void projectDepartDatagrid(ProjectDepartDto projectDepartDto, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) { TSUser tSUser=ResourceUtil.getSessionUser(); UserOrgDto userOrgDto=new UserOrgDto(); userOrgDto.setUserId(tSUser.getId()); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List userOrgDtoList = arrangeDutyService.getUserOrgDtoByUserId(userOrgDto, authSql); List> listMap=new ArrayList>(); List projectDepartIdList=new ArrayList(); for (int i = 0; i < userOrgDtoList.size(); i++) { String projectDepartId=getProjectDepartId(userOrgDtoList.get(i).getOrgId()); if(projectDepartId!=null&&projectDepartId.length()>0){ Map myMap=new HashMap(); myMap.put("projectDepartId", projectDepartId); myMap.put("ifpluralism", userOrgDtoList.get(i).getIfpluralism()); myMap.put("status", userOrgDtoList.get(i).getStatus()); projectDepartIdList.add(projectDepartId); listMap.add(myMap); } } projectDepartDto.getDepartIdList().addAll(projectDepartIdList); authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List projectDepartDtoList = arrangeDutyService.getProjectDepartByListId(projectDepartDto, authSql); for (int i = 0; i < projectDepartDtoList.size(); i++) { for (int j = 0; j < listMap.size(); j++) { if(projectDepartDtoList.get(i).getId().equals(listMap.get(j).get("projectDepartId"))){ projectDepartDtoList.get(i).setIfpluralism(listMap.get(j).get("ifpluralism").toString()); projectDepartDtoList.get(i).setStatus(listMap.get(j).get("status").toString()); break; } // for(Entry entryParam : listMap.get(j).entrySet()){ // //System.out.println("key="+entryParam.getKey()+",value="+entryParam.getValue()); // if(projectDepartDtoList.get(i).getId().equals(entryParam.getValue())){} // } } } dataGrid.setResults(projectDepartDtoList); TagUtil.datagrid(response, dataGrid); }*/ /** * 根据用户与组织机构关系表中的组织id查询项目id; * 业务逻辑 * 任意层节点的zTree,每一层有一个父id,顶级节点父节点为null,一个组织类型orgType,随机给一层的主键id,找到项目id,特征是orgType=3; * 根据是否是顶级父id判断是自上而下还是自下而上查找,当自下而上找到null时,再进行自下而上; * @author zbw * 2017-11-15 * @param projectDepartId * @return */ /* public String getProjectDepartId(String projectDepartId){ String newProjectDepartId=""; ProjectDepartDto projectDepartDto=new ProjectDepartDto(); projectDepartDto.getDepartIdList().add(projectDepartId); String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString(); List projectDepartDtoList = arrangeDutyService.getProjectDepartByListId(projectDepartDto, authSql); if(projectDepartDtoList.get(0).getParentdepartid()!=null){ if(!projectDepartDtoList.get(0).getOrgType().equals(Globals.org_type_3)){ //获取某个父节点下面的所有子节点 List childList = arrangeDutyService.getAllChildrenList(projectDepartId, null, null); for (int i = 0; i < childList.size(); i++) { if(childList.get(i).getOrgType().equals(Globals.org_type_3)){ newProjectDepartId=childList.get(i).getId(); break; } } if(newProjectDepartId.length()==0){ //获取某个子节点上面的所有父节点 List parentList = arrangeDutyService.getAllParentList(projectDepartDtoList.get(0).getParentdepartid(), null, null); for (int i = 0; i < parentList.size(); i++) { if(parentList.get(i).getOrgType().equals(Globals.org_type_3)){ newProjectDepartId=parentList.get(i).getId(); break; } } } }else{ newProjectDepartId=projectDepartDtoList.get(0).getId(); } }else{ newProjectDepartId=null; } // List childList = getAllChildrenList(post.getId(), null, null); // List childList = getAllParentList(post.getParentPostid(), null, null); return newProjectDepartId; }*/ @RequestMapping(params = "changeStatus") @ResponseBody public AjaxJson changeStatus(ArrangeDutyEntity arrangeDuty, HttpServletRequest request) { String message = null; AjaxJson j = new AjaxJson(); message = "更新班次状态成功"; ArrangeDutyEntity t = arrangeDutyService.get(ArrangeDutyEntity.class, arrangeDuty.getId()); try{ MyBeanUtils.copyBeanNotNull2Bean(arrangeDuty, t); arrangeDutyService.saveOrUpdate(t); 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; } }