qushaowei
2024-01-11 0581d9986b4d14cdf8a6f66a929674224dd45b2f
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EquipmentReportRepairController.java
@@ -8,6 +8,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.dto.message.MessageDTO;
import org.jeecg.common.api.vo.Result;
@@ -17,17 +18,25 @@
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.entity.*;
import org.jeecg.modules.eam.service.*;
import org.jeecg.modules.eam.vo.RepairReportExportVo;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -61,6 +70,8 @@
    private IdentityService sysIdentityService;
    @Autowired
    private IFaultInfoService faultInfoService;
    @Value("${jeecg.path.upload}")
    private String upLoadPath;
    /**
@@ -106,6 +117,7 @@
        LoginUser curUser= (LoginUser) SecurityUtils.getSubject().getPrincipal();
        equipmentReportRepair.setStatus("1");
        equipmentReportRepair.setSource("1");
//        equipmentReportRepair.setType("1");
        equipmentReportRepair.setIsCreateOrder(0);
        equipmentReportRepairService.save(equipmentReportRepair);
        String IS_PRODUCT_YES = "yes";
@@ -264,14 +276,14 @@
                FaultInfo faultInfo = faultInfoService.getOne(new QueryWrapper<FaultInfo>().eq("quanlity_id",quanlityConfirm.getId()),false);
                if(ObjectUtils.isNotNull(faultInfo)){
                    String isConfirm2 = faultInfo.getIsConfirm();
                    if(!isConfirm1.equals("yes")||isConfirm2.equals("yes")){
                        return Result.error("验收失败,产品质量隐患确认和事故登记尚未完场,请完成确认后再进行验收");
                    if(!isConfirm1.equals("yes")||!isConfirm2.equals("yes")){
                        return Result.error("验收失败,产品质量隐患确认和事故登记尚未完成,请完成确认后再进行验收");
                    }
                }else {
                    return Result.error("验收失败,未生成事故登记单");
                }
            }else {
                return Result.error("验收失败,未生成产平质量确认");
                return Result.error("验收失败,未生成产品质量确认");
            }
        }
        LoginUser user= (LoginUser)SecurityUtils.getSubject().getPrincipal();
@@ -294,4 +306,31 @@
        }
        return Result.OK("验收成功");
    }
    /**
     * 导出excel
     *
     * @param request
     * @param equipmentReportRepair
     */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, RepairReportExportVo equipmentReportRepair) {
        // Step.1 组装查询条件
        String title = "故障报修导出";
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        // Step.2 获取导出数据
        List<RepairReportExportVo> exportList = equipmentReportRepairService.exportList(equipmentReportRepair);
        // Step.3 AutoPoi 导出Excel
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.FILE_NAME, title);
        mv.addObject(NormalExcelConstants.CLASS, RepairReportExportVo.class);
        //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
        ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
        exportParams.setImageBasePath(upLoadPath);
        //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
        mv.addObject(NormalExcelConstants.PARAMS,exportParams);
        mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
        return mv;
    }
}