| | |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.community.CommunityLocationDto; |
| | | import com.java110.dto.machine.MachineDto; |
| | | import com.java110.intf.common.IMachineAttrInnerServiceSMO; |
| | | import com.java110.intf.common.IMachineV1InnerServiceSMO; |
| | | import com.java110.intf.community.ICommunityLocationV1InnerServiceSMO; |
| | |
| | | machinePo.setLocationObjId(locationDtos.get(0).getLocationObjId()); |
| | | machinePo.setMachineId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | machinePo.setHeartbeatTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | | machinePo.setState(MachineDto.MACHINE_STATE_ON); |
| | | int flag = machineV1InnerServiceSMOImpl.saveMachine(machinePo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | |
| | | dealMachineAttr(reqJson); |
| | | dealMachineAttr(reqJson,machinePo); |
| | | |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.success()); |
| | | } |
| | | |
| | | private void dealMachineAttr(JSONObject paramObj) { |
| | | private void dealMachineAttr(JSONObject paramObj,MachinePo machinePo) { |
| | | |
| | | if (!paramObj.containsKey("attrs")) { |
| | | return; |
| | |
| | | for (int attrIndex = 0; attrIndex < attrs.size(); attrIndex++) { |
| | | attr = BeanConvertUtil.covertBean(attrs.getJSONObject(attrIndex), MachineAttrPo.class); |
| | | attr.setCommunityId(paramObj.getString("communityId")); |
| | | attr.setMachineId(paramObj.getString("machineId")); |
| | | attr.setMachineId(machinePo.getMachineId()); |
| | | attr.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | flag = machineAttrInnerServiceSMOImpl.saveMachineAttrs(attr); |
| | | if (flag < 1) { |