Commit 743ceb4b authored by 李腾威's avatar 李腾威

机构单位人员接口

parent fdaa3411
......@@ -16,4 +16,23 @@ public interface CommonConstant {
public final static String RESULT_FAILURE = "FAILURE";
public final static String X_ACCESS_TOKEN = "X-Access-Token";
/**
* 机构/部门/人员表中 机构类型
*/
public final static String BIZ_ORG_TYPE_DEPARTMENT = "DEPARTMENT";
public final static String BIZ_ORG_TYPE_COMPANY = "COMPANY";
public final static String BIZ_ORG_TYPE_PERSON = "PERSON";
/**
* 未被删除
*/
public final static String IS_DELETE_00 = "0";
/**
* 已被删除
*/
public final static String IS_DELETE_01 = "1";
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author fengwang
* @date 2021-06-18.
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsr对象", description="部门信息")
public class OrgDepartmentDto extends BaseEntity {
@ApiModelProperty(value = "部门名称")
private String bizOrgName;
@ApiModelProperty(value = "部门编码")
private String bizOrgCode;
@ApiModelProperty(value = "amos中公司/部门ID")
private String amosOrgId;
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@ApiModelProperty(value = "机构类型(部门:DEPARTMENT,单位:COMPANY,人员:PERSON)")
private String bizOrgType = CommonConstant.BIZ_ORG_TYPE_DEPARTMENT;
@ApiModelProperty(value = "所属建筑名称")
private String buildName;
@ApiModelProperty(value = "所属建筑ID")
private String buildId;
@ApiModelProperty(value = "归属机构/部门/人员")
private String parentId;
@ApiModelProperty(value = "扩展属性1")
private String orgExpandAttr1;
@ApiModelProperty(value = "扩展属性2")
private String orgExpandAttr2;
@ApiModelProperty(value = "扩展属性3")
private String orgExpandAttr3;
@ApiModelProperty(value = "扩展属性4")
private String orgExpandAttr4;
private String orgExpandAttr5;
private String orgExpandAttr6;
private String orgExpandAttr7;
private String orgExpandAttr8;
@ApiModelProperty(value = "更新人")
@TableField(fill= FieldFill.INSERT_UPDATE)
private String recUserName;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author fengwang
* @date 2021-06-18.
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsr对象", description="人员信息")
public class OrgPersonDto extends BaseEntity {
@ApiModelProperty(value = "人员名称")
private String bizOrgName;
@ApiModelProperty(value = "人员编码")
private String bizOrgCode;
@ApiModelProperty(value = "amos中公司/部门ID")
private String amosOrgId;
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@ApiModelProperty(value = "机构类型(部门:DEPARTMENT,单位:COMPANY,人员:PERSON)")
private String bizOrgType = CommonConstant.BIZ_ORG_TYPE_PERSON;
@ApiModelProperty(value = "所属建筑名称")
private String buildName;
@ApiModelProperty(value = "所属建筑ID")
private String buildId;
@ApiModelProperty(value = "归属机构/部门/人员")
private String parentId;
@ApiModelProperty(value = "扩展属性1")
private String orgExpandAttr1;
@ApiModelProperty(value = "扩展属性2")
private String orgExpandAttr2;
@ApiModelProperty(value = "扩展属性3")
private String orgExpandAttr3;
@ApiModelProperty(value = "扩展属性4")
private String orgExpandAttr4;
private String orgExpandAttr5;
private String orgExpandAttr6;
private String orgExpandAttr7;
private String orgExpandAttr8;
@ApiModelProperty(value = "更新人")
@TableField(fill= FieldFill.INSERT_UPDATE)
private String recUserName;
}
package com.yeejoin.amos.boot.module.jcs.api.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
......@@ -7,11 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/**
* 机构/部门/人员表
*
......@@ -72,6 +70,7 @@ public class OrgUsrDto extends BaseEntity {
private String orgExpandAttr8;
@ApiModelProperty(value = "更新人")
@TableField(fill= FieldFill.INSERT_UPDATE)
private String recUserName;
}
package com.yeejoin.amos.boot.module.jcs.api.entity;
import java.util.List;
/**
* @author fengwang
* @date 2021-06-19.
*/
public class OrgMenu{
public Long key;
public String title;
public Long parentId;
public boolean isLeaf;
public List<OrgMenu> children;
public String bizOrgType;
public OrgMenu(Long key, String title, Long parentId, String bizOrgType, boolean isLeaf) {
super();
this.key = key;
this.title = title;
this.parentId = parentId;
this.bizOrgType = bizOrgType;
this.isLeaf = isLeaf;
}
public OrgMenu(Long key, String title, Long parentId, boolean isLeaf, List<OrgMenu> children, String bizOrgType) {
this.key = key;
this.title = title;
this.parentId = parentId;
this.isLeaf = isLeaf;
this.children = children;
this.bizOrgType = bizOrgType;
}
public Long getKey() {
return key;
}
public void setKey(Long key) {
this.key = key;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public List<OrgMenu> getChildren() {
return children;
}
public void setChildren(List<OrgMenu> children) {
this.children = children;
}
public String getBizOrgType() {
return bizOrgType;
}
public void setBizOrgType(String bizOrgType) {
this.bizOrgType = bizOrgType;
}
}
package com.yeejoin.amos.boot.module.jcs.api.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
/**
* 机构/部门/人员表
*
......@@ -22,11 +23,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsr对象", description="机构/部门/人员表")
public class OrgUsr extends BaseEntity {
@ApiModel(value="OrgUsr对象", description="部门信息")
public class OrgUsr extends BaseEntity implements Serializable {
@ApiModelProperty(value = "机构/部门名称")
private String bizOrgName;
......@@ -40,7 +38,7 @@ public class OrgUsr extends BaseEntity {
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@ApiModelProperty(value = "机构类型(部门:DEPARTMENT,单位:COMPANY,人员:PERSON)")
@ApiModelProperty(value = "机构类型`")
private String bizOrgType;
@ApiModelProperty(value = "所属建筑名称")
......@@ -73,6 +71,8 @@ public class OrgUsr extends BaseEntity {
private String orgExpandAttr8;
@ApiModelProperty(value = "更新人")
@TableField(fill=FieldFill.INSERT_UPDATE)
private String recUserName;
}
package com.yeejoin.amos.boot.module.jcs.api.service;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgMenu;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Collection;
import java.util.List;
/**
* 机构/部门/人员表 服务类
*
......@@ -10,5 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @date 2021-06-18
*/
public interface IOrgUsrService extends IService<OrgUsr> {
List<OrgMenu> getTree(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception;
List<OrgMenu> getSub(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName,String OrgTypeMethodName) throws Exception;
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 机构/部门/人员表
*
* @author tb
* @date 2021-06-18
*/
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrVo", description="部门信息")
public class OrgDepartmentVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "部门人员信息")
private OrgUsr OrgUsr;
@ApiModelProperty(value = "动态表单值")
private List<AlertFormValue> alertFormValue;
public OrgDepartmentVo(OrgUsr orgUsr, List<AlertFormValue> alertFormValue) {
OrgUsr = orgUsr;
this.alertFormValue = alertFormValue;
}
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 机构/部门/人员表
*
* @author tb
* @date 2021-06-18
*/
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrVo", description="人员信息")
public class OrgPersonFormVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "人员基本信息")
private OrgUsr OrgUsr;
@ApiModelProperty(value = "动态表单值")
private List<FormValue> dynamicFormAlert;
public OrgPersonFormVo(OrgUsr orgUsr, List<FormValue> dynamicFormAlert) {
OrgUsr = orgUsr;
this.dynamicFormAlert = dynamicFormAlert;
}
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 机构/部门/人员表
*
* @author tb
* @date 2021-06-18
*/
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrVo", description="人员")
public class OrgPersonVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "人员基本信息")
private OrgUsr OrgUsr;
@ApiModelProperty(value = "动态表单值")
private List<AlertFormValue> alertFormValue;
public OrgPersonVo(OrgUsr orgUsr, List<AlertFormValue> alertFormValue) {
OrgUsr = orgUsr;
this.alertFormValue = alertFormValue;
}
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author fengwang
* @date 2021-06-21.
*/
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrDownloadTemplateVO", description="")
@ExcelTarget("OrgUsrDownloadTemplateVO")
public class OrgUsrDownloadTemplateVO {
@Excel(name = "机构名称",width = 30)
@ApiModelProperty(value = "机构/部门名称")
private String bizOrgName;
@Excel(name = "机构编码",width = 30)
@ApiModelProperty(value = "机构编码")
private String bizOrgCode;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "amos中公司/部门ID")
private String amosOrgId;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "机构类型(单位:COMPANY)")
private String bizOrgType = CommonConstant.BIZ_ORG_TYPE_COMPANY;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "所属建筑名称")
private String buildName;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "所属建筑ID")
private String buildId;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "归属机构/部门/人员")
private String parentId;
@Excel(name = "amos中公司/部门ID",width = 30)
@ApiModelProperty(value = "扩展属性1")
private String orgExpandAttr1;
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 机构/部门/人员表
*
* @author tb
* @date 2021-06-18
*/
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrVo", description="机构/部门/人员表")
public class OrgUsrFormVo {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "机构/部门人员基本信息")
private OrgUsr OrgUsr;
@ApiModelProperty(value = "动态表单值")
private List<FormValue> dynamicFormAlert;
@ApiModelProperty(value = "单位人员信息值")
private List<OrgPersonFormVo> children;
public OrgUsrFormVo(OrgUsr orgUsr, List<FormValue> formValue) {
OrgUsr = orgUsr;
this.dynamicFormAlert = formValue;
}
public OrgUsrFormVo(OrgUsr orgUsr, List<FormValue> dynamicFormAlert, List<OrgPersonFormVo> children) {
this.OrgUsr = orgUsr;
this.dynamicFormAlert = dynamicFormAlert;
this.children = children;
}
}
package com.yeejoin.amos.boot.module.jcs.api.vo;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.util.List;
/**
* 机构/部门/人员表
*
......@@ -21,57 +19,19 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
@Data
@Accessors(chain = true)
@TableName("cb_org_usr")
@ApiModel(value="OrgUsrVo", description="机构/部门/人员表")
@ApiModel(value="OrgUsrVo", description="单位信息")
public class OrgUsrVo{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "单位基本信息")
private OrgUsr OrgUsr;
@ApiModelProperty(value = "机构/部门名称")
private String bizOrgName;
@ApiModelProperty(value = "机构编码")
private String bizOrgCode;
@ApiModelProperty(value = "amos中公司/部门ID")
private String amosOrgId;
@ApiModelProperty(value = "amos中公司/部门编码")
private String amosOrgCode;
@ApiModelProperty(value = "机构类型(部门:DEPARTMENT,单位:COMPANY,人员:PERSON)")
private String bizOrgType;
@ApiModelProperty(value = "所属建筑名称")
private String buildName;
@ApiModelProperty(value = "所属建筑ID")
private String buildId;
@ApiModelProperty(value = "归属机构/部门/人员")
private String parentId;
@ApiModelProperty(value = "扩展属性1")
private String orgExpandAttr1;
@ApiModelProperty(value = "扩展属性2")
private String orgExpandAttr2;
@ApiModelProperty(value = "扩展属性3")
private String orgExpandAttr3;
@ApiModelProperty(value = "扩展属性4")
private String orgExpandAttr4;
private String orgExpandAttr5;
private String orgExpandAttr6;
private String orgExpandAttr7;
private String orgExpandAttr8;
@ApiModelProperty(value = "更新人")
private String recUserName;
@ApiModelProperty(value = "单位动态表单值")
private List<AlertFormValue> alertFormValue;
public OrgUsrVo(OrgUsr orgUsr, List<AlertFormValue> alertFormValue) {
OrgUsr = orgUsr;
this.alertFormValue = alertFormValue;
}
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.biz.common.utils.ExcelUtils;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgMenu;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertFormValueService;
import com.yeejoin.amos.boot.module.jcs.api.service.IOrgUsrService;
import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgDepartmentVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgPersonVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrDownloadTemplateVO;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrFormVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author fengwang
* @date 2021-06-21.
*/
@RestController
@Api(tags = "部门Api")
@RequestMapping(value = "/jcs/org-department")
public class OrgDepartmentController {
@Autowired
IOrgUsrService iOrgUsrService;
@Autowired
IAlertFormValueService iAlertFromValueService;
/**
* 新增部门信息
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增部门信息", notes = "新增部门信息")
public ResponseModel saveOrgUsr(HttpServletRequest request, @RequestBody OrgDepartmentVo OrgDepartmentVo) {
OrgUsr orgUsr = OrgDepartmentVo.getOrgUsr();
// 单位新增情况
iOrgUsrService.save(orgUsr);
// 动态表单
List<AlertFormValue> alertFromValuelist = OrgDepartmentVo.getAlertFormValue();
// 填充主键
alertFromValuelist.stream().forEach(alertFromValue -> {
alertFromValue.setAlertCalledId(orgUsr.getSequenceNbr());
});
// 保存动态表单数据
iAlertFromValueService.saveBatch(alertFromValuelist);
return CommonResponseUtil.success();
}
/**
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public ResponseModel deleteById(HttpServletRequest request, @PathVariable Long id) {
// 删除时,只作逻辑删除
iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", id).set("is_delete", CommonConstant.IS_DELETE_01));
return CommonResponseUtil.success();
}
/**
* 更新部门数据
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "更新单位数据", notes = "更新单位数据")
public ResponseModel updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgDepartmentVo OrgDepartmentVo, @PathVariable Long id) {
OrgUsr orgUsr = OrgDepartmentVo.getOrgUsr();
// 单位新增情况
iOrgUsrService.save(orgUsr);
// 动态表单
List<AlertFormValue> alertFromValuelist = OrgDepartmentVo.getAlertFormValue();
// 填充主键
alertFromValuelist.stream().forEach(alertFromValue -> {
alertFromValue.setAlertCalledId(orgUsr.getSequenceNbr());
});
// 保存动态表单数据
iAlertFromValueService.saveBatch(alertFromValuelist);
return CommonResponseUtil.success();
}
/**
* 根据id查询单位
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取部门详情", notes = "获取部门详情")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("alert_called_id", id);
// 动态表单数据
List<AlertFormValue> list = iAlertFromValueService.list(queryWrapper);
List<FormValue> formValue = new ArrayList();
for (AlertFormValue alertFormValue : list) {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
formValue.add(value);
}
return CommonResponseUtil.success( new OrgUsrFormVo(iOrgUsrService.getById(id), formValue));
}
/**
* 根据bizOrgType分页查询
*
* @param bizOrgType
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/selectByBizOrgType/{bizOrgType}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据bizOrgType分页查询", notes = "根据bizOrgType分页查询")
public IPage<OrgUsr> bizOrgTypeListPage(String pageNum, String pageSize, @PathVariable String bizOrgType) {
Page<OrgUsr> pageBean = new Page();
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
return iOrgUsrService.page(pageBean, new QueryWrapper<OrgUsr>().eq("biz_org_type", bizOrgType));
}
/**
* 获取部门树
*
* @param
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取部门树", notes = "获取部门树")
public ResponseModel selectCompanyTree() throws Exception {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("is_delete", CommonConstant.IS_DELETE_00);
columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_DEPARTMENT);
Collection<OrgUsr> list = iOrgUsrService.listByMap(columnMap);
List<OrgMenu> menus = iOrgUsrService.getTree(null, list, OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType");
return CommonResponseUtil.success(menus);
}
/**
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<OrgUsr> listPage(String pageNum, String pageSize, OrgUsr orgUsr) {
Page<OrgUsr> pageBean;
QueryWrapper<OrgUsr> orgUsrQueryWrapper = new QueryWrapper<>();
Class<? extends OrgUsr> aClass = orgUsr.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(orgUsr);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<OrgUsr> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iOrgUsrService.page(pageBean, orgUsrQueryWrapper);
return page;
}
// /**
// * 导入部门信息
// *
// * @return
// */
// @TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/saveDepartment", method = RequestMethod.POST)
// @ApiOperation(httpMethod = "POST", value = "导入部门信息", notes = "导入部门信息")
// public ResponseModel saveDepartment(HttpServletRequest request, @RequestBody OrgDepartment orgDepartment, @PathVariable Long id) {
// // 导入部门信息的前提条件:单位信息已经存在
// if (iOrgUsrService.getById(id) == null) {
// return CommonResponseUtil.failure("单位信息需存在才可导入部门信息");
// }
// if (orgDepartment.getBizOrgType().equals(CommonConstant.BIZ_ORG_TYPE_DEPARTMENT)) {
// orgUsr.setBizOrgType(type);
// iOrgUsrService.save(orgUsr);
// // 动态表单
// List<AlertFormValue> alertFromValuelist = OrgUsrVo.getAlertFormValue();
// // 填充主键
// alertFromValuelist.stream().forEach(alertFromValue -> {
// alertFromValue.setAlertCalledId(orgUsr.getSequenceNbr());
// });
// // 保存动态表单数据
// iAlertFromValueService.saveBatch(alertFromValuelist);
// return CommonResponseUtil.success();
// }
// return CommonResponseUtil.failure("机构类型需为部门");
// }
/**
* 获取部门列表
*
* @param orgCode
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{orgCode}/users", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取部门人员列表", notes = "获取部门人员列表")
public ResponseModel selectUsersByOrgCode(HttpServletRequest request,@PathVariable Long orgCode) {
IPage<OrgUsr> page;
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("biz_org_code", orgCode);
columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_PERSON);
columnMap.put("is_delete",CommonConstant.IS_DELETE_00);
return CommonResponseUtil.success(iOrgUsrService.listByMap(columnMap));
}
/**
* 导出部门模板
*
* @param response
* @param OrgUsrDownloadTemplateVO
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "download-template/{type}", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "根据类型导出模板", notes = "根据类型导出模板")
public ResponseModel downloadTemplate(HttpServletResponse response, @RequestBody List<OrgUsrDownloadTemplateVO> OrgUsrDownloadTemplateVO) throws UnsupportedEncodingException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
ExcelUtils.exportExcel(OrgUsrDownloadTemplateVO, "部门信息", "部门信息", OrgUsrDownloadTemplateVO.class, simpleDateFormat.format(new Date()) + ".xls", response);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.biz.common.utils.ExcelUtils;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertFormValueService;
import com.yeejoin.amos.boot.module.jcs.api.service.IOrgUsrService;
import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgPersonVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrDownloadTemplateVO;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrFormVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author fengwang
* @date 2021-06-21.
*/
@RestController
@Api(tags = "人员表Api")
@RequestMapping(value = "/org-person")
public class OrgPersonController {
@Autowired
IOrgUsrService iOrgUsrService;
@Autowired
IAlertFormValueService iAlertFromValueService;
/**
* 新增人员信息
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增人员信息", notes = "新增人员信息")
public ResponseModel saveOrgUsr(HttpServletRequest request, @RequestBody OrgPersonVo OrgPersonVo) {
OrgUsr orgUsr = OrgPersonVo.getOrgUsr();
// 单位新增情况
iOrgUsrService.save(orgUsr);
// 动态表单
List<AlertFormValue> alertFromValuelist = OrgPersonVo.getAlertFormValue();
// 填充主键
alertFromValuelist.stream().forEach(alertFromValue -> {
alertFromValue.setAlertCalledId(orgUsr.getSequenceNbr());
});
// 保存动态表单数据
iAlertFromValueService.saveBatch(alertFromValuelist);
return CommonResponseUtil.success();
}
/**
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public ResponseModel deleteById(HttpServletRequest request, @PathVariable Long id) {
// 删除时,只作逻辑删除
iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", id).set("is_delete", CommonConstant.IS_DELETE_01));
return CommonResponseUtil.success();
}
/**
* 更新单位数据
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "更新单位数据", notes = "更新单位数据")
public ResponseModel updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgUsr orgUsr, @PathVariable Long id) {
// 修改单位信息
orgUsr.setSequenceNbr(id);
iOrgUsrService.updateById(orgUsr);
return CommonResponseUtil.success();
}
/**
* 根据id查询人员
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取人员详情", notes = "获取人员详情")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id) {
OrgUsr orgUsr = iOrgUsrService.getById(id);
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("alert_called_id", id);
// 动态表单数据
List<AlertFormValue> list = iAlertFromValueService.list(queryWrapper);
List<FormValue> formValue = new ArrayList();
for (AlertFormValue alertFormValue : list) {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
formValue.add(value);
}
OrgUsrFormVo orgUsrFormVo = new OrgUsrFormVo(orgUsr, formValue);
return CommonResponseUtil.success(orgUsrFormVo);
}
/**
* 根据bizOrgType分页查询
*
* @param bizOrgType
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/selectByBizOrgType/{bizOrgType}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据bizOrgType分页查询", notes = "根据bizOrgType分页查询")
public ResponseModel bizOrgTypeListPage(String pageNum, String pageSize, @PathVariable String bizOrgType) {
Page<OrgUsr> pageBean = new Page();
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
return CommonResponseUtil.success(iOrgUsrService.page(pageBean, new QueryWrapper<OrgUsr>().eq("biz_org_type", bizOrgType)));
}
/**
* 获取人员树
*
* @param
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取人员树", notes = "获取人员树")
public ResponseModel selectCompanyTree() throws Exception {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("is_delete", CommonConstant.IS_DELETE_00);
columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_PERSON);
Collection<OrgUsr> list = iOrgUsrService.listByMap(columnMap);
return CommonResponseUtil.success(iOrgUsrService.getTree(null, list, OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType"));
}
/**
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<OrgUsr> listPage(String pageNum, String pageSize, OrgUsr orgUsr) {
Page<OrgUsr> pageBean;
QueryWrapper<OrgUsr> orgUsrQueryWrapper = new QueryWrapper<>();
Class<? extends OrgUsr> aClass = orgUsr.getClass();
Arrays.stream(aClass.getDeclaredFields()).forEach(field -> {
try {
field.setAccessible(true);
Object o = field.get(orgUsr);
if (o != null) {
Class<?> type = field.getType();
String name = NameUtils.camel2Underline(field.getName());
if (type.equals(Integer.class)) {
Integer fileValue = (Integer) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else if (type.equals(Long.class)) {
Long fileValue = (Long) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) {
String fileValue = (String) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
} else {
String fileValue = (String) field.get(orgUsr);
orgUsrQueryWrapper.eq(name, fileValue);
}
}
} catch (Exception e) {
}
});
IPage<OrgUsr> page;
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iOrgUsrService.page(pageBean, orgUsrQueryWrapper);
return page;
}
/**
*
*
* @param orgCode
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{orgCode}/users", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据orgCode分页查询", notes = "根据orgCode分页查询")
public ResponseModel selectUsersByOrgCode(HttpServletRequest request, String pageNum, String pageSize, @PathVariable Long orgCode) {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("is_delete",CommonConstant.IS_DELETE_00);
columnMap.put("biz_org_code", orgCode);
columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_PERSON);
iOrgUsrService.listByMap(columnMap);
return CommonResponseUtil.success();
}
/**
* 导出人员模板
*
* @param response
* @param OrgUsrDownloadTemplateVO
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "download-template/{type}", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "导出人员模板", notes = "导出人员模板")
public ResponseModel downloadTemplate(HttpServletResponse response, @RequestBody List<OrgUsrDownloadTemplateVO> OrgUsrDownloadTemplateVO) throws UnsupportedEncodingException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
ExcelUtils.exportExcel(OrgUsrDownloadTemplateVO, "人员信息", "人员信息", OrgUsrDownloadTemplateVO.class, simpleDateFormat.format(new Date()) + ".xls", response);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.boot.module.jcs.biz.controller;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.yeejoin.amos.boot.biz.common.constants.CommonConstant;
import com.yeejoin.amos.boot.biz.common.utils.CommonResponseUtil;
import com.yeejoin.amos.boot.biz.common.utils.ExcelUtils;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgMenu;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertFormValueService;
import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrDownloadTemplateVO;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrFormVo;
import com.yeejoin.amos.boot.module.jcs.api.vo.OrgUsrVo;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
......@@ -10,7 +23,10 @@ import com.yeejoin.amos.boot.module.jcs.api.service.IOrgUsrService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -18,84 +34,161 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 机构/部门/人员表
*
* @author tb
* @date 2021-06-18
*/
* 部门信息修改
*
* @author tb
* @date 2021-06-18
*/
@RestController
@Api(tags = "机构/部门/人员表Api")
@Api(tags = "单位Api")
@RequestMapping(value = "/org-usr")
public class OrgUsrController extends BaseController {
@Autowired
IOrgUsrService iOrgUsrService;
@Autowired
IAlertFormValueService iAlertFromValueService;
/**
* 新增机构/部门/人员表
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
* 新增单位信息
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增机构/部门/人员表", notes = "新增机构/部门/人员表")
public boolean saveOrgUsr(HttpServletRequest request, @RequestBody OrgUsr orgUsr){
return iOrgUsrService.save(orgUsr);
@ApiOperation(httpMethod = "POST", value = "新增单位信息", notes = "新增单位信息")
public ResponseModel saveOrgUsr(HttpServletRequest request, @RequestBody OrgUsrVo OrgUsrVo) {
OrgUsr orgUsr = new OrgUsr();
BeanUtils.copyProperties(OrgUsrVo,orgUsr);
// 单位新增情况
iOrgUsrService.save(orgUsr);
// 动态表单
List<AlertFormValue> alertFromValuelist = OrgUsrVo.getAlertFormValue();
// 填充主键
alertFromValuelist.stream().forEach(alertFromValue -> {
alertFromValue.setAlertCalledId(orgUsr.getSequenceNbr());
});
// 保存动态表单数据
iAlertFromValueService.saveBatch(alertFromValuelist);
return CommonResponseUtil.success();
}
/**
* 根据id删除
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
* 根据id删除
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
public boolean deleteById(HttpServletRequest request, @PathVariable Long id){
return iOrgUsrService.removeById(id);
public ResponseModel deleteById(HttpServletRequest request, @PathVariable Long id) {
// 删除时,只作逻辑删除
iOrgUsrService.update(new UpdateWrapper<OrgUsr>().eq("sequence_nbr", id).set("is_delete", CommonConstant.IS_DELETE_01));
return CommonResponseUtil.success();
}
/**
* 更新单位数据
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "更新单位数据", notes = "更新单位数据")
public ResponseModel updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgUsr orgUsr, @PathVariable Long id) {
// 修改单位信息
orgUsr.setSequenceNbr(id);
iOrgUsrService.updateById(orgUsr);
return CommonResponseUtil.success();
}
/**
* 修改机构/部门/人员表
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改机构/部门/人员表", notes = "修改机构/部门/人员表")
public boolean updateByIdOrgUsr(HttpServletRequest request, @RequestBody OrgUsr orgUsr){
return iOrgUsrService.updateById(orgUsr);
* 根据id查询单位
*
* @param id
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取单位详情", notes = "获取单位详情")
public ResponseModel selectById(HttpServletRequest request, @PathVariable Long id) {
OrgUsr orgUsr = iOrgUsrService.getById(id);
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("alert_called_id", id);
// 动态表单数据
List<AlertFormValue> list = iAlertFromValueService.list(queryWrapper);
List<FormValue> formValue = new ArrayList();
for (AlertFormValue alertFormValue : list) {
FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
formValue.add(value);
}
return CommonResponseUtil.success(new OrgUsrFormVo(orgUsr, formValue));
}
/**
* 根据id查询
* @param id
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
public OrgUsr selectById(HttpServletRequest request, @PathVariable Long id){
return iOrgUsrService.getById(id);
* 根据bizOrgType分页查询
*
* @param bizOrgType
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/selectByBizOrgType/{bizOrgType}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据bizOrgType分页查询", notes = "根据bizOrgType分页查询")
public ResponseModel bizOrgTypeListPage(String pageNum, String pageSize, @PathVariable String bizOrgType) {
Page<OrgUsr> pageBean = new Page();
if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
pageBean = new Page<>(0, Long.MAX_VALUE);
} else {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
return CommonResponseUtil.success(iOrgUsrService.page(pageBean, new QueryWrapper<OrgUsr>().eq("biz_org_type", bizOrgType)));
}
/**
* 获取单位树
*
* @param
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/companyTree", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取单位树", notes = "获取单位树")
public ResponseModel selectCompanyTree() throws Exception {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("is_delete", CommonConstant.IS_DELETE_00);
columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_COMPANY);
List<OrgMenu> menus = iOrgUsrService.getTree(null, iOrgUsrService.listByMap(columnMap), OrgUsr.class.getName(), "getSequenceNbr", 2, "getBizOrgName", "getParentId", "getBizOrgType");
return CommonResponseUtil.success(menus);
}
/**
* 列表分页查询
* @return
*/
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
* 列表分页查询
*
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
public IPage<OrgUsr> listPage(String pageNum,String pageSize, OrgUsr orgUsr){
public IPage<OrgUsr> listPage(String pageNum, String pageSize, OrgUsr orgUsr) {
Page<OrgUsr> pageBean;
QueryWrapper<OrgUsr> orgUsrQueryWrapper = new QueryWrapper<>();
......@@ -131,7 +224,74 @@ public class OrgUsrController extends BaseController {
pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iOrgUsrService.page(pageBean, orgUsrQueryWrapper);
return page;
}
return page;
}
/**
* 根据orgCode获取单位人员列表
*
* @param orgCode
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{orgCode}/users", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "根据orgCode获取单位人员列表", notes = "根据orgCode获取单位人员列表")
public ResponseModel selectUsersByOrgCode(HttpServletRequest request, @PathVariable Long orgCode) {
// Map<String, Object> columnMap = new LinkedHashMap<>();
// columnMap.put("is_delete", CommonConstant.IS_DELETE_00);
// columnMap.put("biz_org_code", orgCode);
// columnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_COMPANY);
// // 查询出单位基本信息
// OrgUsr company = iOrgUsrService.getOne(new QueryWrapper<OrgUsr>().allEq(columnMap));
// if (company != null) {
// QueryWrapper queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("alert_called_id", company.getSequenceNbr());
// // 获取单位动态表单数据
// List<AlertFormValue> list = iAlertFromValueService.list(queryWrapper);
// List<FormValue> formValue = new ArrayList();
// for (AlertFormValue alertFormValue : list) {
// FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue());
// formValue.add(value);
// }
// // 获取单位人员列表信息
// Map<String, Object> personColumnMap = new LinkedHashMap<>();
// personColumnMap.put("is_delete", CommonConstant.IS_DELETE_00);
// personColumnMap.put("biz_org_code", orgCode);
// personColumnMap.put("biz_org_type", CommonConstant.BIZ_ORG_TYPE_PERSON);
// List<OrgPersonFormVo> orgPersonFormVos = new ArrayList<>();
// Collection<OrgUsr> orgUsrs = iOrgUsrService.listByMap(personColumnMap);
// orgUsrs.forEach(orgUsr -> {
// QueryWrapper personQueryWrapper = new QueryWrapper<>();
// queryWrapper.eq("alert_called_id", orgUsr.getSequenceNbr());
// // 获取人员动态表单数据
// List<AlertFormValue> personList = iAlertFromValueService.list(queryWrapper);
// List<FormValue> personFormValue = new ArrayList();
// for (AlertFormValue alertFormValue : list) {
// FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue());
// personFormValue.add(value);
// }
// // 添加单位人员信息列表
// orgPersonFormVos.add(new OrgPersonFormVo(orgUsr, formValue));
// });
// return CommonResponseUtil.success(new OrgUsrFormVo(company, formValue, orgPersonFormVos));
// }
// return CommonResponseUtil.failure("根据orgCode获取单位人员列表失败");
return CommonResponseUtil.success();
}
/**
* 导出单位模板
*
* @param response
* @param OrgUsrDownloadTemplateVO
* @return
*/
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "download-template/{type}", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "根据类型导出模板", notes = "根据类型导出模板")
public ResponseModel downloadTemplate(HttpServletResponse response, @RequestBody List<OrgUsrDownloadTemplateVO> OrgUsrDownloadTemplateVO) throws UnsupportedEncodingException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
ExcelUtils.exportExcel(OrgUsrDownloadTemplateVO, "单位信息", "单位信息", OrgUsrDownloadTemplateVO.class, simpleDateFormat.format(new Date()) + ".xls", response);
return CommonResponseUtil.success();
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgMenu;
import com.yeejoin.amos.boot.module.jcs.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.jcs.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IOrgUsrService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* 机构/部门/人员表 服务实现类
......@@ -14,5 +19,104 @@ import org.springframework.stereotype.Service;
*/
@Service
public class OrgUsrServiceImpl extends ServiceImpl<OrgUsrMapper, OrgUsr> implements IOrgUsrService {
@Override
@SuppressWarnings("unchecked")
public List<OrgMenu> getTree(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception{
List<OrgMenu> resultList=new ArrayList<>();
Class clazz= Class.forName(packageURL);
Method IDMethodNameme = null;
switch (IDHierarchy) { case 1:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
case 2:
IDMethodNameme = clazz.getSuperclass().getDeclaredMethod(IDMethodName);
break;
case 3:
IDMethodNameme = clazz.getSuperclass().getSuperclass().getDeclaredMethod(IDMethodName);
break;
default:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
}
Method NAMEMethodNameme = clazz.getDeclaredMethod(NAMEMethodName);
Method PARENTIDMethodNameme = clazz.getDeclaredMethod(PARENTIDMethodName);
Method OrgTypeMethodNameme = clazz.getDeclaredMethod(OrgTypeMethodName);
//获取顶层元素集合
Long parentId;
for (Object ob : entityList) {
Object entity = clazz.cast(ob);
parentId=PARENTIDMethodNameme.invoke(entity)!=null? Long.valueOf(String.valueOf(PARENTIDMethodNameme.invoke(entity))):null;
if(parentId==null||topId==parentId){
OrgMenu menu=new OrgMenu(Long.valueOf(String.valueOf(IDMethodNameme.invoke(entity))), String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,String.valueOf(OrgTypeMethodNameme.invoke(entity)),false);
resultList.add(menu);
}
}
//获取每个顶层元素的子数据集合
for (OrgMenu entity : resultList) {
entity.setChildren(getSub(entity.getKey(), entityList, packageURL, IDMethodName,IDHierarchy, NAMEMethodName, PARENTIDMethodName, OrgTypeMethodName));
}
return resultList;
}
@Override
public List<OrgMenu> getSub(Long topId, Collection entityList, String packageURL, String IDMethodName, int IDHierarchy, String NAMEMethodName, String PARENTIDMethodName, String OrgTypeMethodName) throws Exception{
List<OrgMenu> childList=new ArrayList<>();
Class clazz= Class.forName(packageURL);
Method IDMethodNameme = null;
switch (IDHierarchy) {
case 1:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
case 2:
IDMethodNameme = clazz.getSuperclass().getDeclaredMethod(IDMethodName);
break;
case 3:
IDMethodNameme = clazz.getSuperclass().getSuperclass().getDeclaredMethod(IDMethodName);
break;
default:
IDMethodNameme = clazz.getDeclaredMethod(IDMethodName);
break;
}
Method OrgTypeMethodNameme = clazz.getDeclaredMethod(OrgTypeMethodName);
Method NAMEMethodNameme = clazz.getDeclaredMethod(NAMEMethodName);
Method PARENTIDMethodNameme = clazz.getDeclaredMethod(PARENTIDMethodName);
Long parentId;
//子集的直接子对象
for (Object ob : entityList) {
Object entity = clazz.cast(ob);
parentId=PARENTIDMethodNameme.invoke(entity)!=null? Long.valueOf(String.valueOf(PARENTIDMethodNameme.invoke(entity))):null;
if(parentId==null) {
if(topId==parentId){
OrgMenu menu=new OrgMenu(Long.valueOf(String.valueOf(IDMethodNameme.invoke(entity))), String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,String.valueOf(OrgTypeMethodNameme.invoke(entity)),false);
childList.add(menu);
}
}else {
if(topId.longValue()==parentId.longValue()){
OrgMenu menu=new OrgMenu(Long.valueOf(String.valueOf(IDMethodNameme.invoke(entity))), String.valueOf(NAMEMethodNameme.invoke(entity)), parentId,String.valueOf(OrgTypeMethodNameme.invoke(entity)),true);
childList.add(menu);
}
}
}
//子集的间接子对象
for (OrgMenu entity : childList) {
entity.setChildren(getSub(entity.getKey(), entityList, packageURL, IDMethodName,IDHierarchy, NAMEMethodName, PARENTIDMethodName,OrgTypeMethodName));
}
//递归退出条件
if(childList.size()==0){
return null;
}
return childList;
}
}
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