| | |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | 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.StringUtil; |
| | | import com.java110.utils.util.*; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 |
| | | */ |
| | | @Java110Cmd(serviceCode = "owner.editOwnerCar") |
| | | public class EditOwnerCarCmd extends AbstractServiceCmdListener { |
| | | public class EditOwnerCarCmd extends Cmd { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(EditOwnerCarCmd.class); |
| | | |
| | |
| | | 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")); |
| | | ownerCarDto.setCarId(reqJson.getString("carId")); |
| | | List<OwnerCarDto> ownerCarDtos = ownerCarV1InnerServiceSMOImpl.queryOwnerCars(ownerCarDto); |
| | | |
| | | Assert.listOnlyOne(ownerCarDtos, "未找到车辆信息"); |
| | |
| | | if (StringUtil.isEmpty(psId) || "-1".equals(psId)) { |
| | | throw new IllegalArgumentException("车位已经被释放,不允许修改车辆信息"); |
| | | } |
| | | if (!reqJson.containsKey("leaseType")) { |
| | | reqJson.put("leaseType", OwnerCarDto.LEASE_TYPE_MONTH); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | // 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); |
| | | ownerCarPo.setMemberId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID)); |
| | | int flag = ownerCarV1InnerServiceSMOImpl.updateOwnerCar(ownerCarPo); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | } |