EPC模版

This commit is contained in:
fl 2025-04-27 14:12:17 +08:00
parent 5bcb419e91
commit 380ac1764e
5 changed files with 585 additions and 0 deletions

View File

@ -0,0 +1,118 @@
package com.bonus.tool.controller.search;
import com.bonus.common.core.controller.BaseController;
import com.bonus.common.core.domain.AjaxResult;
import com.bonus.common.core.page.TableDataInfo;
import com.bonus.tool.dto.TbGwModelDto;
import com.bonus.tool.dto.TbGwModelVo;
import com.bonus.tool.service.EpcService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* Epc模版
* @author fly
* @date 2025/4/27
*/
@RestController
@Slf4j
@RequestMapping("/epc")
public class EpcController extends BaseController {
@Resource
private EpcService service;
/**
*Epc模版列表查询
* @param
* @return
*/
@ApiOperation(value = "Epc模版列表查询")
// @PreAuthorize("@ss.hasPermi('key:people:list')")
@GetMapping("/getEpcList")
public TableDataInfo getEpcList(TbGwModelDto bean) {
try {
startPage();
List<TbGwModelVo> list = service.getEpcList(bean);
return getDataTable(list);
}catch (Exception e){
log.info("Epc模版列表失败{}",e.getMessage());
return getDataTableError(null);
}
}
/**
* Epc模版新增
* @param
* @return
*/
@ApiOperation(value = "Epc模版新增")
// @PreAuthorize("@ss.hasPermi('key:people:list')")
@PostMapping("/addEpcTemp")
public AjaxResult addEpcTemp(@RequestBody TbGwModelDto o) {
try {
return service.addEpcTemp(o);
}catch (Exception e){
log.info("Epc模版新增失败{}",e.getMessage());
return error(e.getMessage());
}
}
/**
* Epc模版详情
* @param
* @return
*/
@ApiOperation(value = "Epc模版详情")
// @PreAuthorize("@ss.hasPermi('key:people:query')")
@PostMapping("/getEpcTempById")
public AjaxResult getEpcTempById(@RequestBody TbGwModelDto o) {
try {
return service.getEpcTempById(o);
}catch (Exception e){
log.info("公司业绩管理详情失败{}",e.getMessage());
return error("公司业绩管理详情失败");
}
}
/**
* Epc模版删除
* @param
* @return
*/
@ApiOperation(value = "Epc模版删除")
// @PreAuthorize("@ss.hasPermi('key:people:add')")
@PostMapping("/delEpcTemp")
public AjaxResult delEpcTemp(@RequestBody TbGwModelDto o) {
try {
return service.delEpcTemp(o);
}catch (Exception e){
log.info("Epc模版删除失败{}",e.getMessage());
return error(e.getMessage());
}
}
/**
* Epc模版修改
* @param
* @return
*/
@ApiOperation(value = "Epc模版修改")
// @PreAuthorize("@ss.hasPermi('key:people:add')")
@PostMapping("/updateEpcTemp")
public AjaxResult updateEpcTemp(@RequestBody TbGwModelDto o) {
try {
return service.updateEpcTemp(o);
}catch (Exception e){
log.info("Epc模版修改失败{}",e.getMessage());
return error(e.getMessage());
}
}
}

View File

@ -0,0 +1,98 @@
package com.bonus.tool.mapper;
import com.bonus.tool.dto.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface EpcMapper {
/**
* Epc模版列表查询
* @param
* @return
*/
List<TbGwModelVo> getEpcList(TbGwModelDto bean);
/**
* Epc模版新增
* @param
* @return
*/
int addEpcTemp(TbGwModelDto o);
/**
* Epc模版新增-公司关键人员
* @param comCoreList
* @return
*/
int insertComCore(List<ComCorePersonBean> comCoreList);
/**
* 国网模版新增-公司其他人员
* @param comOtherList
* @return
*/
int insertComOther(List<ComOtherPersonBean> comOtherList);
/**
* Epc模版新增-分包商拟派人员
* @param subPersonList
* @return
*/
int insertSubPerson(List<ComOtherPersonBean> subPersonList);
/**
* Epc模版详情
* @param
* @return
*/
TbGwModelVo getEpcTempById(TbGwModelDto o);
/**
* Epc模版详情-公司业绩
* @param id
* @return
*/
List<ComPerformanceBean> selectComPerfList(Long id);
/**
* Epc模版详情-公司关键人员
* @param id
* @return
*/
List<ComCorePersonBean> selectComCoreList(Long id);
/**
* 国网模版详情-公司其他人员
* @param id
* @return
*/
List<ComOtherPersonBean> selectComOtherList(Long id);
/**
* Epc模版详情-分包商人员
* @param id
* @return
*/
List<ComOtherPersonBean> selectSubOtherList(Long id);
/**
* Epc模版删除
* @param
* @return
*/
int delEpcTemp(Long id);
/**
* Epc模版关联数据删除
* @param o
*/
void delAssociatedData(TbGwModelDto o);
/**
* Epc模版修改
* @param
* @return
*/
int updateEpcTemp(TbGwModelDto o);
}

View File

@ -0,0 +1,44 @@
package com.bonus.tool.service;
import com.bonus.common.core.domain.AjaxResult;
import com.bonus.tool.dto.TbGwModelDto;
import com.bonus.tool.dto.TbGwModelVo;
import java.util.List;
public interface EpcService {
/**
* Epc模版列表查询
* @param
* @return
*/
List<TbGwModelVo> getEpcList(TbGwModelDto bean);
/**
* Epc模版新增
* @param
* @return
*/
AjaxResult addEpcTemp(TbGwModelDto o);
/**
* Epc模版详情
* @param o
* @return
*/
AjaxResult getEpcTempById(TbGwModelDto o);
/**
* Epc模版删除
* @param o
* @return
*/
AjaxResult delEpcTemp(TbGwModelDto o);
/**
* Epc模版修改
* @param o
* @return
*/
AjaxResult updateEpcTemp(TbGwModelDto o);
}

View File

@ -0,0 +1,158 @@
package com.bonus.tool.service.impl;
import com.bonus.common.core.domain.AjaxResult;
import com.bonus.common.utils.SecurityUtils;
import com.bonus.tool.dto.*;
import com.bonus.tool.mapper.EpcMapper;
import com.bonus.tool.service.EpcService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* @author fly
* @date 2025/4/24
*/
@Service
@Slf4j
public class EpcServiceImpl implements EpcService {
@Resource
private EpcMapper mapper;
/**
* Epc模版列表查询
*
* @param
* @return
*/
@Override
public List<TbGwModelVo> getEpcList(TbGwModelDto bean) {
//获取公司业绩列表
return mapper.getEpcList(bean);
}
/**
* Epc模版新增
*
* @param
* @return
*/
@Override
@Transactional
public AjaxResult addEpcTemp(TbGwModelDto o) {
String userName = SecurityUtils.getLoginUser().getUsername();
o.setCreateUser(userName);
//1.新增模板主表
int i = mapper.addEpcTemp(o);
if (i > 0) {
//新增关联数据
addAssociatedData(o);
}
return i > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 新增关联数据
*
* @param o
*/
private void addAssociatedData(TbGwModelDto o) {
//2.1公司关键人员
List<ComCorePersonBean> comCoreList = o.getComCoreList();
if (comCoreList != null && !comCoreList.isEmpty()) {
comCoreList.forEach(item -> {
item.setParentId(o.getId());
});
int y = mapper.insertComCore(comCoreList);
}
//2.2公司其他人员
List<ComOtherPersonBean> comotherList = o.getComOtherList();
if (comotherList != null && !comotherList.isEmpty()) {
comotherList.forEach(item -> {
item.setParentId(o.getId());
});
int y = mapper.insertComOther(comotherList);
}
//2.3 分包商人员
List<ComOtherPersonBean> subPersonList = o.getSubPersonList();
if (subPersonList != null && !subPersonList.isEmpty()) {
subPersonList.forEach(subPerson -> {
subPerson.setParentId(o.getId());
});
int z = mapper.insertSubPerson(subPersonList);
}
}
/**
* Epc模版详情
*
* @param
* @return
*/
@Override
public AjaxResult getEpcTempById(TbGwModelDto o) {
try {
//1.0获取Epc模版详情
TbGwModelVo bean = mapper.getEpcTempById(o);
//2.1获取公司核心人员
List<ComCorePersonBean> comCoreList = mapper.selectComCoreList(o.getId());
bean.setComCoreList(comCoreList);
//2.2获取公司其他人员
List<ComOtherPersonBean> comOtherList = mapper.selectComOtherList(o.getId());
bean.setComOtherList(comOtherList);
//3.1获取分包商人员
List<ComOtherPersonBean> subOtherList = mapper.selectSubOtherList(o.getId());
bean.setSubPersonList(subOtherList);
return AjaxResult.success(bean);
} catch (Exception e) {
log.info("Epc模版详情失败{}", e.getMessage());
return AjaxResult.error("Epc模版详情");
}
}
/**
* Epc模版删除
*
* @param o
* @return
*/
@Override
public AjaxResult delEpcTemp(TbGwModelDto o) {
int i = mapper.delEpcTemp(o.getId());
if (i > 0) {
delAssociatedData(o);
}
return i > 0 ? AjaxResult.success("Epc模板删除成功") : AjaxResult.error("Epc模板删除失败");
}
/**
* Epc模版修改
*
* @param o
* @return
*/
@Transactional
@Override
public AjaxResult updateEpcTemp(TbGwModelDto o) {
String userName = SecurityUtils.getLoginUser().getUsername();
o.setUpdateUser(userName);
int i = mapper.updateEpcTemp(o);
delAssociatedData(o);
addAssociatedData(o);
return AjaxResult.success("Epc模板修改成功");
}
/**
* 删除Epc模版关联数据
*
* @param o
*/
private void delAssociatedData(TbGwModelDto o) {
mapper.delAssociatedData(o);
}
}

View File

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.tool.mapper.EpcMapper">
<insert id="addEpcTemp" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into tb_epc_mdel(name,
create_user)
values (#{name},
#{createUser})
</insert>
<insert id="insertComCore">
insert into tb_epc_company_user(
epc_id,
key_id,
position,
pro_perf
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName},
#{item.proPerf}
)
</foreach>
</insert>
<insert id="insertComOther">
insert into tb_epc_other_user(
epc_id,
other_id,
position
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName}
)
</foreach>
</insert>
<insert id="insertSubPerson">
insert into tb_epc_sub_user(
epc_id,
user_id,
position
)values
<foreach collection="list" item="item" separator=",">
(
#{item.parentId},
#{item.id},
#{item.postName}
)
</foreach>
</insert>
<update id="updateEpcTemp">
update tb_epc_mdel
set
name = #{name},
update_user = #{updateUser}
where id = #{id}
</update>
<delete id="delEpcTemp">
update tb_epc_mdel
set del_flag = 1
where id = #{id}
</delete>
<delete id="delAssociatedData">
delete
from tb_epc_company_user
where epc_id = #{id};
delete
from tb_epc_other_user
where epc_id = #{id};
delete
from tb_epc_sub_user
where epc_id = #{id};
</delete>
<select id="getEpcList" resultType="com.bonus.tool.dto.TbGwModelVo">
select
id,
name,
create_user as createUser,
create_time,
update_time
from
tb_epc_mdel where del_flag =0
<if test="name != '' and name != null">
and name = #{name}
</if>
<if test="startDate != null and startDate != null and endDate != null and endDate != null">
and STR_TO_DATE(create_time, '%Y-%m-%d') between #{startDate} and #{endDate}
</if>
</select>
<select id="getEpcTempById" resultType="com.bonus.tool.dto.TbGwModelVo">
select id,
name
from tb_epc_mdel
where del_flag = 0
and id = #{id}
</select>
<select id="selectComPerfList" resultType="com.bonus.tool.dto.ComPerformanceBean">
SELECT id,
pro_name,
voltage,
station_num,
line_scale,
stop_time,
contract_rang,
owner_unit,
owner_phone
FROM tb_gw_perf_rel tgpr
LEFT JOIN tb_company_perf tcp ON tgpr.perf_id = tcp.id
WHERE tgpr.epc_id = #{id}
</select>
<select id="selectComCoreList" resultType="com.bonus.tool.dto.ComCorePersonBean">
SELECT tgku.id,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tgku.position as post_name,
tkp.major,
tkp.`level`,
tgku.pro_perf
FROM tb_epc_company_user tgku
LEFT JOIN tb_key_people tkp ON tgku.key_id = tkp.id
WHERE tgku.epc_id = #{id}
</select>
<select id="selectComOtherList" resultType="com.bonus.tool.dto.ComOtherPersonBean">
SELECT tgou.id,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tkp.major,
tkp.`level`,
tgou.position as post_name
FROM tb_epc_other_user tgou
LEFT JOIN tb_other_people tkp ON tgou.other_id = tkp.id
WHERE tgou.epc_id = #{id}
</select>
<select id="selectSubOtherList" resultType="com.bonus.tool.dto.ComOtherPersonBean">
SELECT tgou.id,
tkp.user_name,
tkp.id_card,
tkp.title,
tkp.diploma,
tkp.diploma_num,
tgou.position as post_name
FROM tb_epc_other_user tgou
LEFT JOIN tb_sub_people tkp ON tgou.other_id = tkp.id
WHERE tgou.epc_id = #{id}
</select>
</mapper>