| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.chinaztt.mes.plan.state.masterproductionschedule.MasterProductionScheduleStateMachineConfig; |
| | | import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleEvents; |
| | | import com.chinaztt.mes.plan.state.masterproductionschedule.constant.MasterProductionScheduleStates; |
| | | import com.chinaztt.mes.technology.dto.BomDTO; |
| | | import com.chinaztt.mes.technology.dto.StructureTree; |
| | | import com.chinaztt.mes.technology.entity.Document; |
| | | import com.chinaztt.mes.technology.entity.JoinDocumentBomRouting; |
| | | import com.chinaztt.mes.technology.entity.Routing; |
| | | import com.chinaztt.mes.technology.entity.Structure; |
| | | import com.chinaztt.mes.technology.mapper.DocumentMapper; |
| | | import com.chinaztt.mes.technology.mapper.RoutingMapper; |
| | | import com.chinaztt.mes.technology.mapper.StructureMapper; |
| | | import com.chinaztt.mes.technology.mapper.*; |
| | | import com.chinaztt.mes.technology.service.BomService; |
| | | import com.chinaztt.mes.technology.service.DocumentService; |
| | | import com.chinaztt.mes.technology.state.document.constant.DocumentStates; |
| | | import com.chinaztt.ztt.admin.api.vo.TreeUtil; |
| | |
| | | private StateMachineFactory<MasterProductionScheduleStates, MasterProductionScheduleEvents> masterproductionscheduleStateMachineFactory; |
| | | private StateMachinePersister<MasterProductionScheduleStates, MasterProductionScheduleEvents, MasterProductionSchedule> persister; |
| | | private MoStructureComponentMapper moStructureComponentMapper; |
| | | private JoinDocumentBomRoutingMapper joinDocumentBomRoutingMapper; |
| | | private BomComponentMapper bomComponentMapper; |
| | | private BomService bomService; |
| | | private ProcurementPlanMapper procurementPlanMapper; |
| | | private RawMaterialMapper rawMaterialMapper; |
| | | |
| | | |
| | | @Override |
| | | public IPage<List<MasterProductionScheduleDTO>> getMasterProductionSchedulePage(Page page, QueryWrapper<MasterProductionScheduleDTO> masterProductionScheduleDTO) { |
| | |
| | | @Override |
| | | public boolean addPlanPurchasing(List<MasterProductionSchedule>masterProductionSchedules) { |
| | | masterProductionSchedules.forEach(p->{ |
| | | System.out.println("----------------->"+p); |
| | | Long technologyDocumentId = p.getTechnologyDocumentId(); |
| | | Document document = documentMapper.selectById(technologyDocumentId); |
| | | Long firstPart = document.getPartId(); |
| | | JoinDocumentBomRouting joinDocumentBomRouting = joinDocumentBomRoutingMapper.selectOne(new QueryWrapper<JoinDocumentBomRouting>().lambda() |
| | | .eq(JoinDocumentBomRouting::getDocumentId, document.getId()).eq(JoinDocumentBomRouting::getPartId, firstPart)); |
| | | BomDTO bomDtoById = bomService.getBomDtoById(joinDocumentBomRouting.getBomId()); |
| | | StructureTree tree = bomDtoById.getTree(); |
| | | BigDecimal total=p.getQtyRequired().multiply(tree.getOriginalQpa()); |
| | | List<MoStructureComponent> moStructureComponents = moStructureComponentMapper.selectList(new QueryWrapper<MoStructureComponent>().lambda().eq(MoStructureComponent::getPlanManufacturingOrderId, p.getId())); |
| | | moStructureComponents.forEach(m->{ |
| | | Part part = partMapper.selectById(m.getPartId()); |
| | | String url="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_INFO_STD&userId=7632&inAttr={\"LOCATION_NO\": \"1019\",\"PART_NO\":"+part.getPartNo()+"}"; |
| | | String body = HttpRequest.get(url).execute().body(); |
| | | JSONObject partInfo = JSONObject.parseObject(body); |
| | | log.info("库存零件==================================>"+partInfo); |
| | | |
| | | }); |
| | | }); |
| | | return false; |
| | |
| | | |
| | | |
| | | |
| | | public void getPlanPurchase(List<StructureTree> children,List<ProcurementPlan> planList,BigDecimal originalQpa,long planId){ |
| | | children.forEach(l->{ |
| | | String url="http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_INFO_STD&userId=7632&inAttr={\"LOCATION_NO\": \"1019\",\"PART_NO\":"+l.getPartNo()+"}"; |
| | | String body = HttpRequest.get(url).execute().body(); |
| | | JSONObject result = JSONObject.parseObject(body); |
| | | log.info("库存零件==================================>"+result); |
| | | JSONArray listInfo = result.getJSONArray("LIST_INFO"); |
| | | listInfo.forEach(i->{ |
| | | JSONObject data = JSONObject.parseObject(i.toString()); |
| | | //Ifs当前零件库存数量 |
| | | BigDecimal qtyOnhand = data.getBigDecimal("QTY_ONHAND"); |
| | | //需要生产多少数量 |
| | | BigDecimal multiply = l.getOriginalQpa().multiply(originalQpa); |
| | | BigDecimal subtract = qtyOnhand.subtract(multiply); |
| | | |
| | | }); |
| | | |
| | | }); |
| | | } |
| | | |
| | | } |