From e9260e2cac4ad51b6d785af4f0e147fc5d918ae5 Mon Sep 17 00:00:00 2001 From: CZT <czt18638530771@163.com> Date: 星期一, 30 十月 2023 10:49:05 +0800 Subject: [PATCH] 增加4.0版本计划及计划详细 --- src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java | 64 ++++++++ src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java | 11 + src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java | 26 +++ src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java | 16 + src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java | 96 ++++++++++++ src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java | 119 ++++++++++++++ src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java | 87 ++++++++++ src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java | 23 ++ 8 files changed, 436 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java b/src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java index a2f3c0e..360fcb0 100644 --- a/src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java +++ b/src/main/java/com/fzzy/async/fzzy35/impl/Fzzy35Sync1404.java @@ -3,6 +3,7 @@ import com.fzzy.api.Constant; import com.fzzy.api.entity.*; import com.fzzy.api.service.ApiCommonService; +import com.fzzy.api.service.ApiTriggerService; import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.view.repository.Api1404Rep; import com.fzzy.api.view.repository.ApiLogRep; @@ -33,6 +34,8 @@ private Fzzy35Sync1404Rep fzzy35Sync1404Rep; @Autowired private ApiCommonService commonService; + @Autowired + private ApiTriggerService apiTriggerService; @Autowired private Api1404Rep api1404Rep; @Autowired @@ -81,11 +84,13 @@ api1404 = new Api1404(); api1404.setLhjhdh(kqdm.substring(0, 18) + fz35PlanDetail.getPlanId().split("_")[1] + fz35PlanDetail.getPlanId().split("_")[2]); api1404.setJhmxdh(api1404.getLhjhdh() + kqdm + String.valueOf(index).substring(1)); - api1404.setLspzdm(fz35PlanDetail.getFoodVariety()); + String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35PlanDetail.getFoodVariety().substring(0,3)); + api1404.setLspzdm(mappingCode); api1404.setLsdjdm(fz35PlanDetail.getFoodLevel()); - api1404.setLsxzdm(fz35PlanDetail.getFoodType()); + mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35PlanDetail.getFoodType()); + api1404.setLsxzdm(mappingCode); api1404.setShnd(StringUtils.isEmpty(fz35PlanDetail.getYear())?fz35Plan.getYear():fz35PlanDetail.getYear()); - api1404.setLhhwdm(fz35PlanDetail.getDepotId()); + api1404.setLhhwdm(api1105.getHwdm()); api1404.setLhsl(fz35PlanDetail.getPlanNum()); api1404.setLhlx(fz35PlanDetail.getType()); api1404.setZhgxsj(new Date()); diff --git a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java index e485289..d94af34 100644 --- a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java +++ b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService14.java @@ -3,6 +3,9 @@ import com.fzzy.api.data.ApiParam; import com.fzzy.api.data.SyncProtocol; import com.fzzy.api.service.SyncService14; +import com.fzzy.async.fzzy40.impl.Fzzy40Sync1403; +import com.fzzy.async.fzzy40.impl.Fzzy40Sync1404; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -10,6 +13,12 @@ */ @Component public class Fzzy40SyncService14 implements SyncService14 { + + + @Autowired + private Fzzy40Sync1403 fzzy40Sync1403; + @Autowired + private Fzzy40Sync1404 fzzy40Sync1404; @Override public String getProtocol() { @@ -19,10 +28,11 @@ @Override public void syncData(ApiParam param) { - //TODO 杞崲璁″垝鍚屾 + //杞崲璁″垝鍚屾 + fzzy40Sync1403.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd()); - - //TODO 杞崲璁″垝鏄庣粏鍚屾 + //杞崲璁″垝鏄庣粏鍚屾 + fzzy40Sync1404.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd()); } diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java new file mode 100644 index 0000000..b41b2a5 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlan.java @@ -0,0 +1,87 @@ +package com.fzzy.async.fzzy40.entity; + +import com.bstek.dorado.annotation.PropertyDef; +import lombok.Data; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; + +/** + * 璁″垝绠$悊-涓昏〃 + * <p> + * 鍖呮嫭锛氭敹璐鍒掞紝閿�鍞鍒掞紝杞崲璁板綍锛岃鍒掓墽琛� + * + * @author: andy.jia + * @description: 鐗堟湰4.0瀛楁宸插 + * @version: + * @data:2020骞�5鏈�27鏃� + */ +@Data +@Entity +@Table(name = "D_INOUT_PLAN") +public class Fz40InoutPlan implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "ID_", length = 40) + @PropertyDef(label = "璁″垝缂栫爜") + private String id; + + @Column(name = "COMPANY_ID_", length = 10) + @PropertyDef(label = "缁勭粐缂栫爜") + private String companyId; + + @Column(name = "DEPT_ID_", length = 40) + @PropertyDef(label = "鎵�灞炲簱鍖�") + private String deptId; + + @Column(name = "TYPE_", length = 10) + @PropertyDef(label = "璁″垝绫诲瀷") + private String type; + + @Column(name = "NAME_", length = 50) + @PropertyDef(label = "璁″垝鍚嶇О") + private String name; + + @Column(name = "REFERENCE_NUMBER_", length = 40) + @PropertyDef(label = "璁″垝鏂囧彿") + private String referenceNumber; + + @Column(name = "YEAR_", length = 10) + @PropertyDef(label = "骞翠唤") + private String year; + + @Column(name = "BEGIN_TIME_") + @PropertyDef(label = "寮�濮嬫椂闂�") + private Date beginTime; + + @Column(name = "END_TIME_") + @PropertyDef(label = "鎴鏃堕棿") + private Date endTime; + + @PropertyDef(label = "璁″垝涓嬭揪鍗曚綅") + @Column(name = "jhxddw", length = 18) + private String jhxddw; + + @PropertyDef(label = "璁″垝涓嬭揪鏃堕棿") + @Column(name = "jhxdsj") + private Date jhxdsj; + + @Column(name = "CREATE_USER_", length = 30) + @PropertyDef(label = "鍒涘缓浜�") + private String createUser; + + @Column(name = "CREATE_TIME_") + @PropertyDef(label = "鍒涘缓鏃堕棿") + private Date createTime; + + @Column(name = "UPDATE_TIME_") + @PropertyDef(label = "鏁版嵁鏇存柊鏃堕棿") + private Date updateTime; + + @Column(name = "REMARK_", length = 250) + @PropertyDef(label = "澶囨敞") + private String remark; + +} diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java new file mode 100644 index 0000000..811c605 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40InoutPlanDetail.java @@ -0,0 +1,64 @@ +package com.fzzy.async.fzzy40.entity; + +import com.bstek.dorado.annotation.PropertyDef; +import lombok.Data; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.util.Date; + +/** + * 璁″垝锛岃鍒掕缁� + * + * @DESC 鐗堟湰4.0 楠岃瘉 + */ +@Data +@Entity +@Table(name = "D_INOUT_PLAN_DETAIL") +public class Fz40InoutPlanDetail implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "ID_", length = 40) + @PropertyDef(label = "璁″垝鏄庣粏鍙�") + private String id; + + @Column(name = "PLAN_ID_", length = 40) + @PropertyDef(label = "璁″垝缂栫爜") + private String planId; + + @Column(name = "FOOD_VARIETY_", length = 10) + @PropertyDef(label = "绮鍝佺") + private String foodVariety; + + @Column(name = "FOOD_TYPE_", length = 10) + @PropertyDef(label = "绮鎬ц川") + private String foodType; + + @Column(name = "FOOD_LEVEL_", length = 10) + @PropertyDef(label = "绮绛夌骇") + private String foodLevel; + + @Column(name = "YEAR_", length = 10) + @PropertyDef(label = "鏀惰幏骞村害") + private String year; + + @Column(name = "DEPOT_ID_", length = 50) + @PropertyDef(label = "浠撳簱") + private String depotId; + + @Column(name = "PLAN_NUM_", precision = 16, scale = 2) + @PropertyDef(label = "璁″垝鏁伴噺", description = "鍗曚綅锛氬惃") + private Double planNum; + + @Column(name = "TYPE_", length = 4) + @PropertyDef(label = "璁″垝绫诲瀷") + private String type; + + @Column(name = "UPDATE_TIME_") + @PropertyDef(label = "鏁版嵁鏇存柊鏃堕棿") + private Date updateTime; +} diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java new file mode 100644 index 0000000..ad4e506 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1403.java @@ -0,0 +1,96 @@ +package com.fzzy.async.fzzy40.impl; + +import com.fzzy.api.Constant; +import com.fzzy.api.entity.Api1101; +import com.fzzy.api.entity.Api1403; +import com.fzzy.api.entity.ApiLog; +import com.fzzy.api.utils.ContextUtil; +import com.fzzy.api.view.repository.Api1101Rep; +import com.fzzy.api.view.repository.Api1403Rep; +import com.fzzy.api.view.repository.ApiLogRep; +import com.fzzy.async.fzzy40.entity.Fz40InoutPlan; +import com.fzzy.async.fzzy40.repository.Fzzy40Sync1403Rep; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.Date; +import java.util.List; + +/** + * 杞崲璁″垝鍚屾 + * + * @author czt + * @date 2023-10-30 09:55 + */ +@Slf4j +@Component +public class Fzzy40Sync1403 { + + @Autowired + private Fzzy40Sync1403Rep fzzy40Sync1403Rep; + @Autowired + private Api1101Rep api1101Rep; + @Autowired + private Api1403Rep api1403Rep; + @Autowired + private ApiLogRep apiLogRep; + + /** + * 鍚屾骞跺皝瑁呬繚瀛樿疆鎹㈣鍒掓暟鎹� + * + * @param deptId 绯荤粺瀵瑰簲搴撳尯缂栫爜 + * @param start 璧峰鏃堕棿 + * @param end 鎴鏃堕棿 + */ + public void syncData(String kqdm, String deptId, Date start, Date end) { + log.info("-------------1403鎺ュ彛鏁版嵁寮�濮嬪悓姝�------------------"); + //鍚屾鏁版嵁锛屽彧璁板綍澶辫触鐨勪俊鎭� + ApiLog apiLog = new ApiLog(); + apiLog.setType(ApiLog.TYPE_SYNC); + apiLog.setKqdm(deptId); + apiLog.setUploadTime(new Date()); + apiLog.setInteId(Constant.API_CODE_1304); + apiLog.setStatus(99); + apiLog.setId(ContextUtil.getUUID()); + try { + List<Fz40InoutPlan> list = fzzy40Sync1403Rep.findDate("3", start, end); + if (null == list || list.isEmpty()) { + return; + } + + Api1403 api1403; + List<Api1101> api1101List; + List<Api1403> api1403List; + for (Fz40InoutPlan fz35Plan : list) { + api1403 = new Api1403(); + api1403.setLhjhdh(kqdm.substring(0, 18) + fz35Plan.getId().split("_")[1] + fz35Plan.getId().split("_")[2]); + api1403.setJhwh(fz35Plan.getReferenceNumber()); + api1403.setJhmc(fz35Plan.getName()); + api1403.setJhnd(fz35Plan.getYear()); + api1403.setKszxrq(fz35Plan.getBeginTime()); + api1403.setJzzxrq(fz35Plan.getEndTime()); + api1101List = api1101Rep.findPushData(kqdm); + if(null != api1101List && api1101List.size() > 0){ + api1403.setJhxddw(api1101List.get(0).getDwdm()); + } + api1403.setJhxdsj(fz35Plan.getCreateTime()); + + api1403.setZhgxsj(new Date()); + api1403.setKqdm(kqdm); + api1403.setBizId(fz35Plan.getId()); + api1403List = api1403Rep.getDataByLhjhdh(api1403.getLhjhdh()); + if(null == api1403List || api1403List.isEmpty()){ + api1403.setCzbz(Constant.CZBZ_I); + }else { + api1403.setCzbz(api1403List.get(0).getCzbz()); + } + api1403Rep.save(api1403); + } + } catch (Exception e) { + log.error("---鍚屾澶辫触----{}", e); + apiLog.setResult("鍚屾澶辫触锛�" + e.getMessage()); + apiLogRep.save(apiLog); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java new file mode 100644 index 0000000..141ac74 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1404.java @@ -0,0 +1,119 @@ +package com.fzzy.async.fzzy40.impl; + +import com.fzzy.api.Constant; +import com.fzzy.api.entity.Api1105; +import com.fzzy.api.entity.Api1404; +import com.fzzy.api.entity.ApiLog; +import com.fzzy.api.service.ApiCommonService; +import com.fzzy.api.service.ApiTriggerService; +import com.fzzy.api.utils.ContextUtil; +import com.fzzy.api.view.repository.Api1404Rep; +import com.fzzy.api.view.repository.ApiLogRep; +import com.fzzy.async.fzzy40.entity.Fz40InoutPlan; +import com.fzzy.async.fzzy40.entity.Fz40InoutPlanDetail; +import com.fzzy.async.fzzy40.repository.Fzzy40Sync1403Rep; +import com.fzzy.async.fzzy40.repository.Fzzy40Sync1404Rep; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import java.util.Date; +import java.util.List; + +/** + * 杞崲璁″垝鏄庣粏 + * + * @author czt + * @date 2023-10-30 09:55 + */ +@Slf4j +@Component +public class Fzzy40Sync1404 { + + @Autowired + private Fzzy40Sync1403Rep fzzy35Sync1403Rep; + @Autowired + private Fzzy40Sync1404Rep fzzy35Sync1404Rep; + @Autowired + private ApiCommonService commonService; + @Autowired + private ApiTriggerService apiTriggerService; + @Autowired + private Api1404Rep api1404Rep; + @Autowired + private ApiLogRep apiLogRep; + + /** + * 鍚屾骞跺皝瑁呬繚瀛樿川妫�鏁版嵁 + * + * @param deptId 绯荤粺瀵瑰簲搴撳尯缂栫爜 + * @param start 璧峰鏃堕棿 + * @param end 鎴鏃堕棿 + */ + public void syncData(String kqdm, String deptId, Date start, Date end) { + log.info("-------------1404鎺ュ彛鏁版嵁寮�濮嬪悓姝�------------------"); + //鍚屾鏁版嵁锛屽彧璁板綍澶辫触鐨勪俊鎭� + ApiLog apiLog = new ApiLog(); + apiLog.setType(ApiLog.TYPE_SYNC); + apiLog.setKqdm(deptId); + apiLog.setUploadTime(new Date()); + apiLog.setInteId(Constant.API_CODE_1304); + apiLog.setStatus(99); + apiLog.setId(ContextUtil.getUUID()); + try { + List<Fz40InoutPlan> list = fzzy35Sync1403Rep.findDate("3", start, end); + + if (null == list || list.isEmpty()) { + return; + } + + Api1404 api1404; + List<Fz40InoutPlanDetail> fz35PlanDetails; + Api1105 api1105; + List<Api1404> api1404List; + for (Fz40InoutPlan fz35Plan : list) { + + fz35PlanDetails = fzzy35Sync1404Rep.findDate(fz35Plan.getId()); + if (null == fz35PlanDetails || fz35PlanDetails.isEmpty()) { + continue; + } + int index = 10001; + for (Fz40InoutPlanDetail fz35PlanDetail : fz35PlanDetails) { + api1105 = commonService.getApi1105Cache(fz35PlanDetail.getDepotId()); + if (null == api1105) { + continue; + } + api1404 = new Api1404(); + api1404.setLhjhdh(kqdm.substring(0, 18) + fz35PlanDetail.getPlanId().split("_")[1] + fz35PlanDetail.getPlanId().split("_")[2]); + api1404.setJhmxdh(api1404.getLhjhdh() + kqdm + String.valueOf(index).substring(1)); + + String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz35PlanDetail.getFoodVariety().substring(0,3)); + api1404.setLspzdm(mappingCode); + api1404.setLsdjdm(fz35PlanDetail.getFoodLevel()); + mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz35PlanDetail.getFoodType()); + api1404.setLsxzdm(mappingCode); + api1404.setShnd(StringUtils.isEmpty(fz35PlanDetail.getYear())?fz35Plan.getYear():fz35PlanDetail.getYear()); + api1404.setLhhwdm(api1105.getHwdm()); + api1404.setLhsl(fz35PlanDetail.getPlanNum()); + api1404.setLhlx(fz35PlanDetail.getType()); + api1404.setZhgxsj(new Date()); + api1404.setKqdm(kqdm); + api1404.setBizId(fz35PlanDetail.getId()); + api1404List = api1404Rep.getDataByJhmxdh(api1404.getJhmxdh()); + if(null == api1404List || api1404List.isEmpty()){ + api1404.setCzbz(Constant.CZBZ_I); + }else { + api1404.setCzbz(api1404List.get(0).getCzbz()); + } + api1404Rep.save(api1404); + index ++; + } + } + } catch (Exception e) { + log.error("---鍚屾澶辫触----{}", e); + apiLog.setResult("鍚屾澶辫触锛�" + e.getMessage()); + apiLogRep.save(apiLog); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java new file mode 100644 index 0000000..d7b31f4 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1403Rep.java @@ -0,0 +1,26 @@ +package com.fzzy.async.fzzy40.repository; + +import com.fzzy.async.fzzy40.entity.Fz40InoutPlan; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import java.util.Date; +import java.util.List; + +/** + * 鏌ヨ杞崲璁″垝璇︾粏 + * + * @author czt + * @date 2023-10-30 09:55 + */ +public interface Fzzy40Sync1403Rep extends JpaRepository<Fz40InoutPlan, String> { + + /** + * + * @param start + * @param end + * @return + */ + @Query("from Fz40InoutPlan where type =:planType and createTime >=:start and createTime <:end order by createTime ") + List<Fz40InoutPlan> findDate(@Param("planType") String planType, @Param("start") Date start, @Param("end") Date end); +} diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java new file mode 100644 index 0000000..7d3f496 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1404Rep.java @@ -0,0 +1,23 @@ +package com.fzzy.async.fzzy40.repository; + +import com.fzzy.async.fzzy40.entity.Fz40InoutPlanDetail; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import java.util.List; + +/** + * 鏌ヨ杞崲璁″垝璇︾粏 + * + * @author czt + * @date 2023-10-30 09:55 + */ +public interface Fzzy40Sync1404Rep extends JpaRepository<Fz40InoutPlanDetail, String> { + + /** + * + * @return + */ + @Query("from Fz40InoutPlanDetail where planId =:planId ") + List<Fz40InoutPlanDetail> findDate(@Param("planId") String planId); +} -- Gitblit v1.9.3