From e096d728a44eb0c92a107dff8711092fc69d3026 Mon Sep 17 00:00:00 2001 From: Lius <Lius2225@163.com> Date: 星期五, 20 六月 2025 16:04:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- db/数据库产品化设计.pdma.json | 24 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderExpiredJob.java | 96 +++ lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/ExcelUtils.java | 51 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentPurchasePlanMapper.xml | 5 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentPurchasePlanController.java | 414 +++++++++++++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentPurchasePlan.java | 132 ++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamPurchasePlanAttachmentServiceImpl.java | 62 ++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentPurchasePlanMapper.java | 17 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentPurchasePlanService.java | 15 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamPurchasePlanAttachmentMapper.java | 17 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamPurchasePlanAttachmentRequest.java | 33 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderExpiredJob.java | 96 +++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java | 139 +++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamPurchasePlanAttachmentService.java | 20 lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentPurchasePlanServiceImpl.java | 33 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderGenerateJob.java | 154 +++++ lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/EquipmentPurchasePlanStatusEnum.java | 32 + lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamPurchasePlanAttachmentController.java | 182 ++++++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamPurchasePlanAttachment.java | 83 +++ lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamPurchasePlanAttachmentMapper.xml | 5 20 files changed, 1,607 insertions(+), 3 deletions(-) diff --git "a/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json" "b/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json" index 361bb90..f1debbb 100644 --- "a/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json" +++ "b/db/\346\225\260\346\215\256\345\272\223\344\272\247\345\223\201\345\214\226\350\256\276\350\256\241.pdma.json" @@ -2,9 +2,9 @@ "name": "鏁版嵁搴撲骇鍝佸寲璁捐", "describe": "鎻忚堪璁惧绠$悊鏁版嵁搴撹璁℃枃妗�", "avatar": "", - "version": "4.9.2", + "version": "4.9.4", "createdTime": "2025-3-10 16:38:19", - "updatedTime": "2025-6-9 10:59:32", + "updatedTime": "2025-6-20 14:38:56", "dbConns": [], "profile": { "default": { @@ -632,7 +632,7 @@ "#DDE5FF" ], "DDLToggleCase": "L", - "menuWidth": "420px" + "menuWidth": "389px" }, "entities": [ { @@ -11850,6 +11850,24 @@ "baseType": "89D69E81-EA34-42EE-9FA2-93B8BD27E098" }, { + "defKey": "repair_id", + "defName": "缁翠慨ID", + "comment": "", + "type": "", + "len": "", + "scale": "", + "primaryKey": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "", + "hideInGraph": false, + "refDict": "", + "baseType": "FC9790A7-36B8-4A48-8F9A-BC1042BCFE64", + "extProps": {}, + "domain": "16120F75-6AA7-4483-868D-F07F511BB081", + "id": "68C87AA2-0619-4565-8B30-1C4C8D27CD7C" + }, + { "defKey": "equipment_id", "defName": "璁惧ID", "comment": "", diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/EquipmentPurchasePlanStatusEnum.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/constant/EquipmentPurchasePlanStatusEnum.java new file mode 100644 index 0000000..66afe5a --- /dev/null +++ b/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; + } +} diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/ExcelUtils.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/util/ExcelUtils.java new file mode 100644 index 0000000..87ce100 --- /dev/null +++ b/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()); // 灏濊瘯瑙f瀽鍏紡缁撴灉 + } 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; + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentPurchasePlanController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamEquipmentPurchasePlanController.java new file mode 100644 index 0000000..a1b62a4 --- /dev/null +++ b/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); + } + } + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamPurchasePlanAttachmentController.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamPurchasePlanAttachmentController.java new file mode 100644 index 0000000..c08412e --- /dev/null +++ b/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)); + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentPurchasePlan.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamEquipmentPurchasePlan.java new file mode 100644 index 0000000..8230968 --- /dev/null +++ b/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; +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamPurchasePlanAttachment.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/entity/EamPurchasePlanAttachment.java new file mode 100644 index 0000000..dc9a391 --- /dev/null +++ b/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; +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderExpiredJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderExpiredJob.java new file mode 100644 index 0000000..8da6f51 --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderExpiredJob.java @@ -0,0 +1,96 @@ +package org.jeecg.modules.eam.job; + +import cn.hutool.core.collection.CollectionUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.eam.constant.SecondMaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum; +import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder; +import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; +import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderService; +import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.Date; +import java.util.List; + +@Component +@Slf4j +public class SecondMaintenanceOrderExpiredJob implements Job { + + @Autowired + private IEamSecondMaintenanceOrderService eamSecondMaintenanceOrderService; + + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private IFlowTaskService flowTaskService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + LocalDate now = LocalDate.now(); + try { + + List<EamSecondMaintenanceOrder> unCompleteOrderList = eamSecondMaintenanceOrderService.lambdaQuery() + .lt(EamSecondMaintenanceOrder::getMaintenanceDate, now.toString()) + .in(EamSecondMaintenanceOrder::getMaintenanceStatus, SecondMaintenanceStatusEnum.WAIT_MAINTENANCE, SecondMaintenanceStatusEnum.UNDER_MAINTENANCE) + .orderByDesc(EamSecondMaintenanceOrder::getMaintenanceDate) + .list(); + + if (CollectionUtil.isEmpty(unCompleteOrderList)) { + //娌℃湁闇�瑕佸鐞嗙殑鏁版嵁 + return; + } + for (EamSecondMaintenanceOrder order : unCompleteOrderList) { + if (SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(order.getMaintenanceStatus())) { + order.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); + } else if (WeekMaintenanceStatusEnum.UNDER_MAINTENANCE.name().equals(order.getMaintenanceStatus())) { + //宸茬粡琚帴鍗� 浣嗘湭鎵ц瀹屾垚 + order.setMaintenanceStatus(SecondMaintenanceStatusEnum.ABOLISH.name()); + //寮哄埗缁撴潫娴佺▼ 鍒犻櫎鐢ㄦ埛鐨勬寰呭姙浠诲姟 + FlowMyBusiness flowMyBusiness = flowMyBusinessService.selectByDataId(order.getId()); + if (flowMyBusiness != null) { + flowTaskService.end(flowMyBusiness.getProcessInstanceId(), "杩囨湡鍒犻櫎"); + } + } + } + eamSecondMaintenanceOrderService.updateBatchById(unCompleteOrderList); + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("浜屼繚杩囨湡鎵ц瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java new file mode 100644 index 0000000..89b126a --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/SecondMaintenanceOrderGenerateJob.java @@ -0,0 +1,139 @@ +package org.jeecg.modules.eam.job; + +import cn.hutool.core.collection.CollectionUtil; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.eam.constant.BusinessCodeConst; +import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum; +import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; +import org.jeecg.modules.eam.entity.*; +import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest; +import org.jeecg.modules.eam.request.EamWeekMaintenanceRequest; +import org.jeecg.modules.eam.service.IEamMaintenanceStandardDetailService; +import org.jeecg.modules.eam.service.IEamMaintenanceStandardService; +import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderService; +import org.jeecg.modules.eam.service.IEamWeekMaintenanceOrderService; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +@Component +@Slf4j +public class SecondMaintenanceOrderGenerateJob implements Job { + + @Autowired + private IEamSecondMaintenanceOrderService eamSecondMaintenanceOrderService; + @Autowired + private IEamMaintenanceStandardService eamMaintenanceStandardService; + @Autowired + private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; + @Autowired + private ISysBusinessCodeRuleService businessCodeRuleService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + /** + * 鑾峰彇 閰嶇疆浜� 浜屼繚鏍囧噯鐨� 淇℃伅 + */ + List<EamMaintenanceStandard> standardList = eamMaintenanceStandardService.queryListByCategory(MaintenanceCategoryEnum.SECOND_MAINTENANCE.name()); + if (CollectionUtil.isEmpty(standardList)) { + log.warn("娌℃湁閰嶇疆浠讳綍浜屼繚鏍囧噯锛屼换鍔$粨鏉�"); + return; + } + //褰撳墠鏃ユ湡 + LocalDate now = LocalDate.now(); + try { + for (EamMaintenanceStandard standard : standardList) { + if (standard.getMaintenancePeriod() == null || standard.getMaintenancePeriod() < 1) { + log.error("浜屼繚鏍囧噯鍛ㄦ湡璁剧疆閿欒锛岃鍏堥厤缃爣鍑嗗懆鏈�, standard:{}", standard); + continue; + } + if (standard.getInitialDate() == null) { + //璁剧疆鍒濆鏃ユ湡涓哄墠涓�澶� + standard.setInitialDate(DateUtils.localDateToDate(now.minusDays(1))); + } + LocalDate generateDate = DateUtils.dateToLocalDate(standard.getInitialDate()); + if (standard.getLastGenerateTime() != null) { + generateDate = DateUtils.dateToLocalDate(standard.getLastGenerateTime()); + } + //鍔犲懆鏈� + do { + //鍒濆鏃ユ湡璁剧疆鐨勬瘮杈冩棭锛屾垨浠诲姟闀挎椂闂存病鎵ц锛屽繀椤诲懆鏈熷埌浠婂ぉ鎵嶄細鐢熸垚宸ュ崟 + generateDate = generateDate.plusDays(standard.getMaintenancePeriod()); + } while (now.isAfter(generateDate)); + if(!now.isEqual(generateDate)) { + //杩樻湭鍒扮敓鎴愭棩鏈燂紝璺宠繃鎵ц + continue; + } + //鑾峰彇淇濆吇椤规槑缁� + List<EamMaintenanceStandardDetail> standardDetailList = eamMaintenanceStandardDetailService.selectByStandardId(standard.getId()); + if(CollectionUtil.isEmpty(standardDetailList)) { + log.error("浜屼繚鏍囧噯娌℃湁淇濆吇鏄庣粏锛岃鍏堥厤缃繚鍏绘槑缁�, standard:{}", standard); + continue; + } + //寮�濮嬬敓鎴� + EamSecondMaintenanceRequest request = new EamSecondMaintenanceRequest(); + request.setEquipmentId(standard.getEquipmentId()); + request.setStandardId(standard.getId()); + request.setMaintenanceDate(DateUtils.localDateToDate(generateDate)); + String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.SECOND_MAINTENANCE_CODE_RULE); + request.setOrderNum(codeSeq); + request.setCreationMethod(OrderCreationMethodEnum.AUTO.name()); + + List<EamSecondMaintenanceOrderDetail> tableDetailList = new ArrayList<>(); + for (EamMaintenanceStandardDetail msd : standardDetailList) { + EamSecondMaintenanceOrderDetail sod = new EamSecondMaintenanceOrderDetail(); + sod.setItemCode(msd.getItemCode()); + sod.setItemName(msd.getItemName()); + sod.setItemDemand(msd.getItemDemand()); + sod.setItemPart(msd.getItemPart()); + tableDetailList.add(sod); + } +// List<EamSecondMaintenanceOrderDetail> collect = standardDetailList.stream().map(EamSecondMaintenanceOrderDetail::new).collect(Collectors.toList()); + request.setTableDetailList(tableDetailList); + eamSecondMaintenanceOrderService.addMaintenance(request); + + standard.setLastGenerateTime(new Date()); + eamMaintenanceStandardService.updateById(standard); + } + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("浜屼繚鐢熸垚鎵ц瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderExpiredJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderExpiredJob.java new file mode 100644 index 0000000..8a90fee --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderExpiredJob.java @@ -0,0 +1,96 @@ +package org.jeecg.modules.eam.job; + +import cn.hutool.core.collection.CollectionUtil; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.modules.eam.constant.SecondMaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.ThirdMaintenanceStatusEnum; +import org.jeecg.modules.eam.constant.WeekMaintenanceStatusEnum; +import org.jeecg.modules.eam.entity.EamSecondMaintenanceOrder; +import org.jeecg.modules.eam.entity.EamThirdMaintenanceOrder; +import org.jeecg.modules.eam.service.IEamSecondMaintenanceOrderService; +import org.jeecg.modules.eam.service.IEamThirdMaintenanceOrderService; +import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; +import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService; +import org.jeecg.modules.flowable.service.IFlowTaskService; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.Date; +import java.util.List; + +@Component +@Slf4j +public class ThirdMaintenanceOrderExpiredJob implements Job { + + @Autowired + private IEamThirdMaintenanceOrderService eamThirdMaintenanceOrderService; + + @Autowired + private IFlowMyBusinessService flowMyBusinessService; + @Autowired + private IFlowTaskService flowTaskService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + LocalDate now = LocalDate.now(); + try { + + List<EamThirdMaintenanceOrder> unCompleteOrderList = eamThirdMaintenanceOrderService.lambdaQuery() + .lt(EamThirdMaintenanceOrder::getMaintenanceDate, now.toString()) + .in(EamThirdMaintenanceOrder::getMaintenanceStatus, ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE, ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE) + .orderByDesc(EamThirdMaintenanceOrder::getMaintenanceDate) + .list(); + + if (CollectionUtil.isEmpty(unCompleteOrderList)) { + //娌℃湁闇�瑕佸鐞嗙殑鏁版嵁 + return; + } + for (EamThirdMaintenanceOrder order : unCompleteOrderList) { + if (ThirdMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(order.getMaintenanceStatus())) { + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.ABOLISH.name()); + } else if (ThirdMaintenanceStatusEnum.UNDER_MAINTENANCE.name().equals(order.getMaintenanceStatus())) { + //宸茬粡琚帴鍗� 浣嗘湭鎵ц瀹屾垚 + order.setMaintenanceStatus(ThirdMaintenanceStatusEnum.ABOLISH.name()); + //寮哄埗缁撴潫娴佺▼ 鍒犻櫎鐢ㄦ埛鐨勬寰呭姙浠诲姟 + FlowMyBusiness flowMyBusiness = flowMyBusinessService.selectByDataId(order.getId()); + if (flowMyBusiness != null) { + flowTaskService.end(flowMyBusiness.getProcessInstanceId(), "杩囨湡鍒犻櫎"); + } + } + } + eamThirdMaintenanceOrderService.updateBatchById(unCompleteOrderList); + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("涓変繚杩囨湡鎵ц瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + } + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderGenerateJob.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderGenerateJob.java new file mode 100644 index 0000000..8e19741 --- /dev/null +++ b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/job/ThirdMaintenanceOrderGenerateJob.java @@ -0,0 +1,154 @@ +package org.jeecg.modules.eam.job; + +import cn.hutool.core.collection.CollectionUtil; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.util.DateUtils; +import org.jeecg.modules.eam.constant.BusinessCodeConst; +import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum; +import org.jeecg.modules.eam.constant.OrderCreationMethodEnum; +import org.jeecg.modules.eam.entity.*; +import org.jeecg.modules.eam.request.EamSecondMaintenanceRequest; +import org.jeecg.modules.eam.request.EamThirdMaintenanceRequest; +import org.jeecg.modules.eam.service.*; +import org.jeecg.modules.mdc.util.ThrowableUtil; +import org.jeecg.modules.quartz.entity.QuartzJob; +import org.jeecg.modules.quartz.entity.SysQuartzLog; +import org.jeecg.modules.quartz.service.IQuartzJobService; +import org.jeecg.modules.quartz.service.ISysQuartzLogService; +import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +@Component +@Slf4j +public class ThirdMaintenanceOrderGenerateJob implements Job { + + @Autowired + private IEamEquipmentPrecisionParametersService eamEquipmentPrecisionParametersService; + @Autowired + private IEamThirdMaintenanceOrderService eamThirdMaintenanceOrderService; + @Autowired + private IEamMaintenanceStandardService eamMaintenanceStandardService; + @Autowired + private IEamMaintenanceStandardDetailService eamMaintenanceStandardDetailService; + @Autowired + private ISysBusinessCodeRuleService businessCodeRuleService; + @Autowired + private ISysQuartzLogService sysQuartzLogService; + @Autowired + private IQuartzJobService quartzJobService; + + @Override + @Transactional(rollbackFor = Exception.class) + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + //浠诲姟鏃ュ織 + SysQuartzLog quartzLog = new SysQuartzLog(); + quartzLog.setCreateTime(new Date()); + List<QuartzJob> byJobClassName = quartzJobService.findByJobClassName(this.getClass().getName()); + if (byJobClassName != null && !byJobClassName.isEmpty()) { + quartzLog.setJobId(byJobClassName.get(0).getId()); + } + long startTime = System.currentTimeMillis(); + /** + * 鑾峰彇 閰嶇疆浜� 涓変繚鏍囧噯鐨� 淇℃伅 + */ + List<EamMaintenanceStandard> standardList = eamMaintenanceStandardService.queryListByCategory(MaintenanceCategoryEnum.THIRD_MAINTENANCE.name()); + if (CollectionUtil.isEmpty(standardList)) { + log.warn("娌℃湁閰嶇疆浠讳綍涓変繚鏍囧噯锛屼换鍔$粨鏉�"); + return; + } + //褰撳墠鏃ユ湡 + LocalDate now = LocalDate.now(); + try { + for (EamMaintenanceStandard standard : standardList) { + if (standard.getMaintenancePeriod() == null || standard.getMaintenancePeriod() < 1) { + log.error("涓変繚鏍囧噯鍛ㄦ湡璁剧疆閿欒锛岃鍏堥厤缃爣鍑嗗懆鏈�, standard:{}", standard); + continue; + } + if (standard.getInitialDate() == null) { + //璁剧疆鍒濆鏃ユ湡涓哄墠涓�澶� + standard.setInitialDate(DateUtils.localDateToDate(now.minusDays(1))); + } + LocalDate generateDate = DateUtils.dateToLocalDate(standard.getInitialDate()); + if (standard.getLastGenerateTime() != null) { + generateDate = DateUtils.dateToLocalDate(standard.getLastGenerateTime()); + } + //鍔犲懆鏈� + do { + //鍒濆鏃ユ湡璁剧疆鐨勬瘮杈冩棭锛屾垨浠诲姟闀挎椂闂存病鎵ц锛屽繀椤诲懆鏈熷埌浠婂ぉ鎵嶄細鐢熸垚宸ュ崟 + generateDate = generateDate.plusDays(standard.getMaintenancePeriod()); + } while (now.isAfter(generateDate)); + if(!now.isEqual(generateDate)) { + //杩樻湭鍒扮敓鎴愭棩鏈燂紝璺宠繃鎵ц + continue; + } + //鑾峰彇淇濆吇椤规槑缁� + List<EamMaintenanceStandardDetail> standardDetailList = eamMaintenanceStandardDetailService.selectByStandardId(standard.getId()); + if(CollectionUtil.isEmpty(standardDetailList)) { + log.error("涓変繚鏍囧噯娌℃湁淇濆吇鏄庣粏锛岃鍏堥厤缃繚鍏绘槑缁�, standard:{}", standard); + continue; + } + + //寮�濮嬬敓鎴� + EamThirdMaintenanceRequest request = new EamThirdMaintenanceRequest(); + request.setEquipmentId(standard.getEquipmentId()); + request.setStandardId(standard.getId()); + request.setMaintenanceDate(DateUtils.localDateToDate(generateDate)); + String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.THIRD_MAINTENANCE_CODE_RULE); + request.setOrderNum(codeSeq); + request.setCreationMethod(OrderCreationMethodEnum.AUTO.name()); + + List<EamThirdMaintenanceOrderDetail> tableDetailList = new ArrayList<>(); + for (EamMaintenanceStandardDetail msd : standardDetailList) { + EamThirdMaintenanceOrderDetail tod = new EamThirdMaintenanceOrderDetail(); + tod.setItemCode(msd.getItemCode()); + tod.setItemName(msd.getItemName()); + tod.setItemDemand(msd.getItemDemand()); + tod.setItemPart(msd.getItemPart()); + tableDetailList.add(tod); + } +// List<EamThirdMaintenanceOrderDetail> collect = standardDetailList.stream().map(EamThirdMaintenanceOrderDetail::new).collect(Collectors.toList()); + request.setTableDetailList(tableDetailList); + + //閫氳繃璁惧 鑾峰彇璁惧绮惧害鍙傛暟 + List<EamEquipmentPrecisionParameters> precisionParametersList = eamEquipmentPrecisionParametersService + .lambdaQuery().eq(EamEquipmentPrecisionParameters::getEquipmentId, standard.getEquipmentId()).list(); + if(precisionParametersList.size()>0){ + List<EamPrecisionCheckDetail> precisionDetailList = new ArrayList<>(); + for (EamEquipmentPrecisionParameters epp : precisionParametersList) { + EamPrecisionCheckDetail pcd = new EamPrecisionCheckDetail(); + pcd.setParameterId(epp.getParameterId()); + pcd.setEquipmentId(standard.getEquipmentId()); + pcd.setParameterValue(epp.getParameterValue()); + precisionDetailList.add(pcd); + } + request.setPrecisionDetailList(precisionDetailList); + } + eamThirdMaintenanceOrderService.addMaintenance(request); + + standard.setLastGenerateTime(new Date()); + eamMaintenanceStandardService.updateById(standard); + } + quartzLog.setIsSuccess(0); + } catch (Exception e) { + log.error("涓変繚鐢熸垚鎵ц瀹氭椂浠诲姟澶辫触锛寋}", e.getMessage(), e); + quartzLog.setIsSuccess(-1); + quartzLog.setExceptionDetail(ThrowableUtil.getStackTrace(e)); + } + long endTime = System.currentTimeMillis(); + quartzLog.setExecutionTime(Integer.parseInt(String.valueOf(endTime - startTime))); + sysQuartzLogService.save(quartzLog); + + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentPurchasePlanMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamEquipmentPurchasePlanMapper.java new file mode 100644 index 0000000..7ae4072 --- /dev/null +++ b/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> { + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamPurchasePlanAttachmentMapper.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/EamPurchasePlanAttachmentMapper.java new file mode 100644 index 0000000..15e83ca --- /dev/null +++ b/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> { + +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentPurchasePlanMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamEquipmentPurchasePlanMapper.xml new file mode 100644 index 0000000..b051fda --- /dev/null +++ b/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> \ No newline at end of file diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamPurchasePlanAttachmentMapper.xml b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/mapper/xml/EamPurchasePlanAttachmentMapper.xml new file mode 100644 index 0000000..98ccffb --- /dev/null +++ b/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> \ No newline at end of file diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamPurchasePlanAttachmentRequest.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/request/EamPurchasePlanAttachmentRequest.java new file mode 100644 index 0000000..5510a28 --- /dev/null +++ b/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; +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentPurchasePlanService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamEquipmentPurchasePlanService.java new file mode 100644 index 0000000..d35fb64 --- /dev/null +++ b/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); +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamPurchasePlanAttachmentService.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/IEamPurchasePlanAttachmentService.java new file mode 100644 index 0000000..97b394c --- /dev/null +++ b/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); +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentPurchasePlanServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentPurchasePlanServiceImpl.java new file mode 100644 index 0000000..9423de1 --- /dev/null +++ b/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); + } +} diff --git a/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamPurchasePlanAttachmentServiceImpl.java b/lxzn-module-eam/src/main/java/org/jeecg/modules/eam/service/impl/EamPurchasePlanAttachmentServiceImpl.java new file mode 100644 index 0000000..0737137 --- /dev/null +++ b/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("璇峰厛閫夋嫨璁惧閲囪喘璁″垝鍐嶄笂浼犳枃妗o紒"); + } + 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()); + } +} -- Gitblit v1.9.3