| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.base.entity.Factory; |
| | | import org.jeecg.modules.base.entity.LineSideWarehouse; |
| | | import org.jeecg.modules.base.entity.Shift; |
| | |
| | | import org.jeecg.modules.base.service.ILineSideWarehouseService; |
| | | import org.jeecg.modules.base.service.IShiftGroupService; |
| | | import org.jeecg.modules.base.service.IShiftService; |
| | | import org.jeecg.modules.lsw.entity.LswMaterial; |
| | | import org.jeecg.modules.lsw.entity.LswMaterialInventory; |
| | | import org.jeecg.modules.lsw.enums.MaterialCategoryEnum; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialInventoryService; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialService; |
| | | import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo; |
| | | import org.jeecg.modules.mes.dto.MesProductionWorkScheduleRequest; |
| | | import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; |
| | |
| | | import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; |
| | | import org.jeecg.modules.mes.entity.MesProductionWorkOrder; |
| | | import org.jeecg.modules.mes.mapper.MesProductionWorkOrderMapper; |
| | | import org.jeecg.modules.mes.utils.CommonUtils; |
| | | import org.jeecg.modules.pms.entity.PmsProcessBillMaterials; |
| | | import org.jeecg.modules.pms.entity.PmsProcessBillMaterialsDetail; |
| | | import org.jeecg.modules.pms.service.IPmsProcessBillMaterialsDetailService; |
| | |
| | | @Autowired |
| | | private IPmsProcessBillMaterialsDetailService pmsProcessBillMaterialsDetailService; |
| | | @Autowired |
| | | private ILswMaterialService lswMaterialService; |
| | | @Autowired |
| | | private ILswMaterialInventoryService lswMaterialInventoryService; |
| | | @Autowired |
| | | private ILineSideWarehouseService lineSideWarehouseService; |
| | |
| | | .eq(ShiftGroup::getFactoryId, request.getFactoryId()) |
| | | .eq(ShiftGroup::getDelFlag, CommonConstant.DEL_FLAG_0)) |
| | | .stream().collect(Collectors.toMap(ShiftGroup::getShiftId, v1 -> v1, (v1, v2) -> v1)); |
| | | if (shiftGroupMap.isEmpty()) { |
| | | throw new JeecgBootException("该产线下未设置班组,无法排产!"); |
| | | } |
| | | Factory factory = factoryService.getById(request.getFactoryId()); |
| | | Map<String, Shift> shiftNameMap = new HashMap<>(); |
| | | List<Shift> shifts = shiftService.list(new LambdaQueryWrapper<Shift>() |
| | |
| | | .limit(ChronoUnit.DAYS.between(startDate, endDate) + 1) |
| | | .collect(Collectors.toList()); |
| | | List<MesProductionWorkOrder> newProductionWorkOrderList = CollectionUtil.newArrayList(); |
| | | String materialNumber = request.getMaterialNumber(); |
| | | BigDecimal planQuantity = request.getPlanQuantity(); |
| | | if (StringUtils.isNotBlank(materialNumber)) { |
| | | LswMaterial material = lswMaterialService.list(new LambdaQueryWrapper<LswMaterial>() |
| | | .eq(LswMaterial::getMaterialNumber, materialNumber) |
| | | .eq(LswMaterial::getDelFlag, CommonConstant.DEL_FLAG_0) |
| | | .eq(LswMaterial::getMaterialStatus, CommonConstant.STATUS_1)) |
| | | .stream().findFirst().orElse(null); |
| | | request.setMaterialName(Objects.requireNonNull(material).getMaterialName()); |
| | | } |
| | | |
| | | for (LocalDate date : dateRange) { |
| | | for (String shiftId : shiftGroupMap.keySet()) { |
| | |
| | | .setShiftName(shiftNameMap.get(shiftId).getShiftName()) |
| | | .setGroupId(shiftGroup.getId()) |
| | | .setGroupName(shiftGroup.getGroupName()) |
| | | .setWorkOrderDate(workOrderDate); |
| | | .setWorkOrderDate(workOrderDate) |
| | | .setMaterialNumber(StringUtils.isNotBlank(materialNumber) ? materialNumber : "") |
| | | .setMaterialName(StringUtils.isNotBlank(materialNumber) ? request.getMaterialName() : "") |
| | | .setPlanQuantity(Objects.nonNull(planQuantity) ? planQuantity : null); |
| | | |
| | | newProductionWorkOrderList.add(mesProductionWorkOrder); |
| | | } |
| | |
| | | MesProductionWorkOrder mesProductionWorkOrder = new MesProductionWorkOrder() |
| | | .setFactoryId(factory.getId()) |
| | | .setFactoryCode(factory.getFactoryCode()) |
| | | .setFactoryName(factory.getFactoryName()); |
| | | .setFactoryName(factory.getFactoryName()) |
| | | .setMaterialNumber(StringUtils.isNotBlank(materialNumber) ? materialNumber : "") |
| | | .setMaterialName(StringUtils.isNotBlank(materialNumber) ? request.getMaterialName() : "") |
| | | .setPlanQuantity(Objects.nonNull(planQuantity) ? planQuantity : null);; |
| | | newProductionWorkOrderList.add(mesProductionWorkOrder); |
| | | } |
| | | return newProductionWorkOrderList; |
| | |
| | | @Override |
| | | public IPage<MesProductionWorkOrder> queryPageList(Page<MesProductionWorkOrder> page, Map<String, String[]> parameterMap) { |
| | | QueryWrapper<MesProductionWorkOrder> queryWrapper = Wrappers.query(); |
| | | |
| | | LoginUser loginUser = CommonUtils.getCurrentUser(); |
| | | if (loginUser == null) { |
| | | return page; |
| | | } |
| | | queryWrapper.exists("select 1 from base_user_factory t where t.user_id = {0} and t.factory_id = t1.factory_id", loginUser.getId()); |
| | | String[] factoryIds = parameterMap.get("factoryId"); |
| | | if (factoryIds != null && factoryIds.length > 0) { |
| | | queryWrapper.eq("t1.factory_id", factoryIds[0]); |
| | | } |
| | | String[] materialNumbers = parameterMap.get("materialNumber"); |
| | | if (materialNumbers != null && materialNumbers.length > 0) { |
| | | queryWrapper.like("t1.material_number", materialNumbers[0]); |
| | | } |
| | | String[] materialNames = parameterMap.get("materialName"); |
| | | if (materialNames != null && materialNames.length > 0) { |
| | | queryWrapper.like("t1.material_name", materialNames[0]); |
| | | } |
| | | String[] workOrderCodes = parameterMap.get("workOrderCode"); |
| | | if (workOrderCodes != null && workOrderCodes.length > 0) { |
| | | queryWrapper.like("t1.work_order_code", workOrderCodes[0]); |
| | | } |
| | | String[] startDates = parameterMap.get("startDate"); |
| | | String[] endDates = parameterMap.get("endDate"); |
| | | if (startDates != null && startDates.length > 0) { |