Browse Source

修改班组添加

training
caoyizhong 2 years ago
parent
commit
b9a206a362
  1. 3
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTeamStaffController.java
  2. 4
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/dto/BasicdataTeamStaffDTO.java
  3. 3
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTeamStaffService.java
  4. 52
      blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTeamStaffServiceImpl.java

3
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/controller/BasicdataTeamStaffController.java

@ -16,6 +16,7 @@
*/
package com.logpm.basicdata.controller;
import com.logpm.basicdata.dto.BasicdataTeamStaffDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -116,7 +117,7 @@ public class BasicdataTeamStaffController extends BladeController {
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入basicdataTeamStaff")
public R submit(@Valid @RequestBody BasicdataTeamStaffEntity basicdataTeamStaff) {
public R submit(@Valid @RequestBody BasicdataTeamStaffDTO basicdataTeamStaff) {
return R.status(basicdataTeamStaffService.saveOrUpdateOwn(basicdataTeamStaff));
}

4
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/dto/BasicdataTeamStaffDTO.java

@ -20,6 +20,8 @@ import com.logpm.basicdata.entity.BasicdataTeamStaffEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* 班组人员表 数据传输对象实体类
*
@ -31,4 +33,6 @@ import lombok.EqualsAndHashCode;
public class BasicdataTeamStaffDTO extends BasicdataTeamStaffEntity {
private static final long serialVersionUID = 1L;
private List<String> staffIds;
}

3
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/IBasicdataTeamStaffService.java

@ -17,6 +17,7 @@
package com.logpm.basicdata.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.logpm.basicdata.dto.BasicdataTeamStaffDTO;
import com.logpm.basicdata.entity.BasicdataTeamStaffEntity;
import com.logpm.basicdata.vo.BasicdataTeamStaffVO;
import com.logpm.basicdata.excel.BasicdataTeamStaffExcel;
@ -49,5 +50,5 @@ public interface IBasicdataTeamStaffService extends BaseService<BasicdataTeamSta
*/
List<BasicdataTeamStaffExcel> exportBasicdataTeamStaff(Wrapper<BasicdataTeamStaffEntity> queryWrapper);
Boolean saveOrUpdateOwn(BasicdataTeamStaffEntity basicdataTeamStaff);
Boolean saveOrUpdateOwn(BasicdataTeamStaffDTO basicdataTeamStaff);
}

52
blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/service/impl/BasicdataTeamStaffServiceImpl.java

@ -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);
// }
}

Loading…
Cancel
Save