| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- package com.xcgl.device.controller;
- import cn.afterturn.easypoi.entity.vo.NormalExcelConstants;
- import cn.afterturn.easypoi.excel.entity.ExportParams;
- import com.daju.common.util.DataPage;
- import com.daju.mix.dao.entity.PDeviceDefend;
- import com.daju.mix.dao.entity.TBArchivesProvider;
- import com.daju.mix.dao.mapper.TBCarMapper;
- import com.xcgl.device.dao.DeviceDao;
- import com.xcgl.device.service.impl.DeviceDefendServiceImpl;
- import com.xcgl.utils.OrderNumTools;
- 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.util.ResourceUtil;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.servlet.ModelAndView;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @author :sahib.kio.m
- * @date :Created in 2021/7/30 上午11:39
- */
- @Controller
- @RequestMapping("/deviceDefendController")
- public class DeviceDefendController {
- @Resource
- private DeviceDefendServiceImpl deviceDefendService;
- @Autowired
- private DeviceDao deviceDao;
- @Resource
- TBCarMapper tbCarMapper;
- @RequestMapping(params = "list")
- public ModelAndView carScheduleDoneStat(HttpServletRequest request) {
- return new ModelAndView("com/xcgl/device/defendList");
- }
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(HttpServletRequest request) {
- return new ModelAndView("com/xcgl/device/defendList-add");
- }
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(HttpServletRequest request) {
- String id = request.getParameter("id");
- PDeviceDefend common = deviceDefendService.getById(id);
- request.setAttribute("common", common);
- request.setAttribute("type_id", request.getParameter("type_id"));
- return new ModelAndView("com/xcgl/device/defendList-update");
- }
- @RequestMapping(params = "datagrid")
- public void datagrid(HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- Map<String, String> param = new HashMap<>();
- for (String key : request.getParameterMap().keySet()){
- param.put(key, request.getParameter(key));
- }
- DataPage result = deviceDefendService.DefendList(param);
- TagUtil.datagrid(response, dataGrid, result);
- }
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(PDeviceDefend common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案添加成功";
- j.setSuccess(true);
- try{
- common.setCode(OrderNumTools.generateNextBillCode("LSSBYH" + getNowDate(),14, "p_device_defend", "code", 4));
- deviceDefendService.save(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "档案添加失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- private static SimpleDateFormat sdfDate = new SimpleDateFormat("yyyyMMdd");
- private static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- public static String getNowDate(){
- Date now = new Date();
- String time = sdfDate.format(now);
- return time;
- }
- public static String getNowDateTime(){
- Date now = new Date();
- String time = sdfTime.format(now);
- return time;
- }
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(PDeviceDefend common, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案修改成功";
- j.setSuccess(true);
- try{
- deviceDefendService.updateById(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "档案修改失败";
- j.setSuccess(false);
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(PDeviceDefend common, HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "档案删除成功";
- try{
- deviceDefendService.removeById(common);
- }catch(Exception e){
- e.printStackTrace();
- message = "档案删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- @RequestMapping(params = "exportXlsByT")
- public String exportXlsByT(ModelMap modelMap) {
- List<PDeviceDefend> providers = deviceDefendService.list();
- modelMap.put(NormalExcelConstants.FILE_NAME,"设备养护记录档案");
- modelMap.put(NormalExcelConstants.CLASS, PDeviceDefend.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("设备养护记录档案", "导出人:"+ ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST, providers);
- return NormalExcelConstants.EASYPOI_EXCEL_VIEW;
- }
- /**
- * 设备养护记录到期提醒
- */
- @RequestMapping(params = "remind")
- @ResponseBody
- public AjaxJson remind(){
- List<String> list = tbCarMapper.getRemind();
- AjaxJson j = new AjaxJson();
- j.setMsg("请求成功");
- j.setObj(list);
- j.setSuccess(true);
- return j;
- }
- }
|