package com.zjrs.zwnw.rlzysc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.mohrss.leaf.core.framework.web.controller.AjaxResponse;
import org.mohrss.leaf.core.framework.web.exception.AppException;
import com.zjrs.zwnw.rlzysc.bpo.ZphglBPO;
import com.zjrs.zwnw.rlzysc.dto.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/*
招聘会管理
 */
@Api("招聘会管理")
@RestController
@RequestMapping("/api/rlzysc/zphgl")
public class ZphglController {
    private static final Logger LOG = LoggerFactory.getLogger(ZphglController.class);

    @Resource
    private ZphglBPO zphglBPO;
    /*
    招聘会发布*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "招聘会发布*获取列表(会场管理时新增会场前,展位管理新增展位前,需先获取未发布的招聘会，此时fbzt参数为必录)")
    @PostMapping(value = "/zphfb/getZphfbList")
    public AjaxResponse getZphfbList(@RequestBody @Valid ZphQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            Map<String, Object> zphfbList = zphglBPO.getZphfbList(dto);
            ajaxResponse.setData("data", zphfbList.get("result"));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
            ajaxResponse.setData("bae001", zphfbList.get("bae001"));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    招聘会发布*获取招聘会信息
     */
    @ApiOperation(value = "获取招聘会信息", notes = "招聘会发布*获取招聘会信息")
    @PostMapping(value = "/zphfb/getZphXx")
    public AjaxResponse getZphXx(@RequestBody @Valid ZjQueryDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getZphXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "获取参加网络招聘会单位信息", notes = "招聘会发布*获取参加网络招聘会单位信息")
    @PostMapping(value = "/zphfb/getWlZphQyXx")
    public AjaxResponse getWlZphQyXx(@RequestBody ZphQueryDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(StringUtils.isBlank(dto.getZphlsh())){
            ajaxResponse.setErrorMsg("招聘会流水号不能为空");
            ajaxResponse.setAppcode("1");
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getWlZphQyXx(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "导出参加网络招聘会职位信息", notes = "招聘会发布*导出参加网络招聘会职位信息")
    @PostMapping(value = "/zphfb/exportWlzphZwXx")
    public void exportWlzphZwXx(@RequestBody ZjDTO dto,HttpServletResponse res) {
        try {
          zphglBPO.exportWlzphZwXx(dto,res);
        } catch (AppException e) {
            LOG.error(e.getMessage());
        } catch (Exception e) {
            LOG.error(e.getMessage());
        }
    }

    @ApiOperation(value = "获取参加网络招聘会职位信息", notes = "招聘会发布*获取参加网络招聘会职位信息")
    @PostMapping(value = "/zphfb/getWlZphZwXx")
    public AjaxResponse getWlZphZwXx(@RequestBody ZphQueryDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(StringUtils.isBlank(dto.getZphlsh())){
            ajaxResponse.setErrorMsg("招聘会流水号不能为空");
            ajaxResponse.setAppcode("1");
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getWlZphZwXx(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    /*
    招聘会发布*保存招聘会信息
     */
    @ApiOperation(value = "保存招聘会信息", notes = "招聘会发布*保存招聘会信息")
    @PostMapping(value = "/zphfb/saveZphXx")
    public AjaxResponse saveZphXx(@RequestBody @Valid ZphXxUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("ztid", zphglBPO.saveZphXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    招聘会发布*删除招聘会信息
     */
    @ApiOperation(value = "删除招聘会信息", notes = "招聘会发布*删除招聘会信息")
    @PostMapping(value = "/zphfb/delZphXx")
    public AjaxResponse delZphXx(@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.delZphXx(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    招聘会发布*结束招聘会
     */
    @ApiOperation(value = "结束招聘会", notes = "招聘会发布*结束招聘会")
    @PostMapping(value = "/zphfb/endZphXx")
    public AjaxResponse endZphXx(@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.endZphXx(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }


    @ApiOperation(value = "更新招聘会发布状态", notes = "招聘会发布*更新招聘会发布状态")
    @PostMapping(value = "/zphfb/UpdateZphFbzt")
    public AjaxResponse UpdateZphFbzt(@RequestBody @Valid ZjUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.UpdateZphFbzt(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    /**
     *更新招聘会报名状态
     * @return
     */
    @ApiOperation(value = "更新招聘会报名状态", notes = "招聘会发布*更新招聘会报名状态")
    @PostMapping(value = "/zphfb/UpdateZphBmzt")
    public AjaxResponse UpdateZphBmzt(@RequestBody @Valid ZjUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.UpdateZphBmzt(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    招聘会发布*生成招聘会二维码
     */
    @ApiOperation(value = "生成招聘会二维码", notes = "招聘会发布*生成招聘会二维码")
    @PostMapping(value = "/zphfb/getZphEwm")
    public ResponseEntity<byte[]> getZphEwm(HttpServletResponse response,@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        if(bindingResult.hasErrors()) {
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            return new ResponseEntity<byte[]>(
                    errmsg.getBytes(),
                    HttpStatus.BAD_REQUEST);
        }
        try {
            Map<String,Object> res = zphglBPO.getZphEwm(dto);
            if (res!=null && res.size()>0 && res.get("zwm") instanceof byte[]){
                    byte[] zwm = (byte[]) res.get("zwm");
                    HttpHeaders headers = new HttpHeaders();
                    headers.setContentType(MediaType.IMAGE_JPEG);
                    headers.set("Cache-Control", "no-store,no-cache");
                    HttpStatus statusCode = HttpStatus.OK;

                    ResponseEntity<byte[]> entity = new ResponseEntity<byte[]>(zwm, headers, statusCode);
                    return entity;
            } else {
                return new ResponseEntity<byte[]>(
                        "请确认是否有该招聘会".getBytes(),
                        HttpStatus.BAD_REQUEST);
            }

        } catch (AppException e) {
            LOG.error(e.getMessage());
            return new ResponseEntity<byte[]>(
                    e.getMessage().getBytes(),
                    HttpStatus.BAD_REQUEST);
        } catch (Exception e) {
            LOG.error(e.getMessage());
            return new ResponseEntity<byte[]>(
                    "系统异常".getBytes(),
                    HttpStatus.BAD_REQUEST);
        }
    }

    /*
    会场管理*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "会场管理*获取列表(展位管理新增展位前,需先获取未发布的展位，此时fbzt参数为必录)")
    @PostMapping(value = "/hcgl/getHcglList")
    public AjaxResponse getHcglList(@RequestBody @Valid HcQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getHcglList(dto).get("result"));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
            ajaxResponse.setData("ssdq", zphglBPO.getHcglList(dto).get("ssdq"));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    会场管理*获取会场信息
     */
    @ApiOperation(value = "获取会场信息", notes = "会场管理*获取会场信息")
    @PostMapping(value = "/hcgl/getHcXx")
    public AjaxResponse getHcXx(@RequestBody @Valid ZjQueryDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getHcXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    会场管理*保存会场信息
     */
    @ApiOperation(value = "保存会场信息", notes = "会场管理*保存会场信息")
    @PostMapping(value = "/hcgl/saveHcXx")
    public AjaxResponse saveHcXx(@RequestBody @Valid HcXxUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.saveHcXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    会场管理*删除会场信息
     */
    @ApiOperation(value = "删除会场信息", notes = "会场管理*删除会场信息")
    @PostMapping(value = "/hcgl/delHcXx")
    public AjaxResponse delHcXx(@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.delHcXx(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "更新会场发布状态", notes = "会场管理*更新会场发布状态")
    @PostMapping(value = "/hcgl/updateHcFbzt")
    public AjaxResponse updateHcFbzt(@RequestBody @Valid ZjUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.updateHcFbzt(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    /*
    展位管理*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "展位管理*获取列表")
    @PostMapping(value = "/zwgl/getZwglList")
    public AjaxResponse getZwglList(@RequestBody @Valid ZwQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            Map<String, Object> zwglList = zphglBPO.getZwglList(dto);
            ajaxResponse.setData("data", zwglList.get("result"));
            ajaxResponse.setData("bae001", zwglList.get("bae001"));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    展位管理*获取展位信息
     */
    @ApiOperation(value = "获取展位信息", notes = "展位管理*获取展位信息")
    @PostMapping(value = "/zwgl/getZwXx")
    public AjaxResponse getZwXx(@RequestBody @Valid ZjQueryDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getZwXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    展位管理*保存展位信息
     */
    @ApiOperation(value = "保存展位信息", notes = "展位管理*保存展位信息")
    @PostMapping(value = "/zwgl/saveZwXx")
    public AjaxResponse saveZwXx(@RequestBody @Valid ZwXxUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.saveZwXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    展位管理*删除展位信息
     */
    @ApiOperation(value = "删除展位信息", notes = "展位管理*删除展位信息")
    @PostMapping(value = "/zwgl/delZwXx")
    public AjaxResponse delZwXx(@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.delZwXx(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "更新展位发布状态", notes = "展位管理*删除展位信息")
    @PostMapping(value = "/zwgl/updateZwFbzt")
    public AjaxResponse updateZwFbzt(@RequestBody @Valid ZjUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            zphglBPO.updateZwFbzt(dto);
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    展位使用情况查看*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "展位使用情况查看*获取列表")
    @PostMapping(value = "/zwsyqkck/getZwsyqkckList")
    public AjaxResponse getZwsyqkckList(@RequestBody @Valid ZwQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            Map<String, Object> zwsyqkckList = zphglBPO.getZwsyqkckList(dto);
            ajaxResponse.setData("data", zwsyqkckList.get("result"));
            ajaxResponse.setData("bae001", zwsyqkckList.get("bae001"));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    展位使用情况查看*获取展位预定状态
     */
    @ApiOperation(value = "获取展位预定状态", notes = "展位使用情况查看*获取展位预定状态")
    @PostMapping(value = "/zwsyqkck/getZwsyqkckXx")
    public AjaxResponse getZwsyqkckXx(@RequestBody @Valid ZjDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getZwsyqkckXx(dto));
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    /*
    展位使用情况查看*获取展位预定状态
     */
    @ApiOperation(value = "获取展位预定状态详情", notes = "展位使用情况查看*获取展位预定状态详情")
    @PostMapping(value = "/zwsyqkck/getZwsyqkckXx/details")
    public AjaxResponse getZwsyqkckXxDetails(@RequestBody @Valid ZwQueryListDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getZwsyqkckXxDetails(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    单位入场签到*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "单位入场签到*获取列表")
    @PostMapping(value = "/dwrcqd/getDwrcqdList")
    public AjaxResponse getDwrcqdList(@RequestBody @Valid DwQdQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getDwrcqdList(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }
    /*
    个人入场签到*获取列表
     */
    @ApiOperation(value = "获取列表", notes = "个人入场签到*获取列表")
    @PostMapping(value = "/grrcqd/getGrrcqdList")
    public AjaxResponse getGrrcqdList(@RequestBody @Valid GrQdQueryDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.getGrrcqdList(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }


    @ApiOperation(value = "预定招聘会信息导出", notes = "预定招聘会信息导出")
    @PostMapping("/ydxx/export")   //获取加入招聘会的单位信息，传入招聘会流水号
    public void exportYdzphgl(@RequestBody ZphglExportDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportYdzphgl(dto, res);
    }

    @ApiOperation(value = "获取企业参会统计", notes = "招聘会发布*企业参会统计")
    @PostMapping(value = "/qychtj/list")
    public AjaxResponse queryQychtjList(@RequestBody @Valid QychtjDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.queryQychtjList(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "获取企业参会统计", notes = "招聘会发布*企业参会统计")
    @PostMapping(value = "/qychtj/detail/list")
    public AjaxResponse queryQychtjDetailsList(@RequestBody @Valid QychtjDTO dto, BindingResult bindingResult){
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(bindingResult.hasErrors()) {
            ajaxResponse.setAppcode("1");
            List<FieldError> fieldErrors = bindingResult.getFieldErrors();
            String errmsg = "";
            for (int i=0;i<fieldErrors.size();i++){
                if (i == 0){
                    errmsg = errmsg + fieldErrors.get(i).getDefaultMessage();
                } else {
                    errmsg = errmsg + "；" + fieldErrors.get(i).getDefaultMessage();
                }
            }
            ajaxResponse.setErrorMsg(errmsg);
            return ajaxResponse;
        }
        try {
            ajaxResponse.setData("data", zphglBPO.queryQychtjDetailsList(dto));
            ajaxResponse.setData("pagenum", dto.getPagenum());
            ajaxResponse.setData("pagesize", dto.getPagesize());
        } catch (AppException e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg(e.getMessage());
        } catch (Exception e) {
            ajaxResponse.setAppcode("1");
            LOG.error(e.getMessage());
            ajaxResponse.setErrorMsg("系统异常");
        }
        return ajaxResponse;
    }

    @ApiOperation(value = "企业参会统计导出", notes = "企业参会统计导出")
    @PostMapping("/qychtj/export")   //获取加入招聘会的单位信息，传入招聘会流水号
    public void exportQychtj(@RequestBody QychtjDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportQychtj(dto, res);
    }

    @ApiOperation(value = "职位统计导出", notes = "职位统计导出")
    @PostMapping("/zwtj/export")
    public void exportZwtj(@RequestBody QychtjDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportZwtj(dto, res);
    }

    @ApiOperation(value = "职位统计人员类别导出", notes = "职位统计人员类别导出")
    @PostMapping("/zwtj/rylb/export")
    public void exportZwtjRylb(@RequestBody QychtjDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportZwtjRylb(dto, res);
    }
    @ApiOperation(value = "招聘会置顶", notes = "招聘会置顶")
    @PostMapping(value = "/zphfb/UpdateZphZd")
    public AjaxResponse UpdateZphZd(@RequestBody @Valid ZjUDTO dto, BindingResult bindingResult) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        zphglBPO.UpdateZphZd(dto);
        return ajaxResponse;
    }

    @ApiOperation(value = "企业参会统计职位统计导出", notes = "企业参会统计职位统计导出")
    @PostMapping("/qychtj/zwtj/export")
    public void exportQychtjZwtj(@RequestBody ZphQueryDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportQychtjZwtj(dto, res);
    }
    @ApiOperation(value = "企业参会统计人员类别统计导出", notes = "企业参会统计人员类别统计导出")
    @PostMapping("/qychtj/rylbtj/export")
    public void exportQychtjRylbtj(@RequestBody ZphQueryDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportQychtjRylbtj(dto, res);
    }

    @ApiOperation(value = "招聘会发布网申次数明细列表", notes = "招聘会发布网申次数明细列表")
    @PostMapping(value = "/zphfb/wscsmx/getWscsmx")
    public AjaxResponse getWscsmx(@RequestBody ZphQueryDTO dto) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        if(StringUtils.isBlank(dto.getZphlsh())){
            ajaxResponse.setErrorMsg("招聘会流水号不能为空");
            ajaxResponse.setAppcode("1");
            return ajaxResponse;
        }
        ajaxResponse.setData("data", zphglBPO.getWscsmx(dto));
        ajaxResponse.setData("pagenum", dto.getPagenum());
        ajaxResponse.setData("pagesize", dto.getPagesize());
        return ajaxResponse;
    }

    @ApiOperation(value = "报名参加企业数导出", notes = "报名参加企业数导出")
    @PostMapping(value = "/qychtj/bmcjqysdc/export")
    public void exportBmcjqysDc(@RequestBody ZphQueryDTO dto,HttpServletResponse res) throws IOException {
      zphglBPO.exportBmcjqysDc(dto, res);
    }

    @ApiOperation(value = "招聘会发布网申次数明细导出", notes = "招聘会发布网申次数明细导出")
    @PostMapping("/zphfb/wscsmx/export")
    public void exportZphfbWscsmx(@RequestBody ZphQueryDTO dto, HttpServletResponse res) throws IOException {
        zphglBPO.exportZphfbWscsmx(dto, res);
    }

    @ApiOperation(value = "企业参会统计汇总导出", notes = "企业参会统计汇总导出")
    @PostMapping(value = "/qychtj/hzdc/export")
    public void exportHzdc(@RequestBody ZphQueryDTO dto,HttpServletResponse res) throws IOException {
        zphglBPO.exportHzdc(dto, res);
    }

}
