wuxw 1 год назад
Родитель
Сommit
c10c902224

+ 94 - 0
service-user/src/main/java/com/java110/user/cmd/owner/AppDeleteMemberCarCmd.java

@@ -0,0 +1,94 @@
+package com.java110.user.cmd.owner;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.intf.user.*;
+import com.java110.po.car.OwnerCarPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+@Java110Cmd(serviceCode = "owner.appDeleteMemberCar")
+public class AppDeleteMemberCarCmd extends Cmd {
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarV1InnerServiceSMO ownerCarV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        String userId = context.getReqHeaders().get("user-id");
+
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+
+        if (ListUtil.isNull(ownerAppUserDtos)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        String memberId = "";
+        for (OwnerAppUserDto tmpOwnerAppUserDto : ownerAppUserDtos) {
+            if ("-1".equals(tmpOwnerAppUserDto.getMemberId())) {
+                continue;
+            }
+            memberId = tmpOwnerAppUserDto.getMemberId();
+        }
+
+        if (StringUtil.isEmpty(memberId)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        OwnerDto ownerDto = new OwnerDto();
+        ownerDto.setCommunityId(reqJson.getString("communityId"));
+        ownerDto.setMemberId(memberId);
+        List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
+
+        Assert.listOnlyOne(ownerDtos, "业主不存在");
+
+        reqJson.put("ownerId", ownerDtos.get(0).getOwnerId());
+        Assert.jsonObjectHaveKey(reqJson, "carMemberId", "请求报文中未包含carMemberId");
+        Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId");
+
+
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setMemberId(reqJson.getString("carMemberId"));
+        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
+        ownerCarDto.setOwnerId(reqJson.getString("ownerId"));
+        ownerCarDto.setCarTypeCds(new String[]{OwnerCarDto.CAR_TYPE_PRIMARY, OwnerCarDto.CAR_TYPE_MEMBER}); // 临时车除外
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+
+        Assert.listOnlyOne(ownerCarDtos, "当前未找到需要删除车辆");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        OwnerCarPo ownerCarPo = new OwnerCarPo();
+        ownerCarPo.setCommunityId(reqJson.getString("communityId"));
+        ownerCarPo.setMemberId(reqJson.getString("carMemberId"));
+        int flag = ownerCarV1InnerServiceSMOImpl.deleteOwnerCar(ownerCarPo);
+        if (flag < 1) {
+            throw new IllegalArgumentException("删除车辆出错");
+        }
+    }
+}

+ 149 - 0
service-user/src/main/java/com/java110/user/cmd/owner/AppEditSelfCarNumCmd.java

@@ -0,0 +1,149 @@
+package com.java110.user.cmd.owner;
+
+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.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.IotDataDto;
+import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.intf.job.IIotInnerServiceSMO;
+import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
+import com.java110.po.car.OwnerCarPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 业主自己修改车牌号
+ */
+@Java110Cmd(serviceCode = "owner.appEditSelfCarNum")
+public class AppEditSelfCarNumCmd extends Cmd {
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Autowired
+    private IIotInnerServiceSMO iotInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarV1InnerServiceSMO ownerCarV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        Assert.hasKeyAndValue(reqJson, "carId", "未包含carId");
+        Assert.hasKeyAndValue(reqJson, "carNum", "未包含carNum");
+        Assert.hasKeyAndValue(reqJson, "newCarNum", "未包含newCarNum");
+        Assert.hasKeyAndValue(reqJson, "communityId", "未包含communityId");
+
+        String userId = context.getReqHeaders().get("user-id");
+
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
+        ownerAppUserDto.setMemberId(reqJson.getString("memberId"));
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+
+        if (ListUtil.isNull(ownerAppUserDtos)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        String memberId = "";
+        for (OwnerAppUserDto tmpOwnerAppUserDto : ownerAppUserDtos) {
+            if ("-1".equals(tmpOwnerAppUserDto.getMemberId())) {
+                continue;
+            }
+            memberId = tmpOwnerAppUserDto.getMemberId();
+        }
+
+        if (StringUtil.isEmpty(memberId)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        OwnerDto ownerDto = new OwnerDto();
+        ownerDto.setCommunityId(reqJson.getString("communityId"));
+        ownerDto.setMemberId(memberId);
+        List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
+
+        Assert.listOnlyOne(ownerDtos, "业主不存在");
+
+        reqJson.put("ownerId", ownerDtos.get(0).getOwnerId());
+    }
+
+    @Override
+    @Java110Transactional
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCarId(reqJson.getString("carId"));
+        ownerCarDto.setOwnerId(reqJson.getString("ownerId"));
+        ownerCarDto.setCarNum(reqJson.getString("carNum"));
+
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+
+        if (ListUtil.isNull(ownerCarDtos)) {
+            throw new CmdException("车辆不存在");
+        }
+
+        //todo 校验车辆是否场外
+        if (hasInParkingArea(ownerCarDtos.get(0).getCarNum(), ownerCarDtos.get(0).getAreaNum(), ownerCarDtos.get(0).getCommunityId())) {
+            throw new CmdException(ownerCarDtos.get(0).getCarNum() + "车在场,请先出场");
+        }
+        //todo 校验新车辆是否场外
+        if (hasInParkingArea(reqJson.getString("newCarNum"), ownerCarDtos.get(0).getAreaNum(), ownerCarDtos.get(0).getCommunityId())) {
+            throw new CmdException(ownerCarDtos.get(0).getCarNum() + "车在场,请先出场");
+        }
+
+        OwnerCarPo ownerCarPo = new OwnerCarPo();
+        ownerCarPo.setMemberId(ownerCarDtos.get(0).getMemberId());
+        ownerCarPo.setCarId(ownerCarDtos.get(0).getCarId());
+        ownerCarPo.setCarNum(reqJson.getString("newCarNum"));
+        ownerCarPo.setCommunityId(reqJson.getString("communityId"));
+
+
+        ownerCarV1InnerServiceSMOImpl.updateOwnerCar(ownerCarPo);
+
+    }
+
+    private boolean hasInParkingArea(String carNum, String areaNum, String communityId) {
+
+        JSONObject paramIn = new JSONObject();
+        paramIn.put("communityId", communityId);
+        paramIn.put("page", 1);
+        paramIn.put("row", 1);
+        paramIn.put("paNum", areaNum);
+
+        ResultVo resultVo = iotInnerServiceSMOImpl.postIotData(new IotDataDto("listCarInParkingAreaBmoImpl", paramIn));
+
+        if (resultVo.getCode() != ResultVo.CODE_OK) {
+            return true;
+        }
+
+        JSONArray data = (JSONArray) resultVo.getData();
+
+        if (ListUtil.isNull(data)) {
+            return false;
+        }
+
+        return true;
+    }
+}

+ 123 - 0
service-user/src/main/java/com/java110/user/cmd/owner/AppSaveMemberCarCmd.java

@@ -0,0 +1,123 @@
+package com.java110.user.cmd.owner;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.owner.OwnerAppUserDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
+import com.java110.po.car.OwnerCarPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.*;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.List;
+
+@Java110Cmd(serviceCode = "owner.appSaveMemberCar")
+public class AppSaveMemberCarCmd extends Cmd {
+
+    @Autowired
+    private IOwnerAppUserInnerServiceSMO ownerAppUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarV1InnerServiceSMO ownerCarV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        String userId = context.getReqHeaders().get("user-id");
+
+        OwnerAppUserDto ownerAppUserDto = new OwnerAppUserDto();
+        ownerAppUserDto.setUserId(userId);
+        ownerAppUserDto.setCommunityId(reqJson.getString("communityId"));
+        ownerAppUserDto.setMemberId(reqJson.getString("memberId"));
+        List<OwnerAppUserDto> ownerAppUserDtos = ownerAppUserInnerServiceSMOImpl.queryOwnerAppUsers(ownerAppUserDto);
+
+        if (ListUtil.isNull(ownerAppUserDtos)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        String memberId = "";
+        for (OwnerAppUserDto tmpOwnerAppUserDto : ownerAppUserDtos) {
+            if ("-1".equals(tmpOwnerAppUserDto.getMemberId())) {
+                continue;
+            }
+            memberId = tmpOwnerAppUserDto.getMemberId();
+        }
+
+        if (StringUtil.isEmpty(memberId)) {
+            throw new CmdException("未绑定业主");
+        }
+
+        OwnerDto ownerDto = new OwnerDto();
+        ownerDto.setCommunityId(reqJson.getString("communityId"));
+        ownerDto.setMemberId(memberId);
+        List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto);
+
+        Assert.listOnlyOne(ownerDtos, "业主不存在");
+
+        reqJson.put("ownerId", ownerDtos.get(0).getOwnerId());
+
+        Assert.jsonObjectHaveKey(reqJson, "communityId", "未包含小区ID");
+        Assert.jsonObjectHaveKey(reqJson, "carId", "请求报文中未包含carId");
+        Assert.jsonObjectHaveKey(reqJson, "carNum", "请求报文中未包含carNum");
+        Assert.jsonObjectHaveKey(reqJson, "carBrand", "请求报文中未包含carBrand");
+        Assert.jsonObjectHaveKey(reqJson, "carColor", "未包含carColor");
+
+        //校验车牌号是否存在
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
+        ownerCarDto.setCarNum(reqJson.getString("carNum"));
+        ownerCarDto.setCarTypeCds(new String[]{OwnerCarDto.CAR_TYPE_PRIMARY, OwnerCarDto.CAR_TYPE_MEMBER}); // 临时车除外
+        int count = ownerCarInnerServiceSMOImpl.queryOwnerCarsCount(ownerCarDto);
+
+        if (count > 0) {
+            throw new IllegalArgumentException("车辆已存在");
+        }
+    }
+
+    @Override
+    @Java110Transactional
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        //校验车牌号是否存在
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
+        ownerCarDto.setCarTypeCd("1001"); //业主车辆
+        ownerCarDto.setCarId(reqJson.getString("carId"));
+        ownerCarDto.setOwnerId(reqJson.getString("ownerId"));
+        ownerCarDto.setStatusCd("0");
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+        if (ListUtil.isNull(ownerCarDtos)) {
+            throw new IllegalArgumentException("主车辆不存在");
+        }
+
+        JSONObject tmpOwnerCar = JSONObject.parseObject(JSONObject.toJSONString(ownerCarDtos.get(0)));
+        tmpOwnerCar.putAll(reqJson);
+        tmpOwnerCar.put("startTime", DateUtil.getFormatTimeString(ownerCarDtos.get(0).getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
+        tmpOwnerCar.put("endTime", DateUtil.getFormatTimeString(ownerCarDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
+        tmpOwnerCar.put("memberId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_carId));
+
+        OwnerCarPo ownerCarPo = BeanConvertUtil.covertBean(tmpOwnerCar, OwnerCarPo.class);
+        ownerCarPo.setState(OwnerCarDto.STATE_NORMAL);
+        ownerCarPo.setCarTypeCd(OwnerCarDto.CAR_TYPE_MEMBER);
+        int flag = ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo);
+        if (flag < 1) {
+            throw new CmdException("保存车辆属性失败");
+        }
+    }
+}

+ 2 - 1
service-user/src/main/java/com/java110/user/cmd/owner/SaveOwnerCarMemberCmd.java

@@ -16,6 +16,7 @@ import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.utils.util.DateUtil;
 import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
 import java.util.List;
 import java.util.List;
@@ -65,7 +66,7 @@ public class SaveOwnerCarMemberCmd extends Cmd {
         ownerCarDto.setCarId(reqJson.getString("carId"));
         ownerCarDto.setCarId(reqJson.getString("carId"));
         ownerCarDto.setStatusCd("0");
         ownerCarDto.setStatusCd("0");
         List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
         List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-        if (ownerCarDtos.isEmpty() || ownerCarDtos.size() == 0) {
+        if (ListUtil.isNull(ownerCarDtos)) {
             throw new IllegalArgumentException("主车辆不存在");
             throw new IllegalArgumentException("主车辆不存在");
         }
         }