|
|
|
@ -2,9 +2,11 @@ package org.jeecg.modules.largeScreen.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.jeecg.modules.demo.base.entity.ZyProcess; |
|
|
|
|
import org.jeecg.modules.demo.base.service.IZyProcessService; |
|
|
|
|
import org.jeecg.modules.demo.zyorders.entity.ZyOrders; |
|
|
|
|
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService; |
|
|
|
|
import org.jeecg.modules.device.entity.ZyDevice; |
|
|
|
|
import org.jeecg.modules.device.service.IZyDeviceService; |
|
|
|
|
import org.jeecg.modules.largeScreen.service.ProductionLargeService; |
|
|
|
@ -15,11 +17,16 @@ import org.jeecg.modules.productplan.entity.vo.ZyPlanProcessVo; |
|
|
|
|
import org.jeecg.modules.productplan.service.IZyPlanProcessService; |
|
|
|
|
import org.jeecg.modules.productplan.service.IZyProductPlanService; |
|
|
|
|
import org.jeecg.modules.system.entity.SysDepart; |
|
|
|
|
import org.jeecg.modules.system.entity.SysUser; |
|
|
|
|
import org.jeecg.modules.system.service.ISysDepartService; |
|
|
|
|
import org.jeecg.modules.system.service.ISysUserService; |
|
|
|
|
import org.jeecg.modules.team.entity.Groupx; |
|
|
|
|
import org.jeecg.modules.team.entity.Station; |
|
|
|
|
import org.jeecg.modules.team.service.IGroupxService; |
|
|
|
|
import org.jeecg.modules.team.service.IStationService; |
|
|
|
|
import org.jeecg.modules.workorder.entity.WorkOrder; |
|
|
|
|
import org.jeecg.modules.workorder.service.IWorkOrderService; |
|
|
|
|
import org.jeecg.modules.workorder.vo.WorkOrderVo; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -27,9 +34,8 @@ import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
@ -54,6 +60,15 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
@Autowired |
|
|
|
|
private ISysDepartService iSysDepartService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IWorkOrderService iWorkOrderService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private ISysUserService iSysUserService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IZyOrdersService iZyOrdersService; |
|
|
|
|
|
|
|
|
|
// D00010:智能定制生产吊挂系统
|
|
|
|
|
private static final String DIAOGUA = "D00010"; |
|
|
|
|
|
|
|
|
@ -107,7 +122,7 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
//吊挂编码
|
|
|
|
|
diaoguaData.put("code", diaogua.getCode()); |
|
|
|
|
//负载
|
|
|
|
|
String ratioStr = getRatioStr(productPlanList.size(), diaogua.getVal()); |
|
|
|
|
String ratioStr = getRatioStr(diaogua.getVal(), productPlanList.size()); |
|
|
|
|
diaoguaData.put("ratio", ratioStr); |
|
|
|
|
resultMap.put("diaogua_", diaoguaData); |
|
|
|
|
|
|
|
|
@ -118,7 +133,7 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
//吊挂编码
|
|
|
|
|
caichuangData.put("code", caichuang.getCode()); |
|
|
|
|
//负载
|
|
|
|
|
caichuangData.put("ratio", getRatioStr(productPlanList.size(), caichuang.getVal())); |
|
|
|
|
caichuangData.put("ratio", getRatioStr(caichuang.getVal(), productPlanList.size())); |
|
|
|
|
resultMap.put("caichuang_", caichuangData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -164,6 +179,8 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
|
|
|
|
|
List<Station> stationGroup = iStationService.list(new LambdaQueryWrapper<Station>().groupBy(Station::getDepartId)); |
|
|
|
|
Map<String, Object> shengchanxianMap = new LinkedHashMap<>(); |
|
|
|
|
// Map<String, Object> chanxianxinxiMap = new LinkedHashMap<>();
|
|
|
|
|
List<ProductRecordVo> chanxianxinxiVos = new LinkedList<>(); |
|
|
|
|
if (!ObjectUtils.isEmpty(stationGroup)) { |
|
|
|
|
stationGroup.stream().forEach(station -> { |
|
|
|
|
Map<String, Object> departMap = new LinkedHashMap<>(); |
|
|
|
@ -181,7 +198,6 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
.last("limit 1")); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyPlanProcess)) { |
|
|
|
|
ZyProductPlan productPlan = iZyProductPlanService.getById(zyPlanProcess.getPlanId()); |
|
|
|
|
// Optional.ofNullable(productPlan).orElseThrow(() -> new JeecgBootException("生产计划:" + zyPlanProcess.getPlanId() + "不存在!"));
|
|
|
|
|
ProductRecordVo vo = new ProductRecordVo(); |
|
|
|
|
if (!ObjectUtils.isEmpty(productPlan)) { |
|
|
|
|
vo.setWorkOrder(productPlan.getProductNo()); |
|
|
|
@ -193,14 +209,33 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
vo.setMachineNames(zyPlanProcess.getMachineNames()); |
|
|
|
|
vo.setStationNum(zyPlanProcess.getStationNum()); |
|
|
|
|
vo.setProcessStatus(zyPlanProcess.getStatus()); |
|
|
|
|
ZyPlanProcessVo zyPlanProcessVo = new ZyPlanProcessVo(); |
|
|
|
|
BeanUtils.copyProperties(zyPlanProcess, zyPlanProcessVo); |
|
|
|
|
productRecordVos.add(vo); |
|
|
|
|
|
|
|
|
|
ZyPlanProcessVo chanxianxinxiVo = new ZyPlanProcessVo(); |
|
|
|
|
BeanUtils.copyProperties(vo, chanxianxinxiVo); |
|
|
|
|
ZyProcess zyProcess = iZyProcessService.getById(zyPlanProcess.getProcessId()); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyProcess)) { |
|
|
|
|
zyPlanProcessVo.setImage(zyProcess.getImage()); |
|
|
|
|
Map<String, Object> stationInfoMap = new LinkedHashMap<>(); |
|
|
|
|
stationInfoMap.put("stationNum", chanxianxinxiVo.getStationNum()); |
|
|
|
|
stationInfoMap.put("workOrder", chanxianxinxiVo.getWorkOrder()); |
|
|
|
|
stationInfoMap.put("processCode", zyProcess.getProcessCode()); |
|
|
|
|
stationInfoMap.put("status", chanxianxinxiVo.getProcessStatus()); |
|
|
|
|
stationInfoMap.put("processImage", zyProcess.getImage()); |
|
|
|
|
chanxianxinxiVo.setStationInfo(stationInfoMap); |
|
|
|
|
} |
|
|
|
|
vo.setZyPlanProcessVo(zyPlanProcessVo); |
|
|
|
|
productRecordVos.add(vo); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(zyPlanProcess.getUserIds())) { |
|
|
|
|
String[] userIdsArrs = zyPlanProcess.getUserIds().split(","); |
|
|
|
|
SysUser sysUser = iSysUserService.getById(userIdsArrs[0]); |
|
|
|
|
Map<String, Object> userInfoMap = new LinkedHashMap<>(); |
|
|
|
|
userInfoMap.put("realName", sysUser.getRealname()); |
|
|
|
|
userInfoMap.put("userCode", sysUser.getUsername()); |
|
|
|
|
userInfoMap.put("stationName", chanxianxinxiVo.getStationName()); |
|
|
|
|
userInfoMap.put("status", "工作中"); |
|
|
|
|
chanxianxinxiVo.setUserInfo(userInfoMap); |
|
|
|
|
} |
|
|
|
|
chanxianxinxiVos.add(chanxianxinxiVo); |
|
|
|
|
// vo.setZyPlanProcessVo(zyPlanProcessVo);
|
|
|
|
|
} else { //没有工序返回工位信息
|
|
|
|
|
ProductRecordVo vo = new ProductRecordVo(); |
|
|
|
|
vo.setStationName(obj.getStationName()); |
|
|
|
@ -209,11 +244,84 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
SysDepart depart = iSysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getId, station.getDepartId())); |
|
|
|
|
departMap.put(depart.getDepartName(), productRecordVos); |
|
|
|
|
List<ProductRecordVo> voList = productRecordVos.stream().filter(v -> StringUtils.isNotBlank(v.getTeamName())).collect(Collectors.toList()); |
|
|
|
|
departMap.put(depart.getDepartName() + "#" + voList.get(0).getTeamName(), productRecordVos); |
|
|
|
|
shengchanxianMap.putAll(departMap); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
resultMap.put("shengchanxian_", shengchanxianMap); |
|
|
|
|
//生产线实时状态
|
|
|
|
|
resultMap.put("shengchanxianzhuangtai_", shengchanxianMap); |
|
|
|
|
//产线实时信息
|
|
|
|
|
resultMap.put("chanxianxinxi_", chanxianxinxiVos); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> gongdan_data() { |
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
List<WorkOrderVo> workOrderVoList = new LinkedList<>(); |
|
|
|
|
List<ZyOrders> zyOrdersVoList = new LinkedList<>(); |
|
|
|
|
List<WorkOrder> workOrderList = iWorkOrderService.list(new LambdaQueryWrapper<WorkOrder>().orderByDesc(WorkOrder::getCreateTime).last("limit 20")); |
|
|
|
|
Map<String, Object> workOrderMap = new HashMap<>(); |
|
|
|
|
Optional.ofNullable(workOrderList).orElse(new LinkedList<>()).forEach(workOrder -> { |
|
|
|
|
WorkOrderVo vo = new WorkOrderVo(); |
|
|
|
|
BeanUtils.copyProperties(workOrder, vo); |
|
|
|
|
ZyOrders zyOrders = iZyOrdersService.getById(workOrder.getOrdersId()); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyOrders)) { |
|
|
|
|
// String ordersNum = zyOrders.getOrdersNum();
|
|
|
|
|
// String ordersNum2 = ordersNum.substring(ordersNum.length() - 8);
|
|
|
|
|
// zyOrders.setOrdersNum(ordersNum2);
|
|
|
|
|
//// vo.setOrdersInfo(zyOrders);
|
|
|
|
|
//
|
|
|
|
|
// String productCode = vo.getProductCode();
|
|
|
|
|
// String code = productCode.substring(productCode.length() - 8);
|
|
|
|
|
// vo.setProductCode(code);
|
|
|
|
|
workOrderVoList.add(vo); |
|
|
|
|
SysUser sysUser = iSysUserService.getById(zyOrders.getUserId()); |
|
|
|
|
if (!ObjectUtils.isEmpty(sysUser) && StringUtils.isNotBlank(sysUser.getRealname())) { |
|
|
|
|
zyOrders.setUserId(sysUser.getRealname()); |
|
|
|
|
} |
|
|
|
|
zyOrdersVoList.add(zyOrders); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
//工单列表
|
|
|
|
|
Collections.sort(workOrderVoList, Comparator.comparing(WorkOrderVo::getOrdersId)); |
|
|
|
|
workOrderMap.put("workOrderList_", workOrderVoList); |
|
|
|
|
//订单列表
|
|
|
|
|
Collections.sort(zyOrdersVoList, Comparator.comparing(ZyOrders::getId)); |
|
|
|
|
workOrderMap.put("zyOrdersList_", zyOrdersVoList); |
|
|
|
|
//统计占率比
|
|
|
|
|
List<WorkOrder> workOrderList1 = iWorkOrderService.list(); |
|
|
|
|
if (!ObjectUtils.isEmpty(workOrderList1)) { |
|
|
|
|
// 工单状态值:未排产0、已排产1、生产中2、已完成3、已撤销8、异常9,默认0
|
|
|
|
|
//待生产
|
|
|
|
|
List<WorkOrder> tobeProducedWorkOrders = Optional.ofNullable(workOrderList1).orElse(new LinkedList<>()).stream().filter(b -> !ObjectUtils.isEmpty(b.getWorkOrderStatus()) && b.getWorkOrderStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
//已完成
|
|
|
|
|
List<WorkOrder> doneWorkOrders = Optional.ofNullable(workOrderList1).orElse(new LinkedList<>()).stream().filter(b -> !ObjectUtils.isEmpty(b.getWorkOrderStatus()) && b.getWorkOrderStatus().equals(3)).collect(Collectors.toList()); |
|
|
|
|
if (!ObjectUtils.isEmpty(tobeProducedWorkOrders)) { |
|
|
|
|
resultMap.put("workOrder_tobeDone_ratio_", getRatioStr(tobeProducedWorkOrders.size(), workOrderList1.size())); |
|
|
|
|
} |
|
|
|
|
if (!ObjectUtils.isEmpty(doneWorkOrders)) { |
|
|
|
|
resultMap.put("workOrder_done_ratio_", getRatioStr(doneWorkOrders.size(), workOrderList1.size())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<ZyOrders> zyOrdersList = iZyOrdersService.list(); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyOrdersList)) { |
|
|
|
|
// 订单交付状态值:值:未支付0、已支付1、待生产中2、生产中3、已发货4、已到货5、已签收6、申请撤销8、已撤销9,默认0
|
|
|
|
|
//待生产
|
|
|
|
|
List<ZyOrders> tobeProducedZyOrders = zyOrdersList.stream().filter(b -> !ObjectUtils.isEmpty(b.getDeliveryStatus()) && b.getDeliveryStatus().equals(2)).collect(Collectors.toList()); |
|
|
|
|
if (!ObjectUtils.isEmpty(tobeProducedZyOrders)) { |
|
|
|
|
resultMap.put("zyOrder_tobeDone_ratio_", getRatioStr(tobeProducedZyOrders.size(), zyOrdersList.size())); |
|
|
|
|
} |
|
|
|
|
//已完成
|
|
|
|
|
List<ZyOrders> doneZyOrders = zyOrdersList.stream().filter(c -> !ObjectUtils.isEmpty(c.getDeliveryStatus()) && c.getDeliveryStatus().equals(5)).collect(Collectors.toList()); |
|
|
|
|
if (!ObjectUtils.isEmpty(doneZyOrders)) { |
|
|
|
|
resultMap.put("zyOrder_done_ratio_", getRatioStr(doneZyOrders.size(), zyOrdersList.size())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
resultMap.putAll(workOrderMap); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|