济菏高速数据中心代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

174 lines
5.9 KiB

package com.zc.business.controller;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonElement;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.domain.DcShiftsRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.domain.DcShifts;
import com.zc.business.service.IDcShiftsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.spring.web.json.Json;
import com.google.gson.*;
/**
* 值班Controller
*
* @author ruoyi
* @date 2024-01-04
*/
@Api(tags = "值班管理")
@RestController
@RequestMapping("/business/shifts")
public class DcShiftsController extends BaseController
{
@Autowired
private IDcShiftsService dcShiftsService;
/**
* 查询值班列表
*/
@ApiOperation("查询值班列表")
@PreAuthorize("@ss.hasPermi('business:shifts:list')")
@GetMapping("/list")
public TableDataInfo list(DcShifts dcShifts)
{
startPage();
List<DcShifts> list = dcShiftsService.selectDcShiftsList(dcShifts);
return getDataTable(list);
}
/**
* 导出值班列表
*/
@ApiOperation("导出值班列表")
@PreAuthorize("@ss.hasPermi('business:shifts:export')")
@Log(title = "值班", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DcShifts dcShifts)
{
List<DcShifts> list = dcShiftsService.selectDcShiftsListExcel(dcShifts);
ExcelUtil<DcShifts> util = new ExcelUtil<>(DcShifts.class);
util.exportExcel(response, list, "值班数据");
}
/**
* 获取值班详细信息
*/
@ApiOperation("获取值班详细信息")
@PreAuthorize("@ss.hasPermi('business:shifts:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(dcShiftsService.selectDcShiftsById(id));
}
/**
* 新增值班
*/
@ApiOperation("新增值班")
@PreAuthorize("@ss.hasPermi('business:shifts:add')")
@Log(title = "值班", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcShifts dcShifts) throws Exception {
return toAjax(dcShiftsService.insertDcShifts(dcShifts));
}
/**
* 修改值班
*/
@ApiOperation("修改值班")
@PreAuthorize("@ss.hasPermi('business:shifts:edit')")
@Log(title = "值班", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DcShifts dcShifts) throws Exception {
return toAjax(dcShiftsService.updateDcShifts(dcShifts));
}
/**
* 删除值班
*/
@ApiOperation("删除值班")
@PreAuthorize("@ss.hasPermi('business:shifts:remove')")
@Log(title = "值班", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) throws Exception{
return toAjax(dcShiftsService.deleteDcShiftsByIds(ids));
}
/**
* 删除值班,某个时间下驻点下的全部值班信息
*/
@PreAuthorize("@ss.hasPermi('business:shifts:remove')")
@Log(title = "值班", businessType = BusinessType.DELETE)
@PostMapping("/delete")
public AjaxResult removeDelete(@RequestBody DcShifts shifts) throws Exception{
return toAjax(dcShiftsService.deleteDcShiftsListId(shifts));
}
//导出模板
@ApiOperation("导出模板")
@PreAuthorize("@ss.hasPermi('baseData:equipment:export')")
@Log(title = "值班模板", businessType = BusinessType.EXPORT)
@PostMapping("/exportModel")
public void exportModel(HttpServletResponse response)
{
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("excelTemplate/值班示例模板.xlsx");
try {
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
workbook.write(response.getOutputStream());
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 导入值班列表
*/
@ApiOperation("导入值班列表")
@PostMapping("/importEquipment")
public AjaxResult importEquipment(MultipartFile file) throws Exception{
return dcShiftsService.importEquipment(file);
}
/**
* 查询操作记录
*/
@ApiOperation("查询操作记录")
@PostMapping("/recordList")
public TableDataInfo recordList(@RequestBody DcShifts dcShifts)
{
startPage();
List<DcShiftsRecord> list = dcShiftsService.selectDcShiftsRecord(dcShifts);
return getDataTable(list);
}
}