新增工人判断及去重
This commit is contained in:
parent
483199f042
commit
de124e1fbc
@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 维修工人 Mapper
|
* 维修工人 Mapper
|
||||||
*
|
*
|
||||||
@ -26,4 +28,11 @@ public interface RepairWorkerMapper extends BaseMapper<RepairWorker> {
|
|||||||
**/
|
**/
|
||||||
IPage<RepairWorkerRespVO> queryListPage(@Param("entity") RepairWorkerPageReqVO entity, Page<RepairWorkerRespVO> page);
|
IPage<RepairWorkerRespVO> queryListPage(@Param("entity") RepairWorkerPageReqVO entity, Page<RepairWorkerRespVO> page);
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* 获取所有维修工人的id
|
||||||
|
* @return List<Long> 维修工人id列表
|
||||||
|
* @author lzt
|
||||||
|
* @date 2024年10月10日
|
||||||
|
**/
|
||||||
|
List<Long> getAllWorkerIds();
|
||||||
|
}
|
||||||
|
@ -57,4 +57,6 @@ public interface RepairRecordsService extends IService<RepairRecords> {
|
|||||||
*/
|
*/
|
||||||
List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO);
|
List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
|
|||||||
* @apiNote lzt
|
* @apiNote lzt
|
||||||
* @param pageReqVO 查询条件
|
* @param pageReqVO 查询条件
|
||||||
* @return queryAllRepairRecords 所有维修记录
|
* @return queryAllRepairRecords 所有维修记录
|
||||||
* @date
|
* @date 2024年10月9日
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO) {
|
public List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO) {
|
||||||
|
@ -36,20 +36,28 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
|||||||
* 批量创建维修工人
|
* 批量创建维修工人
|
||||||
*
|
*
|
||||||
* @param userList 选中用户集合
|
* @param userList 选中用户集合
|
||||||
* @author PQZ
|
* @author lzt
|
||||||
* @date 18:33 2024/10/9
|
* @date 2024年10月10日
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void saveWorkers(List<UserDTO> userList) {
|
public void saveWorkers(List<UserDTO> userList) {
|
||||||
if (CollectionUtil.isNotEmpty(userList)){
|
if (CollectionUtil.isNotEmpty(userList)){
|
||||||
|
//获取已有的维修工人ID列表
|
||||||
|
List<Long> existingWorkerIds = workerMapper.getAllWorkerIds();
|
||||||
|
|
||||||
List<RepairWorker> saveList = new ArrayList<>();
|
List<RepairWorker> saveList = new ArrayList<>();
|
||||||
userList.forEach(item -> {
|
userList.forEach(item -> {
|
||||||
RepairWorker worker = new RepairWorker();
|
if (!existingWorkerIds.contains(item.getId())) {
|
||||||
worker.setUserId(item.getId());
|
RepairWorker worker = new RepairWorker();
|
||||||
worker.setUserName(item.getNickname());
|
worker.setUserId(item.getId());
|
||||||
saveList.add(worker);
|
worker.setUserName(item.getNickname());
|
||||||
|
saveList.add(worker);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
saveBatch(saveList);
|
|
||||||
|
if (!saveList.isEmpty()) {
|
||||||
|
saveBatch(saveList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,4 +92,4 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
|
|||||||
return workerMapper.queryListPage(pageReqVO,page);
|
return workerMapper.queryListPage(pageReqVO,page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,4 +27,15 @@
|
|||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
|
||||||
|
<select id="getAllWorkerIds" resultType="java.lang.Long">
|
||||||
|
SELECT
|
||||||
|
main.user_id
|
||||||
|
FROM
|
||||||
|
dl_repair_worker main
|
||||||
|
WHERE
|
||||||
|
main.deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
Loading…
Reference in New Issue
Block a user