| | |
| | | package com.zy.acs.manager.manager.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | 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.core.service.AreaGovernService; |
| | | import com.zy.acs.manager.manager.controller.param.MapAreaParam; |
| | | import com.zy.acs.manager.manager.controller.result.MapAreaResult; |
| | | import com.zy.acs.manager.manager.entity.Area; |
| | | import com.zy.acs.manager.manager.entity.AreaAgv; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.mapper.AreaMapper; |
| | | import com.zy.acs.manager.manager.service.AreaAgvService; |
| | | import com.zy.acs.manager.manager.service.AreaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Service("areaService") |
| | | public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService { |
| | | |
| | | @Autowired |
| | | private AreaGovernService areaGovernService; |
| | | @Autowired |
| | | private AreaAgvService areaAgvService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | area.setMemo(param.getMemo()); |
| | | if (!this.save(area)) { |
| | | log.error("failed to save area"); |
| | | } else { |
| | | // update code list in area map |
| | | areaGovernService.reSet(area); |
| | | } |
| | | |
| | | return area; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public MapAreaResult modifyMapArea(MapAreaParam param, Long loginUserId) { |
| | | Long areaId = param.getId(); |
| | | Area area = this.getById(areaId); |
| | | |
| | | // area - agv |
| | | areaAgvService.remove(new LambdaQueryWrapper<AreaAgv>().eq(AreaAgv::getAreaId, areaId)); |
| | | if (!Cools.isEmpty(param.getAgvIds())) { |
| | | for (Long agvId : param.getAgvIds()) { |
| | | if (null == agvId) { continue; } |
| | | |
| | | if (!areaAgvService.save(new AreaAgv(areaId, agvId))) { |
| | | throw new RuntimeException("failed to save AreaAgv"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | // area |
| | | boolean needModify = false; |
| | | if (!Cools.isEmpty(param.getName()) && !area.getName().equals(param.getName())) { |
| | | area.setName(param.getName()); |
| | | needModify = true; |
| | | } |
| | | |
| | | if (needModify) { |
| | | area.setUpdateTime(new Date()); |
| | | area.setUpdateBy(loginUserId); |
| | | if (!this.updateById(area)) { |
| | | throw new RuntimeException("failed to update Area"); |
| | | } |
| | | } |
| | | |
| | | return new MapAreaResult().sync(area); |
| | | } |
| | | |
| | | @Override |
| | | public void removeMapArea(Long areaId, Long loginUserId) { |
| | | // area - agv |
| | | areaAgvService.remove(new LambdaQueryWrapper<AreaAgv>().eq(AreaAgv::getAreaId, areaId)); |
| | | // cache |
| | | areaGovernService.removeArea(areaId); |
| | | // db |
| | | this.removeById(areaId); |
| | | } |
| | | |
| | | } |