Commit 3bdae3dc by 丁伟峰

Merge branch 'feature-dingwf-0715' into develop

2 parents 601ac13a 10c06d10
......@@ -3,6 +3,7 @@ package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.service.BusinessBaseService;
import com.dituhui.pea.order.service.BusinessTeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -15,6 +16,9 @@ public class BusinessController {
@Autowired
private BusinessTeamService businessTeamService;
@Autowired
private BusinessBaseService businessBaseService;
@GetMapping("/business/team/list")
public Result<?> getTeamList(@Validated BusinessTeamsDTO.Request reqDTO) {
Result<?> res = null;
......@@ -102,4 +106,15 @@ public class BusinessController {
}
return res;
}
@GetMapping("/business/skill/list")
public Result<?> getSkillList(@Validated BusinessSkillListDTO.Request reqDTO) {
Result<?> res = null;
try {
res = businessBaseService.getSkillList(reqDTO);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
return res;
}
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapLayerCustomizeEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MapLayerCustomizeDao extends JpaRepository<MapLayerCustomizeEntity, Long> {
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapLayerEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MapLayerDao extends JpaRepository<MapLayerEntity, Long> {
MapLayerEntity getByLayerId(String layerId);
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SkillGroupDao extends JpaRepository<SkillGroupEntity, Long> {
}
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SkillInfoDao extends JpaRepository<SkillInfoEntity, Long> {
List<SkillInfoEntity> findAll();
Page<SkillInfoEntity> findAll(Pageable pageable);
}
package com.dituhui.pea.order.dto;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
import static com.dituhui.pea.order.config.OrderConfig.DEFAULT_PAGE_SIZE;
public class BusinessSkillListDTO {
@lombok.Data
public static class Request {
private Integer size = DEFAULT_PAGE_SIZE;
private Integer page = 1;
/**
* 服务分类,可选
*/
private String skillCategory;
/**
* 产品分类,可选
*/
private String typeCategory;
}
@lombok.Data
@Accessors(chain = true)
public static class Result {
private List<Content> content;
private long pageCurrent;
private long pages;
private long pageSize;
private long total;
}
@lombok.Data
@Accessors(chain = true)
public static class Content {
private String brand;
private LocalDateTime createTime;
private Boolean gasCert;
private String layerId;
private String layerName;
private Boolean lowElectricianCert;
private String memo;
// private Integer priority;
private String skill;
private String skillCategory;
private String skillCode;
private String skillGroupCode;
private String skillGroupName;
private Integer takeEngineer;
private Integer takeTime;
private String type;
private String typeCategory;
private LocalDateTime updateTime;
}
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Entity
@Data
@Table(name = "map_layer_customize_entity")
public class MapLayerCustomizeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "branch_id", nullable = false, length = 32)
private String branchId;
@Column(name = "layer_id", length = 32)
private String layerId;
@Column(name = "layer", nullable = false, length = 50)
private String layer;
@Column(name = "layer_describe", nullable = false, length = 200)
private String layerDescribe;
@Column(name = "disabled", nullable = false)
private boolean disabled;
@Column(name = "memo", nullable = false, length = 100)
private String memo;
@Column(name = "create_time", nullable = false)
private Date createTime;
@Column(name = "update_time", nullable = false)
private Date updateTime;
// Getters and Setters
// ...
}
package com.dituhui.pea.order.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
@Entity
@Data
@Table(name = "map_layer")
public class MapLayerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name = "layer_id", nullable = false, length = 32)
private String layerId;
@Column(name = "layer", nullable = false, length = 50)
private String layer;
@Column(name = "layer_describe", nullable = false, length = 200)
private String layerDescribe;
@Column(name = "memo", nullable = false, length = 100)
private String memo;
@Column(name = "create_time", nullable = false)
private Date createTime;
@Column(name = "update_time", nullable = false)
private Date updateTime;
// Getters and Setters
// ...
}
package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.BusinessSkillListDTO;
public interface BusinessBaseService {
Result<?> getSkillList(BusinessSkillListDTO.Request req);
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dao.MapLayerCustomizeDao;
import com.dituhui.pea.order.dao.MapLayerDao;
import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.dto.BusinessSkillListDTO;
import com.dituhui.pea.order.entity.MapLayerCustomizeEntity;
import com.dituhui.pea.order.entity.MapLayerEntity;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.BusinessBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class BusinessBaseServiceImpl implements BusinessBaseService {
@Autowired
private SkillInfoDao skillInfoDao;
@Autowired
private MapLayerDao mapLayerDao;
@Autowired
private MapLayerCustomizeDao mapLayerCustomizeDao;
@Autowired
private SkillGroupDao skillGroupDao;
private Map<String, String> mapLayer = null;
private Map<String, String> mapSkillGroup = null;
@Override
public Result<?> getSkillList(BusinessSkillListDTO.Request req) {
Pageable pageable = PageRequest.of(req.getPage() - 1, req.getSize());
Page<SkillInfoEntity> page = skillInfoDao.findAll(pageable);
List<BusinessSkillListDTO.Content> contents = page.getContent().stream().map(e -> {
return new BusinessSkillListDTO.Content()
.setSkillCode(e.getSkillCode())
.setBrand(e.getBrand())
.setType(e.getType())
.setSkill(e.getSkill())
.setTakeTime(e.getTakeTime())
.setTakeEngineer(e.getTakeEngineer())
.setLowElectricianCert(e.getLowElectricianCert())
.setGasCert(e.getGasCert())
//.setPriority(e.getPriority())
.setSkillGroupCode(e.getSkillGroupCode())
.setSkillGroupName(this.getSkillGroupName(e.getSkillCode()))
.setLayerId(e.getLayerId())
.setLayerName(this.getLayerName(e.getLayerId()))
.setTypeCategory(e.getTypeCategory())
.setSkillCategory(e.getSkillCategory())
.setMemo(e.getMemo())
.setCreateTime(e.getCreateTime())
.setUpdateTime(e.getUpdateTime());
}).collect(Collectors.toList());
BusinessSkillListDTO.Result rs = new BusinessSkillListDTO.Result();
rs.setTotal(page.getTotalElements())
.setPages(page.getTotalPages())
.setPageSize(page.getSize())
.setPageCurrent(page.getNumber());
rs.setContent(contents);
return Result.success(rs);
}
private void initMaps() {
// 图层
mapLayer = new HashMap<>();
mapLayer.putAll(mapLayerDao.findAll().stream().collect(Collectors.toMap(MapLayerEntity::getLayerId, MapLayerEntity::getLayer)));
mapLayer.putAll(mapLayerCustomizeDao.findAll().stream().collect(Collectors.toMap(MapLayerCustomizeEntity::getLayerId, MapLayerCustomizeEntity::getLayer)));
// 技能组
mapSkillGroup = new HashMap<>();
mapSkillGroup.putAll(skillGroupDao.findAll().stream().collect(Collectors.toMap(SkillGroupEntity::getSkillGroupCode, SkillGroupEntity::getSkillGroup)));
}
String getLayerName(String layerId) {
if (mapLayer == null) {
initMaps();
}
return mapLayer.get(layerId);
}
String getSkillGroupName(String skillGroupCode) {
if (mapSkillGroup == null) {
initMaps();
;
}
return mapSkillGroup.get(skillGroupCode);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!