| | |
| | | */ |
| | | package com.java110.community.cmd.dataPrivilegeUnit; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.intf.community.IDataPrivilegeUnitV1InnerServiceSMO; |
| | | import com.java110.po.dataPrivilegeUnit.DataPrivilegeUnitPo; |
| | | import com.java110.po.privilege.DataPrivilegeUnitPo; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) { |
| | | Assert.hasKeyAndValue(reqJson, "dpId", "请求报文中未包含dpId"); |
| | | Assert.hasKeyAndValue(reqJson, "floorNum", "请求报文中未包含floorNum"); |
| | | Assert.hasKeyAndValue(reqJson, "floorId", "请求报文中未包含floorId"); |
| | | Assert.hasKeyAndValue(reqJson, "unitNum", "请求报文中未包含unitNum"); |
| | | Assert.hasKeyAndValue(reqJson, "unitId", "请求报文中未包含unitId"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId"); |
| | | |
| | | Assert.hasKey(reqJson,"units","不包含单元"); |
| | | |
| | | } |
| | | |
| | |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | |
| | | DataPrivilegeUnitPo dataPrivilegeUnitPo = BeanConvertUtil.covertBean(reqJson, DataPrivilegeUnitPo.class); |
| | | dataPrivilegeUnitPo.setDpUnitId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = dataPrivilegeUnitV1InnerServiceSMOImpl.saveDataPrivilegeUnit(dataPrivilegeUnitPo); |
| | | DataPrivilegeUnitPo dataPrivilegeUnitPo = BeanConvertUtil.covertBean(reqJson, DataPrivilegeUnitPo.class); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | JSONArray units = reqJson.getJSONArray("units"); |
| | | |
| | | for(int unitIndex = 0 ; unitIndex < units.size(); unitIndex++) { |
| | | dataPrivilegeUnitPo.setDpUnitId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | dataPrivilegeUnitPo.setUnitId(units.getJSONObject(unitIndex).getString("unitId")); |
| | | dataPrivilegeUnitPo.setUnitNum(units.getJSONObject(unitIndex).getString("unitNum")); |
| | | dataPrivilegeUnitPo.setFloorId(units.getJSONObject(unitIndex).getString("floorId")); |
| | | dataPrivilegeUnitPo.setFloorNum(units.getJSONObject(unitIndex).getString("floorNum")); |
| | | int flag = dataPrivilegeUnitV1InnerServiceSMOImpl.saveDataPrivilegeUnit(dataPrivilegeUnitPo); |
| | | |
| | | if (flag < 1) { |
| | | throw new CmdException("保存数据失败"); |
| | | } |
| | | } |
| | | |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.success()); |