| | |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.vo.EamEquipmentTree; |
| | | import org.jeecg.modules.eam.vo.EquipmentSearchResult; |
| | | //import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | //import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.system.entity.BaseFactory; |
| | | import org.jeecg.modules.system.entity.EamBaseRepairDepart; |
| | | import org.jeecg.modules.system.service.IBaseFactoryService; |
| | |
| | | equipmentList.forEach(item -> { |
| | | EamEquipmentDto eamEquipmentDto = new EamEquipmentDto(); |
| | | BeanUtils.copyProperties(item,eamEquipmentDto); |
| | | if (eamEquipmentDto.getFactoryOrgCode().length()==12){ |
| | | eamEquipmentDto.setFactoryOrgCode( |
| | | baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getZxfactoryOrgCode()) |
| | | +"/"+baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getGqfactoryOrgCode())+"/"+ |
| | | baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getFactoryOrgCode())); |
| | | }else { |
| | | eamEquipmentDto.setFactoryOrgCode( |
| | | baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getZxfactoryOrgCode()) |
| | | +"/"+ baseFactoryService.factoryDataNameByOrgCode(eamEquipmentDto.getFactoryOrgCode())); |
| | | } |
| | | if (eamEquipmentDto.getEquipmentWeight()!=null){ |
| | | eamEquipmentDto.setEquipmentWeightStr(eamEquipmentDto.getEquipmentWeight().toEngineeringString()); |
| | | } |
| | | eamEquipmentDtos.add(eamEquipmentDto); |
| | | }); |
| | | // Step.3 AutoPoi 导出Excel |
| | |
| | | sb.append(String.format("设备编码[%s]保存失败,无法导入\n\r", eamEquipment.getEquipmentCode())); |
| | | continue; |
| | | } |
| | | EamEquipmentExtend eamEquipmentExtend=new EamEquipmentExtend(); |
| | | BeanUtils.copyProperties(eamEquipmentExtend,equipment); |
| | | eamEquipmentExtendService.save(eamEquipmentExtend); |
| | | } |
| | | log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒"); |
| | | //update-end-author:taoyan date:20190528 for:批量插入数据 |
| | |
| | | @GetMapping(value = "/asyncLoadEquipment") |
| | | public Result<?> asyncLoadEquipment(@RequestParam(name="keyword",required = false) String keyword, |
| | | @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, |
| | | @RequestParam(name="id",required = false) String id) { |
| | | List<EquipmentSearchResult> resultList = eamEquipmentService.asyncLoadEquipment(keyword, pageSize, id); |
| | | return Result.ok(resultList); |
| | | @RequestParam(name="id",required = false) String id, |
| | | @RequestParam(name="factoryOrgCode",required = false) String factoryOrgCode) { |
| | | List<EquipmentSearchResult> resultList = eamEquipmentService.asyncLoadEquipment(keyword, pageSize, id, factoryOrgCode); |
| | | List<JSONObject> items = new ArrayList<>(); |
| | | try { |
| | | for(EquipmentSearchResult vo : resultList) { |
| | | String json = objectMapper.writeValueAsString(vo); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("factoryOrgCode", vo.getFactoryOrgCode(), item, "eam_base_factory,factory_name,org_code"); |
| | | items.add(item); |
| | | } |
| | | return Result.OK(items); |
| | | }catch (Exception e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | } |