提交代码

dev_xds
姜玉琦 2024-01-14 21:23:56 +08:00
parent 785794a948
commit df08d716a7
7 changed files with 215 additions and 3 deletions

View File

@ -4,16 +4,22 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.ApplyCfgTypeEnum;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.ShiFouEnum;
import com.ruoyi.common.utils.NoUtils; import com.ruoyi.common.utils.NoUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysApplyConfig; import com.ruoyi.system.domain.SysApplyConfig;
import com.ruoyi.system.service.ISysApplyConfigService; import com.ruoyi.system.service.ISysApplyConfigService;
import com.yanzhu.jh.project.domain.SurProjectAttendanceCfg;
import com.yanzhu.jh.project.service.ISurProjectAttendanceCfgService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -26,9 +32,14 @@ import java.util.List;
@RequestMapping("/system/applyConfig") @RequestMapping("/system/applyConfig")
public class SysApplyConfigController extends BaseController public class SysApplyConfigController extends BaseController
{ {
private static final String vendorsCode = "yanzhu";
@Autowired @Autowired
private ISysApplyConfigService sysApplyConfigService; private ISysApplyConfigService sysApplyConfigService;
@Autowired
private ISurProjectAttendanceCfgService surProjectAttendanceCfgService;
/** /**
* *
*/ */
@ -72,6 +83,19 @@ public class SysApplyConfigController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody SysApplyConfig sysApplyConfig) public AjaxResult add(@RequestBody SysApplyConfig sysApplyConfig)
{ {
if(ApplyCfgTypeEnum.LABOUR.getCode().equals(sysApplyConfig.getCfgType())){
SurProjectAttendanceCfg surProjectAttendanceCfg = new SurProjectAttendanceCfg();
surProjectAttendanceCfg.setProjectId(sysApplyConfig.getProjectId());
surProjectAttendanceCfg.setSubDeptId(sysApplyConfig.getDeptId());
surProjectAttendanceCfg.setVendorsCode(vendorsCode);
surProjectAttendanceCfg.setEnabled(sysApplyConfig.getIsDel().equals(ShiFouEnum.FOU.getCode())?ShiFouEnum.SHI.getLongCode():ShiFouEnum.FOU.getLongCode());
surProjectAttendanceCfg.setState(ShiFouEnum.FOU.getLongCode());
int res = surProjectAttendanceCfgService.insertSurProjectAttendanceCfg(surProjectAttendanceCfg);
if(res>0){
// 同步将信息保存到sur_project_attendance_cfg
sysApplyConfig.setCfgId(surProjectAttendanceCfg.getId());
}
}
return toAjax(sysApplyConfigService.insertSysApplyConfig(sysApplyConfig)); return toAjax(sysApplyConfigService.insertSysApplyConfig(sysApplyConfig));
} }
@ -83,6 +107,12 @@ public class SysApplyConfigController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody SysApplyConfig sysApplyConfig) public AjaxResult edit(@RequestBody SysApplyConfig sysApplyConfig)
{ {
if(ApplyCfgTypeEnum.LABOUR.getCode().equals(sysApplyConfig.getCfgType())){
SurProjectAttendanceCfg surProjectAttendanceCfg = new SurProjectAttendanceCfg();
surProjectAttendanceCfg.setId(sysApplyConfig.getCfgId());
surProjectAttendanceCfg.setEnabled(sysApplyConfig.getIsDel().equals(ShiFouEnum.FOU.getCode())?ShiFouEnum.SHI.getLongCode():ShiFouEnum.FOU.getLongCode());
surProjectAttendanceCfgService.updateSurProjectAttendanceCfg(surProjectAttendanceCfg);
}
return toAjax(sysApplyConfigService.updateSysApplyConfig(sysApplyConfig)); return toAjax(sysApplyConfigService.updateSysApplyConfig(sysApplyConfig));
} }
@ -94,6 +124,16 @@ public class SysApplyConfigController extends BaseController
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids)
{ {
List<Long> cfgIds = new ArrayList<>();
for(Long id:ids){
SysApplyConfig sysApplyConfig = sysApplyConfigService.selectSysApplyConfigById(id);
if(ApplyCfgTypeEnum.LABOUR.getCode().equals(sysApplyConfig.getCfgType())){
cfgIds.add(sysApplyConfig.getCfgId());
}
}
if(CollectionUtils.isNotEmpty(cfgIds)){
surProjectAttendanceCfgService.deleteSurProjectAttendanceCfgByIds(cfgIds.stream().toArray(Long[]::new));
}
return toAjax(sysApplyConfigService.deleteSysApplyConfigByIds(ids)); return toAjax(sysApplyConfigService.deleteSysApplyConfigByIds(ids));
} }

View File

@ -0,0 +1,30 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum ApplyCfgTypeEnum {
LABOUR("1", "劳务人员信息接入");
private final String code;
private final String info;
ApplyCfgTypeEnum(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.common.enums;
/**
*
*
* @author ruoyi
*/
public enum VendorsCodeEnum {
YANZHU("yanzhu", "研筑");
private final String code;
private final String info;
VendorsCodeEnum(String code, String info)
{
this.code = code;
this.info = info;
}
public String getCode()
{
return code;
}
public String getInfo()
{
return info;
}
}

View File

@ -18,6 +18,12 @@ public class SysApplyConfig extends BaseEntity
/** 主键 */ /** 主键 */
private Long id; private Long id;
/** 服务配置主键 */
private Long cfgId;
/** 服务配置类型 */
private String cfgType;
/** 应用主键 */ /** 应用主键 */
@Excel(name = "应用主键") @Excel(name = "应用主键")
private String appId; private String appId;
@ -129,10 +135,28 @@ public class SysApplyConfig extends BaseEntity
this.deptName = deptName; this.deptName = deptName;
} }
public Long getCfgId() {
return cfgId;
}
public void setCfgId(Long cfgId) {
this.cfgId = cfgId;
}
public String getCfgType() {
return cfgType;
}
public void setCfgType(String cfgType) {
this.cfgType = cfgType;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("cfgId", getCfgId())
.append("cfgType", getCfgType())
.append("appId", getAppId()) .append("appId", getAppId())
.append("publicKey", getPublicKey()) .append("publicKey", getPublicKey())
.append("privateKey", getPrivateKey()) .append("privateKey", getPrivateKey())

View File

@ -6,6 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="SysApplyConfig" id="SysApplyConfigResult"> <resultMap type="SysApplyConfig" id="SysApplyConfigResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="cfgType" column="cfg_type" />
<result property="cfgId" column="cfg_id" />
<result property="appId" column="app_id" /> <result property="appId" column="app_id" />
<result property="publicKey" column="public_key" /> <result property="publicKey" column="public_key" />
<result property="privateKey" column="private_key" /> <result property="privateKey" column="private_key" />
@ -22,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectSysApplyConfigVo"> <sql id="selectSysApplyConfigVo">
select sac.id, sac.app_id, sac.public_key, sac.private_key, sac.project_id, sp.projectName, sac.dept_id, sd.dept_name as deptName, sac.is_del, sac.create_by, sac.create_time, sac.update_by, sac.update_time, sac.remark from sys_apply_config sac select sac.id, sac.cfg_type, sac.cfg_id, sac.app_id, sac.public_key, sac.private_key, sac.project_id, sp.projectName, sac.dept_id, sd.dept_name as deptName, sac.is_del, sac.create_by, sac.create_time, sac.update_by, sac.update_time, sac.remark from sys_apply_config sac
left join sur_project sp on sac.project_id = sp.id left join sur_project sp on sac.project_id = sp.id
left join sys_dept sd on sac.dept_id = sd.dept_id left join sys_dept sd on sac.dept_id = sd.dept_id
</sql> </sql>
@ -30,6 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSysApplyConfigList" parameterType="SysApplyConfig" resultMap="SysApplyConfigResult"> <select id="selectSysApplyConfigList" parameterType="SysApplyConfig" resultMap="SysApplyConfigResult">
<include refid="selectSysApplyConfigVo"/> <include refid="selectSysApplyConfigVo"/>
<where> <where>
<if test="cfgId != null "> and sac.cfg_id = #{cfgId}</if>
<if test="cfgType != null "> and sac.cfg_type = #{cfgType}</if>
<if test="appId != null "> and sac.app_id like concat('%', #{appId}, '%')</if> <if test="appId != null "> and sac.app_id like concat('%', #{appId}, '%')</if>
<if test="projectName != null "> and sp.projectName like concat('%', #{projectName}, '%')</if> <if test="projectName != null "> and sp.projectName like concat('%', #{projectName}, '%')</if>
<if test="deptName != null "> and sd.dept_name like concat('%', #{deptName}, '%')</if> <if test="deptName != null "> and sd.dept_name like concat('%', #{deptName}, '%')</if>
@ -47,6 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sys_apply_config insert into sys_apply_config
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if> <if test="id != null">id,</if>
<if test="cfgType != null">cfg_type,</if>
<if test="cfgId != null">cfg_id,</if>
<if test="appId != null">app_id,</if> <if test="appId != null">app_id,</if>
<if test="publicKey != null">public_key,</if> <if test="publicKey != null">public_key,</if>
<if test="privateKey != null">private_key,</if> <if test="privateKey != null">private_key,</if>
@ -61,6 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
<if test="cfgType != null">#{cfgType},</if>
<if test="cfgId != null">#{cfgId},</if>
<if test="appId != null">#{appId},</if> <if test="appId != null">#{appId},</if>
<if test="publicKey != null">#{publicKey},</if> <if test="publicKey != null">#{publicKey},</if>
<if test="privateKey != null">#{privateKey},</if> <if test="privateKey != null">#{privateKey},</if>
@ -78,6 +86,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateSysApplyConfig" parameterType="SysApplyConfig"> <update id="updateSysApplyConfig" parameterType="SysApplyConfig">
update sys_apply_config update sys_apply_config
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="cfgType != null">cfg_type = #{cfgType},</if>
<if test="cfgId != null">cfg_id = #{cfgId},</if>
<if test="appId != null">app_id = #{appId},</if> <if test="appId != null">app_id = #{appId},</if>
<if test="publicKey != null">public_key = #{publicKey},</if> <if test="publicKey != null">public_key = #{publicKey},</if>
<if test="privateKey != null">private_key = #{privateKey},</if> <if test="privateKey != null">private_key = #{privateKey},</if>

View File

@ -1,6 +1,16 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="应用类型" prop="cfgType">
<el-select v-model="queryParams.cfgType" placeholder="请选择应用类型" clearable>
<el-option
v-for="dict in dict.type.sys_apply_cfg_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="应用主键" prop="appId"> <el-form-item label="应用主键" prop="appId">
<el-input <el-input
v-model="queryParams.appId" v-model="queryParams.appId"
@ -89,6 +99,11 @@
<el-table v-loading="loading" :data="applyConfigList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="applyConfigList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="应用类型" align="center" prop="cfgType">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_apply_cfg_type" :value="scope.row.cfgType"/>
</template>
</el-table-column>
<el-table-column label="项目信息" align="center" prop="projectName" /> <el-table-column label="项目信息" align="center" prop="projectName" />
<el-table-column label="部门信息" align="center" prop="deptName" /> <el-table-column label="部门信息" align="center" prop="deptName" />
<el-table-column label="AppId" align="center" prop="appId" /> <el-table-column label="AppId" align="center" prop="appId" />
@ -138,6 +153,16 @@
<div class="page-warning"> <div class="page-warning">
<p><strong style="color: #E6A23C;">应用公钥</strong> 在注册应用后由系统生成请在保存后查看</p> <p><strong style="color: #E6A23C;">应用公钥</strong> 在注册应用后由系统生成请在保存后查看</p>
</div> </div>
<el-form-item label="应用类型" prop="cfgType">
<el-select v-model="form.cfgType" placeholder="请选择应用类型" style="width: 100%" :disabled="getDisabled()">
<el-option
v-for="dict in dict.type.sys_apply_cfg_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="应用主键" prop="appId"> <el-form-item label="应用主键" prop="appId">
<el-input v-model="form.appId" placeholder="请输入应用主键" :disabled="true"/> <el-input v-model="form.appId" placeholder="请输入应用主键" :disabled="true"/>
</el-form-item> </el-form-item>
@ -210,7 +235,7 @@ import { listApplyConfig, getApplyConfig, delApplyConfig, addApplyConfig, update
export default { export default {
name: "ApplyConfig", name: "ApplyConfig",
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable','sys_apply_cfg_type'],
data() { data() {
return { return {
// //
@ -246,6 +271,9 @@ export default {
form: {}, form: {},
// //
rules: { rules: {
cfgType: [
{ required: true, message: "请选择注册应用类型", trigger: "blur" },
],
projectId: [ projectId: [
{ required: true, message: "请选择所属项目信息", trigger: "blur" }, { required: true, message: "请选择所属项目信息", trigger: "blur" },
], ],

View File

@ -1,7 +1,15 @@
package com.yanzhu.jh.project.service.impl; package com.yanzhu.jh.project.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.ruoyi.common.enums.ApplyCfgTypeEnum;
import com.ruoyi.common.enums.ShiFouEnum;
import com.ruoyi.common.enums.VendorsCodeEnum;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.SysApplyConfig;
import com.ruoyi.system.service.ISysApplyConfigService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yanzhu.jh.project.mapper.SurProjectAttendanceCfgMapper; import com.yanzhu.jh.project.mapper.SurProjectAttendanceCfgMapper;
@ -17,6 +25,10 @@ import com.ruoyi.common.utils.SecurityUtils;
@Service @Service
public class SurProjectAttendanceCfgServiceImpl implements ISurProjectAttendanceCfgService public class SurProjectAttendanceCfgServiceImpl implements ISurProjectAttendanceCfgService
{ {
@Autowired
private ISysApplyConfigService sysApplyConfigService;
@Autowired @Autowired
private SurProjectAttendanceCfgMapper surProjectAttendanceCfgMapper; private SurProjectAttendanceCfgMapper surProjectAttendanceCfgMapper;
@ -69,6 +81,17 @@ public class SurProjectAttendanceCfgServiceImpl implements ISurProjectAttendance
{ {
surProjectAttendanceCfg.setUpdateBy(SecurityUtils.getUsername()); surProjectAttendanceCfg.setUpdateBy(SecurityUtils.getUsername());
surProjectAttendanceCfg.setUpdateTime(DateUtils.getNowDate()); surProjectAttendanceCfg.setUpdateTime(DateUtils.getNowDate());
if(VendorsCodeEnum.YANZHU.getCode().equals(surProjectAttendanceCfg.getVendorsCode())){
SysApplyConfig sysApplyConfig = new SysApplyConfig();
sysApplyConfig.setCfgType(ApplyCfgTypeEnum.LABOUR.getCode());
sysApplyConfig.setCfgId(surProjectAttendanceCfg.getId());
List<SysApplyConfig> list = sysApplyConfigService.selectSysApplyConfigList(sysApplyConfig);
if(CollectionUtils.isNotEmpty(list)){
sysApplyConfig = list.get(0);
sysApplyConfig.setIsDel(surProjectAttendanceCfg.getEnabled().equals(ShiFouEnum.FOU.getLongCode())?ShiFouEnum.SHI.getCode():ShiFouEnum.FOU.getCode());
sysApplyConfigService.updateSysApplyConfig(sysApplyConfig);
}
}
return surProjectAttendanceCfgMapper.updateSurProjectAttendanceCfg(surProjectAttendanceCfg); return surProjectAttendanceCfgMapper.updateSurProjectAttendanceCfg(surProjectAttendanceCfg);
} }
@ -81,6 +104,22 @@ public class SurProjectAttendanceCfgServiceImpl implements ISurProjectAttendance
@Override @Override
public int deleteSurProjectAttendanceCfgByIds(Long[] ids) public int deleteSurProjectAttendanceCfgByIds(Long[] ids)
{ {
List<Long> cfgIds = new ArrayList<>();
for(Long id:ids){
SurProjectAttendanceCfg surProjectAttendanceCfg = surProjectAttendanceCfgMapper.selectSurProjectAttendanceCfgById(id);
if(VendorsCodeEnum.YANZHU.getCode().equals(surProjectAttendanceCfg.getVendorsCode())){
SysApplyConfig sysApplyConfig = new SysApplyConfig();
sysApplyConfig.setCfgType(ApplyCfgTypeEnum.LABOUR.getCode());
sysApplyConfig.setCfgId(id);
List<SysApplyConfig> list = sysApplyConfigService.selectSysApplyConfigList(sysApplyConfig);
if(CollectionUtils.isNotEmpty(list)){
cfgIds.add(list.get(0).getId());
}
}
}
if(CollectionUtils.isNotEmpty(cfgIds)){
sysApplyConfigService.deleteSysApplyConfigByIds(cfgIds.stream().toArray(Long[]::new));
}
return surProjectAttendanceCfgMapper.deleteSurProjectAttendanceCfgByIds(ids); return surProjectAttendanceCfgMapper.deleteSurProjectAttendanceCfgByIds(ids);
} }
@ -93,6 +132,16 @@ public class SurProjectAttendanceCfgServiceImpl implements ISurProjectAttendance
@Override @Override
public int deleteSurProjectAttendanceCfgById(Long id) public int deleteSurProjectAttendanceCfgById(Long id)
{ {
SurProjectAttendanceCfg surProjectAttendanceCfg = surProjectAttendanceCfgMapper.selectSurProjectAttendanceCfgById(id);
if(VendorsCodeEnum.YANZHU.getCode().equals(surProjectAttendanceCfg.getVendorsCode())){
SysApplyConfig sysApplyConfig = new SysApplyConfig();
sysApplyConfig.setCfgType(ApplyCfgTypeEnum.LABOUR.getCode());
sysApplyConfig.setCfgId(id);
List<SysApplyConfig> list = sysApplyConfigService.selectSysApplyConfigList(sysApplyConfig);
if(CollectionUtils.isNotEmpty(list)){
sysApplyConfigService.deleteSysApplyConfigById(list.get(0).getId());
}
}
return surProjectAttendanceCfgMapper.deleteSurProjectAttendanceCfgById(id); return surProjectAttendanceCfgMapper.deleteSurProjectAttendanceCfgById(id);
} }
} }