cuilei
2025-06-20 a84ca213053bb61486f37539efac5a1f500e246f
设备管理-设备采购计划及附件
已添加15个文件
1101 ■■■■■ 文件已修改
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/EquipmentPurchasePlanStatusEnum.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/ExcelUtils.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentPurchasePlanController.java 414 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamPurchasePlanAttachmentController.java 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentPurchasePlan.java 132 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamPurchasePlanAttachment.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentPurchasePlanMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamPurchasePlanAttachmentMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentPurchasePlanMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamPurchasePlanAttachmentMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamPurchasePlanAttachmentRequest.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentPurchasePlanService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamPurchasePlanAttachmentService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentPurchasePlanServiceImpl.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamPurchasePlanAttachmentServiceImpl.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/EquipmentPurchasePlanStatusEnum.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package org.jeecg.modules.eam.constant;
import lombok.Getter;
/**
 * è®¾å¤‡é‡‡è´­è®¡åˆ’状态
 */
@Getter
public enum EquipmentPurchasePlanStatusEnum {
    NEWLY("新建"),//新建
    PENDING_AUDIT("待审核"),//待审核
    COMPLETED("已完成"), //已完成
    REJECT("驳回"); //驳回
    private final String zhName;
    EquipmentPurchasePlanStatusEnum(String zhName) {
        this.zhName = zhName;
    }
    /**
     * æ ¹æ®ä¸­æ–‡åèŽ·å–æžšä¸¾
     */
    public static EquipmentPurchasePlanStatusEnum fromZhName(String zhName) {
        for (EquipmentPurchasePlanStatusEnum e : values()) {
            if (e.getZhName().equals(zhName)) {
                return e;
            }
        }
        return null;
    }
}
lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/ExcelUtils.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package org.jeecg.modules.eam.util;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import java.text.SimpleDateFormat;
public class ExcelUtils {
    // è¾…助方法:根据单元格类型安全地获取字符串值
    public static String getCellValueAsString(Cell cell) {
        if (cell == null) {
            return null;
        }
        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    // å¦‚果是日期格式,返回日期字符串
                    return new SimpleDateFormat("yyyy-MM-dd").format(cell.getDateCellValue());
                } else {
                    // å¦åˆ™è¿”回数值的字符串形式
                    return String.valueOf(cell.getNumericCellValue());
                }
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                try {
                    return String.valueOf(cell.getNumericCellValue()); // å°è¯•解析公式结果
                } catch (Exception e) {
                    return String.valueOf(cell.getStringCellValue()); // å¦‚果公式结果为字符串
                }
            default:
                return "";
        }
    }
    // åˆ¤æ–­æŸä¸€è¡Œæ˜¯å¦å…¨ä¸ºç©º(有效数据行判断)
    public static boolean isRowEmpty(Row row) {
        if (row == null) return true;
        for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
            Cell cell = row.getCell(c);
            if (cell != null && cell.getCellType() != CellType.BLANK) {
                return false;
            }
        }
        return true;
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentPurchasePlanController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,414 @@
package org.jeecg.modules.eam.controller;
import java.io.File;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.PmsUtil;
import org.jeecg.common.util.StrUtils;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.constant.EquipmentPurchasePlanStatusEnum;
import org.jeecg.modules.eam.entity.EamEquipmentPurchasePlan;
import org.jeecg.modules.eam.service.IEamEquipmentPurchasePlanService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.eam.util.ExcelUtils;
import org.jeecg.modules.system.entity.MdcProduction;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.IMdcProductionService;
import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
import org.jeecg.modules.system.service.ISysUserService;
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.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
 /**
 * @Description: eam_equipment_purchase_plan
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Api(tags="eam_equipment_purchase_plan")
@RestController
@RequestMapping("/eam/eamEquipmentPurchasePlan")
@Slf4j
public class EamEquipmentPurchasePlanController extends JeecgController<EamEquipmentPurchasePlan, IEamEquipmentPurchasePlanService> {
    @Autowired
    private IEamEquipmentPurchasePlanService eamEquipmentPurchasePlanService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private IMdcProductionService mdcProductionService;
    @Autowired
    private ISysBusinessCodeRuleService sysBusinessCodeRuleService;
    /**
     * åˆ†é¡µåˆ—表查询
     *
     * @param eamEquipmentPurchasePlan
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "eam_equipment_purchase_plan-分页列表查询")
    @ApiOperation(value="eam_equipment_purchase_plan-分页列表查询", notes="eam_equipment_purchase_plan-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<EamEquipmentPurchasePlan>> queryPageList(EamEquipmentPurchasePlan eamEquipmentPurchasePlan,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<EamEquipmentPurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(eamEquipmentPurchasePlan, req.getParameterMap());
        Page<EamEquipmentPurchasePlan> page = new Page<EamEquipmentPurchasePlan>(pageNo, pageSize);
        IPage<EamEquipmentPurchasePlan> pageList = eamEquipmentPurchasePlanService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     *   æ·»åŠ 
     *
     * @param eamEquipmentPurchasePlan
     * @return
     */
    @AutoLog(value = "eam_equipment_purchase_plan-添加")
    @ApiOperation(value="eam_equipment_purchase_plan-添加", notes="eam_equipment_purchase_plan-添加")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody EamEquipmentPurchasePlan eamEquipmentPurchasePlan) {
        eamEquipmentPurchasePlanService.savePurchasePlan(eamEquipmentPurchasePlan);
        return Result.OK("添加成功!");
    }
    /**
     *  ç¼–辑
     *
     * @param eamEquipmentPurchasePlan
     * @return
     */
    @AutoLog(value = "eam_equipment_purchase_plan-编辑")
    @ApiOperation(value="eam_equipment_purchase_plan-编辑", notes="eam_equipment_purchase_plan-编辑")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody EamEquipmentPurchasePlan eamEquipmentPurchasePlan) {
        eamEquipmentPurchasePlanService.updateById(eamEquipmentPurchasePlan);
        return Result.OK("编辑成功!");
    }
    @AutoLog(value = "eam_equipment_purchase_plan-提交")
    @ApiOperation(value="eam_equipment_purchase_plan-提交", notes = "eam_equipment_purchase_plan-提交")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:submit")
    @GetMapping(value = "/submit")
    public Result<String> submit(@RequestParam("id") String id) {
        EamEquipmentPurchasePlan plan = eamEquipmentPurchasePlanService.getById(id);
        if (Objects.isNull(plan) || !EquipmentPurchasePlanStatusEnum.NEWLY.name().equals(plan.getPlanStatus())) {
            return Result.error("采购计划不存在/计划已提交!");
        }
        plan.setPlanStatus(EquipmentPurchasePlanStatusEnum.PENDING_AUDIT.name());
        eamEquipmentPurchasePlanService.updateById(plan);
        return Result.OK("提交成功!");
    }
    @AutoLog(value = "eam_equipment_purchase_plan-审核")
    @ApiOperation(value="eam_equipment_purchase_plan-审核", notes = "eam_equipment_purchase_plan-审核")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:audit")
    @RequestMapping(value = "/audit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> audit(@RequestBody EamEquipmentPurchasePlan request) {
        EamEquipmentPurchasePlan plan = eamEquipmentPurchasePlanService.getById(request.getId());
        if (Objects.isNull(plan)) {
            return Result.error("采购计划不存在!");
        }
        if (!EquipmentPurchasePlanStatusEnum.PENDING_AUDIT.name().equals(plan.getPlanStatus())) {
            return Result.error("计划未提交或已审核!");
        }
        if (EquipmentPurchasePlanStatusEnum.COMPLETED.name().equals(request.getPlanStatus())) {
            plan.setPlanStatus(EquipmentPurchasePlanStatusEnum.COMPLETED.name());
        }
        if (EquipmentPurchasePlanStatusEnum.REJECT.name().equals(request.getPlanStatus())) {
            //如果驳回,状态改为新建,重新提交审核
            plan.setPlanStatus(EquipmentPurchasePlanStatusEnum.NEWLY.name());
        }
        eamEquipmentPurchasePlanService.updateById(plan);
        return Result.OK("审核成功!");
    }
    /**
     *   é€šè¿‡id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "eam_equipment_purchase_plan-通过id删除")
    @ApiOperation(value="eam_equipment_purchase_plan-通过id删除", notes="eam_equipment_purchase_plan-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        eamEquipmentPurchasePlanService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     *  æ‰¹é‡åˆ é™¤
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "eam_equipment_purchase_plan-批量删除")
    @ApiOperation(value="eam_equipment_purchase_plan-批量删除", notes="eam_equipment_purchase_plan-批量删除")
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.eamEquipmentPurchasePlanService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
    /**
     * é€šè¿‡id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "eam_equipment_purchase_plan-通过id查询")
    @ApiOperation(value="eam_equipment_purchase_plan-通过id查询", notes="eam_equipment_purchase_plan-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<EamEquipmentPurchasePlan> queryById(@RequestParam(name="id",required=true) String id) {
        EamEquipmentPurchasePlan eamEquipmentPurchasePlan = eamEquipmentPurchasePlanService.getById(id);
        if(eamEquipmentPurchasePlan==null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(eamEquipmentPurchasePlan);
    }
    /**
    * å¯¼å‡ºexcel
    *
    * @param request
    * @param eamEquipmentPurchasePlan
    */
    //@RequiresPermissions("org.jeecg.modules:eam_equipment_purchase_plan:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, EamEquipmentPurchasePlan eamEquipmentPurchasePlan) {
        return super.exportXls(request, eamEquipmentPurchasePlan, EamEquipmentPurchasePlan.class, "设备采购计划");
    }
    /**
      * é€šè¿‡excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("eam_equipment_purchase_plan:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
        int successLines = 0,dataLines = 0;
        List<String> errorMessage = CollectionUtil.newArrayList();
        List<EamEquipmentPurchasePlan> importList = CollectionUtil.newArrayList();
        try {
            for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
                // èŽ·å–ä¸Šä¼ æ–‡ä»¶å¯¹è±¡
                MultipartFile file = entity.getValue();
                InputStream inputStream = file.getInputStream();
                Workbook workbook = WorkbookFactory.create(inputStream);
                Sheet sheet = workbook.getSheetAt(0);
                for (Row row : sheet) {
                    EamEquipmentPurchasePlan plan = new EamEquipmentPurchasePlan();
                    int rowNum = row.getRowNum();
                    int currentRowNum  = rowNum + 1;
                    if (rowNum < 3 || ExcelUtils.isRowEmpty(row)) {
                        //跳过表头和空行
                        continue;
                    }
                    dataLines++;
                    Cell cell0 = row.getCell(0);
                    if (cell0 == null || cell0.getCellType() == CellType.BLANK) {
                        errorMessage.add("第" + currentRowNum + "行采购计划名称为空,无法导入");
                        continue;
                    } else {
                        plan.setPlanName(ExcelUtils.getCellValueAsString(cell0));
                    }
                    Cell cell1 = row.getCell(1);
                    if (cell1 == null || cell1.getCellType() == CellType.BLANK) {
                        //如果计划状态为空,默认给 æ–°å»º çŠ¶æ€
                        plan.setPlanStatus(EquipmentPurchasePlanStatusEnum.NEWLY.name());
                    } else {
                        String statusZh = ExcelUtils.getCellValueAsString(cell1).trim();
                        EquipmentPurchasePlanStatusEnum planStatusEnum = EquipmentPurchasePlanStatusEnum.fromZhName(statusZh);
                        if (Objects.isNull(planStatusEnum)) {
                            errorMessage.add("第 " + currentRowNum + " è¡Œè®¡åˆ’状态不合法,无法导入,请使用 [新建, å¾…审核, å·²å®Œæˆ] ä¸­çš„一个值");
                            continue;
                        }
                        plan.setPlanStatus(planStatusEnum.name());
                    }
                    Cell cell2 = row.getCell(2);
                    if (cell2 == null || cell2.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œåž‹å·ä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        plan.setEquipmentModel(ExcelUtils.getCellValueAsString(cell2));
                    }
                    Cell cell3 = row.getCell(3);
                    if (cell3 == null || cell3.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œé‡‡è´­æ•°é‡ä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        plan.setPurchaseNumber(Integer.valueOf(ExcelUtils.getCellValueAsString(cell3)));
                    }
                    Cell cell4 = row.getCell(4);
                    if (cell4 == null || cell4.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œé¢„计单价为空,无法导入");
                        continue;
                    } else {
                        plan.setEstimatedUnitPrice(new BigDecimal(ExcelUtils.getCellValueAsString(cell4)));
                    }
                    Cell cell5 = row.getCell(5);
                    if (cell5 == null || cell5.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œæ€»ä»·ä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        plan.setTotalPrice(new BigDecimal(ExcelUtils.getCellValueAsString(cell5)));
                    }
                    Cell cell6 = row.getCell(6);
                    if (cell6 == null || cell6.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡ŒåˆåŒæ€»é‡‘额为空,无法导入");
                        continue;
                    } else {
                        plan.setOverallContractAmount(new BigDecimal(ExcelUtils.getCellValueAsString(cell6)));
                    }
                    Cell cell7 = row.getCell(7);
                    if (cell7 == null || cell7.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œç®¡ç†åˆ†ç±»ä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        plan.setEquipmentImportance(ExcelUtils.getCellValueAsString(cell7));
                    }
                    Cell cell8 = row.getCell(8);
                    if (cell8 == null || cell8.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œç”³è¯·äººä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        String username = ExcelUtils.getCellValueAsString(cell8);
                        SysUser sysUser = sysUserService.getUserByName(username);
                        if (sysUser == null) {
                            errorMessage.add("第 " + currentRowNum + " è¡Œç”³è¯·äººä¸å­˜åœ¨ï¼Œæ— æ³•导入");
                            continue;
                        }
                        plan.setPlanCategory(username);
                    }
                    Cell cell9 = row.getCell(9);
                    if (cell9 == null || cell9.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œç”³è¯·è½¦é—´ä¸ºç©ºï¼Œæ— æ³•导入");
                        continue;
                    } else {
                        String productionName = ExcelUtils.getCellValueAsString(cell9);
                        boolean present = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>()
                                .eq(MdcProduction::getProductionName, productionName)
                                .eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0))
                                .stream().findAny().isPresent();
                        if (!present) {
                            errorMessage.add("第 " + currentRowNum + " è¡Œç”³è¯·è½¦é—´ä¸å­˜åœ¨ï¼Œæ— æ³•导入");
                            continue;
                        }
                        plan.setApplicantProduction(productionName);
                    }
                    Cell cell10 = row.getCell(10);
                    if (cell10 == null || cell10.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œè®¡åˆ’开始日期为空,无法导入");
                        continue;
                    } else {
                        String planStartDateStr = ExcelUtils.getCellValueAsString(cell10);
                        try {
                            Date date = DateUtils.parseDate(planStartDateStr, "yyyy/MM/dd HH", "yyyy/MM/dd", "yyyy-MM-dd HH", "yyyy-MM-dd");
                            plan.setPlanStartDate(date);
                        } catch (ParseException e) {
                            errorMessage.add("第 " + currentRowNum + " è¡Œè®¡åˆ’开始日期格式错误,无法导入,请使用 yyyy-MM-dd æ ¼å¼");
                            continue;
                        }
                    }
                    Cell cell11 = row.getCell(11);
                    if (cell11 == null || cell11.getCellType() == CellType.BLANK) {
                        errorMessage.add("第 " + currentRowNum + " è¡Œè®¡åˆ’完成时间为空,无法导入");
                        continue;
                    } else {
                        String planEndDateStr = ExcelUtils.getCellValueAsString(cell11);
                        try {
                            Date date = DateUtils.parseDate(planEndDateStr, "yyyy/MM/dd HH", "yyyy/MM/dd", "yyyy-MM-dd HH", "yyyy-MM-dd");
                            plan.setPlanEndDate(date);
                        } catch (ParseException e) {
                            errorMessage.add("第 " + currentRowNum + " è¡Œè®¡åˆ’完成日期格式错误,无法导入,请使用 yyyy-MM-dd æ ¼å¼");
                            continue;
                        }
                    }
                    Cell cell12 = row.getCell(12);
                    plan.setPlanDescription(ExcelUtils.getCellValueAsString(cell12));
                    Cell cell13 = row.getCell(13);
                    plan.setRelatedDeparts(ExcelUtils.getCellValueAsString(cell13));
                    Cell cell14 = row.getCell(14);
                    plan.setRemark(ExcelUtils.getCellValueAsString(cell14));
                    plan.setPlanCode(sysBusinessCodeRuleService.generateBusinessCodeSeq("EquipmentPurchasePlanRule"));
                    plan.setDelFlag(CommonConstant.DEL_FLAG_0);
                    importList.add(plan);
                    successLines++;
                }
            }
            eamEquipmentPurchasePlanService.saveBatch(importList);
            if (successLines == dataLines) {
                return Result.OK("共" + dataLines + "行数据全部导入成功!");
            } else {
                JSONObject result = new JSONObject(5);
                result.put("successCount", successLines);
                result.put("msg", "总上传行数:" + dataLines + ",成功导入行数:" + successLines);
                result.put("errorMsg", errorMessage);
                String fileUrl = PmsUtil.saveErrorMsgByList(errorMessage, "userImportExcelErrorLog");
                int lastIndex = fileUrl.lastIndexOf(File.separator);
                String fileName = fileUrl.substring(lastIndex + 1);
                result.put("fileUrl", "/sys/common/static/" + fileUrl);
                result.put("fileName", fileName);
                Result res = Result.ok(result);
                res.setCode(201);
                res.setMessage("文件导入成功,但有错误。");
                return res;
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamPurchasePlanAttachmentController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,182 @@
package org.jeecg.modules.eam.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.eam.entity.EamPurchasePlanAttachment;
import org.jeecg.modules.eam.request.EamPurchasePlanAttachmentRequest;
import org.jeecg.modules.eam.service.IEamPurchasePlanAttachmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
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.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
 /**
 * @Description: eam_purchase_plan_attachment
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Api(tags="eam_purchase_plan_attachment")
@RestController
@RequestMapping("/eam/eamPurchasePlanAttachment")
@Slf4j
public class EamPurchasePlanAttachmentController extends JeecgController<EamPurchasePlanAttachment, IEamPurchasePlanAttachmentService> {
    @Autowired
    private IEamPurchasePlanAttachmentService eamPurchasePlanAttachmentService;
    /**
     * åˆ†é¡µåˆ—表查询
     *
     * @param eamPurchasePlanAttachment
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "eam_purchase_plan_attachment-分页列表查询")
    @ApiOperation(value="eam_purchase_plan_attachment-分页列表查询", notes="eam_purchase_plan_attachment-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<EamPurchasePlanAttachment>> queryPageList(EamPurchasePlanAttachment eamPurchasePlanAttachment,
                                   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                   HttpServletRequest req) {
        QueryWrapper<EamPurchasePlanAttachment> queryWrapper = QueryGenerator.initQueryWrapper(eamPurchasePlanAttachment, req.getParameterMap());
        Page<EamPurchasePlanAttachment> page = new Page<EamPurchasePlanAttachment>(pageNo, pageSize);
        IPage<EamPurchasePlanAttachment> pageList = eamPurchasePlanAttachmentService.page(page, queryWrapper);
        return Result.OK(pageList);
    }
    /**
     *   æ·»åŠ 
     *
     * @param request
     * @return
     */
    @AutoLog(value = "eam_purchase_plan_attachment-添加")
    @ApiOperation(value="eam_purchase_plan_attachment-添加", notes="eam_purchase_plan_attachment-添加")
    //@RequiresPermissions("org.jeecg.modules:eam_purchase_plan_attachment:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody EamPurchasePlanAttachmentRequest request) {
        eamPurchasePlanAttachmentService.saveAttachmentList(request);
        return Result.OK("添加成功!");
    }
    /**
     *  ç¼–辑
     *
     * @param eamPurchasePlanAttachment
     * @return
     */
    @AutoLog(value = "eam_purchase_plan_attachment-编辑")
    @ApiOperation(value="eam_purchase_plan_attachment-编辑", notes="eam_purchase_plan_attachment-编辑")
    //@RequiresPermissions("org.jeecg.modules:eam_purchase_plan_attachment:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody EamPurchasePlanAttachment eamPurchasePlanAttachment) {
        eamPurchasePlanAttachmentService.updateById(eamPurchasePlanAttachment);
        return Result.OK("编辑成功!");
    }
    /**
     *   é€šè¿‡id删除
     *
     * @param id
     * @return
     */
    @AutoLog(value = "eam_purchase_plan_attachment-通过id删除")
    @ApiOperation(value="eam_purchase_plan_attachment-通过id删除", notes="eam_purchase_plan_attachment-通过id删除")
    //@RequiresPermissions("org.jeecg.modules:eam_purchase_plan_attachment:delete")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        eamPurchasePlanAttachmentService.removeById(id);
        return Result.OK("删除成功!");
    }
    /**
     *  æ‰¹é‡åˆ é™¤
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "eam_purchase_plan_attachment-批量删除")
    @ApiOperation(value="eam_purchase_plan_attachment-批量删除", notes="eam_purchase_plan_attachment-批量删除")
    //@RequiresPermissions("org.jeecg.modules:eam_purchase_plan_attachment:deleteBatch")
    @DeleteMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
        this.eamPurchasePlanAttachmentService.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }
    /**
     * é€šè¿‡id查询
     *
     * @param id
     * @return
     */
    //@AutoLog(value = "eam_purchase_plan_attachment-通过id查询")
    @ApiOperation(value="eam_purchase_plan_attachment-通过id查询", notes="eam_purchase_plan_attachment-通过id查询")
    @GetMapping(value = "/queryById")
    public Result<EamPurchasePlanAttachment> queryById(@RequestParam(name="id",required=true) String id) {
        EamPurchasePlanAttachment eamPurchasePlanAttachment = eamPurchasePlanAttachmentService.getById(id);
        if(eamPurchasePlanAttachment==null) {
            return Result.error("未找到对应数据");
        }
        return Result.OK(eamPurchasePlanAttachment);
    }
    /**
    * å¯¼å‡ºexcel
    *
    * @param request
    * @param eamPurchasePlanAttachment
    */
    //@RequiresPermissions("org.jeecg.modules:eam_purchase_plan_attachment:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, EamPurchasePlanAttachment eamPurchasePlanAttachment) {
        return super.exportXls(request, eamPurchasePlanAttachment, EamPurchasePlanAttachment.class, "eam_purchase_plan_attachment");
    }
    /**
      * é€šè¿‡excel导入数据
    *
    * @param request
    * @param response
    * @return
    */
    //@RequiresPermissions("eam_purchase_plan_attachment:importExcel")
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, EamPurchasePlanAttachment.class);
    }
    @GetMapping("/downloadFile")
    public void downloadFile(@RequestParam("id") String id, HttpServletResponse response) {
        eamPurchasePlanAttachmentService.downloadFile(response, eamPurchasePlanAttachmentService.getById(id));
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentPurchasePlan.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,132 @@
package org.jeecg.modules.eam.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
 * @Description: eam_equipment_purchase_plan
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Data
@TableName("eam_equipment_purchase_plan")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="eam_equipment_purchase_plan对象", description="eam_equipment_purchase_plan")
public class EamEquipmentPurchasePlan implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**采购计划名称*/
    @Excel(name = "采购计划名称", width = 20, orderNum = "2")
    @ApiModelProperty(value = "采购计划名称")
    private String planName;
    /**采购计划编码*/
    @Excel(name = "采购计划编码", width = 20, orderNum = "1")
    @ApiModelProperty(value = "采购计划编码")
    private String planCode;
    /**计划状态*/
    @Dict(dicCode = "equipment_purchase_plan_status")
    @Excel(name = "计划状态", width = 20, dicCode = "equipment_purchase_plan_status", orderNum = "3")
    @ApiModelProperty(value = "计划状态")
    private String planStatus;
    /**型号*/
    @Excel(name = "型号", width = 15, orderNum = "4")
    @ApiModelProperty(value = "型号")
    private String equipmentModel;
    /**采购数量*/
    @Excel(name = "采购数量", width = 15, orderNum = "5")
    @ApiModelProperty(value = "采购数量")
    private Integer purchaseNumber;
    /**预计单价*/
    @Excel(name = "预计单价", width = 15, orderNum = "6")
    @ApiModelProperty(value = "预计单价")
    private BigDecimal estimatedUnitPrice;
    /**总价*/
    @Excel(name = "总价", width = 15, orderNum = "7")
    @ApiModelProperty(value = "总价")
    private BigDecimal totalPrice;
    /**合同总金额*/
    @Excel(name = "合同总金额", width = 15, orderNum = "8")
    @ApiModelProperty(value = "合同总金额")
    private BigDecimal overallContractAmount;
    /**ABC标识(管理分类)*/
    @Excel(name = "管理分类", width = 10, orderNum = "9")
    @ApiModelProperty(value = "ABC标识(管理分类)")
    private String equipmentImportance;
    /**计划类别*/
    @ApiModelProperty(value = "计划类别")
    private String planCategory;
    /**申请人*/
    @Excel(name = "申请人", width = 15, orderNum = "10")
    @ApiModelProperty(value = "申请人")
    private String applicant;
    /**申请车间*/
    @Excel(name = "申请车间", width = 15, dictTable = "mdc_production", dicText = "production_name", dicCode = "id", orderNum = "11")
    @ApiModelProperty(value = "申请车间")
    @Dict(dictTable = "mdc_production", dicText = "production_name", dicCode = "id")
    private String applicantProduction;
    /**计划开始日期*/
    @Excel(name = "计划开始日期", width = 15, format = "yyyy/MM/dd HH", orderNum = "12")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "计划开始日期")
    private Date planStartDate;
    /**计划完成日期*/
    @Excel(name = "计划完成日期", width = 15, format = "yyyy/MM/dd HH", orderNum = "13")
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "计划完成日期")
    private Date planEndDate;
    /**计划描述*/
    @Excel(name = "计划描述", width = 50, orderNum = "14")
    @ApiModelProperty(value = "计划描述")
    private String planDescription;
    /**实施及协助部门*/
    @Excel(name = "实施及协助部门", width = 15, orderNum = "15")
    @ApiModelProperty(value = "实施及协助部门")
    private String relatedDeparts;
    /**备注*/
    @Excel(name = "备注", width = 50, orderNum = "16")
    @ApiModelProperty(value = "备注")
    private String remark;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**更新时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    /**删除标记*/
    @ApiModelProperty(value = "删除标记")
    @TableLogic
    private Integer delFlag;
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamPurchasePlanAttachment.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,83 @@
package org.jeecg.modules.eam.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
 * @Description: eam_purchase_plan_attachment
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Data
@TableName("eam_purchase_plan_attachment")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="eam_purchase_plan_attachment对象", description="eam_purchase_plan_attachment")
public class EamPurchasePlanAttachment implements Serializable {
    private static final long serialVersionUID = 1L;
    /**主键*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**计划ID*/
    @Excel(name = "计划ID", width = 15)
    @ApiModelProperty(value = "计划ID")
    private String planId;
    /**文件加密名*/
    @Excel(name = "文件加密名", width = 15)
    @ApiModelProperty(value = "文件加密名")
    private String fileEncodeName;
    /**文件名称*/
    @Excel(name = "文件名称", width = 15)
    @ApiModelProperty(value = "文件名称")
    private String fileName;
    /**文件保存路径*/
    @Excel(name = "文件保存路径", width = 15)
    @ApiModelProperty(value = "文件保存路径")
    private String filePath;
    /**文件后缀名*/
    @Excel(name = "文件后缀名", width = 15)
    @ApiModelProperty(value = "文件后缀名")
    private String fileSuffix;
    /**文件大小*/
    @Excel(name = "文件大小", width = 15)
    @ApiModelProperty(value = "文件大小")
    private Long fileSize;
    /**描述*/
    @Excel(name = "描述", width = 15)
    @ApiModelProperty(value = "描述")
    private String description;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**更新时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH")
    @DateTimeFormat(pattern="yyyy-MM-dd HH")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentPurchasePlanMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.eam.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.eam.entity.EamEquipmentPurchasePlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * @Description: eam_equipment_purchase_plan
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
public interface EamEquipmentPurchasePlanMapper extends BaseMapper<EamEquipmentPurchasePlan> {
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamPurchasePlanAttachmentMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package org.jeecg.modules.eam.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.eam.entity.EamPurchasePlanAttachment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
 * @Description: eam_purchase_plan_attachment
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
public interface EamPurchasePlanAttachmentMapper extends BaseMapper<EamPurchasePlanAttachment> {
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentPurchasePlanMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
<?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.jeecg.modules.eam.mapper.EamEquipmentPurchasePlanMapper">
</mapper>
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamPurchasePlanAttachmentMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,5 @@
<?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.jeecg.modules.eam.mapper.EamPurchasePlanAttachmentMapper">
</mapper>
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamPurchasePlanAttachmentRequest.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
package org.jeecg.modules.eam.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.api.vo.FileUploadResult;
import java.io.Serializable;
import java.util.List;
/**
 * @Description: è®¾å¤‡é™„件管理
 * @Author: jeecg-boot
 * @Date:   2025-03-17
 * @Version: V1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="请求对象", description="设备采购计划附件管理")
public class EamPurchasePlanAttachmentRequest implements Serializable {
    /**描述*/
    @ApiModelProperty(value = "描述")
    private String description;
    /**计划ID*/
    @ApiModelProperty(value = "计划ID")
    private String planId;
    /**上传文件对系*/
    @ApiModelProperty(value = "上传文件对系")
    private List<FileUploadResult> fileList;
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentPurchasePlanService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package org.jeecg.modules.eam.service;
import org.jeecg.modules.eam.entity.EamEquipmentPurchasePlan;
import com.baomidou.mybatisplus.extension.service.IService;
/**
 * @Description: eam_equipment_purchase_plan
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
public interface IEamEquipmentPurchasePlanService extends IService<EamEquipmentPurchasePlan> {
    void savePurchasePlan(EamEquipmentPurchasePlan eamEquipmentPurchasePlan);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamPurchasePlanAttachmentService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package org.jeecg.modules.eam.service;
import org.jeecg.modules.eam.entity.EamPurchasePlanAttachment;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.eam.request.EamPurchasePlanAttachmentRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * @Description: eam_purchase_plan_attachment
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
public interface IEamPurchasePlanAttachmentService extends IService<EamPurchasePlanAttachment> {
    void saveAttachmentList(EamPurchasePlanAttachmentRequest request);
    void downloadFile(HttpServletResponse response, EamPurchasePlanAttachment byId);
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentPurchasePlanServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,33 @@
package org.jeecg.modules.eam.service.impl;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.eam.constant.EquipmentPurchasePlanStatusEnum;
import org.jeecg.modules.eam.entity.EamEquipmentPurchasePlan;
import org.jeecg.modules.eam.mapper.EamEquipmentPurchasePlanMapper;
import org.jeecg.modules.eam.service.IEamEquipmentPurchasePlanService;
import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
 * @Description: eam_equipment_purchase_plan
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Service
public class EamEquipmentPurchasePlanServiceImpl extends ServiceImpl<EamEquipmentPurchasePlanMapper, EamEquipmentPurchasePlan> implements IEamEquipmentPurchasePlanService {
    @Autowired
    private ISysBusinessCodeRuleService sysBusinessCodeRuleService;
    @Override
    public void savePurchasePlan(EamEquipmentPurchasePlan eamEquipmentPurchasePlan) {
        eamEquipmentPurchasePlan.setPlanCode(sysBusinessCodeRuleService.generateBusinessCodeSeq("EquipmentPurchasePlanRule"));
        eamEquipmentPurchasePlan.setPlanStatus(EquipmentPurchasePlanStatusEnum.NEWLY.name());
        eamEquipmentPurchasePlan.setDelFlag(CommonConstant.DEL_FLAG_0);
        save(eamEquipmentPurchasePlan);
    }
}
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamPurchasePlanAttachmentServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
package org.jeecg.modules.eam.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import org.jeecg.common.util.FileUtil;
import org.jeecg.modules.eam.entity.EamEquipmentPurchasePlan;
import org.jeecg.modules.eam.entity.EamPurchasePlanAttachment;
import org.jeecg.modules.eam.mapper.EamPurchasePlanAttachmentMapper;
import org.jeecg.modules.eam.request.EamPurchasePlanAttachmentRequest;
import org.jeecg.modules.eam.service.IEamEquipmentPurchasePlanService;
import org.jeecg.modules.eam.service.IEamPurchasePlanAttachmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Objects;
/**
 * @Description: eam_purchase_plan_attachment
 * @Author: jeecg-boot
 * @Date:   2025-06-18
 * @Version: V1.0
 */
@Service
public class EamPurchasePlanAttachmentServiceImpl extends ServiceImpl<EamPurchasePlanAttachmentMapper, EamPurchasePlanAttachment> implements IEamPurchasePlanAttachmentService {
    @Autowired
    private IEamEquipmentPurchasePlanService eamEquipmentPurchasePlanService;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveAttachmentList(EamPurchasePlanAttachmentRequest request) {
        if (Objects.isNull(request) || CollectionUtil.isEmpty(request.getFileList())) {
            throw new RuntimeException("请选择文档再上传!");
        }
        EamEquipmentPurchasePlan plan = eamEquipmentPurchasePlanService.getById(request.getPlanId());
        if (Objects.isNull(plan)) {
            throw new RuntimeException("请先选择设备采购计划再上传文档!");
        }
        ArrayList<EamPurchasePlanAttachment> attachmentList = CollectionUtil.newArrayList();
        request.getFileList().forEach(fileUploadResult -> {
            EamPurchasePlanAttachment attachment = new EamPurchasePlanAttachment()
                    .setPlanId(request.getPlanId())
                    .setFilePath(fileUploadResult.getFilePath())
                    .setFileName(fileUploadResult.getFileName())
                    .setFileEncodeName(fileUploadResult.getFileEncodeName())
                    .setFileSize(fileUploadResult.getFileSize())
                    .setFileSuffix(fileUploadResult.getFileSuffix())
                    .setDescription(request.getDescription());
            attachmentList.add(attachment);
        });
        saveBatch(attachmentList);
    }
    @Override
    public void downloadFile(HttpServletResponse response, EamPurchasePlanAttachment entity) {
        FileUtil.downLoadFile(response, entity.getFilePath(), entity.getFileName());
    }
}