| | |
| | | import cn.smallbun.screw.core.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.yulichang.base.MPJBaseServiceImpl; |
| | | import com.mes.md.entity.KBBTJPDrawingBP; |
| | | import com.mes.md.entity.KBBTProgramsOperationLogBP; |
| | | import com.mes.md.entity.TaskingLog; |
| | | import com.mes.md.mapper.KBBTJPDrawingBPMapper; |
| | | import com.mes.md.mapper.KBBTProgramsOperationLogBPMapper; |
| | | import com.mes.md.mapper.TaskingLogMapper; |
| | | import com.mes.md.service.TaskingLogService; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | KBBTProgramsOperationLogBPMapper kBBTProgramsOperationLogBPMapper; |
| | | @Autowired |
| | | KBBTJPDrawingBPMapper kBBTJPDrawingBPMapper; |
| | | |
| | | public List<TaskingLog> findTaskingLog(){ |
| | | return new ArrayList<TaskingLog>(); |
| | | } |
| | | |
| | | /** |
| | | * 查询 dayCount 天 完工数量-分线路 |
| | | */ |
| | | @Override |
| | | public List<Map> selectTaskingLog(int dayCount) { |
| | | Calendar cal = Calendar.getInstance(); |
| | | //设置当前时间 |
| | | cal.setTime(new Date()); |
| | | cal.set(Calendar.HOUR_OF_DAY, 0); |
| | | cal.set(Calendar.MINUTE, 0); |
| | | cal.set(Calendar.SECOND, 0); |
| | | cal.set(Calendar.MILLISECOND, 0); |
| | | cal.add(Calendar.DATE, 0-dayCount); |
| | | Date startDate = cal.getTime(); |
| | | |
| | | QueryWrapper<KBBTJPDrawingBP> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("CAST(CreateDate AS DATE) AS CreateDate,isNull(sum(task_quantity),0) as task_quantity_sum") |
| | | .gt("CreateDate",startDate).groupBy("CAST(CreateDate AS DATE)") |
| | | .orderByAsc("CAST(CreateDate AS DATE)"); |
| | | List<Map> list=kBBTJPDrawingBPMapper.selectMaps((QueryWrapper)queryWrapper); |
| | | |
| | | List<Map<String, Object>> listTasking1 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>() |
| | | .select("operation_record,operation_mode,DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time,count(1) as count") |
| | | .eq("operation_record", "旋转1") |
| | | .eq("operation_mode", "结束") |
| | | .gt("operation_record_time", startDate) |
| | | .groupBy("operation_record", "operation_mode", "DATE_FORMAT(operation_record_time, '%Y-%m-%d')") |
| | | .orderByAsc("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")); |
| | | List<Map<String, Object>> listTasking2 = baseMapper.selectMaps(new QueryWrapper<TaskingLog>() |
| | | .select("operation_record,operation_mode,DATE_FORMAT(operation_record_time, '%Y-%m-%d') as operation_record_time,count(1) as count") |
| | | .eq("operation_record", "旋转2") |
| | | .eq("operation_mode", "结束") |
| | | .gt("operation_record_time", startDate) |
| | | .groupBy("operation_record", "operation_mode", "DATE_FORMAT(operation_record_time, '%Y-%m-%d')") |
| | | .orderByAsc("DATE_FORMAT(operation_record_time, '%Y-%m-%d')")); |
| | | //log.info("客户表计划量:{},{},{}",list,listTasking1,listTasking2); |
| | | List<Map> Result=new ArrayList<>(); |
| | | for (int i=0;i<dayCount;i++){ |
| | | Date thisdate=cal.getTime(); |
| | | cal.add(Calendar.DATE, 1); |
| | | Map thisMap=new HashMap<>(); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String dateString = sdf.format(thisdate); |
| | | thisMap.put("date",dateString); |
| | | if (listTasking1.size()>0&&listTasking1.get(0).get("operation_record_time").toString().equals(dateString)){ |
| | | |
| | | thisMap.put("line1",listTasking1.get(0).get("count")); |
| | | listTasking1.remove(0); |
| | | }else{ |
| | | thisMap.put("line1",0); |
| | | } |
| | | if (listTasking2.size()>0&&listTasking2.get(0).get("operation_record_time").toString().equals(dateString)){ |
| | | thisMap.put("line2",listTasking2.get(0).get("count")); |
| | | listTasking2.remove(0); |
| | | }else{ |
| | | thisMap.put("line2",0); |
| | | } |
| | | // if(list.size()>0){ |
| | | // log.info("对比:{},{},{}", |
| | | // list.get(0).get("CreateDate"), |
| | | // dateString, |
| | | // list.get(0).get("CreateDate").toString().equals(dateString)); |
| | | // } |
| | | |
| | | if (list.size()>0&&list.get(0).get("CreateDate").toString().equals(dateString)){ |
| | | |
| | | thisMap.put("plan",list.get(0).get("task_quantity_sum")); |
| | | list.remove(0); |
| | | }else{ |
| | | thisMap.put("plan",0); |
| | | } |
| | | Result.add(thisMap); |
| | | } |
| | | |
| | | return Result; |
| | | } |
| | | /** |
| | | * 回传报工数据+ 设备玻璃过片记录给 九牧 |
| | | */ |
| | | @Override |