|
|
|
@ -1,17 +1,19 @@
|
|
|
|
|
package com.op.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.mes.domain.MesReportWork;
|
|
|
|
|
import com.op.mes.mapper.MesMapper;
|
|
|
|
|
import com.op.mes.service.IMesBoradService;
|
|
|
|
|
import com.op.system.api.domain.dto.BoardDTO;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class MesBoradServiceImpl implements IMesBoradService {
|
|
|
|
@ -34,4 +36,86 @@ public class MesBoradServiceImpl implements IMesBoradService {
|
|
|
|
|
map.put("ProductionInProgress", ProductionInProgress);
|
|
|
|
|
return AjaxResult.success(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<BoardDTO> getLineList(BoardDTO boardDTO) {
|
|
|
|
|
DynamicDataSourceContextHolder.push(boardDTO.getFactoryCode());
|
|
|
|
|
boardDTO.setEquipmentTypeCode("equ_type_bzx");
|
|
|
|
|
List<BoardDTO> lineList = mesMapper.getLineList(boardDTO);
|
|
|
|
|
return lineList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BoardDTO getProduction15Days(BoardDTO boardDTO) {
|
|
|
|
|
DynamicDataSourceContextHolder.push(boardDTO.getFactoryCode());
|
|
|
|
|
BoardDTO dto = new BoardDTO();
|
|
|
|
|
|
|
|
|
|
String nowDate = DateUtils.getDate();
|
|
|
|
|
|
|
|
|
|
List<String> days = this.getDays(15);
|
|
|
|
|
//days
|
|
|
|
|
dto.setDays(days);
|
|
|
|
|
boardDTO.setStartTime(days.get(0));
|
|
|
|
|
boardDTO.setEndTime(days.get(days.size()-1));
|
|
|
|
|
Map<String,MesReportWork> pros15 = mesMapper.getProduction15Days(boardDTO);
|
|
|
|
|
MesReportWork todaydto = pros15.get(nowDate);
|
|
|
|
|
if(todaydto != null){
|
|
|
|
|
dto.setPlanProduction(todaydto.getQuantity().toString().replace(".00",""));
|
|
|
|
|
dto.setActProduction(todaydto.getQuantityFeedback().toString());
|
|
|
|
|
}else{
|
|
|
|
|
dto.setPlanProduction("0");
|
|
|
|
|
dto.setActProduction("0");
|
|
|
|
|
}
|
|
|
|
|
//plans;
|
|
|
|
|
List<String> plans = new ArrayList<>();
|
|
|
|
|
List<String> acts = new ArrayList<>();
|
|
|
|
|
//acts;
|
|
|
|
|
for(String dayStr:days){
|
|
|
|
|
MesReportWork workR = pros15.get(dayStr);
|
|
|
|
|
if(workR != null){
|
|
|
|
|
plans.add(workR.getQuantity().toString());
|
|
|
|
|
acts.add(workR.getQuantityFeedback().toString());
|
|
|
|
|
}else{
|
|
|
|
|
plans.add("0");
|
|
|
|
|
acts.add("0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dto.setPlans(plans);
|
|
|
|
|
dto.setActs(acts);
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前日期前几天
|
|
|
|
|
private List<String> getDays(int dayNum){
|
|
|
|
|
List<String> days = new ArrayList<>();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
//获取前面的时间用-负号
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
for(int num=0;num<dayNum;num++){
|
|
|
|
|
cal.setTime(date);
|
|
|
|
|
cal.add(Calendar.DAY_OF_MONTH, -num);
|
|
|
|
|
days.add(sdf.format(cal.getTime()));
|
|
|
|
|
}
|
|
|
|
|
Collections.reverse(days);
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args){
|
|
|
|
|
List<String> days = new ArrayList<>();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
//获取前面的时间用-负号
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
for(int num=0;num<15;num++){
|
|
|
|
|
cal.setTime(date);
|
|
|
|
|
cal.add(Calendar.DAY_OF_MONTH, -num);
|
|
|
|
|
days.add(sdf.format(cal.getTime()));
|
|
|
|
|
}
|
|
|
|
|
Collections.reverse(days);
|
|
|
|
|
|
|
|
|
|
System.out.println(JSONObject.toJSONString(days));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|