| | |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.pro.packaged.Q; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.DateUtils; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog; |
| | | import org.jeecg.modules.eam.constant.*; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | * @Version: V1.0 |
| | | */ |
| | | @Service("IEamSecondMaintenanceOrderService") |
| | | @Slf4j |
| | | public class EamSecondMaintenanceOrderServiceImpl extends ServiceImpl<EamSecondMaintenanceOrderMapper, EamSecondMaintenanceOrder> implements IEamSecondMaintenanceOrderService, FlowCallBackServiceI { |
| | | @Resource |
| | | private EamSecondMaintenanceOrderMapper eamSecondMaintenanceOrderMapper; |
| | | @Autowired |
| | | private IEamSecondMaintenanceOrderDetailService secondMaintenanceOrderDetailService; |
| | | |
| | | @Autowired |
| | | private FlowCommonService flowCommonService; |
| | | @Autowired |
| | |
| | | private BaseFactoryMapper baseFactoryMapper; |
| | | @Autowired |
| | | private IEamSecondMaintenanceOrderDetailService eamSecondMaintenanceOrderDetailService; |
| | | @Autowired |
| | | private IEamFactorySecondMaintPlanService factorySecondMaintPlanService; |
| | | |
| | | @Override |
| | | public IPage<EamSecondMaintenanceOrder> queryPageList(Page<EamSecondMaintenanceOrder> page, EamSecondMaintenanceQuery query) { |
| | |
| | | }); |
| | | secondMaintenanceOrderDetailService.saveBatch(requestTableDetailList); |
| | | } |
| | | // 插入首页二保养计划 |
| | | // 使用 SimpleDateFormat 直接格式化为“yyyy年MM月”格式 |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月"); |
| | | // String formattedDate = sdf.format(order.getMaintenanceDate()); |
| | | // factorySecondMaintPlanService.add(order.getEquipmentId(), formattedDate); |
| | | return true; |
| | | } |
| | | |
| | |
| | | if (!SecondMaintenanceStatusEnum.WAIT_MAINTENANCE.name().equals(entity.getMaintenanceStatus())) { |
| | | throw new JeecgBootException("只有待保养状态的数据才可编辑!"); |
| | | } |
| | | // 编辑首页二保养计划 |
| | | // 使用 SimpleDateFormat 直接格式化为“yyyy年MM月”格式 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月"); |
| | | String oldFormattedDate = sdf.format(entity.getMaintenanceDate()); |
| | | String newFormattedDate = sdf.format(request.getMaintenanceDate()); |
| | | factorySecondMaintPlanService.dateChange(entity.getEquipmentId(), oldFormattedDate,newFormattedDate); |
| | | entity.setMaintenanceDate(request.getMaintenanceDate()); |
| | | entity.setRemark(request.getRemark()); |
| | | |
| | | eamSecondMaintenanceOrderMapper.updateById(entity); |
| | | //判断是否存在保养人 如果存在则启动流程 |
| | | if (StringUtils.isNotBlank(entity.getOperator())) { |
| | |
| | | eamEquipmentExtendService.updateEquipmentMaintenanceStatus(entity.getEquipmentId(), EquipmentMaintenanceStatus.UNDER_SECOND_MAINTENANCE.name()); |
| | | return result.isSuccess(); |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @EquipmentHistoryLog(operationTag = EquipmentOperationTagEnum.SECOND_MAINTENANCE, businessTable = "eam_second_maintenance_order") |
| | | public EamSecondMaintenanceOrder approval(EamSecondMaintenanceRequest request) { |
| | | public EamSecondMaintenanceOrder approval(EamSecondMaintenanceRequest request) throws ParseException { |
| | | EamSecondMaintenanceOrder entity = eamSecondMaintenanceOrderMapper.selectById(request.getId()); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("审批的数据已删除,请刷新重试!"); |
| | |
| | | } |
| | | //保存工单 |
| | | eamSecondMaintenanceOrderMapper.updateById(entity); |
| | | //异步生成下次二保工单 |
| | | if (SecondMaintenanceStatusEnum.COMPLETE.name().equals(entity.getMaintenanceStatus())) { |
| | | //填充计算下次二保日期 |
| | | EamEquipmentExtend eamEquipmentExtend=eamEquipmentExtendService.getById(entity.getEquipmentId()); |
| | | eamEquipmentExtend.setLatestSecondMaintenance(entity.getMaintenanceDate()); |
| | | eamEquipmentExtend.setNextSecondMaintenance(calculateNextMaintenanceDate(entity.getMaintenanceDate())); |
| | | eamEquipmentExtendService.updateById(eamEquipmentExtend); |
| | | } |
| | | return entity; |
| | | } |
| | | |
| | | /** |
| | | * 计算六个月后的当月最后一天 |
| | | * @param currentDate 当前工单日期 |
| | | * @return 六个月后的当月最后一天 |
| | | */ |
| | | private Date calculateNextMaintenanceDate(Date currentDate) { |
| | | // 转换为LocalDate处理日期 |
| | | LocalDate localDate = DateUtils.dateToLocalDate(currentDate); |
| | | // 计算六个月后的日期 |
| | | LocalDate sixMonthsLater = localDate.plusMonths(6); |
| | | // 调整到当月的最后一天 |
| | | LocalDate lastDayOfMonth = sixMonthsLater.with(TemporalAdjusters.lastDayOfMonth()); |
| | | // 转换回Date类型 |
| | | return DateUtils.localDateToDate(lastDayOfMonth); |
| | | } |
| | | |
| | | /** |
| | | * 批量打印二保工单 |
| | | * @param ids |
| | | * @return |