Merge remote-tracking branch 'origin/master'
10 files modified
12 files added
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import lombok.AllArgsConstructor; |
| | | import javax.validation.Valid; |
| | | |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.sxkj.fw.fwDevicePerShare.vo.FwDevicePerShareVO; |
| | | import org.sxkj.fw.fwDevicePerShare.excel.FwDevicePerShareExcel; |
| | | import org.sxkj.fw.fwDevicePerShare.wrapper.FwDevicePerShareWrapper; |
| | | import org.sxkj.fw.fwDevicePerShare.service.IFwDevicePerShareService; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * 设备权限分享表 控制器 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("fwDevicePerShare/fwDevicePerShare") |
| | | @Api(value = "设备权限分享表", tags = "设备权限分享表接口") |
| | | public class FwDevicePerShareController extends BladeController { |
| | | |
| | | private final IFwDevicePerShareService fwDevicePerShareService; |
| | | |
| | | /** |
| | | * 设备权限分享表 详情 |
| | | */ |
| | | @GetMapping("/detail") |
| | | @ApiOperationSupport(order = 1) |
| | | @ApiOperation(value = "详情", notes = "传入fwDevicePerShare") |
| | | public R<FwDevicePerShareVO> detail(FwDevicePerShareEntity fwDevicePerShare) { |
| | | FwDevicePerShareEntity detail = fwDevicePerShareService.getOne(Condition.getQueryWrapper(fwDevicePerShare)); |
| | | return R.data(FwDevicePerShareWrapper.build().entityVO(detail)); |
| | | } |
| | | /** |
| | | * 设备权限分享表 分页 |
| | | */ |
| | | @GetMapping("/list") |
| | | @ApiOperationSupport(order = 2) |
| | | @ApiOperation(value = "分页", notes = "传入fwDevicePerShare") |
| | | public R<IPage<FwDevicePerShareVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwDevicePerShare, Query query) { |
| | | IPage<FwDevicePerShareEntity> pages = fwDevicePerShareService.page(Condition.getPage(query), Condition.getQueryWrapper(fwDevicePerShare, FwDevicePerShareEntity.class)); |
| | | return R.data(FwDevicePerShareWrapper.build().pageVO(pages)); |
| | | } |
| | | |
| | | /** |
| | | * 设备权限分享表 自定义分页 |
| | | */ |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入fwDevicePerShare") |
| | | public R<IPage<FwDevicePerShareVO>> page(FwDevicePerShareVO fwDevicePerShare, Query query) { |
| | | IPage<FwDevicePerShareVO> pages = fwDevicePerShareService.selectFwDevicePerSharePage(Condition.getPage(query), fwDevicePerShare); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 设备权限分享表 新增 |
| | | */ |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入fwDevicePerShare") |
| | | public R save(@Valid @RequestBody FwDevicePerShareEntity fwDevicePerShare) { |
| | | return R.status(fwDevicePerShareService.save(fwDevicePerShare)); |
| | | } |
| | | |
| | | /** |
| | | * 设备权限分享表 修改 |
| | | */ |
| | | @PostMapping("/update") |
| | | @ApiOperationSupport(order = 5) |
| | | @ApiOperation(value = "修改", notes = "传入fwDevicePerShare") |
| | | public R update(@Valid @RequestBody FwDevicePerShareEntity fwDevicePerShare) { |
| | | return R.status(fwDevicePerShareService.updateById(fwDevicePerShare)); |
| | | } |
| | | |
| | | /** |
| | | * 设备权限分享表 新增或修改 |
| | | */ |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入fwDevicePerShare") |
| | | public R submit(@Valid @RequestBody FwDevicePerShareEntity fwDevicePerShare) { |
| | | return R.status(fwDevicePerShareService.saveOrUpdate(fwDevicePerShare)); |
| | | } |
| | | |
| | | /** |
| | | * 设备权限分享表 删除 |
| | | */ |
| | | @PostMapping("/remove") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "逻辑删除", notes = "传入ids") |
| | | public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
| | | return R.status(fwDevicePerShareService.deleteLogic(Func.toLongList(ids))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出数据 |
| | | */ |
| | | @GetMapping("/export-fwDevicePerShare") |
| | | @ApiOperationSupport(order = 9) |
| | | @ApiOperation(value = "导出数据", notes = "传入fwDevicePerShare") |
| | | public void exportFwDevicePerShare(@ApiIgnore @RequestParam Map<String, Object> fwDevicePerShare, BladeUser bladeUser, HttpServletResponse response) { |
| | | QueryWrapper<FwDevicePerShareEntity> queryWrapper = Condition.getQueryWrapper(fwDevicePerShare, FwDevicePerShareEntity.class); |
| | | //if (!AuthUtil.isAdministrator()) { |
| | | // queryWrapper.lambda().eq(FwDevicePerShare::getTenantId, bladeUser.getTenantId()); |
| | | //} |
| | | queryWrapper.lambda().eq(FwDevicePerShareEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED); |
| | | List<FwDevicePerShareExcel> list = fwDevicePerShareService.exportFwDevicePerShare(queryWrapper); |
| | | ExcelUtil.export(response, "设备权限分享表数据" + DateUtil.time(), "设备权限分享表数据表", list, FwDevicePerShareExcel.class); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.dto; |
| | | |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 设备权限分享表 数据传输对象实体类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FwDevicePerShareDTO extends FwDevicePerShareEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springblade.core.mp.base.BaseEntity; |
| | | import org.springblade.core.tenant.mp.TenantEntity; |
| | | |
| | | /** |
| | | * 设备权限分享表 实体类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @Data |
| | | @TableName("ja_fw_device_per_share") |
| | | @ApiModel(value = "FwDevicePerShare对象", description = "设备权限分享表") |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FwDevicePerShareEntity extends BaseEntity { |
| | | |
| | | /** |
| | | * 设备编号 |
| | | */ |
| | | @ApiModelProperty(value = "设备编号") |
| | | private String deviceSn; |
| | | /** |
| | | * 借出方部门ID |
| | | */ |
| | | @ApiModelProperty(value = "借出方部门ID") |
| | | private Long loanFromDeptId; |
| | | /** |
| | | * 借入方部门ID |
| | | */ |
| | | @ApiModelProperty(value = "借入方部门ID") |
| | | private Long loanToDeptId; |
| | | /** |
| | | * 设备权限菜单ID |
| | | */ |
| | | @ApiModelProperty(value = "设备权限菜单ID") |
| | | private String devicePerMenuId; |
| | | /** |
| | | * 区域编码 |
| | | */ |
| | | @ApiModelProperty(value = "区域编码") |
| | | private String areaCode; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.excel; |
| | | |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | |
| | | /** |
| | | * 设备权限分享表 Excel实体类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @Data |
| | | @ColumnWidth(25) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class FwDevicePerShareExcel implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 设备编号 |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("设备编号") |
| | | private String deviceSn; |
| | | /** |
| | | * 借出方部门ID |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("借出方部门ID") |
| | | private Long loanFromDeptId; |
| | | /** |
| | | * 借入方部门ID |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("借入方部门ID") |
| | | private Long loanToDeptId; |
| | | /** |
| | | * 设备权限菜单ID |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("设备权限菜单ID") |
| | | private String devicePerMenuId; |
| | | /** |
| | | * 区域编码 |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("区域编码") |
| | | private String areaCode; |
| | | /** |
| | | * 删除标志(0存在 1删除) |
| | | */ |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("删除标志(0存在 1删除)") |
| | | private Byte isDeleted; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.mapper; |
| | | |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.sxkj.fw.fwDevicePerShare.vo.FwDevicePerShareVO; |
| | | import org.sxkj.fw.fwDevicePerShare.excel.FwDevicePerShareExcel; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 设备权限分享表 Mapper 接口 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | public interface FwDevicePerShareMapper extends BaseMapper<FwDevicePerShareEntity> { |
| | | |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param fwDevicePerShare |
| | | * @return |
| | | */ |
| | | List<FwDevicePerShareVO> selectFwDevicePerSharePage(IPage page, FwDevicePerShareVO fwDevicePerShare); |
| | | |
| | | |
| | | /** |
| | | * 获取导出数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<FwDevicePerShareExcel> exportFwDevicePerShare(@Param("ew") Wrapper<FwDevicePerShareEntity> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.sxkj.fw.fwDevicePerShare.mapper.FwDevicePerShareMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="fwDevicePerShareResultMap" type="org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity"> |
| | | <result column="id" property="id"/> |
| | | <result column="device_sn" property="deviceSn"/> |
| | | <result column="loan_from_dept_id" property="loanFromDeptId"/> |
| | | <result column="loan_to_dept_id" property="loanToDeptId"/> |
| | | <result column="device_per_menu_id" property="devicePerMenuId"/> |
| | | <result column="area_code" property="areaCode"/> |
| | | <result column="create_user" property="createUser"/> |
| | | <result column="create_dept" property="createDept"/> |
| | | <result column="create_time" property="createTime"/> |
| | | <result column="update_user" property="updateUser"/> |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="status" property="status"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="selectFwDevicePerSharePage" resultMap="fwDevicePerShareResultMap"> |
| | | select * from ja_fw_device_per_share where is_deleted = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="exportFwDevicePerShare" resultType="org.sxkj.fw.fwDevicePerShare.excel.FwDevicePerShareExcel"> |
| | | SELECT * FROM ja_fw_device_per_share ${ew.customSqlSegment} |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.sxkj.fw.fwDevicePerShare.vo.FwDevicePerShareVO; |
| | | import org.sxkj.fw.fwDevicePerShare.excel.FwDevicePerShareExcel; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseService; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 设备权限分享表 服务类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | public interface IFwDevicePerShareService extends BaseService<FwDevicePerShareEntity> { |
| | | /** |
| | | * 自定义分页 |
| | | * |
| | | * @param page |
| | | * @param fwDevicePerShare |
| | | * @return |
| | | */ |
| | | IPage<FwDevicePerShareVO> selectFwDevicePerSharePage(IPage<FwDevicePerShareVO> page, FwDevicePerShareVO fwDevicePerShare); |
| | | |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * |
| | | * @param queryWrapper |
| | | * @return |
| | | */ |
| | | List<FwDevicePerShareExcel> exportFwDevicePerShare(Wrapper<FwDevicePerShareEntity> queryWrapper); |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.service.impl; |
| | | |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.sxkj.fw.fwDevicePerShare.vo.FwDevicePerShareVO; |
| | | import org.sxkj.fw.fwDevicePerShare.excel.FwDevicePerShareExcel; |
| | | import org.sxkj.fw.fwDevicePerShare.mapper.FwDevicePerShareMapper; |
| | | import org.sxkj.fw.fwDevicePerShare.service.IFwDevicePerShareService; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 设备权限分享表 服务实现类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @Service |
| | | public class FwDevicePerShareServiceImpl extends BaseServiceImpl<FwDevicePerShareMapper, FwDevicePerShareEntity> implements IFwDevicePerShareService { |
| | | |
| | | @Override |
| | | public IPage<FwDevicePerShareVO> selectFwDevicePerSharePage(IPage<FwDevicePerShareVO> page, FwDevicePerShareVO fwDevicePerShare) { |
| | | return page.setRecords(baseMapper.selectFwDevicePerSharePage(page, fwDevicePerShare)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<FwDevicePerShareExcel> exportFwDevicePerShare(Wrapper<FwDevicePerShareEntity> queryWrapper) { |
| | | List<FwDevicePerShareExcel> fwDevicePerShareList = baseMapper.exportFwDevicePerShare(queryWrapper); |
| | | //fwDevicePerShareList.forEach(fwDevicePerShare -> { |
| | | // fwDevicePerShare.setTypeName(DictCache.getValue(DictEnum.YES_NO, FwDevicePerShare.getType())); |
| | | //}); |
| | | return fwDevicePerShareList; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.vo; |
| | | |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.springblade.core.tool.node.INode; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * 设备权限分享表 视图实体类 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class FwDevicePerShareVO extends FwDevicePerShareEntity { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.fw.fwDevicePerShare.wrapper; |
| | | |
| | | import org.springblade.core.mp.support.BaseEntityWrapper; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.sxkj.fw.fwDevicePerShare.entity.FwDevicePerShareEntity; |
| | | import org.sxkj.fw.fwDevicePerShare.vo.FwDevicePerShareVO; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * 设备权限分享表 包装类,返回视图层所需的字段 |
| | | * |
| | | * @author lw |
| | | * @since 2026-01-28 |
| | | */ |
| | | public class FwDevicePerShareWrapper extends BaseEntityWrapper<FwDevicePerShareEntity, FwDevicePerShareVO> { |
| | | |
| | | public static FwDevicePerShareWrapper build() { |
| | | return new FwDevicePerShareWrapper(); |
| | | } |
| | | |
| | | @Override |
| | | public FwDevicePerShareVO entityVO(FwDevicePerShareEntity fwDevicePerShare) { |
| | | FwDevicePerShareVO fwDevicePerShareVO = Objects.requireNonNull(BeanUtil.copy(fwDevicePerShare, FwDevicePerShareVO.class)); |
| | | |
| | | //User createUser = UserCache.getUser(fwDevicePerShare.getCreateUser()); |
| | | //User updateUser = UserCache.getUser(fwDevicePerShare.getUpdateUser()); |
| | | //fwDevicePerShareVO.setCreateUserName(createUser.getName()); |
| | | //fwDevicePerShareVO.setUpdateUserName(updateUser.getName()); |
| | | |
| | | return fwDevicePerShareVO; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <if test="param2.skilledTaskType != null and param2.skilledTaskType != ''"> |
| | | and skilled_task_type = #{param2.skilledTaskType} |
| | | </if> |
| | | <if test="param2.deptList != null and param2.deptList.size > 0"> |
| | | AND create_dept in |
| | | <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")"> |
| | | #{deptId} |
| | | </foreach> |
| | | </if> |
| | | <!-- <if test="param2.deptList != null and param2.deptList.size > 0"> --> |
| | | <!-- AND create_dept in --> |
| | | <!-- <foreach collection="param2.deptList" item="deptId" open="(" separator="," close=")"> --> |
| | | <!-- #{deptId} --> |
| | | <!-- </foreach> --> |
| | | <!-- </if> --> |
| | | </where> |
| | | </select> |
| | | |
| | |
| | | * @return 更新影响行数 |
| | | */ |
| | | Integer updateWorkOrderById(@Param("workOrderParam") GdWorkOrderEntity workOrderParam); |
| | | |
| | | /** |
| | | * 获取巡查任务详情 |
| | | * @param patrolTaskId |
| | | * @return |
| | | */ |
| | | GdPatrolTaskVO getPatrolTaskIdById(Long patrolTaskId); |
| | | } |
| | |
| | | <select id="exportGdPatrolTask" resultType="org.sxkj.gd.workorder.excel.GdPatrolTaskExcel"> |
| | | SELECT * FROM ja_gd_patrol_task ${ew.customSqlSegment} |
| | | </select> |
| | | <select id="getPatrolTaskIdById" resultType="org.sxkj.gd.workorder.vo.GdPatrolTaskVO"> |
| | | SELECT |
| | | pt.*, |
| | | md.airport_id as airport_id |
| | | FROM |
| | | ja_gd_patrol_task pt |
| | | left join |
| | | ja_gd_manage_device md on md.id = pt.device_id |
| | | WHERE id = #{patrolTaskId} |
| | | </select> |
| | | |
| | | <!-- 自定义更新工单状态语句 --> |
| | | <update id="updateWorkOrderById" parameterType="org.sxkj.gd.workorder.entity.GdWorkOrderEntity"> |
| | |
| | | if (patrolTaskId == null) { |
| | | return R.fail("巡查任务主键不能为空"); |
| | | } |
| | | GdPatrolTaskEntity taskEntity = getById(patrolTaskId); |
| | | GdPatrolTaskVO taskEntity = baseMapper.getPatrolTaskIdById(patrolTaskId); |
| | | if (taskEntity == null) { |
| | | return R.fail("巡查任务不存在"); |
| | | } |
| | |
| | | return jianXingtuApiService.saveFlyTask(param); |
| | | } |
| | | |
| | | private GdXingtuFlyTaskSaveDTO buildXingtuFlyTask(GdPatrolTaskEntity taskEntity) { |
| | | /** |
| | | * 构建巡察任务推送的巡察任务信息 |
| | | * @param gdPatrolTaskVO |
| | | * @return |
| | | */ |
| | | private GdXingtuFlyTaskSaveDTO buildXingtuFlyTask(GdPatrolTaskVO gdPatrolTaskVO) { |
| | | GdXingtuFlyTaskSaveDTO param = new GdXingtuFlyTaskSaveDTO(); |
| | | if (StringUtil.isNotBlank(taskEntity.getPatrolTaskName())) { |
| | | param.setName(taskEntity.getPatrolTaskName()); |
| | | } else if (StringUtil.isNotBlank(taskEntity.getTaskNo())) { |
| | | param.setName(taskEntity.getTaskNo()); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskName())) { |
| | | param.setName(gdPatrolTaskVO.getPatrolTaskName()); |
| | | } else if (StringUtil.isNotBlank(gdPatrolTaskVO.getTaskNo())) { |
| | | param.setName(gdPatrolTaskVO.getTaskNo()); |
| | | } |
| | | if (StringUtil.isNotBlank(taskEntity.getPatrolTaskType())) { |
| | | param.setInspectionType(taskEntity.getPatrolTaskType()); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getPatrolTaskType())) { |
| | | param.setInspectionType(gdPatrolTaskVO.getPatrolTaskType()); |
| | | } |
| | | param.setTimingType("单次执行"); |
| | | if (StringUtil.isNotBlank(taskEntity.getAirlineId())) { |
| | | param.setAirlineId(taskEntity.getAirlineId()); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirlineId())) { |
| | | param.setAirlineId(gdPatrolTaskVO.getAirlineId()); |
| | | } |
| | | if (taskEntity.getExecuteTime() != null) { |
| | | param.setSingleTime(DateUtil.format(taskEntity.getExecuteTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | if (gdPatrolTaskVO.getExecuteTime() != null) { |
| | | param.setSingleTime(DateUtil.format(gdPatrolTaskVO.getExecuteTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | if (StringUtil.isNotBlank(taskEntity.getAreaCode())) { |
| | | param.setRegionCode(taskEntity.getAreaCode()); |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAreaCode())) { |
| | | param.setRegionCode(gdPatrolTaskVO.getAreaCode()); |
| | | } |
| | | if (StringUtil.isNotBlank(taskEntity.getDeviceId())) { |
| | | GdManageDeviceEntity device = null; |
| | | if (StringUtils.isNumeric(taskEntity.getDeviceId())) { |
| | | device = gdManageDeviceService.getById(Long.valueOf(taskEntity.getDeviceId())); |
| | | } |
| | | if (device == null) { |
| | | device = gdManageDeviceService.lambdaQuery() |
| | | .eq(GdManageDeviceEntity::getAirportId, taskEntity.getDeviceId()) |
| | | .one(); |
| | | } |
| | | if (device != null && StringUtil.isNotBlank(device.getAirportId())) { |
| | | param.setAirportId(device.getAirportId()); |
| | | } else { |
| | | param.setAirportId(taskEntity.getDeviceId()); |
| | | } |
| | | if (StringUtil.isNotBlank(gdPatrolTaskVO.getAirportId())) { |
| | | param.setAirportId(gdPatrolTaskVO.getAirportId()); |
| | | // GdManageDeviceEntity device = null; |
| | | // if (StringUtils.isNumeric(taskEntity.getAirportId())) { |
| | | // device = gdManageDeviceService.getById(Long.valueOf(taskEntity.getDeviceId())); |
| | | // } |
| | | // if (device == null) { |
| | | // device = gdManageDeviceService.lambdaQuery() |
| | | // .eq(GdManageDeviceEntity::getAirportId, taskEntity.getDeviceId()) |
| | | // .one(); |
| | | // } |
| | | // if (device != null && StringUtil.isNotBlank(device.getAirportId())) { |
| | | // param.setAirportId(device.getAirportId()); |
| | | // } else { |
| | | // param.setAirportId(taskEntity.getAirportId()); |
| | | // } |
| | | } |
| | | String status = parseStatus(taskEntity.getTaskStatus()); |
| | | String status = parseStatus(gdPatrolTaskVO.getTaskStatus()); |
| | | if (StringUtil.isNotBlank(status)) { |
| | | param.setStatus(status); |
| | | } |
| | |
| | | * 关联设备ID |
| | | */ |
| | | @ApiModelProperty(value = "关联设备ID") |
| | | private String deviceId; |
| | | private Long deviceId; |
| | | |
| | | @ApiModelProperty(value = "设备名称") |
| | | private String deviceName; |
| | |
| | | @ApiModelProperty(value = "逻辑删除") |
| | | private Integer isDeleted; |
| | | |
| | | @ApiModelProperty(value = "机场id") |
| | | private String airportId; |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.sxkj.system.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.sxkj.system.entity.Region; |
| | | import org.sxkj.system.entity.User; |
| | | import org.sxkj.system.enums.DictEnum; |
| | | import org.sxkj.system.excel.DeptExcel; |
| | | import org.sxkj.system.excel.DeptImporter; |
| | | import org.sxkj.system.excel.RegionExcel; |
| | | import org.sxkj.system.excel.RegionImporter; |
| | | import org.sxkj.system.excel.*; |
| | | import org.sxkj.system.mapper.DeptMapper; |
| | | import org.sxkj.system.mapper.UserMapper; |
| | | import org.sxkj.system.param.DeptAddParam; |
| | | import org.sxkj.system.param.DeptExportParam; |
| | | import org.sxkj.system.param.DeptPageParam; |
| | | import org.sxkj.system.service.IDeptService; |
| | | import org.sxkj.system.util.excel.RegionSheetWriteHandler; |
| | | import org.sxkj.system.vo.DeptVO; |
| | | import org.sxkj.system.wrapper.DeptWrapper; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @ApiOperation(value = "导入机构", notes = "传入excel") |
| | | public R importRegion(MultipartFile file, Integer isCovered) { |
| | | DeptImporter deptImporter = new DeptImporter(deptService, isCovered == 1); |
| | | ExcelUtil.save(file, deptImporter, DeptExcel.class); |
| | | ExcelUtil.save(file, deptImporter, DeptImportExcel.class); |
| | | return R.success("操作成功"); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 导出模板 |
| | | * <p> |
| | | * 为区域列添加下拉选择功能,限制用户只能选择预设的区域名称 |
| | | * </p> |
| | | * |
| | | * @param response HTTP响应对象 |
| | | * @throws IOException 导出异常 |
| | | */ |
| | | @GetMapping("export-template") |
| | | @ApiOperationSupport(order = 16) |
| | | @ApiOperation(value = "导出模板") |
| | | public void exportUser(HttpServletResponse response) { |
| | | List<DeptExcel> list = new ArrayList<>(); |
| | | ExcelUtil.export(response, "机构模板", "机构表", list, DeptExcel.class); |
| | | public void exportUser(HttpServletResponse response) throws IOException { |
| | | // 设置响应头 |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(StandardCharsets.UTF_8.name()); |
| | | String fileName = URLEncoder.encode("机构模板", StandardCharsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | |
| | | // 准备空数据列表 |
| | | List<DeptImportExcel> list = new ArrayList<>(); |
| | | |
| | | // 使用EasyExcel导出,并注册RegionSheetWriteHandler |
| | | EasyExcel.write(response.getOutputStream(), DeptImportExcel.class) |
| | | .registerWriteHandler(new RegionSheetWriteHandler()) |
| | | .sheet("机构表") |
| | | .doWrite(list); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package org.sxkj.system.excel; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.annotation.write.style.ColumnWidth; |
| | | import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import lombok.Data; |
| | | import org.sxkj.system.util.excel.ExcelDictConverter; |
| | | import org.sxkj.system.util.excel.ExcelDictItem; |
| | | import org.sxkj.system.util.excel.ExcelDictItemLabel; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * RegionExcel |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Data |
| | | @ColumnWidth(16) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | public class DeptImportExcel implements Serializable { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | |
| | | @ExcelProperty("机构名称") |
| | | @ColumnWidth(20) |
| | | private String deptName; |
| | | |
| | | @ExcelProperty(value = "所属区划", converter = ExcelDictConverter.class) |
| | | @ColumnWidth(20) |
| | | @ExcelDictItemLabel(type = "regionName") |
| | | @ExcelDictItem(type = "regionName") |
| | | private String areaCode; |
| | | |
| | | @ExcelProperty("机构描述") |
| | | @ColumnWidth(20) |
| | | private String remark; |
| | | |
| | | @ColumnWidth(20) |
| | | @ExcelProperty(value = "机构状态", converter = ExcelDictConverter.class) |
| | | @ExcelDictItemLabel(type = "institutionStatus") |
| | | @ExcelDictItem(type = "institutionStatus") |
| | | private String status; |
| | | } |
| | |
| | | * @author Chill |
| | | */ |
| | | @RequiredArgsConstructor |
| | | public class DeptImporter implements ExcelImporter<DeptExcel> { |
| | | public class DeptImporter implements ExcelImporter<DeptImportExcel> { |
| | | |
| | | private final IDeptService service; |
| | | private final Boolean isCovered; |
| | | |
| | | @Override |
| | | public void save(List<DeptExcel> data) { |
| | | public void save(List<DeptImportExcel> data) { |
| | | service.importDept(data, isCovered); |
| | | } |
| | | } |
| | |
| | | FROM |
| | | blade_region |
| | | <where> |
| | | city_code = '360800000000' |
| | | city_code = '360800000000' |
| | | and region_level > '2' |
| | | <if test="param2.status!=null"> |
| | | and status = #{param1.status} |
| | | </if> |
| | |
| | | import org.sxkj.common.node.TreeStringNode; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.excel.DeptExcel; |
| | | import org.sxkj.system.excel.DeptImportExcel; |
| | | import org.sxkj.system.param.DeptExportParam; |
| | | import org.sxkj.system.param.DeptPageParam; |
| | | import org.sxkj.system.vo.DeptVO; |
| | |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | void importDept(List<DeptExcel> data, Boolean isCovered); |
| | | void importDept(List<DeptImportExcel> data, Boolean isCovered); |
| | | |
| | | /** |
| | | * 导出部门 |
| | |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | import org.springframework.stereotype.Service; |
| | | import org.sxkj.common.constant.WordOrderConstant; |
| | | import org.sxkj.common.func.Streams; |
| | | import org.sxkj.common.node.TreeStringNode; |
| | | import org.sxkj.common.utils.NodeTreeUtil; |
| | | import org.sxkj.common.utils.OrderNumUtils; |
| | | import org.sxkj.system.cache.SysCache; |
| | | import org.sxkj.system.entity.Dept; |
| | | import org.sxkj.system.excel.DeptExcel; |
| | | import org.sxkj.system.excel.DeptImportExcel; |
| | | import org.sxkj.system.mapper.DeptMapper; |
| | | import org.sxkj.system.param.DeptExportParam; |
| | | import org.sxkj.system.param.DeptPageParam; |
| | |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param page |
| | | * @param deptPageParam |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 导入部门 |
| | | * |
| | | * @param data |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importDept(List<DeptExcel> data, Boolean isCovered) { |
| | | public void importDept(List<DeptImportExcel> data, Boolean isCovered) { |
| | | List<Dept> list = new ArrayList<>(); |
| | | data.forEach(deptExcel -> { |
| | | Dept dept = BeanUtil.copy(deptExcel, Dept.class); |
| | |
| | | if (isCovered) { |
| | | this.saveOrUpdateBatch(list); |
| | | } else { |
| | | list.forEach(item -> { |
| | | String times = OrderNumUtils.initOrderNum2(WordOrderConstant.ORG_CODE); |
| | | String deptCode = WordOrderConstant.ORG_PREFIX + times; |
| | | item.setDeptCode(deptCode); |
| | | }); |
| | | this.saveBatch(list); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<DeptExcel> exportDept(DeptExportParam dept) { |
| | | return baseMapper.exportDept(dept); |
| | | return baseMapper.exportDept(dept); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.sxkj.system.util.excel; |
| | | |
| | | import com.alibaba.excel.write.handler.SheetWriteHandler; |
| | | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| | | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.util.CellRangeAddressList; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 区域数据验证处理器 |
| | | * <p> |
| | | * 用于为Excel导出模板中的区域列添加下拉选择功能 |
| | | * </p> |
| | | * |
| | | * @author Chill |
| | | */ |
| | | public class RegionSheetWriteHandler implements SheetWriteHandler { |
| | | |
| | | /** |
| | | * 区域名称列表 |
| | | * <p> |
| | | * 这里需要根据实际情况从区域数据源获取 |
| | | * </p> |
| | | */ |
| | | private static final String[] REGION_NAMES = { |
| | | "吉州区", "青原区", "吉安县", "吉水县", "峡江县", "新干县", "永丰县", "泰和县", "遂川县", "万安县" |
| | | }; |
| | | |
| | | @Override |
| | | public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | // 工作表创建前的操作,暂时不需要 |
| | | } |
| | | |
| | | @Override |
| | | public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) { |
| | | Workbook workbook = writeWorkbookHolder.getWorkbook(); |
| | | Sheet sheet = writeSheetHolder.getSheet(); |
| | | |
| | | // 为区域列添加下拉选择 |
| | | // 假设区域列是第3列(索引为1),从第2行开始(索引为1) |
| | | addRegionValidation(workbook, sheet, 1, 1, 1000); |
| | | } |
| | | |
| | | /** |
| | | * 为区域列添加数据验证,设置下拉选择 |
| | | * |
| | | * @param workbook 工作簿 |
| | | * @param sheet 工作表 |
| | | * @param column 列索引 |
| | | * @param startRow 开始行索引 |
| | | * @param endRow 结束行索引 |
| | | */ |
| | | private void addRegionValidation(Workbook workbook, Sheet sheet, int column, int startRow, int endRow) { |
| | | // 创建数据验证助手 |
| | | DataValidationHelper helper = sheet.getDataValidationHelper(); |
| | | |
| | | // 创建下拉列表约束 |
| | | DataValidationConstraint constraint = helper.createExplicitListConstraint(REGION_NAMES); |
| | | |
| | | // 创建数据验证区域 |
| | | CellRangeAddressList addressList = new CellRangeAddressList(startRow, endRow, column, column); |
| | | |
| | | // 创建数据验证 |
| | | DataValidation validation = helper.createValidation(constraint, addressList); |
| | | |
| | | // 设置验证错误提示 |
| | | validation.setErrorStyle(DataValidation.ErrorStyle.STOP); |
| | | validation.setShowErrorBox(true); |
| | | validation.setSuppressDropDownArrow(true); |
| | | validation.createErrorBox("输入错误", "请从下拉列表中选择区域名称"); |
| | | |
| | | // 添加数据验证到工作表 |
| | | sheet.addValidationData(validation); |
| | | } |
| | | } |