Commit ec09224f authored by lisong's avatar lisong

同步接口修改

parent c6d81d91
...@@ -29,8 +29,10 @@ public interface CylCylinderFillingCheckMapper extends BaseMapper<CylinderFillin ...@@ -29,8 +29,10 @@ public interface CylCylinderFillingCheckMapper extends BaseMapper<CylinderFillin
List<CylinderInfo> getCylinderInfoList(); List<CylinderInfo> getCylinderInfoList();
void updateBatch(@Param("sequenceNbrS") List<Long> sequenceNbrS); void updateBatch(@Param("sequenceNbrS") List<Long> sequenceNbrS);
List<CylinderFilling> queryUnSyncFilling(); List<CylinderFilling> queryUnSyncFilling();
boolean updataSyncFilling(List<String> appIds,List<String> fillingBeforeIds,List<String> sequenceCodes);
boolean updataSyncFilling(@Param("ids") List<Long> appIds);
boolean saveAndBatchInsert(@Param("list") List<CylinderFilling> list); boolean saveAndBatchInsert(@Param("list") List<CylinderFilling> list);
......
...@@ -71,24 +71,29 @@ ...@@ -71,24 +71,29 @@
<update id="updataSyncFilling"> <update id="updataSyncFilling">
update tm_cylinder_filling set sync_state = 3 update tm_cylinder_filling set sync_state = 3
<where> <where>
<if test="appIds != null and appIds.size() > 0"> <!-- <if test="appIds != null and appIds.size() > 0">-->
app_id in <!-- app_id in-->
<foreach collection="appIds" item="appId" index="index" open="(" close=")" separator=","> <!-- <foreach collection="appIds" item="appId" index="index" open="(" close=")" separator=",">-->
#{appId} <!-- #{appId}-->
</foreach> <!-- </foreach>-->
</if> <!-- </if>-->
<if test="fillingBeforeIds != null and fillingBeforeIds.size() > 0"> <!-- <if test="fillingBeforeIds != null and fillingBeforeIds.size() > 0">-->
and filling_before_id in <!-- and filling_before_id in-->
<foreach collection="fillingBeforeIds" item="fillingBeforeId" index="index" open="(" close=")" separator=","> <!-- <foreach collection="fillingBeforeIds" item="fillingBeforeId" index="index" open="(" close=")" separator=",">-->
#{fillingBeforeId} <!-- #{fillingBeforeId}-->
</foreach> <!-- </foreach>-->
</if> <!-- </if>-->
<if test="sequenceCodes != null and sequenceCodes.size() > 0"> <!-- <if test="sequenceCodes != null and sequenceCodes.size() > 0">-->
and sequence_code in <!-- and sequence_code in-->
<foreach collection="sequenceCodes" item="sequenceCode" index="index" open="(" close=")" separator=","> <!-- <foreach collection="sequenceCodes" item="sequenceCode" index="index" open="(" close=")" separator=",">-->
#{sequenceCode} <!-- #{sequenceCode}-->
<!-- </foreach>-->
<!-- </if>-->
sequence_nbr in
<foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach> </foreach>
</if>
</where> </where>
</update> </update>
......
...@@ -127,10 +127,18 @@ public class CylSyncServiceImpl { ...@@ -127,10 +127,18 @@ public class CylSyncServiceImpl {
public Object fillingSync() { public Object fillingSync() {
try { try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<CylinderFilling> unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling(); List<CylinderFilling> unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling();
stopWatch.stop();
System.out.println("查询时间:"+stopWatch.getTotalTimeSeconds());
while (!unSyncFilling.isEmpty()) { while (!unSyncFilling.isEmpty()) {
fillingDataProcessing(unSyncFilling); fillingDataProcessing(unSyncFilling);
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling(); unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling();
stopWatch1.stop();
System.out.println("查询2时间:"+stopWatch.getTotalTimeSeconds());
} }
} catch (Exception ex) { } catch (Exception ex) {
return "failed"; return "failed";
...@@ -140,13 +148,14 @@ public class CylSyncServiceImpl { ...@@ -140,13 +148,14 @@ public class CylSyncServiceImpl {
@Transactional(rollbackFor = {Exception.class}) @Transactional(rollbackFor = {Exception.class})
public void fillingDataProcessing(List<CylinderFilling> data) { public void fillingDataProcessing(List<CylinderFilling> data) {
List<String> appIds = new ArrayList<>(); // List<String> appIds = new ArrayList<>();
List<String> fillingBeforeIds = new ArrayList<>(); // List<String> fillingBeforeIds = new ArrayList<>();
List<String> sequenceCodes = new ArrayList<>(); // List<String> sequenceCodes = new ArrayList<>();
List<Long> ids = data.stream().map(CylinderFilling::getSequenceNbr).collect(Collectors.toList());
data.forEach(e -> { data.forEach(e -> {
appIds.add(e.getAppId()); // appIds.add(e.getAppId());
fillingBeforeIds.add(e.getFillingBeforeId()); // fillingBeforeIds.add(e.getFillingBeforeId());
sequenceCodes.add(e.getSequenceCode()); // sequenceCodes.add(e.getSequenceCode());
String isValid = e.getIsValid(); String isValid = e.getIsValid();
if (!ObjectUtil.isEmpty(isValid) && ("1".equals(isValid) || "0".equals(isValid))) { if (!ObjectUtil.isEmpty(isValid) && ("1".equals(isValid) || "0".equals(isValid))) {
CylDictEnum cylDictEnum = CylDictEnum.getEnum(Integer.valueOf(isValid), "isValid"); CylDictEnum cylDictEnum = CylDictEnum.getEnum(Integer.valueOf(isValid), "isValid");
...@@ -204,8 +213,17 @@ public class CylSyncServiceImpl { ...@@ -204,8 +213,17 @@ public class CylSyncServiceImpl {
} }
}); });
StopWatch stopWatch = new StopWatch();
stopWatch.start();
cylCylinderFillingCheckMapper.saveAndBatchInsert(data); cylCylinderFillingCheckMapper.saveAndBatchInsert(data);
sourceFillingCheckServiceImpl.updataSyncFilling(appIds, fillingBeforeIds, sequenceCodes); stopWatch.stop();
System.out.println("插入时间:"+ stopWatch.getTotalTimeSeconds());
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
sourceFillingCheckServiceImpl.updataSyncFilling(ids);
stopWatch1.stop();
System.out.println("更新时间:"+ stopWatch1.getTotalTimeSeconds());
} }
......
...@@ -54,8 +54,8 @@ public class CylinderSyncServiceImpl { ...@@ -54,8 +54,8 @@ public class CylinderSyncServiceImpl {
return fillingCheckMapper.queryUnSyncFilling(); return fillingCheckMapper.queryUnSyncFilling();
} }
public boolean updataSyncFilling(List<String> appIds,List<String> fillingBeforeIds,List<String> sequenceCodes){ public boolean updataSyncFilling(List<Long> ids){
return fillingCheckMapper.updataSyncFilling(appIds, fillingBeforeIds, sequenceCodes); return fillingCheckMapper.updataSyncFilling(ids);
} }
public Long fillingRecordSync(){ public Long fillingRecordSync(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment