|
|
|
@ -16,10 +16,11 @@
|
|
|
|
|
*/ |
|
|
|
|
package com.logpm.basicdata.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.BeanUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.dto.BasicdataTeamStaffDTO; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataTeamStaffEntity; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.service.IBasicdataWarehouseService; |
|
|
|
|
import com.logpm.basicdata.vo.BasicdataTeamStaffVO; |
|
|
|
|
import com.logpm.basicdata.excel.BasicdataTeamStaffExcel; |
|
|
|
@ -27,10 +28,16 @@ import com.logpm.basicdata.mapper.BasicdataTeamStaffMapper;
|
|
|
|
|
import com.logpm.basicdata.service.IBasicdataTeamStaffService; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.BeanUtil; |
|
|
|
|
import org.springblade.system.entity.User; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -45,6 +52,8 @@ public class BasicdataTeamStaffServiceImpl extends BaseServiceImpl<BasicdataTeam
|
|
|
|
|
|
|
|
|
|
private final IBasicdataWarehouseService basicdataWarehouseService; |
|
|
|
|
|
|
|
|
|
private IUserClient userClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<BasicdataTeamStaffVO> selectBasicdataTeamStaffPage(IPage<BasicdataTeamStaffVO> page, BasicdataTeamStaffVO basicdataTeamStaff) { |
|
|
|
|
return page.setRecords(baseMapper.selectBasicdataTeamStaffPage(page, basicdataTeamStaff)); |
|
|
|
@ -66,27 +75,42 @@ public class BasicdataTeamStaffServiceImpl extends BaseServiceImpl<BasicdataTeam
|
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Boolean saveOrUpdateOwn(BasicdataTeamStaffEntity basicdataTeamStaff) { |
|
|
|
|
public Boolean saveOrUpdateOwn(BasicdataTeamStaffDTO basicdataTeamStaff) { |
|
|
|
|
if(ObjectUtils.isNull(basicdataTeamStaff)){ |
|
|
|
|
throw new ServiceException("参数不全!!"); |
|
|
|
|
} |
|
|
|
|
BasicdataWarehouseEntity one = basicdataWarehouseService.getOne(Wrappers.<BasicdataWarehouseEntity>query().lambda().eq(BasicdataWarehouseEntity::getId, basicdataTeamStaff.getWarehouseId())); |
|
|
|
|
if(ObjectUtils.isNull(one)){ |
|
|
|
|
throw new ServiceException("仓库数据异常!!"); |
|
|
|
|
} |
|
|
|
|
if(ObjectUtils.isNotNull(basicdataTeamStaff.getId())){ |
|
|
|
|
|
|
|
|
|
/*if(ObjectUtils.isNotNull(basicdataTeamStaff.getId())){ |
|
|
|
|
//修改
|
|
|
|
|
basicdataTeamStaff.setDepartment(one.getDepartment()); |
|
|
|
|
basicdataTeamStaff.setDepartmentName(one.getDepartmentName()); |
|
|
|
|
this.updateById(basicdataTeamStaff); |
|
|
|
|
return true; |
|
|
|
|
}else{ |
|
|
|
|
//添加
|
|
|
|
|
basicdataTeamStaff.setDepartment(one.getDepartment()); |
|
|
|
|
basicdataTeamStaff.setDepartmentName(one.getDepartmentName()); |
|
|
|
|
this.save(basicdataTeamStaff); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}else{*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//添加
|
|
|
|
|
List<BasicdataTeamStaffEntity> list = new ArrayList<>(); |
|
|
|
|
basicdataTeamStaff.getStaffIds().forEach(i ->{ |
|
|
|
|
//查询是否已存在
|
|
|
|
|
List<BasicdataTeamStaffEntity> list1 = baseMapper.selectList(Wrappers.<BasicdataTeamStaffEntity>query().lambda() |
|
|
|
|
.eq(BasicdataTeamStaffEntity::getStaffId, i) |
|
|
|
|
.eq(BasicdataTeamStaffEntity::getWarehouseId, basicdataTeamStaff.getWarehouseId()) |
|
|
|
|
.eq(BasicdataTeamStaffEntity::getIsDeleted,0) |
|
|
|
|
); |
|
|
|
|
if(list1.size() > 0){ |
|
|
|
|
throw new ServiceException("人员已存在,不能重复添加!"); |
|
|
|
|
} |
|
|
|
|
R<User> userR = userClient.userInfoById(Long.valueOf(i)); |
|
|
|
|
BasicdataTeamStaffEntity entity = new BasicdataTeamStaffEntity(); |
|
|
|
|
BeanUtil.copyProperties(basicdataTeamStaff,entity); |
|
|
|
|
entity.setStaffId(Long.valueOf(i)); |
|
|
|
|
entity.setName(userR.getData().getName()); |
|
|
|
|
list.add(entity); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return this.saveBatch(list); |
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|