lyh
2025-07-03 ed911867411f882a49e9949284e43dca97e149cc
设备台账导出
已修改6个文件
149 ■■■■■ 文件已修改
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamEquipment.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/entity/EamEquipment.java
@@ -118,7 +118,7 @@
    /**
     * 工段
     */
    @Excel(name = "中心/工区/工段", width = 15, orderNum = "4")
    @Excel(name = "中心/工区/工段", width = 15, orderNum = "4",dictTable = "eam_base_factory",dicText = "factory_name",dicCode = "org_code")
    @ApiModelProperty(value = "中心/工区/工段")
    @Dict(dictTable = "eam_base_factory",dicText = "factory_name",dicCode = "org_code")
    private String factoryOrgCode;
@@ -162,8 +162,9 @@
    /**
     * 维修班组
     */
    @Excel(name = "维修班组", width = 15, orderNum = "10")
    @Excel(name = "维修班组", width = 15, orderNum = "10",dictTable = "eam_base_repair_depart",dicText = "depart_name",dicCode = "org_code")
    @ApiModelProperty(value = "维修班组")
    @Dict(dictTable = "eam_base_repair_depart",dicText = "depart_name",dicCode = "org_code")
    private String repairDepartOrgCode;
    /**
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentMapper.java
@@ -32,4 +32,11 @@
     * @return
     */
    IPage<EamEquipment> queryPageList(IPage<EamEquipment> page, @Param(Constants.WRAPPER) Wrapper<EamEquipment> queryWrapper);
    /**
     * 列表查询
     * @param queryWrapper
     * @return
     */
    List<EamEquipment> queryList(@Param(Constants.WRAPPER) Wrapper<EamEquipment> queryWrapper);
}
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentMapper.xml
@@ -20,4 +20,22 @@
        on e.id = ext.id
        ${ew.customSqlSegment}
    </select>
    <select id="queryList" resultType="org.jeecg.modules.eam.entity.EamEquipment">
        select e.*,
               ext.maintenance_status,
               ext.repair_status,
               ext.latest_second_maintenance,
               ext.next_second_maintenance,
               ext.latest_third_maintenance,
               ext.next_third_maintenance,
               ext.technology_status,
               ext.third_maintenance_period,
               ext.technology_check_period,
               ext.latest_technology_check,
               ext.next_technology_check
        from eam_equipment e
                 left join eam_equipment_extend ext
                           on e.id = ext.id
            ${ew.customSqlSegment}
    </select>
</mapper>
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentService.java
@@ -58,4 +58,11 @@
     * @return
     */
    EamEquipment selectByEquipmentCode(String equipmentCode);
    /**
     * 设备台账导出
     * @param eamEquipment
     * @return
     */
    List<EamEquipment> exportList(EamEquipmentQuery eamEquipment);
}
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java
@@ -274,6 +274,90 @@
    }
    /**
     * 设备台账导出
     * @param eamEquipment
     * @return
     */
    @Override
    public List<EamEquipment> exportList(EamEquipmentQuery eamEquipment){
        QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("e.del_flag", CommonConstant.DEL_FLAG_0);
        //用户数据权限
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        if (sysUser == null) {
            return new ArrayList<>();
        }
        if (StringUtils.isNotBlank(sysUser.getEamEquipmentIds())) {
            //选择了设备,根据设备id过滤设备
            List<String> equipArr = Arrays.asList(sysUser.getEamEquipmentIds().split(","));
            queryWrapper.in("e.equipment_code", equipArr);
        } else {
            //没有选择设备,根据中心过滤设备
            List<BaseFactoryUser> baseFactoryUserList=baseFactoryUserService.
                    list(new LambdaQueryWrapper<BaseFactoryUser>().eq(BaseFactoryUser::getUserId,sysUser.getId()));
            if(!CollectionUtils.isEmpty(baseFactoryUserList)){
                List<String> factoryIds = baseFactoryUserList.stream().map(BaseFactoryUser::getFactoryId).collect(Collectors.toList());
                List<String> factoryCode= baseFactoryService.listByIds(factoryIds).stream().map(BaseFactory::getFactoryCode).collect(Collectors.toList());
                queryWrapper.in("e.factory_code", factoryCode);
            }
        }
        //查询条件过滤
        if (eamEquipment != null) {
            if (StringUtils.isNotBlank(eamEquipment.getEquipmentCode())) {
                queryWrapper.like("e.equipment_code", eamEquipment.getEquipmentCode());
            }
            if (StringUtils.isNotBlank(eamEquipment.getEquipmentName())) {
                queryWrapper.like("e.equipment_name", eamEquipment.getEquipmentName());
            }
            if (StringUtils.isNotBlank(eamEquipment.getEquipmentImportance())) {
                queryWrapper.eq("e.equipment_importance", eamEquipment.getEquipmentImportance());
            }
            if (StringUtils.isNotBlank(eamEquipment.getAssetStatus())) {
                queryWrapper.like("e.asset_status", eamEquipment.getAssetStatus());
            }
            if (StringUtils.isNotBlank(eamEquipment.getTechnologyStatus())) {
                queryWrapper.like("e.technology_status", eamEquipment.getTechnologyStatus());
            }
            if (StringUtils.isNotBlank(eamEquipment.getOperationSystem())) {
                queryWrapper.like("e.operation_system", eamEquipment.getOperationSystem());
            }
            if (StringUtils.isNotBlank(eamEquipment.getOrgId())) {
                //车间编码不为空
                List<String> productIds = mdcProductionService.recursionChildren(eamEquipment.getOrgId());
                if (CollectionUtil.isNotEmpty(productIds)) {
                    //不做筛选
                    queryWrapper.in("e.org_id", productIds);
                }
            }
            if (StringUtils.isNotBlank(eamEquipment.getEquipmentCategory())) {
                queryWrapper.like("e.equipment_category", eamEquipment.getEquipmentCategory());
            }
            if (StringUtils.isNotBlank(eamEquipment.getId())) {
                queryWrapper.eq("e.id", eamEquipment.getId());
            }
            //排序
            if (StringUtils.isNotBlank(eamEquipment.getColumn()) && StringUtils.isNotBlank(eamEquipment.getOrder())) {
                //queryWrapper.like("column", eamEquipment.getColumn());
                String column = eamEquipment.getColumn();
                if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) {
                    column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX));
                }
                if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(eamEquipment.getOrder())) {
                    queryWrapper.orderByAsc("e." + oConvertUtils.camelToUnderline(column));
                } else {
                    queryWrapper.orderByDesc("e." + oConvertUtils.camelToUnderline(column));
                }
            } else {
                queryWrapper.orderByDesc("e.create_time");
            }
        } else {
            queryWrapper.orderByDesc("e.create_time");
        }
        return eamEquipmentMapper.queryList(queryWrapper);
    }
    /**
     * 获取所有的产线id(包含所有上级)
     */
    private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) {
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentController.java
@@ -11,10 +11,13 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.TranslateDictTextUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.entity.EamEquipment;
import org.jeecg.modules.eam.entity.EamEquipmentExtend;
import org.jeecg.modules.eam.request.EamEquipmentQuery;
@@ -25,7 +28,10 @@
//import org.jeecg.modules.mdc.entity.MdcEquipment;
//import org.jeecg.modules.mdc.service.IMdcEquipmentService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -38,6 +44,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * @Description: 设备台账
@@ -198,13 +205,26 @@
    /**
     * 导出excel
     *
     * @param request
     * @param eamEquipment
     */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, EamEquipment eamEquipment) {
        return super.exportXls(request, eamEquipment, EamEquipment.class, "设备台账");
    public ModelAndView exportXls(HttpServletRequest request,EamEquipmentQuery eamEquipment) {
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        List<EamEquipment> equipmentList=eamEquipmentService.exportList(eamEquipment);
        String selections = request.getParameter("selections");
        if (oConvertUtils.isNotEmpty(selections)) {
            List<String> selectionList = Arrays.asList(selections.split(","));
            equipmentList = equipmentList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
        }
        // Step.3 AutoPoi 导出Excel
        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
        mv.addObject(NormalExcelConstants.FILE_NAME, "设备台账"); //此处设置的filename无效 ,前端会重更新设置一下
        mv.addObject(NormalExcelConstants.CLASS, EamEquipment.class);
        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("设备台账" + "报表", "导出人:" + sysUser.getRealname(), "设备台账"));
        mv.addObject(NormalExcelConstants.DATA_LIST, equipmentList);
        return mv;
    }
    /**