| | |
| | | package com.aps.core.service.impl; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | |
| | | import com.aps.common.core.utils.uuid.IdUtils; |
| | | import com.aps.common.core.utils.uuid.UUID; |
| | | import com.aps.common.core.web.domain.AjaxResult; |
| | | import com.aps.core.domain.ApsResourceDateStat; |
| | | import com.aps.core.mapper.ApsResourceGroupMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor; |
| | | import org.springframework.stereotype.Service; |
| | | import com.aps.core.mapper.ApsPartRouteStatMapper; |
| | | import com.aps.core.domain.ApsPartRouteStat; |
| | |
| | | { |
| | | @Autowired |
| | | private ApsPartRouteStatMapper apsPartRouteStatMapper; |
| | | private DefaultsBindHandlerAdvisor.MappingsProvider mappingsProvider; |
| | | private ApsResourceGroupMapper resourceGroupMapper; |
| | | |
| | | /** |
| | | * 查询零件统计表 |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询零件工序并更新计划开工日期 |
| | | * */ |
| | | public void updatePartRoutPlanDate() { |
| | | List<ApsPartRouteStat> tempList = apsPartRouteStatMapper.selectPartRoutStat(); |
| | | /*对tempList 按照 workOrderNo 进行分组*/ |
| | |
| | | } |
| | | } |
| | | apsPartRouteStatMapper.deleteLastBatch(batchNum); |
| | | |
| | | } |
| | | /** 查询资源日历表 |
| | | */ |
| | | @Override |
| | | public AjaxResult selectResourceDateStat() { |
| | | /*查出所有统计的数据*/ |
| | | List<ApsResourceDateStat> list = apsPartRouteStatMapper.selectResourceDateStat(); |
| | | /*求出计划的最大时间,没有 设置为当前时间+15天*/ |
| | | ApsResourceDateStat apsResourceDateStat = list.stream().max(Comparator.comparing(ApsResourceDateStat::getPlanDay)).orElse(null); |
| | | LocalDate maxPlanDay = LocalDate.now().plus(15, ChronoUnit.DAYS); |
| | | if(apsResourceDateStat!=null){ |
| | | maxPlanDay=apsResourceDateStat.getPlanDay(); |
| | | } |
| | | /*组织出日期表头*/ |
| | | List<String> planDays = new ArrayList<>(); |
| | | LocalDate startDay = LocalDate.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | while (startDay .isBefore( maxPlanDay)){ |
| | | planDays.add(startDay.format(formatter)); |
| | | startDay=startDay.plus(1,ChronoUnit.DAYS); |
| | | } |
| | | /*根据日期表头的顺序,组织出每个日期下的统计项目*/ |
| | | List<ApsResourceDateStat> targetList = new ArrayList<>(); |
| | | for (String planDay : planDays) { |
| | | ApsResourceDateStat apsResourceDateStat1 = list.stream() |
| | | .filter(item -> item.getPlanDay().equals(LocalDate.parse(planDay, formatter))) |
| | | .findFirst().orElse(null); |
| | | if(apsResourceDateStat1!=null){ |
| | | targetList.add(apsResourceDateStat1); |
| | | }else{ |
| | | ApsResourceDateStat apsResourceDateStat2 = new ApsResourceDateStat(); |
| | | apsResourceDateStat2.setPlanDay( LocalDate.parse(planDay, formatter)); |
| | | targetList.add(apsResourceDateStat2); |
| | | } |
| | | } |
| | | AjaxResult result=new AjaxResult(200,"生成成功") |
| | | .put("planTitle",planDays) |
| | | .put("planTable",targetList); |
| | | return result; |
| | | } |
| | | |
| | | } |