package com.flow.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.flow.mapper.OperationLogMapper;
|
import com.flow.mapper.TbFuwuqiMapper;
|
import com.flow.pojo.Card;
|
import com.flow.pojo.OperationLog;
|
import com.flow.pojo.TbFuwuqi;
|
import com.flow.service.CompanyService;
|
import com.flow.service.OperationLogService;
|
import com.flow.service.TbFuwuqiService;
|
import com.flow.util.result;
|
import com.flow.util.resultutil;
|
import com.github.pagehelper.PageInfo;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.List;
|
|
@RestController
|
@RequestMapping({"/hxzk"})
|
public class TbFuwuqiController {
|
|
@Autowired
|
TbFuwuqiService tbFuwuqiService;
|
@Autowired
|
CompanyService companyService;
|
|
@Autowired
|
OperationLogService operationLogService;
|
@Autowired
|
TbFuwuqiMapper tbFuwuqiMapper;
|
@Autowired
|
OperationLogMapper operationLogMapper;
|
@GetMapping({"findTbFuwuqi"})
|
result<List<TbFuwuqi>> findBangZhu(Integer page, Integer limit) throws ParseException {
|
PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.FindTbFuwuqi(page, limit);
|
for(int i = 0; i < cz.getSize(); ++i) {
|
if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
|
SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
|
Date date = new Date();
|
Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
|
Long starTime = date.getTime();
|
Long endTime = endDay.getTime();
|
Long num11 = endTime - starTime;//时间戳
|
if ((num11/24/60/60/1000)<0){
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
|
}else{
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
|
}
|
if (!((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals("0天") || !((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals(+num11/24/60/60/1000+"天") ){
|
System.out.println("打印数据==========》》》》》》》》》》");
|
this.tbFuwuqiService.UpdateTbFuwuqi((TbFuwuqi)cz.getList().get(i));
|
}
|
//
|
}
|
}
|
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
|
}
|
|
@GetMapping({"findTbFuwuqiZi"})
|
result<List<TbFuwuqi>> findTbFuwuqiZi(String Zong, Integer page, Integer limit) throws ParseException {
|
PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.findTbFuwuqiZi(Zong, page, limit);
|
for(int i = 0; i < cz.getSize(); ++i) {
|
if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
|
SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
|
Date date = new Date();
|
Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
|
Long starTime = date.getTime();
|
Long endTime = endDay.getTime();
|
Long num11 = endTime - starTime;//时间戳
|
if ((num11/24/60/60/1000)<0){
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
|
}else{
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
|
}
|
if (!((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals("0天") || !((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals(+num11/24/60/60/1000+"天") ){
|
System.out.println("222222222222");
|
this.tbFuwuqiService.UpdateTbFuwuqi((TbFuwuqi)cz.getList().get(i));
|
}
|
}
|
}
|
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
|
}
|
|
@PostMapping({"addTbFuwuqi"})
|
public ModelAndView addBang(TbFuwuqi tbFuwuqi) throws Exception {
|
ModelAndView modelAndView = new ModelAndView();
|
tbFuwuqi.setId(null);
|
this.tbFuwuqiService.addTbFuwuqi(tbFuwuqi);
|
modelAndView.addObject("suoshu", this.companyService.findSuoShu());
|
modelAndView.setViewName("/page/Fuwuqi.jsp");
|
return modelAndView;
|
}
|
|
@PostMapping({"UpdateTbFuwuqi"})
|
public ModelAndView UpdateCard(TbFuwuqi tbFuwuqi) {
|
this.tbFuwuqiService.UpdateTbFuwuqi(tbFuwuqi);
|
QueryWrapper queryWrapper = new QueryWrapper();
|
queryWrapper.eq("id", tbFuwuqi.getId());
|
TbFuwuqi tbFuwuqi1 = tbFuwuqiMapper.selectOne(queryWrapper);
|
OperationLog operationLog = new OperationLog();
|
operationLog.setCaozuotype("修改");
|
operationLog.setCaozuocontent("修改服务器:"+tbFuwuqi1.getServername());
|
operationLog.setCaozuoname(tbFuwuqi1.getCaozuoname());
|
operationLogService.addOperationLog(operationLog);
|
Date date = new Date();
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
operationLog.setCaozuodate(formatter.format(date));
|
operationLogMapper.insert(operationLog);
|
ModelAndView modelAndView = new ModelAndView();
|
modelAndView.setViewName("/page/Fuwuqi.jsp");
|
return modelAndView;
|
}
|
|
@PostMapping({"DeleteTbFuwuqi"})
|
public int DeleteCard(String num,String caozuoname) {
|
return this.tbFuwuqiService.DeleteTbFuwuqi(num,caozuoname);
|
}
|
|
@PostMapping({"tbFuwuqiSearch"})
|
public result<List<TbFuwuqi>> tableSearch(TbFuwuqi tbFuwuqi, int page, int limit) throws Exception {
|
PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.tableSearch(tbFuwuqi, page, limit);
|
for(int i = 0; i < cz.getSize(); ++i) {
|
if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
|
SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
|
Date date = new Date();
|
Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
|
Long starTime = date.getTime();
|
Long endTime = endDay.getTime();
|
Long num11 = endTime - starTime;//时间戳
|
|
if ((num11/24/60/60/1000)<0){
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
|
}else{
|
((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
|
}
|
// this.cardService.UpdateCard((Card)cz.getList().get(i));
|
// this.cardService.UpdateCard((Card)cz.getList().get(i));
|
}
|
}
|
return resultutil.returnSuccess(cz.getTotal(), cz.getList());
|
}
|
@PostMapping({"ifFuwuqi"})
|
public TbFuwuqi ifFuwuqi(TbFuwuqi tbFuwuqi) {
|
return this.tbFuwuqiService.ifFuwuqi(tbFuwuqi);
|
}
|
|
|
}
|