| | |
| | | package com.zy.acs.manager.manager.service.impl; |
| | | |
| | | import com.zy.acs.manager.manager.mapper.AreaMapper; |
| | | import com.zy.acs.manager.manager.entity.Area; |
| | | import com.zy.acs.manager.manager.service.AreaService; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.domain.AreaShapeDto; |
| | | import com.zy.acs.manager.manager.controller.param.MapAreaParam; |
| | | import com.zy.acs.manager.manager.entity.Area; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.mapper.AreaMapper; |
| | | import com.zy.acs.manager.manager.service.AreaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Slf4j |
| | | @Service("areaService") |
| | | public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService { |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveMapArea(MapAreaParam param, Long loginUserId) { |
| | | Date now = new Date(); |
| | | |
| | | Area area = new Area(); |
| | | // major |
| | | if (!Cools.isEmpty(param.getZoneId())) { |
| | | area.setZoneId(Long.parseLong(param.getZoneId())); |
| | | } |
| | | area.setName(param.getName()); |
| | | area.setCode(param.getCode()); |
| | | area.setColor(param.getColor()); |
| | | area.setMaxCount(param.getMaxCount()); |
| | | area.setSpeedLimit(param.getSpeedLimit()); |
| | | area.setPriority(param.getPriority()); |
| | | |
| | | // shape |
| | | AreaShapeDto shapeDto = new AreaShapeDto(); |
| | | shapeDto.setStart(param.getStart()); |
| | | shapeDto.setEnd(param.getEnd()); |
| | | area.setShapeData(JSON.toJSONString(shapeDto)); |
| | | |
| | | // common |
| | | area.setStatus(StatusType.ENABLE.val); |
| | | area.setCreateTime(now); |
| | | area.setCreateBy(loginUserId); |
| | | area.setUpdateTime(now); |
| | | area.setUpdateBy(loginUserId); |
| | | area.setMemo(param.getMemo()); |
| | | if (!this.save(area)) { |
| | | log.error("failed to save area"); |
| | | } |
| | | } |
| | | |
| | | } |