wuxw
2024-12-09 a287637246610731eebc91edb13fd97c72233698
service-user/src/main/java/com/java110/user/cmd/owner/EditOwnerCarCmd.java
@@ -26,10 +26,7 @@
import com.java110.intf.user.IOwnerCarV1InnerServiceSMO;
import com.java110.po.car.OwnerCarPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.utils.util.*;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -66,6 +63,13 @@
        Assert.jsonObjectHaveKey(reqJson, "carType", "请求报文中未包含carType");
        Assert.hasLength(reqJson.getString("communityId"), "小区ID不能为空");
    }
    @Override
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
        OwnerCarDto ownerCarDto = new OwnerCarDto();
        ownerCarDto.setMemberId(reqJson.getString("memberId"));
        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
@@ -79,21 +83,14 @@
        if (StringUtil.isEmpty(psId) || "-1".equals(psId)) {
            throw new IllegalArgumentException("车位已经被释放,不允许修改车辆信息");
        }
    }
    @Override
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
        if (!reqJson.containsKey("leaseType")) {
            reqJson.put("leaseType", OwnerCarDto.LEASE_TYPE_MONTH);
        }
        if (!OwnerCarDto.LEASE_TYPE_MONTH.equals(reqJson.getString("leaseType"))) {
            reqJson.put("startTime", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
            reqJson.put("endTime", "2037-01-01");
        }
//        if (!OwnerCarDto.LEASE_TYPE_MONTH.equals(reqJson.getString("leaseType"))) {
//            reqJson.put("startTime", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
//            reqJson.put("endTime", "2050-01-01");
//        }
        OwnerCarPo ownerCarPo = BeanConvertUtil.covertBean(reqJson, OwnerCarPo.class);
        int flag = ownerCarV1InnerServiceSMOImpl.updateOwnerCar(ownerCarPo);
@@ -101,7 +98,35 @@
        if (flag < 1) {
            throw new CmdException("修改数据失败");
        }
        cmdDataFlowContext.setResponseEntity(ResultVo.success());
        if (OwnerCarDto.CAR_TYPE_MEMBER.equals(ownerCarDtos.get(0).getCarTypeCd())) {
            return;
        }
        ownerCarDto = new OwnerCarDto();
        ownerCarDto.setMemberId(reqJson.getString("memberId"));
        ownerCarDto.setCommunityId(reqJson.getString("communityId"));
        ownerCarDto.setCarId(reqJson.getString("carId"));
        ownerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
        // todo 修改成员车辆的开始时间和结束时间
        OwnerCarDto tmpOwnerCarDto = new OwnerCarDto();
        tmpOwnerCarDto.setCarId(ownerCarDtos.get(0).getCarId());
        tmpOwnerCarDto.setCarTypeCd(OwnerCarDto.CAR_TYPE_MEMBER);
        List<OwnerCarDto> memberOwnerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(tmpOwnerCarDto);
        if (ListUtil.isNull(memberOwnerCarDtos)) {
            return;
        }
        OwnerCarPo memberOwnerCarPo = null;
        for (OwnerCarDto mOwnerCarDto : memberOwnerCarDtos) {
            memberOwnerCarPo = new OwnerCarPo();
            memberOwnerCarPo.setMemberId(mOwnerCarDto.getMemberId());
            memberOwnerCarPo.setStartTime(DateUtil.getFormatTimeStringA(ownerCarDtos.get(0).getStartTime()));
            memberOwnerCarPo.setEndTime(DateUtil.getFormatTimeStringA(ownerCarDtos.get(0).getEndTime()));
            ownerCarV1InnerServiceSMOImpl.updateOwnerCar(memberOwnerCarPo);
        }
    }
}