| | |
| | | import org.jeecg.modules.eam.request.EamEquipmentQuery; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentExtendService; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamThirdMaintenanceWorkPlanSheetService; |
| | | import org.jeecg.modules.eam.vo.EamEquipmentTree; |
| | | import org.jeecg.modules.eam.vo.EquipmentSearchResult; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import java.util.function.Consumer; |
| | | import java.util.stream.Collectors; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | |
| | | /** |
| | | * @Description: 设备台账 |
| | |
| | | }else { |
| | | eamEquipment.setRepairDepartOrgCode(eamBaseRepairDepart.getOrgCode()); |
| | | } |
| | | // 字段校验与填充 |
| | | if (StringUtils.isNotBlank(eamEquipment.getLeaveFactory())) { |
| | | String leaveFactoryStr = eamEquipment.getLeaveFactory(); |
| | | try { |
| | | // 定义支持解析的日期格式 |
| | | String[] parsePatterns = { |
| | | "yyyy/MM/dd", "yyyy-MM-dd", "yyyyMMdd" |
| | | }; |
| | | // 格式1: 包含分隔符的日期格式 (如2025/07/30, 2025-07-30等) |
| | | if (leaveFactoryStr.contains("/") || leaveFactoryStr.contains("-") || |
| | | (leaveFactoryStr.length() == 8 && leaveFactoryStr.matches("\\d{8}"))) { |
| | | |
| | | // 使用指定的格式数组解析日期 |
| | | Date leaveFactoryDate = DateUtils.parseDate(leaveFactoryStr, parsePatterns); |
| | | eamEquipment.setLeaveFactoryDate(leaveFactoryDate); |
| | | } else { |
| | | log.warn("离开工厂日期格式无效: {}", leaveFactoryStr); |
| | | } |
| | | } catch (ParseException e) { |
| | | log.error("日期解析失败: {}", leaveFactoryStr, e); |
| | | } |
| | | } |
| | | // 计算三保日期 |
| | | if (eamEquipment.getNextThirdMaintenance() != null && |
| | | eamEquipment.getThirdMaintenancePeriod() != null) { |
| | | |
| | | org.jeecg.common.util.DateUtils.calculateMaintenanceDates( |
| | | eamEquipment.getNextThirdMaintenance(), |
| | | eamEquipment.getThirdMaintenancePeriod(), |
| | | newDate -> eamEquipment.setNextThirdMaintenance(newDate), |
| | | latestDate -> eamEquipment.setLatestThirdMaintenance(latestDate) |
| | | ); |
| | | } |
| | | |
| | | // 计算技术状态鉴定日期 |
| | | if (eamEquipment.getNextTechnologyCheck() != null && |
| | | eamEquipment.getTechnologyCheckPeriod() != null) { |
| | | |
| | | org.jeecg.common.util.DateUtils.calculateMaintenanceDates( |
| | | eamEquipment.getNextTechnologyCheck(), |
| | | eamEquipment.getTechnologyCheckPeriod(), |
| | | newDate -> eamEquipment.setNextTechnologyCheck(newDate), |
| | | latestDate -> eamEquipment.setLatestTechnologyCheck(latestDate) |
| | | ); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.saveEquipment(eamEquipment); |
| | | if (equipment == null) { |
| | | //保存失败,跳过本次循环 |