研发项目立项同步C4项目档案

This commit is contained in:
hecan 2025-05-15 15:45:22 +08:00
parent 88f2bd23e7
commit fa0ac883c1
9 changed files with 421 additions and 2 deletions

View File

@ -0,0 +1,29 @@
package com.hzya.frame.plugin.c4project.dao;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.c4project.entity.C4ProjectEntity;
import java.util.List;
public interface IC4ProjectDao extends IBaseDao<C4ProjectEntity,String> {
/**
*
* @content 查询研发项目立项数据推送C4项目档案
* @Param
* @Return
* @Author hecan
* @Date 2025-05-14 11:48
* **/
List<C4ProjectEntity> queryProjectToC4(C4ProjectEntity entity);
/**
*
* @content 新增数据到C4项目档案
* @Param
* @Return
* @Author hecan
* @Date 2025-05-14 11:53
* **/
Integer saveC4Project(C4ProjectEntity entity);
}

View File

@ -0,0 +1,22 @@
package com.hzya.frame.plugin.c4project.dao.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.c4project.dao.IC4ProjectDao;
import com.hzya.frame.plugin.c4project.entity.C4ProjectEntity;
import java.util.List;
public class C4ProjectDaoImpl extends MybatisGenericDao<C4ProjectEntity,String> implements IC4ProjectDao {
@DS("#entity.dataSourceCode")
@Override
public List<C4ProjectEntity> queryProjectToC4(C4ProjectEntity entity) {
return (List<C4ProjectEntity>) super.selectList("queryProjectToC4",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer saveC4Project(C4ProjectEntity entity) {
return super.insert("saveC4Project",entity);
}
}

View File

@ -0,0 +1,142 @@
package com.hzya.frame.plugin.c4project.entity;
import com.hzya.frame.web.entity.BaseEntity;
public class C4ProjectEntity extends BaseEntity {
private String caNo;//项目编号
private String caName;//项目名称
private String caTypenm;//项目类型
private String caManagernm;//项目负责人
private String caBegindate;//项目开始时间
private String caEnddate;//项目结束时间
private String caBudgetamt;//项目预算总额
private String caBudgetorg;//公司id
private String caBudgetornm;//公司名称
private String caFathernm;//项目档案
private String caFactmat;//项目实际到账额
private String caCoveramt;//项目实际报销额
private String caFulllevelno;//
private String startTime;//开始时间
private String endTime;//结束时间
public String getCaBudgetorg() {
return caBudgetorg;
}
public void setCaBudgetorg(String caBudgetorg) {
this.caBudgetorg = caBudgetorg;
}
public String getCaBudgetornm() {
return caBudgetornm;
}
public void setCaBudgetornm(String caBudgetornm) {
this.caBudgetornm = caBudgetornm;
}
public String getCaFathernm() {
return caFathernm;
}
public void setCaFathernm(String caFathernm) {
this.caFathernm = caFathernm;
}
public String getCaFactmat() {
return caFactmat;
}
public void setCaFactmat(String caFactmat) {
this.caFactmat = caFactmat;
}
public String getCaCoveramt() {
return caCoveramt;
}
public void setCaCoveramt(String caCoveramt) {
this.caCoveramt = caCoveramt;
}
public String getCaFulllevelno() {
return caFulllevelno;
}
public void setCaFulllevelno(String caFulllevelno) {
this.caFulllevelno = caFulllevelno;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getCaNo() {
return caNo;
}
public void setCaNo(String caNo) {
this.caNo = caNo;
}
public String getCaName() {
return caName;
}
public void setCaName(String caName) {
this.caName = caName;
}
public String getCaTypenm() {
return caTypenm;
}
public void setCaTypenm(String caTypenm) {
this.caTypenm = caTypenm;
}
public String getCaManagernm() {
return caManagernm;
}
public void setCaManagernm(String caManagernm) {
this.caManagernm = caManagernm;
}
public String getCaBegindate() {
return caBegindate;
}
public void setCaBegindate(String caBegindate) {
this.caBegindate = caBegindate;
}
public String getCaEnddate() {
return caEnddate;
}
public void setCaEnddate(String caEnddate) {
this.caEnddate = caEnddate;
}
public String getCaBudgetamt() {
return caBudgetamt;
}
public void setCaBudgetamt(String caBudgetamt) {
this.caBudgetamt = caBudgetamt;
}
}

View File

@ -0,0 +1,86 @@
<?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.hzya.frame.plugin.c4project.dao.impl.C4ProjectDaoImpl">
<resultMap id="get-C4ProjectEntity-result" type="com.hzya.frame.plugin.c4project.entity.C4ProjectEntity" >
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="sorts" column="sorts" jdbcType="INTEGER"/>
<result property="create_user_id" column="create_user_id" jdbcType="VARCHAR"/>
<result property="create_time" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modify_user_id" column="modify_user_id" jdbcType="VARCHAR"/>
<result property="modify_time" column="modify_time" jdbcType="TIMESTAMP"/>
<result property="sts" column="sts" jdbcType="VARCHAR"/>
<result property="org_id" column="org_id" jdbcType="VARCHAR"/>
<result property="companyId" column="company_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id = "C4ProjectEntity_Base_Column_List">
main.id as id,
main.MODIFY_DATE as MODIFY_DATE,
'formmain_9555' as tab_name,
field0047 as caNo,
field0012 as caName,
field0080 as caTypenm,
ORG_MEMBER.name as caManagernm,
field0044 as caBegindate,
field0045 as caEnddate,
field0077 as caBudgetamt,
'670869647114347' as caBudgetorg,
'三维通信股份有限公司' as caBudgetornm,
'项目档案' as caFathernm,
'0' as caFactmat,
'0' as caCoveramt
</sql>
<!--查询研发项目立项推送BC4项目档案-->
<select id="queryProjectToC4" resultMap="get-C4ProjectEntity-result" parameterType = "com.hzya.frame.plugin.c4project.entity.C4ProjectEntity">
select
<include refid="C4ProjectEntity_Base_Column_List" />
from formmain_9555 main
-- LEFT JOIN COL_SUMMARY summary ON summary.FORM_RECORDID = main.id
left join ORG_MEMBER on ORG_MEMBER.id=field0020
WHERE 1=1 -- and summary.state in ('1','3') -- 2回退
AND MODIFY_DATE &gt;= TO_DATE('2025-03-07 11:00:00','yyyy-MM-dd HH24:mi:ss')
AND MODIFY_DATE &gt;= TO_DATE(#{startTime},'yyyy-MM-dd HH24:mi:ss')
and field0047 ='L120250503-R'
</select>
<!--新增所有列-->
<insert id="saveC4Project" parameterType="com.hzya.frame.plugin.c4project.entity.C4ProjectEntity">
insert into LEXMISC4_case(
<trim suffix="" suffixOverrides=",">
<if test="caBudgetorg != null and caBudgetorg != ''">CA_BUDGETORG ,</if>
<if test="caBudgetornm != null and caBudgetornm !='' ">CA_BUDGETORGNM ,</if>
<if test="caNo != null and caNo != '' ">CA_NO ,</if>
<if test="caName != null and caName != ''">CA_NAME ,</if>
<if test="caTypenm != null and caTypenm != ''">CA_TYPENM ,</if>
<if test="caManagernm != null and caManagernm != ''">CA_MANAGERNM ,</if>
<if test="caBegindate != null and caBegindate != ''">CA_BEGINDATE ,</if>
<if test="caEnddate != null and caEnddate != ''">CA_ENDDATE ,</if>
<if test="caFathernm != null and caFathernm != ''">CA_FATHERNM ,</if>
<if test="caBudgetamt != null and caBudgetamt != ''">CA_BUDGETAMT ,</if>
<if test="caFactmat != null and caFactmat != ''">CA_FACTAMT ,</if>
<if test="caCoveramt != null and caCoveramt != ''">CA_COVERAMT ,</if>
<if test="caFulllevelno != null and caFulllevelno != ''">CA_FULLLEVELNO </if>
</trim>
)values(
<trim suffix="" suffixOverrides=",">
<if test="caBudgetorg != null and caBudgetorg != ''">#{caBudgetorg} ,</if>
<if test="caBudgetornm != null and caBudgetornm !='' ">#{caBudgetornm} ,</if>
<if test="caNo != null and caNo != '' ">#{caNo} ,</if>
<if test="caName != null and caName != ''">#{caName} ,</if>
<if test="caTypenm != null and caTypenm != ''">#{caTypenm} ,</if>
<if test="caManagernm != null and caManagernm != ''">#{caManagernm} ,</if>
<if test="caBegindate != null and caBegindate != ''">TO_TIMESTAMP(#{caBegindate}, 'SYYYY-MM-DD HH24:MI:SS:FF6') ,</if>
<if test="caEnddate != null and caEnddate != ''">TO_TIMESTAMP(#{caEnddate}, 'SYYYY-MM-DD HH24:MI:SS:FF6') ,</if>
<if test="caFathernm != null and caFathernm != ''">#{caFathernm} ,</if>
<if test="caBudgetamt != null and caBudgetamt != ''">#{caBudgetamt} ,</if>
<if test="caFactmat != null and caFactmat != ''">#{caFactmat} ,</if>
<if test="caCoveramt != null and caCoveramt != ''">#{caCoveramt} ,</if>
<if test="caFulllevelno != null and caFulllevelno != ''">#{caFulllevelno} </if>
</trim>
)
</insert>
</mapper>

View File

@ -0,0 +1,124 @@
package com.hzya.frame.plugin.c4project.plugin;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.c4project.dao.IC4ProjectDao;
import com.hzya.frame.plugin.c4project.dao.impl.C4ProjectDaoImpl;
import com.hzya.frame.plugin.c4project.entity.C4ProjectEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
public class C4ProjectPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(C4ProjectPluginInitializer.class);
@Autowired
private IC4ProjectDao ic4ProjectDao;
@Autowired
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "C4ProjectPluginInitializer";
}
@Override
public String getPluginName() {
return "研发项目立项生成C4项目档案";
}
@Override
public String getPluginLabel() {
return "C4ProjectPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
try {
String startTime = DateUtil.format(requestJson.getDate("startTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间
String endTime = DateUtil.format(requestJson.getDate("endTime"),"yyyy-MM-dd HH:mm:ss");//定时任务执行时传入的开始时间
logger.info("=======研发项目立项推送C4项目档案的开始时间为{}=======",startTime);
logger.info("=======研发项目立项推送C4项目档案的结束时间为{}=======",endTime);
if(StrUtil.isEmpty(startTime)){
DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss");
}
logger.info("=======在:{}时间查询研发项目立项推送C4项目档案=======",startTime);
C4ProjectEntity c4ProjectEntity=new C4ProjectEntity();
c4ProjectEntity.setStartTime(startTime);
c4ProjectEntity.setDataSourceCode("SW-OA");
List<C4ProjectEntity> c4ProjectEntities = ic4ProjectDao.queryProjectToC4(c4ProjectEntity);
if(c4ProjectEntities == null || c4ProjectEntities.size() == 0){
logger.info("=====查询研发项目立项推送C4项目档案数据有:{}条",c4ProjectEntities.size());
return BaseResult.getSuccessMessageEntity("查询成功");
}
for (C4ProjectEntity projectEntity : c4ProjectEntities) {
projectEntity.setDataSourceCode("SW-OA");
projectEntity.setCaFulllevelno("@"+projectEntity.getCaNo()+"@");
projectEntity.setCaTypenm(projectEntity.getCaTypenm()==null?"项目类型":projectEntity.getCaTypenm());
logger.info("======开始将项目编号:{},项目名称:{}新增到C4项目档案中=======",projectEntity.getCaNo(),projectEntity.getCaName());
Integer integer = ic4ProjectDao.saveC4Project(projectEntity);
logger.info("======将项目编号:{},项目名称:{}新增到C4项目档案中完毕=======",projectEntity.getCaNo(),projectEntity.getCaName());
saveTaskLivingDetails(projectEntity.getId(),projectEntity.getCaNo(),JSONObject.parseObject(projectEntity.toString()).toJSONString(),String.valueOf(integer),true);
}
logger.info("=======研发项目立项推送C4项目档案执行成功=======");
return BaseResult.getSuccessMessageEntity("研发项目立项推送C4项目档案执行成功");
}catch (Exception e){
logger.info("========研发项目立项推送C4项目档案失败,:{}",e.getMessage());
e.printStackTrace();
}
return BaseResult.getFailureMessageEntity("研发项目立项推送C4项目档案执行成功");
}
private void saveTaskLivingDetails(String rootAppPk,String rootAppBill,String rootAppNewData,String newTransmitInfo,boolean flag) {
try {
IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity();
integrationTaskLivingDetailsEntity.setId(UUIDUtils.getUUID());
integrationTaskLivingDetailsEntity.setSts("Y");
integrationTaskLivingDetailsEntity.setCreate_user_id("1");
integrationTaskLivingDetailsEntity.setModify_user_id("1");
integrationTaskLivingDetailsEntity.setCreate_time(new Date());
integrationTaskLivingDetailsEntity.setModify_time(new Date());
integrationTaskLivingDetailsEntity.setOrg_id("0");
integrationTaskLivingDetailsEntity.setCompanyId("0");
integrationTaskLivingDetailsEntity.setRootAppPk(rootAppPk);
integrationTaskLivingDetailsEntity.setRootAppBill(rootAppBill);
integrationTaskLivingDetailsEntity.setPluginId("C4ProjectPluginInitializer");
integrationTaskLivingDetailsEntity.setRootAppNewData(rootAppNewData);
integrationTaskLivingDetailsEntity.setNewTransmitInfo(newTransmitInfo);
if(flag){
taskLivingDetailsService.saveLogToSuccess(integrationTaskLivingDetailsEntity);
}else {
taskLivingDetailsService.saveLogToFail(integrationTaskLivingDetailsEntity);
}
}catch (Exception e){
logger.info("保存日志到集成任务日志明细中失败:{}",e.getMessage());
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>C4ProjectPluginInitializer</id>
<name>C4ProjectPluginInitializer</name>
<category>90000098</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="C4ProjectDaoImpl" class="com.hzya.frame.plugin.c4project.dao.impl.C4ProjectDaoImpl" />
</beans>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="C4ProjectPluginInitializer" class="com.hzya.frame.plugin.c4project.plugin.C4ProjectPluginInitializer" />
</beans>

View File

@ -420,7 +420,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
Object object = comparisonServiceimpl.saveEntity(jsonStr);
logger.info("单据视图新增结果为:{}", JSON.toJSONString(object));
result.add(object);
} else {
}/* else {
hashMap.put("appName","数智中台");
hashMap.put("appCode","800004");
hashMap.put("mdmCode", mdmCode);
@ -429,7 +429,7 @@ public class ServiceDataServiceImpl extends BaseService<ComparisonEntity,String>
Object object = comparisonServiceimpl.updateEntity(jsonStr);
logger.info("单据视图更新结果为:{}", JSON.toJSONString(result));
result.add(object);
}
}*/
}
return result;
}catch (Exception e){