Commit 173a4ada authored by H2T's avatar H2T

filling 同步接口提交

parent 676d549f
......@@ -16,6 +16,20 @@ import java.util.Map;
*/
public enum CylDictEnum {
isValid_0(3125,0,"isValid"),
isValid_1(3126,1,"isValid"),
same_0(3127,0,"same"),
same_1(3128,1,"same"),
SecurityDocuments_0(3137,0,"SecurityDocuments"),
SecurityDocuments_1(3138,1,"SecurityDocuments"),
isComplete_0(3135,0,"isComplete"),
isComplete_1(3136,1,"isComplete"),
haveStillPressure_0(3133,0,"haveStillPressure"),
haveStillPressure_1(3134,1,"haveStillPressure"),
isComplianceWithGBT_0(3131,0,"isComplianceWithGBT"),
isComplianceWithGBT_1(3132,1,"isComplianceWithGBT"),
isRegulations_0(3129,0,"isRegulations"),
isRegulations_1(3130,1,"isRegulations"),
withinScope_0 (3141,0, "withinScope"),
withinScope_1 (3142,1, "withinScope"),
sealedState_0 (3143,0, "sealedState"),
......
......@@ -3,10 +3,15 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingCheck;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylCylinderFillingCheck;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFilling;
import org.apache.ibatis.annotations.Param;
import java.util.HashSet;
import java.util.List;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 液化气体气瓶充装信息-充装后复查 Mapper 接口
......@@ -27,4 +32,8 @@ public interface CylCylinderFillingCheckMapper extends BaseMapper<CylinderFillin
List<CylinderInfo> getCylinderInfoList();
void updateBatch(@Param("sequenceNbrS") List<Long> sequenceNbrS);
List<CylinderFilling> queryUnSyncFilling();
void updataSyncFilling(List<String> appIds,List<String> fillingBeforeIds,List<String> sequenceCodes);
void batchInsert(@Param("list") List<CylinderFilling> list);
}
......@@ -68,6 +68,23 @@
</foreach>
</where>
</update>
<update id="updataSyncFilling">
update tm_cylinder_filling set sync_state = 3
<where>
app_id in
<foreach collection="appIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and filling_before_id in
<foreach collection="fillingBeforeIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
and sequence_code in
<foreach collection="sequenceCodes" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</where>
</update>
<update id="updateBatch">
......@@ -81,4 +98,111 @@
</if>
</where>
</update>
<select id="queryUnSyncFilling" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFilling">
SELECT cf.*,
'3' sync_state,
CAST(
(
(filling_before_id IS NOT NULL) +
(filling_unit_name IS NOT NULL) +
(sequence_code IS NOT NULL) +
(is_valid IS NOT NULL) +
(same IS NOT NULL) +
(is_regulations IS NOT NULL) +
(is_compliance_withGBT IS NOT NULL) +
(have_still_pressure IS NOT NULL) +
(is_complete IS NOT NULL) +
(have_security_documents IS NOT NULL) +
(inspector_user IS NOT NULL) +
(inspection_date IS NOT NULL) +
(credit_code IS NOT NULL) +
(fill_before_item IS NOT NULL) +
(check_results IS NOT NULL) +
(nonconformances IS NOT NULL)
) / 16 AS DECIMAL(10, 2)
) integrity
FROM tm_cylinder_filling cf
WHERE cf.sync_state != 3
ORDER BY
cf.sync_date DESC
LIMIT 10
</select>
<insert id="batchInsert">
INSERT INTO tz_cylinder_filling (
sequence_nbr,
filling_before_id,
filling_unit_name,
sequence_code,
is_valid,
same,
is_regulations,
is_compliance_withgbt,
have_still_pressure,
is_complete,
have_security_documents,
inspector_user,
inspection_date,
rec_date,
rec_user_id,
sync_date,
sync_state,
app_id,
integrity,
credit_code,
fill_before_item,
check_results,
nonconformances
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.sequenceNbr},
#{item.fillingBeforeId},
#{item.fillingUnitName},
#{item.isValid},
#{item.sequenceCode},
#{item.same},
#{item.isRegulations},
#{item.isComplianceWithgbt},
#{item.haveStillPressure},
#{item.isComplete},
#{item.haveSecurityDocuments},
#{item.inspectorUser},
#{item.inspectionDate},
#{item.recDate},
#{item.recUserId},
#{item.syncDate},
#{item.syncState},
#{item.appId},
#{item.integrity},
#{item.creditCode},
#{item.fillBeforeItem},
#{item.checkResults},
#{item.nonconformances}
)
</foreach>
on conflict (app_id, filling_before_id,sequence_code) do update set
sequence_nbr = EXCLUDED.sequence_nbr,
filling_before_id = EXCLUDED.filling_before_id,
filling_unit_name = EXCLUDED.filling_unit_name,
sequence_code = EXCLUDED.sequence_code,
is_valid = EXCLUDED.is_valid,
same = EXCLUDED.same,
is_regulations = EXCLUDED.is_regulations,
is_compliance_withgbt = EXCLUDED.is_compliance_withgbt,
have_still_pressure = EXCLUDED.have_still_pressure,
is_complete = EXCLUDED.is_complete,
have_security_documents = EXCLUDED.have_security_documents,
inspector_user = EXCLUDED.inspector_user,
inspection_date = EXCLUDED.inspection_date,
rec_date = EXCLUDED.rec_date,
rec_user_id = EXCLUDED.rec_user_id,
sync_date = EXCLUDED.sync_date,
sync_state = EXCLUDED.sync_state,
app_id = EXCLUDED.app_id,
integrity = EXCLUDED.integrity,
credit_code = EXCLUDED.credit_code,
fill_before_item = EXCLUDED.fill_before_item,
check_results = EXCLUDED.check_results,
nonconformances = EXCLUDED.nonconformances
</insert>
</mapper>
......@@ -48,4 +48,15 @@ public class CylSyncController {
return ResponseHelper.buildResponse(cylSyncService.cylinderInfo());
}
/**
* 同步cylinder_filling表
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET",value = "Filling表同步", notes = "Filling表同步")
@GetMapping(value = "/sync/Filling")
public ResponseModel<Object> synchronizationFilling(){
return ResponseHelper.buildResponse(cylSyncService.fillingSync());
}
}
package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.module.cylinder.api.enums.CylDictEnum;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFilling;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingCheck;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylCylinderFillingCheckMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderFillingCheckMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderInfoMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service
......@@ -32,6 +33,9 @@ public class CylSyncServiceImpl {
@Autowired
private CylinderFillingCheckMapper fillingCheckMapper;
@Autowired
private CylCylinderFillingCheckMapper cylCylinderFillingCheckMapper;
public void syncFillingCheckInfo() {
Integer totalSize = sourceFillingCheckServiceImpl.getFillCheckListTotal();
Integer times;
......@@ -50,7 +54,7 @@ public class CylSyncServiceImpl {
}
@Transactional
void traverseSave() {
public void traverseSave() {
List<CylinderFillingCheck> fillingChecks = sourceFillingCheckServiceImpl.getFillingCheckList();
if (!ValidationUtil.isEmpty(fillingChecks)) {
HashSet<String> fillingCheckIdList = Sets.newHashSet();
......@@ -102,7 +106,7 @@ public class CylSyncServiceImpl {
}
@Transactional(rollbackFor = {Exception.class})
void LoopSaveCylinderInfo() {
public void LoopSaveCylinderInfo() {
List<CylinderInfo> cylinderInfoList = sourceFillingCheckServiceImpl.getCylinderInfoList();
if (!ObjectUtils.isEmpty(cylinderInfoList)) {
for (CylinderInfo cylinderInfo : cylinderInfoList) {
......@@ -116,4 +120,56 @@ public class CylSyncServiceImpl {
sourceFillingCheckServiceImpl.updateBatch(sequenceNbrS);
}
}
public Object fillingSync() {
try {
List<CylinderFilling> unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling();
while (!unSyncFilling.isEmpty()) {
fillingDataProcessing(unSyncFilling);
unSyncFilling = sourceFillingCheckServiceImpl.queryUnSyncFilling();
}
} catch (Exception ex) {
return "failed";
}
return "success";
}
@Transactional
public void fillingDataProcessing(List<CylinderFilling> data) {
List<String> appIds = new ArrayList<>();
List<String> fillingBeforeIds = new ArrayList<>();
List<String> sequenceCodes = new ArrayList<>();
data.forEach(e -> {
CylinderFilling clf = new CylinderFilling();
BeanUtils.copyProperties(e, clf);
appIds.add(e.getAppId());
fillingBeforeIds.add(e.getFillingBeforeId());
sequenceCodes.add(e.getSequenceCode());
if (!ObjectUtil.isEmpty(e.getIsValid()) && ("1" == e.getIsValid() || "0" == e.getIsValid())){
e.setIsValid(CylDictEnum.getEnum(Integer.valueOf(e.getIsValid()), "isValid").getSeqNbr().toString());
}
if(!ObjectUtil.isEmpty(e.getSame()) && (1==e.getSame() || 0== e.getSame())){
e.setSame(CylDictEnum.getEnum(e.getSame(), "same").getSeqNbr());
}
if(!ObjectUtil.isEmpty(e.getIsRegulations()) && (1==e.getIsRegulations() || 0== e.getIsRegulations())){
e.setIsRegulations(CylDictEnum.getEnum(e.getIsRegulations(), "isRegulations").getSeqNbr());
}
if(!ObjectUtil.isEmpty(e.getIsComplianceWithgbt()) && (1==e.getIsComplianceWithgbt() || 0== e.getIsComplianceWithgbt())){
e.setIsComplianceWithgbt(CylDictEnum.getEnum(e.getIsComplianceWithgbt(), "isComplianceWithGBT").getSeqNbr());
}
if(!ObjectUtil.isEmpty(e.getHaveStillPressure()) && (1==e.getHaveStillPressure() || 0== e.getHaveStillPressure())){
e.setHaveStillPressure(CylDictEnum.getEnum(e.getHaveStillPressure(), "haveStillPressure").getSeqNbr());
}
if (!ObjectUtil.isEmpty(e.getIsComplete()) && (1==e.getIsComplete() || 0== e.getIsComplete())){
e.setIsComplete(CylDictEnum.getEnum(e.getIsComplete(), "isComplete").getSeqNbr());
}
if (!ObjectUtil.isEmpty(e.getHaveSecurityDocuments()) && (1==e.getHaveSecurityDocuments() || 0== e.getHaveSecurityDocuments())){
e.setHaveSecurityDocuments(CylDictEnum.getEnum(e.getHaveSecurityDocuments(), "SecurityDocuments").getSeqNbr());
}
});
sourceFillingCheckServiceImpl.updataSyncFilling(appIds, fillingBeforeIds, sequenceCodes);
cylCylinderFillingCheckMapper.batchInsert(data);
}
}
......@@ -3,12 +3,15 @@ package com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingCheck;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInfo;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylCylinderFillingCheck;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFilling;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylCylinderFillingCheckMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/**
* 液化气体气瓶同步实现类
......@@ -47,4 +50,12 @@ public class CylinderSyncServiceImpl {
public void updateBatch(List<Long> sequenceNbrS) {
fillingCheckMapper.updateBatch(sequenceNbrS);
}
public List<CylinderFilling> queryUnSyncFilling() {
return fillingCheckMapper.queryUnSyncFilling();
}
public void updataSyncFilling(List<String> appIds,List<String> fillingBeforeIds,List<String> sequenceCodes){
fillingCheckMapper.updataSyncFilling(appIds,fillingBeforeIds,sequenceCodes);
}
}
\ No newline at end of file
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