Commit 286bc4bf by 王力

Merge branch 'dev_engineer_filter' into 'develop'

Dev engineer filter

See merge request !165
2 parents b8b99416 70692180
package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.EngineerInfo;
import com.dituhui.pea.order.entity.EngineerSkillGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface EngineerSkillGroupMPDao extends BaseMapper<EngineerSkillGroup> {
@Select("select * from engineer_skill_group where engineer_code = #{engineerCode}")
List<EngineerSkillGroup> selectByEngineerCode(String engineerCode);
}
package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.SkillGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface SkillGroupMPDao extends BaseMapper<SkillGroup> {
@Select("select * from skill_group where skill_group_code = #{groupCode}")
SkillGroup selectByGroupCode(String groupCode);
}
package com.dituhui.pea.order.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dituhui.pea.order.entity.SkillInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SkillInfoMPDao extends BaseMapper<SkillInfo> {
}
......@@ -19,6 +19,6 @@ public class EngineerSkillListResp {
private String engineerName;
private String groupName;
private String updateTime;
private List<String> categoryIds;
private List<String> skillGroupIds;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class EngineerSkillGroup {
private Integer id;
private String engineerCode;
private String skillGroupCode;
private String description;
private Integer beanStatus;
private Integer status;
private String memo;
private Timestamp createTime;
private Timestamp updateTime;
}
\ No newline at end of file
package com.dituhui.pea.order.entity;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class SkillGroup {
private Integer id;
private String skillCode;
private String brand;
private String type;
private String skill;
private Integer takeTime;
private Integer takeEngineer;
private Integer lowElectricianCert;
private Integer gasCert;
private Integer priority;
private String skillGroupCode;
private String layerId;
private String typeCategory;
private String skillCategory;
private String memo;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
@Data
public class SkillInfo {
private Integer id;
private String skillGroupCode;
private String skillGroup;
private String describe;
private String category;
private String memo;
private LocalDateTime createTime;
private LocalDate updateTime;
}
......@@ -29,7 +29,7 @@ public class EngineerServiceImpl implements EngineerService {
private EngineerInfoMPDao engineerInfoMPDao;
@Autowired
private EngineerSkillMPDao engineerSkillMPDao;
private EngineerSkillGroupMPDao engineerSkillGroupMPDao;
@Autowired
private OrgGroupMPDao orgGroupMPDao;
......@@ -49,6 +49,7 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired
private CapacityEngineerStatDao capacityEngineerStatDao;
@Transactional
@Override
public Result<?> getEngineerInfoList(String levelType, String levelValue, long page, long size, String kind, String key) {
......@@ -126,23 +127,23 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional
@Override
public Result<?> engineerSkillUpdate(String engineerCode, List<String> categoryIds) {
public Result<?> engineerSkillUpdate(String engineerCode, List<String> skillGroupIds) {
// 更新技术员技能
// 先将所有技能更新为0-不可用状态
LambdaUpdateWrapper<EngineerSkill> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerSkill::getEngineerCode, engineerCode).set(EngineerSkill::getStatus, 0);
engineerSkillMPDao.update(null, wrapper);
if (categoryIds.isEmpty()) {
LambdaUpdateWrapper<EngineerSkillGroup> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerSkillGroup::getEngineerCode, engineerCode).set(EngineerSkillGroup::getStatus, 0);
engineerSkillGroupMPDao.update(null, wrapper);
if (skillGroupIds.isEmpty()) {
return null;
}
// 更新categoryIds状态为1
wrapper.eq(EngineerSkill::getEngineerCode, engineerCode);
wrapper.in(EngineerSkill::getCategoryId, categoryIds);
wrapper.set(EngineerSkill::getStatus, 1);
int n = engineerSkillMPDao.update(null, wrapper);
if (categoryIds.size() == n) {
wrapper.eq(EngineerSkillGroup::getEngineerCode, engineerCode);
wrapper.in(EngineerSkillGroup::getSkillGroupCode, skillGroupIds);
wrapper.set(EngineerSkillGroup::getStatus, 1);
int n = engineerSkillGroupMPDao.update(null, wrapper);
if (skillGroupIds.size() == n) {
// 更新记录条数等于提交记录条数
return null;
}
......@@ -152,15 +153,15 @@ public class EngineerServiceImpl implements EngineerService {
List<String> engineerCodes = new ArrayList<>(Collections.singletonList(engineerCode));
HashMap<String, List<String>> engineerSkills = this.queryEngineerSkills(engineerCodes, statuses);
Set<String> sInput = new HashSet<>(categoryIds);
Set<String> sInput = new HashSet<>(skillGroupIds);
Set<String> sDB = new HashSet<>(engineerSkills.get(engineerCode));
sInput.removeAll(sDB);
for (String categoryId : sInput) {
EngineerSkill e = new EngineerSkill();
for (String skillGroupId : sInput) {
EngineerSkillGroup e = new EngineerSkillGroup();
e.setEngineerCode(engineerCode);
e.setCategoryId(categoryId);
e.setSkillGroupCode(skillGroupId);
e.setStatus(1);
engineerSkillMPDao.insert(e);
engineerSkillGroupMPDao.insert(e);
}
return null;
}
......@@ -282,21 +283,21 @@ public class EngineerServiceImpl implements EngineerService {
if (engineerCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerSkill> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkill::getEngineerCode, engineerCodes);
lqw.in(EngineerSkill::getStatus, statuses);
List<EngineerSkill> records = engineerSkillMPDao.selectList(lqw);
LambdaQueryWrapper<EngineerSkillGroup> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerSkillGroup::getEngineerCode, engineerCodes);
lqw.in(EngineerSkillGroup::getStatus, statuses);
List<EngineerSkillGroup> records = engineerSkillGroupMPDao.selectList(lqw);
Comparator<EngineerSkill> ec = Comparator.comparing(EngineerSkill::getEngineerCode, String.CASE_INSENSITIVE_ORDER);
List<EngineerSkill> results = records.stream().sorted(ec).collect(Collectors.toList());
Comparator<EngineerSkillGroup> ec = Comparator.comparing(EngineerSkillGroup::getEngineerCode, String.CASE_INSENSITIVE_ORDER);
List<EngineerSkillGroup> results = records.stream().sorted(ec).collect(Collectors.toList());
// 根据engineerCode分组
Map<String, List<EngineerSkill>> g = results.stream().collect(Collectors.groupingBy(EngineerSkill::getEngineerCode));
Map<String, List<EngineerSkillGroup>> g = results.stream().collect(Collectors.groupingBy(EngineerSkillGroup::getEngineerCode));
for (String engineerCode : g.keySet()) {
// 技术员技能ID列表
List<String> skillIds = g.get(engineerCode).stream().map(EngineerSkill::getCategoryId).collect(Collectors.toList());
map.put(engineerCode, skillIds);
List<String> skillGroupIds = g.get(engineerCode).stream().map(EngineerSkillGroup::getSkillGroupCode).collect(Collectors.toList());
map.put(engineerCode, skillGroupIds);
}
return map;
}
......@@ -371,8 +372,8 @@ public class EngineerServiceImpl implements EngineerService {
List<String> engineerCodes = engineers.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList());
// 获取技术员的可用技能列表
List<Integer> statuses = new ArrayList<Integer>(List.of(1));
HashMap<String, List<String>> engineerSkills = this.queryEngineerSkills(engineerCodes, statuses);
List<Integer> statuses = Collections.singletonList(1);
HashMap<String, List<String>> engineerSkillGroups = this.queryEngineerSkills(engineerCodes, statuses);
List<String> emptySkills = Collections.emptyList();
List<EngineerSkillListResp.EngineerSkill> items = new ArrayList<>();
......@@ -384,7 +385,7 @@ public class EngineerServiceImpl implements EngineerService {
skill.setUpdateTime(TimeUtils.IsoTimestamp2DateTime(e.getUpdateTime()));
// 获取一个工程师的技能列表
skill.setCategoryIds(engineerSkills.getOrDefault(e.getEngineerCode(), emptySkills));
skill.setSkillGroupIds(engineerSkillGroups.getOrDefault(e.getEngineerCode(), emptySkills));
items.add(skill);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!