|
|
@ -29,6 +29,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
|
import com.epmet.dao.CustomerAgencyDao; |
|
|
|
import com.epmet.dao.CustomerGridDao; |
|
|
|
import com.epmet.dao.CustomerStaffGridDao; |
|
|
|
import com.epmet.dto.*; |
|
|
@ -71,6 +72,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
private CustomerStaffGridService customerStaffGridService; |
|
|
|
@Autowired |
|
|
|
private CustomerStaffGridDao customerStaffGridDao; |
|
|
|
@Autowired |
|
|
|
private CustomerAgencyDao customerAgencyDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<CustomerGridDTO> page(Map<String, Object> params) { |
|
|
@ -197,21 +200,22 @@ public class CustomerGridServiceImpl extends BaseServiceImpl<CustomerGridDao, Cu |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<AddGridResultDTO> addGrid(TokenDto tokenDto, AddGridFormDTO addGridFormDTO) { |
|
|
|
//查询是否重名
|
|
|
|
String checkGridName = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null); |
|
|
|
if (checkGridName!=null){ |
|
|
|
return new Result().error(EpmetErrorCode.NOT_ADD_GRID.getCode()); |
|
|
|
} |
|
|
|
//查询地区编码
|
|
|
|
String areaCode = customerAgencyDao.selectAreaCodeByAgencyId(addGridFormDTO.getAgencyId()); |
|
|
|
CustomerGridEntity customerGridEntity = new CustomerGridEntity(); |
|
|
|
customerGridEntity.setCustomerId(baseDao.selectCustomerIdByUserId(tokenDto.getUserId())); |
|
|
|
customerGridEntity.setAreaCode(areaCode); |
|
|
|
customerGridEntity.setCustomerId(baseDao.selectCustomerIdByUserId(tokenDto.getUserId()));//查询customerId
|
|
|
|
customerGridEntity.setGridName(addGridFormDTO.getGridName()); |
|
|
|
customerGridEntity.setDelFlag("0"); |
|
|
|
customerGridEntity.setCreatedBy(tokenDto.getUserId()); |
|
|
|
customerGridEntity.setUpdatedBy(tokenDto.getUserId()); |
|
|
|
customerGridEntity.setTotalUser(0); |
|
|
|
customerGridEntity.setManageDistrict(addGridFormDTO.getManageDistrict()); |
|
|
|
customerGridEntity.setPid(addGridFormDTO.getAgencyId()); |
|
|
|
customerGridEntity.setPids(baseDao.selectPidsByPid(addGridFormDTO.getAgencyId())); |
|
|
|
customerGridEntity.setPids(baseDao.selectPidsByPid(addGridFormDTO.getAgencyId()));//查询所有上级组织id
|
|
|
|
baseDao.insert(customerGridEntity); |
|
|
|
//查询刚刚添加的gridId
|
|
|
|
String gridId = baseDao.selectGridIdByGridName(addGridFormDTO.getGridName(),addGridFormDTO.getAgencyId(),null); |
|
|
|
AddGridResultDTO addGridResultDTO = new AddGridResultDTO(); |
|
|
|
addGridResultDTO.setGridId(gridId); |
|
|
|