|
|
@@ -1,13 +1,17 @@
|
|
|
package com.java110.api.listener.machine;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.java110.api.bmo.machine.IMachineBMO;
|
|
|
import com.java110.api.listener.AbstractServiceApiPlusListener;
|
|
|
import com.java110.core.annotation.Java110Listener;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
+import com.java110.po.machine.MachineAttrPo;
|
|
|
+import com.java110.utils.constant.BusinessTypeConstant;
|
|
|
import com.java110.utils.constant.ServiceCodeMachineConstant;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
+import com.java110.utils.util.BeanConvertUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
|
@@ -20,6 +24,7 @@ public class SaveMachineListener extends AbstractServiceApiPlusListener {
|
|
|
@Autowired
|
|
|
private IMachineBMO machineBMOImpl;
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
|
|
|
//Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
|
|
|
@@ -33,7 +38,8 @@ public class SaveMachineListener extends AbstractServiceApiPlusListener {
|
|
|
Assert.hasKeyAndValue(reqJson, "locationTypeCd", "必填,请选择位置类型");
|
|
|
Assert.hasKeyAndValue(reqJson, "locationObjId", "必填,请填写位置对象ID");
|
|
|
|
|
|
-
|
|
|
+ //属性校验
|
|
|
+ Assert.judgeAttrValue(reqJson);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -42,6 +48,28 @@ public class SaveMachineListener extends AbstractServiceApiPlusListener {
|
|
|
|
|
|
machineBMOImpl.addMachine(reqJson, context);
|
|
|
|
|
|
+ dealMachineAttr(reqJson, context);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void dealMachineAttr(JSONObject paramObj, DataFlowContext context) {
|
|
|
+
|
|
|
+ if (!paramObj.containsKey("attrs")) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray attrs = paramObj.getJSONArray("attrs");
|
|
|
+ if (attrs.size() < 1) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ MachineAttrPo attr = null;
|
|
|
+ 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.setAttrId(((attrIndex + 1) * -1) + "");
|
|
|
+ super.insert(context, attr, BusinessTypeConstant.BUSINESS_TYPE_SAVE_MACHINE);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|