| | |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | import com.moral.api.pojo.bo.ExcelBO; |
| | | import com.moral.api.pojo.vo.excel.ExcelVo; |
| | | import com.moral.api.pojo.vo.excel.HnExcelVo; |
| | | import com.moral.api.pojo.vo.excel.SyExcelVo; |
| | | import com.moral.api.service.ExcelService; |
| | | import com.moral.api.service.HnExcelService; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | |
| | | @Autowired |
| | | private ExcelService excelService; |
| | | |
| | | |
| | | @Autowired |
| | | private HnExcelService hnExcelService; |
| | | |
| | | /** |
| | | * 导入 |
| | | * 高新区导入 |
| | | * @param request |
| | | * @return |
| | | * @throws IOException |
| | |
| | | |
| | | |
| | | /** |
| | | * 导出 |
| | | * 高新区导出 |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),excelBOS); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 浑南区模板导入 |
| | | * @param request |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | @PostMapping("syExcelImport") |
| | | public ResultMessage syExcelImport(HttpServletRequest request) throws IOException, ParseException { |
| | | Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); |
| | | if (!params.containsKey("time") || !params.containsKey("code") || params.containsKey("data")){ |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("files"); |
| | | ExcelBO excelImport = hnExcelService.getExcelImport(files, params); |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),excelImport); |
| | | } |
| | | |
| | | /** |
| | | * 浑南区导出 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/syExcelExport") |
| | | public ResultMessage syExcelExport(Integer id){ |
| | | if (id==null){ |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | |
| | | SyExcelVo syExcelVo = hnExcelService.SyExport(id); |
| | | if (syExcelVo==null){ |
| | | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); |
| | | } |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),syExcelVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 浑南区质量报告导出 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @GetMapping("/hnExcelExport") |
| | | public ResultMessage hnExcelExport(Integer id) throws ParseException { |
| | | if (id==null){ |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | |
| | | HnExcelVo hnExcelVo = hnExcelService.hnExport(id); |
| | | if (hnExcelVo==null){ |
| | | return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(), ResponseCodeEnum.TARGET_IS_NULL.getMsg()); |
| | | } |
| | | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),hnExcelVo); |
| | | } |
| | | |
| | | |
| | | } |