Browse Source

[SBBJ-806] 固定资产QAD同步数据

master
zengqinyuan 1 week ago
parent
commit
dd1981a580
  1. 2
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/teaTaskSub/TeaTaskSubDO.java
  2. 3
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/tesFaMstr/TesFaMstrDO.java
  3. 16
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/teaTaskSub/TeaTaskSubMapper.java
  4. 12
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/tesFaMstr/TesFaMstrMapper.java
  5. 13
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/tesFaMstr/TesFaMstrService.java
  6. 109
      win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/tesFaMstr/TesFaMstrServiceImpl.java
  7. 17
      win-module-eam/win-module-eam-biz/src/main/resources/mapper/teaTaskSub/SupplierMapper.xml

2
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/teaTaskSub/TeaTaskSubDO.java

@ -14,7 +14,7 @@ import java.time.LocalDateTime;
*
* @author 超级管理员
*/
@TableName("tea_task_sub")
@TableName("TEA_TASK_SUB")
@Data
@ToString(callSuper = true)
@Builder

3
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/dataobject/tesFaMstr/TesFaMstrDO.java

@ -1,10 +1,7 @@
package com.win.module.eam.dal.dataobject.tesFaMstr;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.win.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.math.BigDecimal;

16
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/teaTaskSub/TeaTaskSubMapper.java

@ -1,9 +1,12 @@
package com.win.module.eam.dal.mysql.teaTaskSub;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.win.framework.mybatis.core.mapper.BaseMapperX;
import com.win.module.eam.dal.dataobject.teaTaskSub.TeaTaskSubDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 任务信息 Mapper
*
@ -12,4 +15,17 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TeaTaskSubMapper extends BaseMapperX<TeaTaskSubDO> {
default List<TeaTaskSubDO> findTaskList() {
return selectList(
new LambdaQueryWrapper<TeaTaskSubDO>()
.eq(TeaTaskSubDO::getTableName, "TES_FA_MSTR")
.eq(TeaTaskSubDO::getCreator, "QAD")
.eq(TeaTaskSubDO::getSubscriber, "BJSYS")
.in(TeaTaskSubDO::getTaskState, 0, 3)
);
}
List<TeaTaskSubDO> findTaskList2();
}

12
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/tesFaMstr/TesFaMstrMapper.java

@ -1,9 +1,14 @@
package com.win.module.eam.dal.mysql.tesFaMstr;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.win.framework.datasource.core.enums.DataSourceEnum;
import com.win.framework.mybatis.core.mapper.BaseMapperX;
import com.win.module.eam.dal.dataobject.tesFaMstr.TesFaMstrDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 固定资产主 Mapper
*
@ -12,4 +17,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TesFaMstrMapper extends BaseMapperX<TesFaMstrDO> {
default List<TesFaMstrDO> findListByTaskIds(List<String> taskIds) {
return selectList(
new LambdaQueryWrapper<TesFaMstrDO>()
.in(TesFaMstrDO::getTaskid, taskIds)
);
}
}

13
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/tesFaMstr/TesFaMstrService.java

@ -1,6 +1,11 @@
package com.win.module.eam.service.tesFaMstr;
import com.win.module.eam.dal.dataobject.teaTaskSub.TeaTaskSubDO;
import com.win.module.eam.dal.dataobject.tesFaMstr.TesFaMstrDO;
import java.util.List;
/**
* 固定资产主 Service 接口
*
@ -8,5 +13,11 @@ package com.win.module.eam.service.tesFaMstr;
*/
public interface TesFaMstrService {
void synchronizeData();
void findQadDataList();
List<TesFaMstrDO> getTesFaMstrDOS(List<String> taskIds);
List<TeaTaskSubDO> getTeaTaskSubDOS();
void updateQadDataList(List<TeaTaskSubDO> list);
}

109
win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/service/tesFaMstr/TesFaMstrServiceImpl.java

@ -38,110 +38,27 @@ public class TesFaMstrServiceImpl implements TesFaMstrService {
@Autowired
private TeaTaskSubMapper teaTaskSubMapper;
@Autowired
private FixedAssetsMapper fixedAssetsMapper;
@Override
public void synchronizeData() {
log.debug("===============================固定资产QAD同步数据===============================");
log.info("===============================固定资产QAD同步数据===============================");
List<TeaTaskSubDO> tasks = getTeaTaskSubDOS();
if (tasks.isEmpty()) {
log.info("TesFaMstrService.SynchronizeData:没有需要同步的数据");
return;
}
List<String> taskIds = tasks.stream().map(TeaTaskSubDO::getTaskID).filter(Objects::nonNull).toList();
if (taskIds.isEmpty()) {
log.info("TesFaMstrService.SynchronizeData:TaskId不存在");
return;
}
List<TesFaMstrDO> tesFaMstrDOS = getTesFaMstrDOS(taskIds);
if (tesFaMstrDOS.isEmpty()) {
log.info("TesFaMstrService.SynchronizeData:tesFaMstrDOS 资产集合不存在");
return;
}
int taskStatus = 2;
String failedInfo = "success";
LocalDateTime updateTime = LocalDateTime.now();
try {
Map<String, List<TesFaMstrDO>> map = tesFaMstrDOS.stream().collect(Collectors.groupingBy(TesFaMstrDO::getFixedAssetId));
Map<String, Long> fixedAssetsMap = fixedAssetsMapper.selectList(
new LambdaQueryWrapper<FixedAssetsDO>()
.in(FixedAssetsDO::getNumber, map.keySet())
.eq(FixedAssetsDO::getCategory, "1")
).stream().collect(Collectors.toMap(FixedAssetsDO::getNumber, FixedAssetsDO::getId));
List<FixedAssetsDO> saveList = map.values().stream()
.map(item -> item.stream().sorted(Comparator.comparing(TesFaMstrDO::getCreateTime).reversed()).toList().get(0))
.map(item -> {
FixedAssetsDO fixedAssetsDO = new FixedAssetsDO();
String fixedAssetId = item.getFixedAssetId();
Long id = fixedAssetsMap.get(fixedAssetId);
if (id != null) {
fixedAssetsDO.setId(id);
}
fixedAssetsDO.setCategory("1");
// 编号
fixedAssetsDO.setNumber(fixedAssetId);
// 名称
fixedAssetsDO.setName(item.getFixedAssetName());
// 库位编号
fixedAssetsDO.setLocationNumber(item.getLocation());
// 投入使用时间
fixedAssetsDO.setBeginUseDate(item.getFixedAssetStart());
// 期间费用科目描述
fixedAssetsDO.setCostSubjectDesc(item.getExpenseName());
// 供应商编号
fixedAssetsDO.setSupplierNumber(item.getSupplier());
// 制造商
fixedAssetsDO.setManufacturer(item.getManufacture());
// 单位
fixedAssetsDO.setUnit(item.getUm());
// 数量
fixedAssetsDO.setQty(item.getQuantity());
fixedAssetsDO.setSourceType("QAD");
return fixedAssetsDO;
}).toList();
fixedAssetsMapper.saveOrUpdateBatch(saveList);
} catch (Exception e) {
taskStatus = 3;
failedInfo = e.getMessage();
}
public void findQadDataList() {
for (TeaTaskSubDO task : tasks) {
task.setTaskState(taskStatus);
task.setFailedInfo(failedInfo);
task.setUpdateTime(updateTime);
task.setUpdateUser("BJSYS");
}
updateTask(tasks);
}
@DS(DataSourceEnum.SQL_SERVER_All)
private List<TesFaMstrDO> getTesFaMstrDOS(List<String> taskIds) {
List<TesFaMstrDO> tesFaMstrDOS = tesFaMstrMapper.selectList(
new LambdaQueryWrapper<TesFaMstrDO>()
.in(TesFaMstrDO::getTaskid, taskIds)
);
return tesFaMstrDOS;
@Override
public void updateQadDataList(List<TeaTaskSubDO> list) {
if (!list.isEmpty()) {
teaTaskSubMapper.updateBatch(list);
}
}
@DS(DataSourceEnum.SQL_SERVER_All)
private List<TeaTaskSubDO> getTeaTaskSubDOS() {
List<TeaTaskSubDO> tasks = teaTaskSubMapper.selectList(
new LambdaQueryWrapper<TeaTaskSubDO>()
.eq(TeaTaskSubDO::getTableName, "TES_FA_MSTR")
.eq(TeaTaskSubDO::getCreator, "QAD")
.eq(TeaTaskSubDO::getSubscriber, "BJSYS")
.in(TeaTaskSubDO::getTaskState, 0, 3)
);
return tasks;
@Override
public List<TeaTaskSubDO> getTeaTaskSubDOS() {
return teaTaskSubMapper.findTaskList2();
}
@DS(DataSourceEnum.SQL_SERVER_All)
private void updateTask(List<TeaTaskSubDO> tasks) {
if (!tasks.isEmpty()) {
teaTaskSubMapper.updateBatch(tasks);
}
@Override
public List<TesFaMstrDO> getTesFaMstrDOS(List<String> taskIds) {
return tesFaMstrMapper.findListByTaskIds(taskIds);
}
}

17
win-module-eam/win-module-eam-biz/src/main/resources/mapper/teaTaskSub/SupplierMapper.xml

@ -0,0 +1,17 @@
<?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.win.module.eam.dal.mysql.teaTaskSub.TeaTaskSubMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="findTaskList2" resultType="com.win.module.eam.dal.dataobject.teaTaskSub.TeaTaskSubDO">
select *
from TEA_TASK_SUB
WHERE (TableName = 'TES_FA_MSTR' AND Creator = 'QAD' AND Subscriber = 'BJSYS' AND TaskState IN (0, 3))
</select>
</mapper>
Loading…
Cancel
Save