| | |
| | | package com.doumee.api.business; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.config.annotation.EncryptionReq; |
| | | import com.doumee.config.annotation.EncryptionResp; |
| | | 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.*; |
| | | import com.doumee.dao.web.dto.OrderDataDTO; |
| | | import com.doumee.dao.web.vo.WorkOrderDataVO; |
| | | import com.doumee.service.business.WorkorderService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | 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; |
| | | |
| | | /** |
| | |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("新建") |
| | | @EncryptionReq |
| | | @EncryptionResp |
| | | @PostMapping("/create") |
| | | @RequiresPermissions("business:workorder:create") |
| | | public ApiResponse create(@RequestBody Workorder workorder) { |
| | |
| | | workorderService.updateById(workorder); |
| | | return ApiResponse.success(null); |
| | | } |
| | | @ApiOperation("工作台统计数据") |
| | | @PostMapping("/getIndexData") |
| | | @EncryptionReq |
| | | @EncryptionResp |
| | | public ApiResponse<WorkorderIndexNumVO> getIndexData(@RequestBody Workorder workorder) { |
| | | return ApiResponse.success( workorderService.getIndexData(workorder)); |
| | | } |
| | | @ApiOperation("工作台统计报表数据") |
| | | @PostMapping("/getWorkOrderData") |
| | | @EncryptionReq |
| | | @EncryptionResp |
| | | public ApiResponse<List<WorkOrderDataVO>> getWorkOrderData(@RequestBody OrderDataDTO workorder) { |
| | | return ApiResponse.success( workorderService.getWorkOrderData(workorder)); |
| | | } |
| | | |
| | | @ApiOperation("分页查询") |
| | | @PostMapping("/page") |
| | | @EncryptionReq |
| | | @EncryptionResp |
| | | @RequiresPermissions("business:workorder:query") |
| | | public ApiResponse<PageData<Workorder>> findPage (@RequestBody PageWrap<Workorder> pageWrap) { |
| | | return ApiResponse.success(workorderService.findPage(pageWrap)); |
| | |
| | | |
| | | @ApiOperation("导出Excel") |
| | | @PostMapping("/exportExcel") |
| | | @EncryptionReq |
| | | @RequiresPermissions("business:workorder:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<Workorder> pageWrap, HttpServletResponse response) { |
| | | ExcelExporter.build(Workorder.class).exportData(workorderService.findPage(pageWrap).getRecords(), "工单信息表", 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("本人"); |
| | | if(Constants.equalsInteger(model.getMemberType(),Constants.ONE)){ |
| | | t.setMemberNames( "同事-"+StringUtils.defaultString(model.getMemberNames(),"")); |
| | | }else if(Constants.equalsInteger(model.getMemberType(),Constants.TWO)){ |
| | | t.setMemberNames("供应商"); |
| | | t.setMemberNames( "供应商-"+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") |
| | | @EncryptionResp |
| | | @EncryptionReq |
| | | public ApiResponse findById(@PathVariable Integer id) { |
| | | return ApiResponse.success(workorderService.getDetail(id,null)); |
| | | } |