This commit is contained in:
xiaofajia 2024-10-10 11:48:31 +08:00
commit 4d3d3aa971
6 changed files with 43 additions and 13 deletions

View File

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

View File

@ -57,4 +57,6 @@ public interface RepairRecordsService extends IService<RepairRecords> {
*/ */
List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO); List<RepairRecordsRespVO> queryAllRepairRecords(RepairRecordsPageReqVO pageReqVO);
} }

View File

@ -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) {

View File

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

View File

@ -28,4 +28,15 @@
order by main.create_time desc order by main.create_time desc
</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>

View File

@ -4,7 +4,7 @@
"avatar": "", "avatar": "",
"version": "4.9.2", "version": "4.9.2",
"createdTime": "2024-10-9 10:34:15", "createdTime": "2024-10-9 10:34:15",
"updatedTime": "2024-10-9 17:32:50", "updatedTime": "2024-10-10 10:48:48",
"dbConns": [], "dbConns": [],
"profile": { "profile": {
"default": { "default": {
@ -683,7 +683,7 @@
"optionsFetcher": "" "optionsFetcher": ""
} }
}, },
"menuWidth": "266px" "menuWidth": "298px"
}, },
"entities": [ "entities": [
{ {