package com.doumee.api.business;
|
|
import com.doumee.api.BaseController;
|
import com.doumee.core.annotation.excel.ExcelExporter;
|
import com.doumee.core.annotation.pr.PreventRepeat;
|
import com.doumee.core.constants.Constants;
|
import com.doumee.core.constants.ResponseStatus;
|
import com.doumee.core.exception.BusinessException;
|
import com.doumee.core.model.ApiResponse;
|
import com.doumee.core.model.PageWrap;
|
import com.doumee.core.model.PageData;
|
import com.doumee.core.utils.DateUtil;
|
import com.doumee.dao.business.model.Workorder;
|
import com.doumee.dao.business.vo.WorkorderDbhDto;
|
import com.doumee.dao.business.vo.WorkorderDcaChildDto;
|
import com.doumee.dao.business.vo.WorkorderDcaDto;
|
import com.doumee.dao.business.vo.WorkorderSheDto;
|
import com.doumee.service.business.WorkorderService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.lang3.StringUtils;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.ObjectUtils;
|
import org.springframework.web.bind.annotation.*;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @author 江蹄蹄
|
* @since 2025/04/02 17:49
|
*/
|
@Api(tags = "工单信息表")
|
@RestController
|
@RequestMapping("/business/workorder")
|
public class WorkorderController extends BaseController {
|
|
@Autowired
|
private WorkorderService workorderService;
|
|
@PreventRepeat
|
@ApiOperation("新建")
|
@PostMapping("/create")
|
@RequiresPermissions("business:workorder:create")
|
public ApiResponse create(@RequestBody Workorder workorder) {
|
return ApiResponse.success(workorderService.create(workorder));
|
}
|
|
@ApiOperation("根据ID删除")
|
@GetMapping("/delete/{id}")
|
@RequiresPermissions("business:workorder:delete")
|
public ApiResponse deleteById(@PathVariable Integer id) {
|
workorderService.deleteById(id);
|
return ApiResponse.success(null);
|
}
|
|
@ApiOperation("批量删除")
|
@GetMapping("/delete/batch")
|
@RequiresPermissions("business:workorder:delete")
|
public ApiResponse deleteByIdInBatch(@RequestParam String ids) {
|
workorderService.deleteByIdInBatch(this.getIdList(ids));
|
return ApiResponse.success(null);
|
}
|
|
@ApiOperation("根据ID修改")
|
@PostMapping("/updateById")
|
@RequiresPermissions("business:workorder:update")
|
public ApiResponse updateById(@RequestBody Workorder workorder) {
|
workorderService.updateById(workorder);
|
return ApiResponse.success(null);
|
}
|
|
@ApiOperation("分页查询")
|
@PostMapping("/page")
|
@RequiresPermissions("business:workorder:query")
|
public ApiResponse<PageData<Workorder>> findPage (@RequestBody PageWrap<Workorder> pageWrap) {
|
return ApiResponse.success(workorderService.findPage(pageWrap));
|
}
|
|
@ApiOperation("导出Excel")
|
@PostMapping("/exportExcel")
|
@RequiresPermissions("business:workorder:exportExcel")
|
public void exportExcel (@RequestBody PageWrap<Workorder> pageWrap, HttpServletResponse response) {
|
//0SHE事件 1DCA事件提交记录 2DCA工单 3跌绊滑事件
|
long index = 1;
|
if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ZERO)){
|
List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
|
List<WorkorderSheDto> list = new ArrayList<>();
|
if(records!=null){
|
for(Workorder model : records){
|
WorkorderSheDto t = new WorkorderSheDto();
|
t.setIndex(index++);
|
BeanUtils.copyProperties(model,t);
|
if(Constants.equalsInteger(model.getOutJiuyi(),Constants.ONE)){
|
t.setJiuyiInfo("外部就医");
|
}else{
|
t.setJiuyiInfo("非外部就医");
|
if(Constants.equalsInteger(model.getIsYiwushi(),Constants.ONE)){
|
t.setJiuyiInfo(t.getJiuyiInfo() + "-医务室");
|
}else{
|
t.setJiuyiInfo(t.getJiuyiInfo() + "-非医务室");
|
if(Constants.equalsInteger(model.getIsHurted(),Constants.ONE)){
|
t.setJiuyiInfo(t.getJiuyiInfo() + "-受伤");
|
}else{
|
t.setJiuyiInfo(t.getJiuyiInfo() + "-未受伤");
|
}
|
}
|
}
|
t.setMemberNames("本人");
|
t.setMemberNames(t.getMemberNames()+"-"+StringUtils.defaultString(model.getMemberNames(),""));
|
list.add(t);
|
}
|
}
|
ExcelExporter.build(WorkorderSheDto.class).export(list, "SHE事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
|
}else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.ONE)){
|
List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
|
List<WorkorderDcaDto> list = new ArrayList<>();
|
if(records!=null){
|
for(Workorder model : records){
|
WorkorderDcaDto t = new WorkorderDcaDto();
|
t.setIndex(index++);
|
BeanUtils.copyProperties(model,t);
|
list.add(t);
|
}
|
}
|
ExcelExporter.build(WorkorderDcaDto.class).export(list, "DCA事件工单提交记录报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
|
}else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.TWO)){
|
List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
|
List<WorkorderDcaChildDto> list = new ArrayList<>();
|
if(records!=null){
|
for(Workorder model : records){
|
WorkorderDcaChildDto t = new WorkorderDcaChildDto();
|
t.setIndex(index++);
|
BeanUtils.copyProperties(model,t);
|
list.add(t);
|
}
|
}
|
ExcelExporter.build(WorkorderDcaChildDto.class).export(list, "DCA事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
|
}else if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.THREE)){
|
List<Workorder> records = workorderService.findPage(pageWrap).getRecords();
|
List<WorkorderDbhDto> list = new ArrayList<>();
|
if(records!=null){
|
for(Workorder model : records){
|
WorkorderDbhDto t = new WorkorderDbhDto();
|
t.setIndex(index++);
|
BeanUtils.copyProperties(model,t);
|
list.add(t);
|
}
|
}
|
ExcelExporter.build(WorkorderDbhDto.class).export(list, "跌绊滑事件工单报表_"+ DateUtil.formatDate(new Date(),"yyyyMMddHHmmss"), response);
|
}else{
|
throw new BusinessException(ResponseStatus.BAD_REQUEST);
|
}
|
}
|
|
@ApiOperation("根据ID查询")
|
@GetMapping("/{id}")
|
@RequiresPermissions("business:workorder:query")
|
public ApiResponse findById(@PathVariable Integer id) {
|
return ApiResponse.success(workorderService.getDetail(id));
|
}
|
}
|