package com.hikvision.mes.report.service.service.impl;
import cn.evun.ime.platform.core.utils.PaginationHelp;
import cn.evun.ime.platform.core.utils.StringUtils;
import cn.evun.sweet.framework.core.mvc.model.QueryResult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hikvision.mes.report.sdk.constant.MaStatusConfig;
import com.hikvision.mes.report.sdk.dto.*;
import com.hikvision.mes.report.service.configuration.ExecutorsPoolConfiguration;
import com.hikvision.mes.report.service.dao.BulletinBoardBasicInfoDao;
import com.hikvision.mes.report.service.dao.WorkInProcessDao;
import com.hikvision.mes.report.service.service.AndonDataAnalyseKanbanService;
import com.hikvision.mes.report.service.service.WorkInProcessService;
import com.hikvision.mes.report.service.utils.ReflectionNameUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.LazyLoader;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
/**
* @Description: 在制品据分析报表
* @Author: xuchenghua
* @CreateDate: 2021/14/10 14:04
* @UpdateUser: xuchenghua
* @UpdateDate: 2021/14/10 14:04
* @UpdateRemark: 修改内容
* @Version: 1.0
*/
@Service
public class WorkInProcessServiceImpl implements WorkInProcessService {
@Autowired
private WorkInProcessDao workInProcessDao;
@Autowired
private AndonDataAnalyseKanbanService andonDataAnalyseKanbanService;
@Autowired
private BulletinBoardBasicInfoDao bulletinBoardBasicInfoDao;
/**
* 查询电装在制品列表报表数据"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectWorkInProcessListChart(WorkInProcessDto req) {
WorkInProcessDto resq = new WorkInProcessDto();
resq.setBaseCode("8001");
List<String> factoryCodes = new ArrayList<>();
factoryCodes.add("W911");
resq.setFactoryCodes(factoryCodes);
resq.setByType("BY_HOUR");
req = resq;
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
//查询电装订单数目
List<WorkInProcessResultDto> total = workInProcessDao.selectElectricTotalNumber(req);
//查询数目
List<WorkInProcessResultDto> resultList = new ArrayList<>();
//获取v1 list
List<WorkInProcessV1Dto> list = workInProcessDao.getBaseSearchList(req);
this.list = list;
//获取基础集合
List<WorkInProcessV3Dto> baseList = workInProcessDao.getBaseList(list);
this.baseList = baseList;
//下面这些接口可以并行执行
ExecutorService threadPool = Executors.newFixedThreadPool(5);
Future<List<WorkInProcessV4Dto>> smtFuture = threadPool.submit(new Task(this, "method1", null));
Future<List<WorkInProcessV5Dto>> patchFuture = threadPool.submit(new Task(this, "method2", null));
try {
List<WorkInProcessV4Dto> s1 = smtFuture.get();
List<WorkInProcessV5Dto> s2 = patchFuture.get();
System.out.println(s2.toString());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
// List<WorkInProcessV4Dto> baseResult2 = futureGetProxy(smtFuture, WorkInProcessV4Dto.class);
//获取smtWitList
List<WorkInProcessV4Dto> smtWitList = workInProcessDao.getSmtWitList(baseList);
//获取DZ01,DZ02,待贴片集合
List<WorkInProcessV5Dto> patchList = workInProcessDao.getPatchList(list,baseList);
//获取待插件,待测试,待维修数据 wait_plug,wait_test,wait_repair
List<WorkInProcessV6Dto> waitPlugList = workInProcessDao.getWaitPlugList(list,baseList);
//获取wait_in_storage集合 待入库集合
List<WorkInProcessV8Dto> inStorageList = workInProcessDao.getInStorageList(list);
//根据工单号进行分组
Map<String, List<WorkInProcessV4Dto>> smtWitMap = smtWitList.stream().collect(groupingBy(WorkInProcessV4Dto::getAufnr));
Map<String, List<WorkInProcessV5Dto>> patchMap = patchList.stream().collect(groupingBy(WorkInProcessV5Dto::getAufnr));
Map<String, List<WorkInProcessV6Dto>> waitMap = waitPlugList.stream().collect(groupingBy(WorkInProcessV6Dto::getAufnr));
Map<String, List<WorkInProcessV8Dto>> inStorageMap = inStorageList.stream().collect(groupingBy(WorkInProcessV8Dto::getAufnr));
Double smtWip = 0.0;
Double dz01num = 0.0;
Double dz02num = 0.0;
Double plug = 0.0;
Double test = 0.0;
Double repair = 0.0;
Double inStorage = 0.0;
//baseList根据产线进行分组
Map<String, List<WorkInProcessV3Dto>> plineMap = baseList.stream().collect(groupingBy(WorkInProcessV3Dto::getPline));
if("BY_HOUR".equals(req.getByType())){
//获取dz01_time,dz02_time,dz03_time,dz04_time配置时间
List<WorkInProcessV9Dto> wipTimeList = workInProcessDao.getWipTimeList(list);
//根据工单号进行分组
Map<String, List<WorkInProcessV9Dto>> wiMap = wipTimeList.stream().collect(groupingBy(WorkInProcessV9Dto::getAufnr));
for (Map.Entry<String, List<WorkInProcessV3Dto>> ent : plineMap.entrySet()) {
WorkInProcessResultDto work = new WorkInProcessResultDto();
String pline = ent.getKey();
work.setPline(pline);
work.setCategory(pline);
List<WorkInProcessV3Dto> v3Dtos = ent.getValue();
for (WorkInProcessV3Dto dto:v3Dtos){
//根据订单号获取DZ01-4 的配置时间
GetDzTime dzTime = new GetDzTime(wiMap, dto).invoke();
Double dz01_time = dzTime.getDz01_time();
Double dz02_time = dzTime.getDz02_time();
Double dz03_time = dzTime.getDz03_time();
Double dz04_time = dzTime.getDz04_time();
//根据订单获取各个指标
GetNumber target = new GetNumber(smtWitMap, patchMap, waitMap, inStorageMap, dto).invoke();
Double d1 = target.getD1();
Double d2 = target.getD2();
Double pl = target.getPl();
Double te = target.getTe();
Double re = target.getRe();
Double in = target.getIn();
Double inNum = target.getInNum();
//当选择是swip工时的时候
try {
Double num1 = inNum * dz03_time;
smtWip = smtWip + num1;
} catch (Exception e) {
System.out.println("inNum="+inNum+"dz03_time="+dz03_time+"当前订单=="+dto.getAufnr());
}
try {
Double num2 = d1 * dz01_time;
dz01num = dz01num + num2;
} catch (Exception e) {
System.out.println("d1="+d1+"dz01_time="+dz01_time+"当前订单=="+dto.getAufnr());
}
Double num3 = d2 * dz02_time;
dz02num = dz02num + num3;
Double num4 = pl * dz03_time;
plug = plug + num4;
Double num5 = te * dz04_time;
test = test + num5;
Double num6 = re * dz04_time;
repair = repair + num6;
Double num7 = in * (dz04_time+dz04_time);
inStorage = inStorage + num7;
}
work.setSmtWip(new BigDecimal(smtWip * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setDzOne(new BigDecimal(dz01num * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setDzTwo(new BigDecimal(dz02num * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setPlug(new BigDecimal(plug * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setTest(new BigDecimal(test * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setRepair(new BigDecimal(repair * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
work.setInStorage(new BigDecimal(inStorage * 1.00 / (3600 * 1)).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
resultList.add(work);
}
}else {
for (Map.Entry<String, List<WorkInProcessV3Dto>> ent : plineMap.entrySet()) {
WorkInProcessResultDto work = new WorkInProcessResultDto();
String pline = ent.getKey();
work.setPline(pline);
work.setCategory(pline);
List<WorkInProcessV3Dto> v3Dtos = ent.getValue();
for (WorkInProcessV3Dto dto:v3Dtos){
//根据订单获取各个指标
GetNumber target = new GetNumber(smtWitMap, patchMap, waitMap, inStorageMap, dto).invoke();
Double d1 = target.getD1();
Double d2 = target.getD2();
Double pl = target.getPl();
Double te = target.getTe();
Double re = target.getRe();
Double in = target.getIn();
Double inNum = target.getInNum();
smtWip = smtWip + inNum;
inStorage = inStorage + in;
repair = repair + re;
dz01num = dz01num + d1;
dz02num = dz02num + d2;
plug = plug + pl;
test = test + te;
}
work.setSmtWip(smtWip);
work.setDzOne(dz01num);
work.setDzTwo(dz02num);
work.setPlug(plug);
work.setTest(test);
work.setRepair(repair);
work.setInStorage(inStorage);
resultList.add(work);
}
}
if (resultList != null && resultList.size() > 0) {
Map<String, List<WorkInProcessResultDto>> map = total.stream().collect(groupingBy(WorkInProcessResultDto::getDimCode));
for (WorkInProcessResultDto wd : resultList) {
wd.setOrdNum(map.get(wd.getPline()).get(0).getTotalnum());
}
}
WorkInProcessResultDto wpd = new WorkInProcessResultDto();
wpd.setPatch(resultList.stream().mapToDouble(WorkInProcessResultDto::getPatch).sum());
wpd.setSmtWip(resultList.stream().mapToDouble(WorkInProcessResultDto::getSmtWip).sum());
wpd.setPlug(resultList.stream().mapToDouble(WorkInProcessResultDto::getPlug).sum());
wpd.setTest(resultList.stream().mapToDouble(WorkInProcessResultDto::getTest).sum());
wpd.setRepair(resultList.stream().mapToDouble(WorkInProcessResultDto::getRepair).sum());
wpd.setInStorage(resultList.stream().mapToDouble(WorkInProcessResultDto::getInStorage).sum());
wpd.setOrdNum(resultList.stream().mapToInt(WorkInProcessResultDto::getOrdNum).sum());
if ("BY_HOUR".equals(req.getByType())) {
wpd.setPatch(new BigDecimal((double) wpd.getPatch()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setSmtWip(new BigDecimal((double) wpd.getSmtWip()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setPlug(new BigDecimal((double) wpd.getPlug()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setTest(new BigDecimal((double) wpd.getTest()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setRepair(new BigDecimal((double) wpd.getRepair()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setInStorage(new BigDecimal((double) wpd.getInStorage()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
}
wpd.setCategory("汇总");
resultList.add(0, wpd);
return resultList;
}
/**
* 查询所有基地
*
* @param
* @return
*/
@Override
public List<WorkInProcessResultDto> selectAllBaseCode() {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAllBaseCode();
//如果是杭州环境则过滤基地
String baseCode =bulletinBoardBasicInfoDao.selectEnvironmentalByShiftTime();
if("8001".equals(baseCode)){
if(resultList !=null && resultList.size()>0){
resultList = resultList.stream().filter(e-> MaStatusConfig.baseSet.contains(e.getBaseCode())).collect(Collectors.toList());
}
}
return resultList;
}
/**
* 查询电装工厂"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectElectricFactory(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectElectricFactory(req);
return resultList;
}
/**
* 查询组装工厂"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectAssembleFactory(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleFactory(req);
return resultList;
}
/**
* 查询组装车间"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectAssembleFloor(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleFloor(req);
return resultList;
}
/**
* 查询组装产线"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectAssembleWorkLine(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleWorkLine(req);
return resultList;
}
/**
* 查询电装产线"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectElectricWorkLine(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectElectricWorkLine(req);
return resultList;
}
/**
* 查询电装车间"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectElectricFloor(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectElectricFloor(req);
return resultList;
}
/**
* 查询分类下钻"
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectCategoryRunIn(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getPageNum(), req.getNumPerPage());
// List<WorkInProcessResultDto> resultList = workInProcessDao.selectCategoryRunIn(req);
Page<WorkInProcessResultDto> page = workInProcessDao.selectCategoryRunIn(req);
page.stream().forEach(e -> e.setOrderNo(e.getAufnr()));
WorkInProcessResultDto total = workInProcessDao.selectCategoryRunInTotal(req);
//订单号为了和别的区别开来
total.setOrderNo("汇总");
total.setAufnr("汇总");
page.add(0, total);
// WorkInProcessResultDto wpd = new WorkInProcessResultDto();
// resultList.stream().forEach(e->e.setOrderNo(e.getAufnr()));
// wpd.setPatch(resultList.stream().mapToDouble(WorkInProcessResultDto::getPatch).sum());
// wpd.setSmtWip(resultList.stream().mapToDouble(WorkInProcessResultDto::getSmtWip).sum());
// wpd.setPlug(resultList.stream().mapToDouble(WorkInProcessResultDto::getPlug).sum());
// wpd.setTest(resultList.stream().mapToDouble(WorkInProcessResultDto::getTest).sum());
// wpd.setRepair(resultList.stream().mapToDouble(WorkInProcessResultDto::getRepair).sum());
// wpd.setInStorage(resultList.stream().mapToDouble(WorkInProcessResultDto::getInStorage).sum());
wpd.setOrdNum(resultList.stream().mapToInt(WorkInProcessResultDto::getOrdNum).sum());
// if("BY_HOUR".equals(req.getByType())){
// wpd.setPatch(new BigDecimal((double)wpd.getPatch()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// wpd.setSmtWip(new BigDecimal((double)wpd.getSmtWip()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// wpd.setPlug(new BigDecimal((double)wpd.getPlug()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// wpd.setTest(new BigDecimal((double)wpd.getTest()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// wpd.setRepair(new BigDecimal((double)wpd.getRepair()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// wpd.setInStorage(new BigDecimal((double)wpd.getInStorage()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
// }
// wpd.setOrderNo("汇总");
// wpd.setAufnr("汇总");
// resultList.add(0,wpd);
return PaginationHelp.parseDTOPage(page);
}
/**
* 查询分类下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectCategoryRunInAll(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
List<WorkInProcessResultDto> resultList = workInProcessDao.selectCategoryRunIn(req);
WorkInProcessResultDto wpd = new WorkInProcessResultDto();
resultList.stream().forEach(e->e.setOrderNo(e.getAufnr()));
wpd.setPatch(resultList.stream().mapToDouble(WorkInProcessResultDto::getPatch).sum());
wpd.setSmtWip(resultList.stream().mapToDouble(WorkInProcessResultDto::getSmtWip).sum());
wpd.setPlug(resultList.stream().mapToDouble(WorkInProcessResultDto::getPlug).sum());
wpd.setTest(resultList.stream().mapToDouble(WorkInProcessResultDto::getTest).sum());
wpd.setRepair(resultList.stream().mapToDouble(WorkInProcessResultDto::getRepair).sum());
wpd.setInStorage(resultList.stream().mapToDouble(WorkInProcessResultDto::getInStorage).sum());
if("BY_HOUR".equals(req.getByType())){
wpd.setPatch(new BigDecimal((double)wpd.getPatch()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setSmtWip(new BigDecimal((double)wpd.getSmtWip()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setPlug(new BigDecimal((double)wpd.getPlug()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setTest(new BigDecimal((double)wpd.getTest()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setRepair(new BigDecimal((double)wpd.getRepair()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
wpd.setInStorage(new BigDecimal((double)wpd.getInStorage()).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
}
wpd.setOrderNo("汇总");
wpd.setAufnr("汇总");
resultList.add(0,wpd);
return resultList;
}
/**
* 查询待贴片下钻"
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectPatchRunIn(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getPageNum(), req.getNumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectPatchRunIn(req);
if ("smtWip".equals(req.getFlagType()) || "inStorage".equals(req.getFlagType())) {
resultList.stream().forEach(e -> e.setStVal(e.getWaitValue()));
}
WorkInProcessResultDto total = workInProcessDao.selectPatchRunInTotal(req);
if ("smtWip".equals(req.getFlagType()) || "inStorage".equals(req.getFlagType())) {
total.setStVal(total.getWaitValue());
}
total.setAufnr("汇总");
resultList.add(0, total);
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询待贴片下钻导出全部的
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectPatchRunInAll(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
List<WorkInProcessResultDto> resultList = workInProcessDao.selectPatchRunIn(req);
WorkInProcessResultDto wd = new WorkInProcessResultDto();
wd.setWaitValue(resultList.stream().mapToDouble(WorkInProcessResultDto::getWaitValue).sum());
wd.setAufnr("汇总");
resultList.add(0, wd);
if ("smtWip".equals(req.getFlagType()) || "inStorage".equals(req.getFlagType())) {
resultList.stream().forEach(e -> e.setStVal(e.getWaitValue()));
}
return resultList;
}
/**
* 查询SMT WIP下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectSmtWipRunIn(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectSmtWipRunIn(req);
return resultList;
}
/**
* 查询待插件下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectPlugRunIn(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectPlugRunIn(req);
return resultList;
}
/**
* 查询待测试下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectTestRunIn(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectTestRunIn(req);
return resultList;
}
/**
* 查询待修复下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectRepairRunIn(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectRepairRunIn(req);
return resultList;
}
/**
* 查询待入库下钻"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectInStorageRunIn(WorkInProcessDto req) {
List<WorkInProcessResultDto> resultList = workInProcessDao.selectInStorageRunIn(req);
return resultList;
}
/**
* 查询订单号三级下钻"
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectThirdRunIn(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectThirdRunIn(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 电装查询待维修三级下钻
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectRepairThird(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectRepairThird(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 电装查询三级下钻
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectElectricThird(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectElectricThird(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询电装在制品待贴片下钻明细
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectPatchThird(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectPatchThird(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询电装在制品待贴片下钻明细
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectPlugThird(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectPlugThird(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询电装在制品待测试下钻明细
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectTestThird(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectTestThird(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询订单号三级下钻导出全部
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectThirdRunInAll(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
List<WorkInProcessResultDto> resultList = workInProcessDao.selectThirdRunIn(req);
resultList.stream().forEach(e -> e.setScanTime(e.getScanTime().substring(0, 19)));
return resultList;
}
/**
* 查询订单号三级下钻导出全部
*
* @param req
* @return
*/
@Override
public Integer selectThirdRunInAllCount(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
Integer resultList = workInProcessDao.selectThirdRunInAllCount(req);
return resultList;
}
/**
* 查询组装信息二级下钻列表"
*
* @param req
* @return
*/
public Integer selectAssembleSecondOrderNum(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
Map<String, Object> resultMap = new HashMap<>();
Map<String, AssembleTitleDto> titleMap = new HashMap<>();
List<AssembleWorkInProcessDto> result = new ArrayList<>();
List<AssembleTitleDto> titleDtos = new ArrayList<>();
List<AssembleTitleDto> titleDtoSort = new ArrayList<>();
Integer sum = 0;
req.setProcessname("");
// if ("分类".equals(req.getProcessname())) {
// req.setProcessname("");
// }
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleSecondList(req);
if (resultList != null && resultList.size() > 0) {
Set<String> processNameList = new LinkedHashSet<>();
for (WorkInProcessResultDto ls :resultList){
processNameList.add(ls.getProcessname());
}
List<String> lists = getStringList();
//按照工厂或者线体分组
Map<String, List<WorkInProcessResultDto>> codeMap = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getAufnr));
//按照工序分组
Map<String, List<WorkInProcessResultDto>> map = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcess));
//先循环工厂或者线体
for (Map.Entry<String, List<WorkInProcessResultDto>> entry : codeMap.entrySet()) {
String key = entry.getKey();
AssembleWorkInProcessDto processDto = new AssembleWorkInProcessDto();
processDto.setOrderNumber(key);
// processDto.setTname(entry.getValue().get(0).getTname());
int x = 0;
//再循环工序
for (Map.Entry<String, List<WorkInProcessResultDto>> ent : map.entrySet()) {
List<WorkInProcessResultDto> list = ent.getValue();
String field = lists.get(x);
AssembleTitleDto titleDto = new AssembleTitleDto();
titleDto.setElement(field);
titleDto.setElementName(list.get(0).getProcessname());
titleMap.put(field, titleDto);
for (int i = 0; i < list.size(); i++) {
WorkInProcessResultDto ls = list.get(i);
if (key.equals(ls.getAufnr())) {
try {
processDto.setProcess(ls.getProcess());
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), ls.getTotalnum());
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
} else {
try {
processDto.setProcess(ls.getProcess());
Object ob = ReflectionNameUtil.getGetMethod(processDto, field);
if (ob == null) {
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
x = x + 1;
}
result.add(processDto);
}
//获取菜单列
if (titleMap.size() > 0) {
for (Map.Entry<String, AssembleTitleDto> entry : titleMap.entrySet()) {
titleDtos.add(entry.getValue());
}
}
//按照工序名称分组
Map<String, List<WorkInProcessResultDto>> map2 = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcessname));
AssembleWorkInProcessDto wp = new AssembleWorkInProcessDto();
for (AssembleWorkInProcessDto aw : result) {
req.setAufnr(aw.getOrderNumber());
//查询订单数字段
Integer tn = workInProcessDao.selectTotalNumberByOrderNumber(req);
if (tn == null) {
tn = 0;
}
aw.setTotalnum(tn);
Integer num = 0;
for (AssembleTitleDto at : titleDtos) {
String name = at.getElementName();
String element = at.getElement();
try {
Integer ob = (Integer) ReflectionNameUtil.getGetMethod(aw, element);
if ("GR交货数".equals(name) || "报工待入库".equals(name)) {
} else {
num = num + ob;
}
//再循环工序名称
for (Map.Entry<String, List<WorkInProcessResultDto>> et : map2.entrySet()) {
if (name.equals(et.getKey())) {
Integer number = et.getValue().stream().mapToInt(WorkInProcessResultDto::getTotalnum).sum();
ReflectionNameUtil.setValue(wp, wp.getClass(), element, AssembleWorkInProcessDto.class.getDeclaredField(element).getType(), number);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
aw.setWaitNumber(tn - num);
}
for (String pl:processNameList){
for (AssembleTitleDto tl:titleDtos){
if(pl.equals(tl.getElementName())){
titleDtoSort.add(tl);
}
}
}
result.sort(Comparator.comparing(AssembleWorkInProcessDto::getOrderNumber));
wp.setWaitNumber(result.stream().mapToInt(AssembleWorkInProcessDto::getWaitNumber).sum());
wp.setTotalnum(result.stream().mapToInt(AssembleWorkInProcessDto::getTotalnum).sum());
wp.setOrderNumber("汇总");
sum = wp.getTotalnum();
}
AssembleTitleDto cateDto = new AssembleTitleDto();
cateDto.setElementName("订单号");
cateDto.setElement("orderNumber");
titleDtoSort.add(0, cateDto);
AssembleTitleDto titleDto2 = new AssembleTitleDto();
titleDto2.setElementName("工序编码");
titleDto2.setElement("process");
titleDtoSort.add(titleDto2);
resultMap.put("resultList", result);
resultMap.put("titleList", titleDtoSort);
return sum;
}
/**
* 查询组装信息列表"
*
* @param req
* @return
*/
@Override
public Map<String, Object> selectAssembleList(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
Map<String, Object> resultMap = new HashMap<>();
Map<String, AssembleTitleDto> titleMap = new HashMap<>();
List<AssembleWorkInProcessDto> result = new ArrayList<>();
List<AssembleTitleDto> titleDtos = new ArrayList<>();
List<AssembleTitleDto> titleDtoSort = new ArrayList<>();
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleList(req);
if (resultList != null && resultList.size() > 0) {
Set<String> processNameList = new LinkedHashSet<>();
for (WorkInProcessResultDto ls :resultList){
processNameList.add(ls.getProcessname());
}
List<String> lists = getStringList();
//按照工厂或者线体分组
Map<String, List<WorkInProcessResultDto>> codeMap = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getDimCode));
//按照工序分组
Map<String, List<WorkInProcessResultDto>> map = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcess));
//先循环工厂或者线体
for (Map.Entry<String, List<WorkInProcessResultDto>> entry : codeMap.entrySet()) {
String key = entry.getKey();
AssembleWorkInProcessDto processDto = new AssembleWorkInProcessDto();
processDto.setDimCode(key);
processDto.setTname(entry.getValue().get(0).getTname());
int x = 0;
//再循环工序
for (Map.Entry<String, List<WorkInProcessResultDto>> ent : map.entrySet()) {
List<WorkInProcessResultDto> list = ent.getValue();
String field = lists.get(x);
AssembleTitleDto titleDto = new AssembleTitleDto();
titleDto.setElement(field);
titleDto.setElementName(list.get(0).getProcessname());
titleMap.put(field, titleDto);
for (int i = 0; i < list.size(); i++) {
WorkInProcessResultDto ls = list.get(i);
if (key.equals(ls.getDimCode())) {
try {
processDto.setProcess(ls.getProcess());
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), ls.getTotalnum());
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
} else {
try {
processDto.setProcess(ls.getProcess());
Object ob = ReflectionNameUtil.getGetMethod(processDto, field);
if (ob == null) {
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
x = x + 1;
}
result.add(processDto);
}
//获取菜单列
if (titleMap.size() > 0) {
for (Map.Entry<String, AssembleTitleDto> entry : titleMap.entrySet()) {
titleDtos.add(entry.getValue());
}
}
//查询订单数字段
List<WorkInProcessResultDto> totalNumbers = workInProcessDao.selectTotalNumber(req);
//按照工序名称分组
Map<String, List<WorkInProcessResultDto>> map2 = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcessname));
if (totalNumbers != null && totalNumbers.size() > 0) {
Map<String, List<WorkInProcessResultDto>> totalMap = totalNumbers.stream().collect(groupingBy(WorkInProcessResultDto::getDimCode));
AssembleWorkInProcessDto wp = new AssembleWorkInProcessDto();
for (AssembleWorkInProcessDto aw : result) {
// int tn = totalMap.get(aw.getDimCode()).get(0).getTotalnum();
req.setPline(aw.getDimCode());
int tn = selectAssembleSecondOrderNum(req);
aw.setTotalnum(tn);
Integer num = 0;
for (AssembleTitleDto at : titleDtos) {
String name = at.getElementName();
String element = at.getElement();
try {
Integer ob = (Integer) ReflectionNameUtil.getGetMethod(aw, element);
if ("GR交货数".equals(name) || "报工待入库".equals(name)) {
} else {
num = num + ob;
}
//再循环工序名称
for (Map.Entry<String, List<WorkInProcessResultDto>> et : map2.entrySet()) {
if (name.equals(et.getKey())) {
Integer number = et.getValue().stream().mapToInt(WorkInProcessResultDto::getTotalnum).sum();
ReflectionNameUtil.setValue(wp, wp.getClass(), element, AssembleWorkInProcessDto.class.getDeclaredField(element).getType(), number);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
aw.setWaitNumber(tn - num);
}
for (String pl:processNameList){
for (AssembleTitleDto tl:titleDtos){
if(pl.equals(tl.getElementName())){
titleDtoSort.add(tl);
}
}
}
result.sort(Comparator.comparing(AssembleWorkInProcessDto ::getDimCode));
wp.setWaitNumber(result.stream().mapToInt(AssembleWorkInProcessDto::getWaitNumber).sum());
wp.setTotalnum(result.stream().mapToInt(AssembleWorkInProcessDto::getTotalnum).sum());
wp.setTname("汇总");
result.add(0, wp);
AssembleTitleDto cateDtoa = new AssembleTitleDto();
cateDtoa.setElementName("待投数(有WIP的订单)");
cateDtoa.setElement("waitNumber");
titleDtoSort.add(cateDtoa);
AssembleTitleDto cateDtob = new AssembleTitleDto();
cateDtob.setElementName("订单数量(有WIP的订单)");
cateDtob.setElement("totalnum");
titleDtoSort.add(cateDtob);
}
}
AssembleTitleDto cateDto = new AssembleTitleDto();
cateDto.setElementName("分类");
cateDto.setElement("tname");
titleDtoSort.add(0, cateDto);
AssembleTitleDto titleDto1 = new AssembleTitleDto();
titleDto1.setElementName("分类编码");
titleDto1.setElement("dimCode");
AssembleTitleDto titleDto2 = new AssembleTitleDto();
titleDto2.setElementName("工序编码");
titleDto2.setElement("process");
titleDtoSort.add(titleDto1);
titleDtoSort.add(titleDto2);
resultMap.put("resultList", result);
resultMap.put("titleList", titleDtoSort);
Map<String, Object> resp = new HashMap<>(16);
resp.put("DataList", titleDtoSort);
resp.put("restList", result);
String key = UUID.randomUUID().toString();
Map<String, String> map = new LinkedHashMap<>();
map.put("cumulativeDate", "日期");
andonDataAnalyseKanbanService.saveAndGetValueByRedis(key, JSONObject.toJSONString(map) + "&" + JSONArray.toJSONString(resp));
resultMap.put("keyOne", key);
return resultMap;
}
public List<String> getStringList() {
List<String> list = new LinkedList<>();
list.add("oneNum");
list.add("twoNum");
list.add("threeNum");
list.add("fourNum");
list.add("fiveNum");
list.add("sixNum");
list.add("sevenNum");
list.add("eightNum");
list.add("nineNum");
list.add("tenNum");
list.add("elevenNum");
list.add("twelveNum");
list.add("thirteenNum");
list.add("fourteenNum");
list.add("fifteenNum");
list.add("sixteenNum");
list.add("seventeenNum");
list.add("eighteenNum");
list.add("nineteenNum");
list.add("twentyNum");
list.add("twentyOneNum");
list.add("twentyTwoNum");
list.add("twentyThree");
list.add("twentyFour");
list.add("twentyFIve");
list.add("twentySix");
list.add("twentySeven");
list.add("twentyEight");
list.add("twentyNine");
list.add("twentyTen");
list.add("ThirtyOne");
list.add("ThirtyTwo");
list.add("ThirtyThree");
list.add("ThirtyFour");
list.add("ThirtyFive");
return list;
}
/**
* 查询组装信息二级下钻列表"
*
* @param req
* @return
*/
@Override
public Map<String, Object> selectAssembleSecondList(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
Map<String, Object> resultMap = new HashMap<>();
Map<String, AssembleTitleDto> titleMap = new HashMap<>();
List<AssembleWorkInProcessDto> result = new ArrayList<>();
List<AssembleTitleDto> titleDtos = new ArrayList<>();
List<AssembleTitleDto> titleDtoSort = new ArrayList<>();
if ("分类".equals(req.getProcessname())) {
req.setProcessname("");
}
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleSecondList(req);
if (resultList != null && resultList.size() > 0) {
Set<String> processNameList = new LinkedHashSet<>();
for (WorkInProcessResultDto ls :resultList){
processNameList.add(ls.getProcessname());
}
List<String> lists = getStringList();
//按照工厂或者线体分组
Map<String, List<WorkInProcessResultDto>> codeMap = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getAufnr));
//按照工序分组
Map<String, List<WorkInProcessResultDto>> map = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcess));
//先循环工厂或者线体
for (Map.Entry<String, List<WorkInProcessResultDto>> entry : codeMap.entrySet()) {
String key = entry.getKey();
List<WorkInProcessResultDto> valueList = entry.getValue();
AssembleWorkInProcessDto processDto = new AssembleWorkInProcessDto();
processDto.setOrderNumber(key);
processDto.setPsStartTime(valueList.get(0).getPsStartTime());
processDto.setWorkLine(valueList.get(0).getPline());
int x = 0;
//再循环工序
for (Map.Entry<String, List<WorkInProcessResultDto>> ent : map.entrySet()) {
List<WorkInProcessResultDto> list = ent.getValue();
String field = lists.get(x);
AssembleTitleDto titleDto = new AssembleTitleDto();
titleDto.setElement(field);
titleDto.setElementName(list.get(0).getProcessname());
titleMap.put(field, titleDto);
for (int i = 0; i < list.size(); i++) {
WorkInProcessResultDto ls = list.get(i);
if (key.equals(ls.getAufnr())) {
try {
processDto.setProcess(ls.getProcess());
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), ls.getTotalnum());
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
} else {
try {
processDto.setProcess(ls.getProcess());
Object ob = ReflectionNameUtil.getGetMethod(processDto, field);
if (ob == null) {
ReflectionNameUtil.setValue(processDto, processDto.getClass(), field, AssembleWorkInProcessDto.class.getDeclaredField(field).getType(), 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
x = x + 1;
}
result.add(processDto);
}
//获取菜单列
if (titleMap.size() > 0) {
for (Map.Entry<String, AssembleTitleDto> entry : titleMap.entrySet()) {
titleDtos.add(entry.getValue());
}
}
//按照工序名称分组
Map<String, List<WorkInProcessResultDto>> map2 = resultList.stream().collect(groupingBy(WorkInProcessResultDto::getProcessname));
AssembleWorkInProcessDto wp = new AssembleWorkInProcessDto();
for (AssembleWorkInProcessDto aw : result) {
req.setAufnr(aw.getOrderNumber());
//查询订单数字段
Integer tn = workInProcessDao.selectTotalNumberByOrderNumber(req);
if (tn == null) {
tn = 0;
}
aw.setTotalnum(tn);
Integer num = 0;
for (AssembleTitleDto at : titleDtos) {
String name = at.getElementName();
String element = at.getElement();
try {
Integer ob = (Integer) ReflectionNameUtil.getGetMethod(aw, element);
if ("GR交货数".equals(name) || "报工待入库".equals(name)) {
} else {
num = num + ob;
}
//再循环工序名称
for (Map.Entry<String, List<WorkInProcessResultDto>> et : map2.entrySet()) {
if (name.equals(et.getKey())) {
Integer number = et.getValue().stream().mapToInt(WorkInProcessResultDto::getTotalnum).sum();
ReflectionNameUtil.setValue(wp, wp.getClass(), element, AssembleWorkInProcessDto.class.getDeclaredField(element).getType(), number);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
aw.setWaitNumber(tn - num);
}
for (String pl:processNameList){
for (AssembleTitleDto tl:titleDtos){
if(pl.equals(tl.getElementName())){
titleDtoSort.add(tl);
}
}
}
result.sort(Comparator.comparing(AssembleWorkInProcessDto::getOrderNumber));
wp.setWaitNumber(result.stream().mapToInt(AssembleWorkInProcessDto::getWaitNumber).sum());
wp.setTotalnum(result.stream().mapToInt(AssembleWorkInProcessDto::getTotalnum).sum());
wp.setOrderNumber("汇总");
result.add(0, wp);
AssembleTitleDto cateDtoa = new AssembleTitleDto();
cateDtoa.setElementName("待投数(有WIP的订单)");
cateDtoa.setElement("waitNumber");
titleDtoSort.add(cateDtoa);
AssembleTitleDto cateDtob = new AssembleTitleDto();
cateDtob.setElementName("订单数量(有WIP的订单)");
cateDtob.setElement("totalnum");
titleDtoSort.add(cateDtob);
}
AssembleTitleDto cateDto01 = new AssembleTitleDto();
cateDto01.setElementName("产线");
cateDto01.setElement("workLine");
titleDtoSort.add(0, cateDto01);
AssembleTitleDto cateDto02 = new AssembleTitleDto();
cateDto02.setElementName("排程开始时间");
cateDto02.setElement("psStartTime");
titleDtoSort.add(0, cateDto02);
AssembleTitleDto cateDto = new AssembleTitleDto();
cateDto.setElementName("订单号");
cateDto.setElement("orderNumber");
titleDtoSort.add(0, cateDto);
AssembleTitleDto titleDto2 = new AssembleTitleDto();
titleDto2.setElementName("工序编码");
titleDto2.setElement("process");
titleDtoSort.add(titleDto2);
resultMap.put("resultList", result);
resultMap.put("titleList", titleDtoSort);
Map<String, Object> resp = new HashMap<>(16);
resp.put("DataList", titleDtoSort);
resp.put("restList", result);
String key = UUID.randomUUID().toString();
Map<String, String> map = new LinkedHashMap<>();
map.put("cumulativeDate", "日期");
andonDataAnalyseKanbanService.saveAndGetValueByRedis(key, JSONObject.toJSONString(map) + "&" + JSONArray.toJSONString(resp));
resultMap.put("keyTwo", key);
return resultMap;
}
/**
* 查询组装信息三级下钻列表"
*
* @param req
* @return
*/
@Override
public QueryResult<WorkInProcessResultDto> selectAssembleThirdList(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
if ("订单号".equals(req.getProcessname())) {
if("gx".equals(req.getTwoName())){
req.setProcessname("");
}else {
req.setProcessname(req.getTwoName());
}
}
PageHelper.startPage(req.getTpageNum(), req.getTnumPerPage());
Page<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleThirdList(req);
return PaginationHelp.parseDTOPage(resultList);
}
/**
* 查询组装信息三级下钻列表"
*
* @param req
* @return
*/
@Override
public List<WorkInProcessResultDto> selectAssembleThirdListAll(WorkInProcessDto req) {
List<String> orderNos = StringUtils.isEmpty(req.getOrderNum()) ? null : Arrays.asList(req.getOrderNum().split("\n"));
req.setOrderNos(orderNos);
if ("订单号".equals(req.getProcessname())) {
req.setProcessname("");
}
List<WorkInProcessResultDto> resultList = workInProcessDao.selectAssembleThirdList(req);
return resultList;
}
private List<WorkInProcessV4Dto> getV4(List<WorkInProcessV3Dto> baseList ){
return workInProcessDao.getSmtWitList(baseList);
}
class Task<T> implements Callable<T> {
private Object object;
private Object[] args;
private String methodName;
public Task(Object object, String methodName, Object[] args) {
this.object = object;
this.args = args;
this.methodName = methodName;
}
@Override
public T call() throws Exception {
Method method = object.getClass().getMethod(methodName);
return (T) method.invoke(object, args);
}
}
public List<WorkInProcessV4Dto> method1() {
List<WorkInProcessV4Dto> smtWitList = null;
try {
smtWitList = workInProcessDao.getSmtWitList(this.baseList);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
return smtWitList;
}
public List<WorkInProcessV5Dto> method2() {
List<WorkInProcessV5Dto> patchList = null;
try {
patchList = workInProcessDao.getPatchList(this.list,this.baseList);
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
return patchList;
}
private <T> T futureGetProxy(Future<T> future, Class clazz) {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(clazz);
return (T) enhancer.create(clazz, new FutureLazyLoader(future));
}
/**
* 延迟加载类
* @param <T>
*/
class FutureLazyLoader<T> implements LazyLoader {
private Future<T> future;
public FutureLazyLoader(Future<T> future) {
this.future = future;
}
@Override
public Object loadObject() throws Exception {
return future.get();
}
}
private List<WorkInProcessV3Dto> baseList;
private List<WorkInProcessV1Dto> list;
private class GetNumber {
private Map<String, List<WorkInProcessV4Dto>> smtWitMap;
private Map<String, List<WorkInProcessV5Dto>> patchMap;
private Map<String, List<WorkInProcessV6Dto>> waitMap;
private Map<String, List<WorkInProcessV8Dto>> inStorageMap;
private WorkInProcessV3Dto dto;
private Double d1;
private Double d2;
private Double pl;
private Double te;
private Double re;
private Double in;
private Double inNum;
public GetNumber(Map<String, List<WorkInProcessV4Dto>> smtWitMap, Map<String, List<WorkInProcessV5Dto>> patchMap, Map<String, List<WorkInProcessV6Dto>> waitMap, Map<String, List<WorkInProcessV8Dto>> inStorageMap, WorkInProcessV3Dto dto) {
this.smtWitMap = smtWitMap;
this.patchMap = patchMap;
this.waitMap = waitMap;
this.inStorageMap = inStorageMap;
this.dto = dto;
}
public Double getD1() {
return d1;
}
public Double getD2() {
return d2;
}
public Double getPl() {
return pl;
}
public Double getTe() {
return te;
}
public Double getRe() {
return re;
}
public Double getIn() {
return in;
}
public Double getInNum() {
return inNum;
}
public GetNumber invoke() {
try {
d1 = patchMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV5Dto::getDz01num).sum();
} catch (Exception e) {
d1 = 0.0;
}
try {
d2 = patchMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV5Dto::getDz02num).sum();
} catch (Exception e) {
d2 = 0.0;
}
try {
pl = waitMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV6Dto::getWait_plug).sum();
} catch (Exception e) {
pl = 0.0;
}
try {
te = waitMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV6Dto::getWait_test).sum();
} catch (Exception e) {
te = 0.0;
}
try {
re = waitMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV6Dto::getWait_repair).sum();
} catch (Exception e) {
re = 0.0;
}
try {
in = inStorageMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV8Dto::getWait_in_storage).sum();
} catch (Exception e) {
in = 0.0;
}
try {
inNum = smtWitMap.get(dto.getAufnr()).stream().mapToDouble(WorkInProcessV4Dto::getIn_num).sum();
} catch (Exception e) {
inNum = 0.0;
}
return this;
}
}
private class GetDzTime {
private Map<String, List<WorkInProcessV9Dto>> wiMap;
private WorkInProcessV3Dto dto;
private Double dz01_time;
private Double dz02_time;
private Double dz03_time;
private Double dz04_time;
public GetDzTime(Map<String, List<WorkInProcessV9Dto>> wiMap, WorkInProcessV3Dto dto) {
this.wiMap = wiMap;
this.dto = dto;
}
public Double getDz01_time() {
return dz01_time;
}
public Double getDz02_time() {
return dz02_time;
}
public Double getDz03_time() {
return dz03_time;
}
public Double getDz04_time() {
return dz04_time;
}
public GetDzTime invoke() {
try {
dz01_time = wiMap.get(dto.getAufnr()).get(0).getDz01_time();
if(dz01_time == null){
dz01_time = 0.0;
}
} catch (Exception e) {
dz01_time = 0.0;
}
try {
dz02_time = wiMap.get(dto.getAufnr()).get(0).getDz02_time();
if(dz02_time == null){
dz02_time = 0.0;
}
} catch (Exception e) {
dz02_time = 0.0;
}
try {
dz03_time = wiMap.get(dto.getAufnr()).get(0).getDz03_time();
if(dz03_time == null){
dz03_time = 0.0;
}
} catch (Exception e) {
dz03_time = 0.0;
}
try {
dz04_time = wiMap.get(dto.getAufnr()).get(0).getDz04_time();
if(dz04_time == null){
dz04_time = 0.0;
}
} catch (Exception e) {
dz04_time = 0.0;
}
return this;
}
}
}
利用反射和多线程
最新推荐文章于 2024-08-30 19:56:58 发布