Commit 14089f96 authored by tangwei's avatar tangwei

人员存入es ,增加批量新增,修改,删除接口

parent b46f2106
...@@ -2,18 +2,21 @@ package com.yeejoin.amos.boot.module.common.api.dto; ...@@ -2,18 +2,21 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
/** /**
* @description: * @description:
* @author: tw * @author: tw
* @createDate: 2024/8/14 * @createDate: 2024/8/14
*/ */
@Data @Data
@Document(indexName = "user", shards = 1, replicas = 0) @Accessors(chain = true)
@Document(indexName = "biz_user_doc", shards = 1, replicas = 0)
public class ESOrgUser { public class ESOrgUser {
...@@ -21,124 +24,66 @@ public class ESOrgUser { ...@@ -21,124 +24,66 @@ public class ESOrgUser {
@ApiModelProperty(value = "人员id") @ApiModelProperty(value = "人员id")
@Field(type = FieldType.Long) @Field(type = FieldType.Long)
private Long sequenceNbr; private Long sequenceNbr;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员code") @ApiModelProperty(value = "人员code")
private String bizOrgCode; private String bizOrgCode;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员名称") @ApiModelProperty(value = "人员名称")
private String bizOrgName; private String bizOrgName;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员对应平台id") @ApiModelProperty(value = "人员对应平台id")
private String amosOrgId; private String amosOrgId;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员账号")
private String amosOrgCode;
@Field(type = FieldType.Keyword)
@ApiModelProperty(value = "父id") @ApiModelProperty(value = "父id")
private String parentId; private String parentId;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员黄绿码") @ApiModelProperty(value = "人员黄绿码")
private String personStatus; private String personStatus;
@Field(type = FieldType.Date) @Field(type = FieldType.Date, format = DateFormat.basic_date_time)
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
private String recDate; private Date recDate;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员父节点名称") @ApiModelProperty(value = "人员父节点名称")
private String companyName; private String companyName;
@Field(type = FieldType.Keyword)
@Field(type = FieldType.Integer)
@ApiModelProperty(value = "人员巡检任务统计/动态数据")
private String patrol;
@Field(type = FieldType.Integer)
@ApiModelProperty(value = "人员非巡检任务统计/动态数据")
private String other;
@Field(type = FieldType.Text)
@ApiModelProperty(value = "员工编号") @ApiModelProperty(value = "员工编号")
private String personNumber; private String personNumber;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "证件类型") @ApiModelProperty(value = "证件类型")
private String certificatesTypeCode; private String certificatesTypeCode;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "性别") @ApiModelProperty(value = "性别")
private String gender; private String gender;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "证件号码") @ApiModelProperty(value = "证件号码")
private String certificatesNumber; private String certificatesNumber;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "联系电话") @ApiModelProperty(value = "联系电话")
private String telephone; private String telephone;
// @Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
// @ApiModelProperty(value = "人员状态")
// private String state;
@Field(type = FieldType.Text)
@ApiModelProperty(value = "是否进行安全培训") @ApiModelProperty(value = "是否进行安全培训")
private String safetyTraining; private String safetyTraining;
// @Field(type = FieldType.Text)
// @ApiModelProperty(value = "行政职务")
// private String administrativePositionCode;
// @Field(type = FieldType.Text)
// @ApiModelProperty(value = "消防管理组织机构内部职务")
// private String internalPositionCode;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "消防管理岗位code") @ApiModelProperty(value = "消防管理岗位code")
private String fireManagementPostCode; private String fireManagementPostCode;
@Field(type = FieldType.Keyword)
@Field(type = FieldType.Text)
@ApiModelProperty(value = "消防管理岗位") @ApiModelProperty(value = "消防管理岗位")
private String fireManagementPostName; private String fireManagementPostName;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "岗位类型code") @ApiModelProperty(value = "岗位类型code")
private String positionType; private String positionType;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "岗位类型") @ApiModelProperty(value = "岗位类型")
private String positionTypeName; private String positionTypeName;
// @Field(type = FieldType.Text)
// @ApiModelProperty(value = "持证类别")
// private String certificateType;
// @Field(type = FieldType.Date)
// @ApiModelProperty(value = "持证时间")
// private String holdingTime;
// @Field(type = FieldType.Keyword)
// @ApiModelProperty(value = "审核周期")
// private String auditCycle;
@Field(type = FieldType.Keyword) @Field(type = FieldType.Keyword)
@ApiModelProperty(value = "人员照片") @ApiModelProperty(value = "人员照片")
private String personImg; private String personImg;
@Field(type = FieldType.Keyword)
// @Field(type = FieldType.Keyword)
// @ApiModelProperty(value = "重点工种资质证书")
// private String certificateImg;
@Field(type = FieldType.Text)
@ApiModelProperty(value = "人员类型") @ApiModelProperty(value = "人员类型")
private String peopleType; private String peopleType;
// @Field(type = FieldType.Text)
// @ApiModelProperty(value = "人员状态名称")
// private String stateName;
// @Field(type = FieldType.Text)
// @ApiModelProperty(value = "人员对应平台code")
// private String amosOrgCode;
@ApiModelProperty(value = "对象id")
@Field(type = FieldType.Long)
private String instance_id;
} }
...@@ -7,7 +7,6 @@ import lombok.Data; ...@@ -7,7 +7,6 @@ import lombok.Data;
* @author: tw * @author: tw
* @createDate: 2024/8/14 * @createDate: 2024/8/14
*/ */
@Data
public class EsUserData { public class EsUserData {
private String bizOrgName; private String bizOrgName;
private String positionType; private String positionType;
...@@ -15,4 +14,52 @@ public class EsUserData { ...@@ -15,4 +14,52 @@ public class EsUserData {
private String OrgCode; private String OrgCode;
private int pageNum; private int pageNum;
private int pageSize; private int pageSize;
public String getBizOrgName() {
return bizOrgName;
}
public void setBizOrgName(String bizOrgName) {
this.bizOrgName = bizOrgName;
}
public String getPositionType() {
return positionType;
}
public void setPositionType(String positionType) {
this.positionType = positionType;
}
public String getAmosOrgId() {
return amosOrgId;
}
public void setAmosOrgId(String amosOrgId) {
this.amosOrgId = amosOrgId;
}
public String getOrgCode() {
return OrgCode;
}
public void setOrgCode(String OrgCode) {
OrgCode = OrgCode;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
} }
...@@ -1674,15 +1674,12 @@ ...@@ -1674,15 +1674,12 @@
u.sequence_nbr sequenceNbr, u.sequence_nbr sequenceNbr,
u.biz_org_name bizOrgName, u.biz_org_name bizOrgName,
u.amos_org_id amosOrgId, u.amos_org_id amosOrgId,
u.amos_org_code amosOrgCode,
u.biz_org_code bizOrgCode, u.biz_org_code bizOrgCode,
u.parent_id parentId, u.parent_id parentId,
u.person_status personStatus, u.person_status personStatus,
u.rec_date recDate, u.rec_date recDate,
(select biz_org_name from cb_org_usr where sequence_nbr = u.parent_id) as companyName, (select biz_org_name from cb_org_usr where sequence_nbr = u.parent_id) as companyName,
(SELECT IFNULL(SUM(IF(aqr.SOURCE = 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE
aqr.buss_id = u.sequence_nbr ) as 'patrol',
(SELECT IFNULL(SUM(IF(aqr.SOURCE != 'patrol', 1, 0)), 0) FROM dl_amos_idx_biz.idx_access_qrcode_record aqr WHERE
aqr.buss_id = u.sequence_nbr ) as 'other',
g.* g.*
FROM FROM
cb_org_usr u cb_org_usr u
...@@ -1697,30 +1694,22 @@ ...@@ -1697,30 +1694,22 @@
max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end) max(case v.field_code when 'certificatesNumber' then IFNULL(v.field_value_label,v.field_value) end)
certificatesNumber, certificatesNumber,
max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone, max(case v.field_code when 'telephone' then IFNULL(v.field_value_label,v.field_value) end) telephone,
-- max(case v.field_code when 'stateCode' then IFNULL(v.field_value_label,v.field_value) end) state,
max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining, max(case v.field_code when 'safetyTraining' then IFNULL(v.field_value_label,v.field_value) end) safetyTraining,
-- max(case v.field_code when 'administrativePositionCode' then IFNULL(v.field_value_label,v.field_value) end)
-- administrativePositionCode,
-- max(case v.field_code when 'internalPositionCode' then IFNULL(v.field_value_label,v.field_value) end)
-- internalPositionCode,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end) max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,v.field_value) end)
fireManagementPostCode, fireManagementPostCode,
max(case v.field_code when 'fireManagementPostCode' then v.field_value end) fireManagementPost,
max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,'其他') end) max(case v.field_code when 'fireManagementPostCode' then IFNULL(v.field_value_label,'其他') end)
fireManagementPostName, fireManagementPostName,
max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType, max(case v.field_code when 'positionType' then IFNULL(v.field_value,v.field_value_label) end) positionType,
max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'其他') end) positionTypeName, max(case v.field_code when 'positionType' then IFNULL(v.field_value_label,'其他') end) positionTypeName,
-- max(case v.field_code when 'certificateType' then IFNULL(v.field_value_label,v.field_value) end)
-- certificateType,
-- max(case v.field_code when 'holdingTime' then IFNULL(v.field_value_label,v.field_value) end) holdingTime,
-- max(case v.field_code when 'auditCycle' then IFNULL(v.field_value_label,v.field_value) end) auditCycle,
max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg, max(case v.field_code when 'personImg' then IFNULL(v.field_value_label,v.field_value) end) personImg,
-- max(case v.field_code when 'certificateImg' then IFNULL(v.field_value_label,v.field_value) end) certificateImg,
max(case v.field_code when 'peopleType' then v.field_value end) peopleType max(case v.field_code when 'peopleType' then v.field_value end) peopleType
FROM FROM
`cb_dynamic_form_instance` v `cb_dynamic_form_instance` v
WHERE WHERE
v.group_code = 246 v.group_code = 246
<if test="sequenceNbr != null and sequenceNbr != ''">
AND v.`instance_id`= = #{sequenceNbr}
</if>
GROUP BY GROUP BY
v.`instance_id` v.`instance_id`
) g ) g
......
...@@ -34,7 +34,7 @@ public class ESOrgUserController extends BaseController { ...@@ -34,7 +34,7 @@ public class ESOrgUserController extends BaseController {
@Autowired @Autowired
ESOrgUserServicempl esOrgUserServicempl; ESOrgUserServicempl esOrgUserServicempl;
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增/修改", notes = "新增/修改") @ApiOperation(httpMethod = "POST", value = "新增/修改", notes = "新增/修改")
public ResponseModel<List<ESOrgUser>> saveEsOrgUser(@RequestBody List<ESOrgUser> model) throws Exception { public ResponseModel<List<ESOrgUser>> saveEsOrgUser(@RequestBody List<ESOrgUser> model) throws Exception {
...@@ -42,14 +42,14 @@ public class ESOrgUserController extends BaseController { ...@@ -42,14 +42,14 @@ public class ESOrgUserController extends BaseController {
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse(model);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
@ApiOperation(httpMethod = "POST", value = "删除", notes = "删除") @ApiOperation(httpMethod = "POST", value = "删除", notes = "删除")
public ResponseModel<Object> deleteEsOrgUser(@RequestBody List<Long> ids) throws Exception { public ResponseModel<Object> deleteEsOrgUser(@RequestBody List<Long> ids) throws Exception {
esOrgUserServicempl.deleteByIds(ids); esOrgUserServicempl.deleteByIds(ids);
return ResponseHelper.buildResponse("成功"); return ResponseHelper.buildResponse("成功");
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping (value = "/init") @GetMapping (value = "/init")
@ApiOperation(httpMethod = "GET", value = "初始化", notes = "初始化") @ApiOperation(httpMethod = "GET", value = "初始化", notes = "初始化")
public ResponseModel<Object> initEsOrgUser() throws Exception { public ResponseModel<Object> initEsOrgUser() throws Exception {
...@@ -58,11 +58,15 @@ public class ESOrgUserController extends BaseController { ...@@ -58,11 +58,15 @@ public class ESOrgUserController extends BaseController {
} }
@TycloudOperation( ApiLevel = UserType.AGENCY) @TycloudOperation( ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.POST)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询") @ApiOperation(httpMethod = "POST", value = "列表分页查询", notes = "列表分页查询")
public ResponseModel<Page<ESOrgUser>> listPage(@RequestParam EsUserData requestBody) { public ResponseModel<Page<ESOrgUser>> listPage(@RequestBody Map<String, Object> requestBody) {
Page<ESOrgUser> pa= esOrgUserServicempl.listPage(requestBody,requestBody.getPageNum(),requestBody.getPageSize());
Page<ESOrgUser> pa= esOrgUserServicempl.listPage(requestBody,Integer.valueOf(requestBody.get("pageNum").toString()),Integer.valueOf(requestBody.get("pageSize").toString()));
return ResponseHelper.buildResponse(pa); return ResponseHelper.buildResponse(pa);
} }
......
...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.biz.dao.ESOrgUserRepository; ...@@ -8,6 +8,7 @@ import com.yeejoin.amos.boot.module.common.biz.dao.ESOrgUserRepository;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -22,6 +23,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -22,6 +23,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: * @description:
...@@ -68,21 +70,22 @@ public class ESOrgUserServicempl implements IESOrgUserService { ...@@ -68,21 +70,22 @@ public class ESOrgUserServicempl implements IESOrgUserService {
} }
public Page<ESOrgUser> listPage(EsUserData keyword, int current, int size) { public Page<ESOrgUser> listPage(Map<String, Object> keyword, int current, int size) {
//构建返回对象 //构建返回对象
Page<ESOrgUser> result = new Page<ESOrgUser>(current, size); Page<ESOrgUser> result = new Page<ESOrgUser>(current, size);
//组装查询条件 must类似and匹配到所有字段后进行组合查询 //组装查询条件 must类似and匹配到所有字段后进行组合查询
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery(); BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if(StringUtils.isNotBlank(keyword.getBizOrgName())){ if(keyword.get("bizOrgName")!=null&&StringUtils.isNotBlank(keyword.get("bizOrgName").toString())){
queryBuilder.must(QueryBuilders.matchQuery("bizOrgName", keyword.getBizOrgName())); queryBuilder.must(QueryBuilders.wildcardQuery("bizOrgName", "*"+keyword.get("bizOrgName").toString()+"*"));
} }
if(StringUtils.isNotBlank(keyword.getAmosOrgId())){ if(keyword.get("amosOrgId")!=null&&StringUtils.isNotBlank(keyword.get("amosOrgId").toString())){
queryBuilder.must(QueryBuilders.matchQuery("amosOrgId", keyword.getAmosOrgId())); queryBuilder.must(QueryBuilders.wildcardQuery("amosOrgCode", "*"+keyword.get("amosOrgId").toString()+"*"));
} }
if(StringUtils.isNotBlank(keyword.getPositionType())){ if(keyword.get("positionType")!=null&&StringUtils.isNotBlank(keyword.get("positionType").toString())){
queryBuilder.must(QueryBuilders.termQuery("positionType",keyword.getPositionType())); queryBuilder.must(QueryBuilders.termQuery("positionType",keyword.get("positionType").toString()));
} }
queryBuilder.must(QueryBuilders.wildcardQuery("bizOrgCode", keyword.getOrgCode()));
queryBuilder.must(QueryBuilders.wildcardQuery("bizOrgCode",keyword.get("OrgCode").toString()+"*"));
NativeSearchQuery build = new NativeSearchQueryBuilder() NativeSearchQuery build = new NativeSearchQueryBuilder()
.withQuery(queryBuilder) .withQuery(queryBuilder)
.withPageable(PageRequest.of(current, size)) .withPageable(PageRequest.of(current, size))
...@@ -90,6 +93,7 @@ public class ESOrgUserServicempl implements IESOrgUserService { ...@@ -90,6 +93,7 @@ public class ESOrgUserServicempl implements IESOrgUserService {
.withSort(SortBuilders.fieldSort("personStatus").order(SortOrder.DESC)) .withSort(SortBuilders.fieldSort("personStatus").order(SortOrder.DESC))
.withSort(SortBuilders.fieldSort("recDate").order(SortOrder.DESC)) .withSort(SortBuilders.fieldSort("recDate").order(SortOrder.DESC))
.build(); .build();
build.setTrackTotalHits(true);
SearchHits<ESOrgUser> search = elasticsearchTemplate.search(build, ESOrgUser.class); SearchHits<ESOrgUser> search = elasticsearchTemplate.search(build, ESOrgUser.class);
SearchPage<ESOrgUser> page = SearchHitSupport.searchPageFor(search, build.getPageable()); SearchPage<ESOrgUser> page = SearchHitSupport.searchPageFor(search, build.getPageable());
List<ESOrgUser> list = new LinkedList<>(); List<ESOrgUser> list = new LinkedList<>();
......
...@@ -297,10 +297,10 @@ ...@@ -297,10 +297,10 @@
<artifactId>log4j-api</artifactId> <artifactId>log4j-api</artifactId>
<version>2.17.0</version> <version>2.17.0</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>org.springframework.boot</groupId> <!-- <groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-data-elasticsearch</artifactId> <!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
</dependency> <!-- </dependency>-->
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment