定时器增量工程添加至工程表
This commit is contained in:
parent
bc8822fc1f
commit
0a41ecc202
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.material.push.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author : 洪超
|
||||
* @version : 1.0
|
||||
* @time : 2025-10-10 15:03
|
||||
* @Description: 实施单位枚举
|
||||
*/
|
||||
@Getter
|
||||
public enum IwsImpUnitEnum {
|
||||
|
||||
IMP_UNIT_HY(309, "安徽宏源电力建设有限公司"),
|
||||
IMP_UNIT_SA(339, "安徽顺安电网建设有限公司"),
|
||||
IMP_UNIT_BD(333, "变电分公司"),
|
||||
IMP_UNIT_HYBD(309, "宏源变电工程处"),
|
||||
IMP_UNIT_HYSD(309, "宏源送电工程处"),
|
||||
IMP_UNIT_JJ(101, "机具(物流)分公司"),
|
||||
IMP_UNIT_JXHFGS(344, "机械化分公司"),
|
||||
IMP_UNIT_JXSY(337, "检修试验分公司"),
|
||||
IMP_UNIT_JZFGS(338, "建筑分公司(消防分公司)"),
|
||||
IMP_UNIT_SR(102, "送电二分公司"),
|
||||
IMP_UNIT_SY(327, "送电一分公司"),
|
||||
IMP_UNIT_YJFGS(346, "运检分公司(无人机作业中心)");
|
||||
|
||||
private final Integer impUnitId;
|
||||
private final String impUnitName;
|
||||
|
||||
IwsImpUnitEnum(Integer impUnitId, String impUnitName) {
|
||||
this.impUnitId = impUnitId;
|
||||
this.impUnitName = impUnitName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -37,4 +37,8 @@ public interface ConsProjectLeaseMoneyMapper {
|
|||
List<BmProject> getIwsProjectList();
|
||||
|
||||
void updateIwsProject(@Param("list") List<BmProject> list);
|
||||
|
||||
List<BmProject> getBmProjectIsExist();
|
||||
|
||||
int insertBmProject(@Param("list") List<BmProject> newProjects);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.bonus.material.push.domain.AccProjectLeaseMoneyBean;
|
|||
import com.bonus.material.push.domain.ConsProjectLeaseMoneyBean;
|
||||
import com.bonus.material.push.domain.IwsCostPushBean;
|
||||
import com.bonus.material.push.domain.RentalCostsBean;
|
||||
import com.bonus.material.push.enums.IwsImpUnitEnum;
|
||||
import com.bonus.material.push.mapper.AccProjectLeaseMoneyMapper;
|
||||
import com.bonus.material.push.mapper.ConsProjectLeaseMoneyMapper;
|
||||
import com.bonus.material.push.mapper.IwsCostPushMapper;
|
||||
|
|
@ -88,6 +89,52 @@ public class RentalCostsServiceImpl implements RentalCostsService {
|
|||
consDao.updateIwsProject(list);
|
||||
}
|
||||
|
||||
/***************将没有的工程插入到bm_project表中****************/
|
||||
//1.获取bm_project表中已有的工程
|
||||
List<BmProject> isExistList = consDao.getBmProjectIsExist();
|
||||
//2.筛选出不在bm_project表中的工程
|
||||
List<BmProject> newProjects = new ArrayList<>();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Set<String> existingExternalIds = isExistList.stream()
|
||||
.map(BmProject::getExternalId) // 从每个 BmProject 对象中提取 externalId(唯一标识)
|
||||
.collect(Collectors.toSet());
|
||||
newProjects = list.stream()
|
||||
.filter(project -> !existingExternalIds.contains(project.getExternalId())) // 判断当前工程的 externalId 是否不在已有 ID 集合中
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
//3.如果有不存在的的工程,则需要将其插入到bm_project表中
|
||||
if (newProjects != null && !newProjects.isEmpty()) {
|
||||
//4.定义实施单位,通过impUnitName确定impUnit
|
||||
for (BmProject project : newProjects) {
|
||||
String impUnitName = project.getImpUnitName(); // 假设项目名称字段为proName
|
||||
if(impUnitName!=null && !impUnitName.isEmpty()) {
|
||||
// 遍历枚举,查找项目名称中包含的单位名称
|
||||
for (IwsImpUnitEnum unitEnum : IwsImpUnitEnum.values()) {
|
||||
if (impUnitName.contains(unitEnum.getImpUnitName())) {
|
||||
project.setImpUnit(String.valueOf(unitEnum.getImpUnitId())); // 假设setImpUnit方法
|
||||
break; // 找到匹配就跳出内层循环
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有匹配到,可以设置一个默认值或保持null
|
||||
if (project.getImpUnit() == null) {
|
||||
project.setImpUnit(null);
|
||||
}
|
||||
}
|
||||
// 5.过滤掉impUnit为null的数据
|
||||
newProjects = newProjects.stream()
|
||||
.filter(project -> project.getImpUnit() != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int res = consDao.insertBmProject(newProjects);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("新增bm_project失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1043,6 +1043,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getTeamInOrOutInfo" resultType="com.bonus.material.clz.domain.TeamVo">
|
||||
SELECT DISTINCT
|
||||
sd.dept_name AS impUnitName,
|
||||
bp.pro_center AS departName,
|
||||
bzgl_bz.ssfbdw AS subcontractor,
|
||||
bzgl_bz.bzmc AS teamName,
|
||||
bzgl_bz.bzz_name AS teamLeaderName,
|
||||
|
|
@ -1069,6 +1071,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
`micro-tool`.bzgl_bz bzgl_bz
|
||||
LEFT JOIN `uni_org`.org_user org_user ON bzgl_bz.bzz_idcard = org_user.id_card
|
||||
LEFT JOIN bm_project bp ON bp.external_id = bzgl_bz.project_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||||
WHERE 1 = 1
|
||||
<if test="proId != null and proId != ''">
|
||||
AND bp.pro_id = #{proId}
|
||||
|
|
@ -1076,6 +1079,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="impUnit != null and impUnit != ''">
|
||||
AND bp.imp_unit = #{impUnit}
|
||||
</if>
|
||||
<if test="impUnitName != null and impUnitName != ''">
|
||||
AND sd.dept_name like concat('%',#{impUnitName},'%')
|
||||
</if>
|
||||
<if test="departName != null and departName != ''">
|
||||
AND bp.pro_center like concat('%',#{departName},'%')
|
||||
</if>
|
||||
<if test="teamName != null and teamName != ''">
|
||||
AND bzgl_bz.bzmc like concat('%',#{teamName},'%')
|
||||
</if>
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
AND (
|
||||
bzgl_bz.ssfbdw like concat('%',#{keyWord},'%') or
|
||||
|
|
|
|||
|
|
@ -200,6 +200,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="getIwsProjectList" resultType="com.bonus.material.basic.domain.BmProject">
|
||||
select
|
||||
dfs.id as externalId,
|
||||
dfs.name as proName,
|
||||
dfs.project_leader_name as proManager,
|
||||
case dfs.project_type_id
|
||||
when 1 then 0
|
||||
when 2 then 1
|
||||
else ''
|
||||
end as proTypeId,
|
||||
dfs.pc_no as proCode,
|
||||
case dfs.engineer_type
|
||||
when '基建' then 0
|
||||
when '用户工程' then 1
|
||||
when '技改大修' then 2
|
||||
else 3
|
||||
end as proNature,
|
||||
case dfs.project_status
|
||||
when '开工准备' then 0
|
||||
when '在建' then 1
|
||||
|
|
@ -208,7 +222,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
when '竣工' then 4
|
||||
else dfs.project_status
|
||||
end as proStatus,
|
||||
dfs.real_end_date as actualEndDate
|
||||
dfs.contract_body as contractPart,
|
||||
dfs.project_dept as proCenter,
|
||||
dfs.real_start_date as actualStartDate,
|
||||
dfs.real_end_date as actualEndDate,
|
||||
dfs.apply_company as impUnitName
|
||||
from data_center.dx_fb_son dfs
|
||||
</select>
|
||||
|
||||
|
|
@ -221,4 +239,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE external_id = #{item.externalId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="getBmProjectIsExist" resultType="com.bonus.material.basic.domain.BmProject">
|
||||
select
|
||||
distinct external_id as externalId
|
||||
from bm_project
|
||||
where external_id is not null
|
||||
</select>
|
||||
|
||||
<insert id="insertBmProject">
|
||||
insert into bm_project (pro_name,external_id,pro_type_id,pro_manager,create_by,create_time,del_flag,pro_code,imp_unit,pro_nature,pro_status,contract_part,pro_center,actual_start_date,actual_end_date)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.proName},#{item.externalId},#{item.proTypeId},#{item.proManager},1,now(),0,#{item.proCode},#{item.impUnit},#{item.proNature},#{item.proStatus},#{item.contractPart},#{item.proCenter},#{item.actualStartDate},#{item.actualEndDate})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue