From 0fac4397b7655b2cc5d9a1aea8c4e901a26e218f Mon Sep 17 00:00:00 2001 From: WS <1143478319@qq.com> Date: 星期二, 15 八月 2023 10:11:03 +0800 Subject: [PATCH] V4.0版本库存数据同步 --- src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java | 161 +++++++++++++++++++++++ src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1208Rep.java | 23 +++ src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java | 170 ++++++++++++++++++++++++ src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java | 10 4 files changed, 359 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java index 13eb1a0..6aa894c 100644 --- a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java +++ b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService12.java @@ -3,10 +3,8 @@ import com.fzzy.api.data.ApiParam; import com.fzzy.api.data.SyncProtocol; import com.fzzy.api.service.SyncService12; -import com.fzzy.async.fzzy40.impl.Fzzy40Sync1201; -import com.fzzy.async.fzzy40.impl.Fzzy40Sync1202; -import com.fzzy.async.fzzy40.impl.Fzzy40Sync1205; -import com.fzzy.async.fzzy40.impl.Fzzy40Sync1212; +import com.fzzy.async.fzzy35.impl.Fzzy35Sync1208; +import com.fzzy.async.fzzy40.impl.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; @@ -27,6 +25,8 @@ private Fzzy40Sync1205 fzzySync1205; @Autowired private Fzzy40Sync1212 fzzySync1212; + @Autowired + private Fzzy40Sync1208 fzzySync1208; @Override public String getProtocol() { @@ -68,7 +68,7 @@ //绮搴撳瓨鍚屾 TODO - + fzzySync1208.syncData(kqdm, deptId, start, end); //绮鎬ц川杞彉淇℃伅鍚屾 TODO diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java new file mode 100644 index 0000000..988f681 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40DepotStore.java @@ -0,0 +1,170 @@ +package com.fzzy.async.fzzy40.entity; + +import com.bstek.dorado.annotation.PropertyDef; +import com.fzzy.async.fzzy30.entity.Depot; +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: 绮搴撳瓨绠$悊锛屾牴鎹浗鏍囨爣缁撴灉瑕佹眰鍒涘缓 + * @author: Andy + * @update-time: 2022/11/17 + */ +@Data +@Entity +@Table(name = "D_DEPOT_STORE") +public class Fz40DepotStore implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -5548540780391804729L; + + @Id + @Column(name = "ID_", length = 40) + 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 = "DEPOT_ID_", length = 50) + @PropertyDef(label = "鎵�灞炰粨搴�") + private String depotId; + + @Column(name = "COUNTRY_", length = 10) + @PropertyDef(label = "鍥藉埆") + private String country; + + @Column(name = "STORE_TYPE_", length = 6) + @PropertyDef(label = "鍌ㄧ伯鏂瑰紡", description = "1:鏁h鍌ㄧ伯 2:鍖呰鍌ㄧ伯 3:鍥村寘鏁e瓨 9:鍏朵粬") + private String storeType; + + @Column(name = "MANAGE_TYPE_", length = 6) + @PropertyDef(label = "绠$悊鏂瑰紡", description = "01 鐩村偍02 浠e偍03 绉熶粨04 濮旀墭") + private String manageType; + + @Column(name = "FOOD_TYPE_", length = 10) + @PropertyDef(label = "绮鎬ц川") + private String foodType; + + @Column(name = "FOOD_VARIETY_", length = 10) + @PropertyDef(label = "绮鍝佺") + private String foodVariety; + + @Column(name = "FOOD_LEVEL_", length = 10) + @PropertyDef(label = "绮绛夌骇") + private String foodLevel; + + @Column(name = "FOOD_LOCATION_ID_", length = 50) + @PropertyDef(label = "绮浜у湴") + private String foodLocationId; + + @Column(name = "FOOD_LOCATION_", length = 50) + @PropertyDef(label = "绮浜у湴") + private String foodLocation; + + @Column(name = "FOOD_YEAR_", length = 10) + @PropertyDef(label = "鏀惰揣骞村害") + private String foodYear; + + @Column(name = "DEPOT_STATUS_", length = 10) + @PropertyDef(label = "浠撳簱鐘舵��", description = "1=绌轰粨銆�2=鍏ュ簱涓��3=婊′粨銆�4=鍑哄簱涓��9=鍏朵粬") + private String depotStatus; + + @Column(name = "STORE_DATE_") + @PropertyDef(label = "鍏ュ簱鏃堕棿", description = "鍏ュ簱鏃堕棿锛岀涓�杞︾伯椋熷叆浠撴椂闂�,鏍煎紡锛歽yyy-MM-dd HH:mm:ss") + private Date storeDate; + + @Column(name = "FULL_DATE_") + @PropertyDef(label = "灏佷粨鏃ユ湡", description = "褰撹揣浣嶏紙娌圭綈锛夌姸鎬佷负灏佷粨鏃讹紝姝ら」涓哄繀濉」") + private Date fullDate; + + @Column(name = "OUT_DATE_") + @PropertyDef(label = "鍑轰粨鏃堕棿", description = "鍑哄簱鏃堕棿锛屾渶鍚庝竴杞︾伯椋熷嚭浠撳畬鎴愭椂闂�,鏍煎紡锛歽yyy-MM-dd HH:mm:ss") + private Date outDate; + + @Column(name = "STORAGE_REAL_") + @PropertyDef(label = "瀹為檯鍌ㄩ噺", description = "鍗曚綅锛欿G") + private Double storageReal; + + @Column(name = "STORE_SETTLE__") + @PropertyDef(label = "璁′环鏁伴噺", description = "鍗曚綅锛欿G") + private Double storageSettle; + + @Column(name = "GRAIN_HEIGHT_") + @PropertyDef(label = "瑁呯伯绾块珮", description = "鍗曚綅锛氱背") + private Double grainHeight; + + @Column(name = "GRAIN_VOLUME_") + @PropertyDef(label = "瑁呯伯浣撶Н", description = "鍗曚綅锛氱珛鏂圭背") + private Double grainVolume; + + @Column(name = "REMARK_", length = 250) + @PropertyDef(label = "澶囨敞", description = "澶囨敞淇℃伅") + private String remark; + + @Column(name = "UPDATE_USER_", length = 50) + @PropertyDef(label = "淇敼浜�") + private String updateUser; + + + @Column(name = "UPDATE_DATE_") + @PropertyDef(label = "淇敼鏃堕棿") + private Date updateDate; + + @Column(name = "CREATE_DATE_") + private Date createDate; + + public Fz40DepotStore() { + } + + public Fz40DepotStore(String id, String companyId, String deptId, String depotId, String storeType, String foodType, String foodVariety, String foodLevel, String foodLocation, String depotStatus, String foodYear, Date storeDate, Double storageReal, Date fullDate, Date outDate, Double grainHeight, Double grainVolume, String remark, String updateUser, Date updateDate, Date createDate) { + this.id = id; + this.companyId = companyId; + this.deptId = deptId; + this.depotId = depotId; + this.storeType = storeType; + this.foodType = foodType; + this.foodVariety = foodVariety; + this.foodLevel = foodLevel; + this.foodLocation = foodLocation; + this.depotStatus = depotStatus; + this.foodYear = foodYear; + this.storeDate = storeDate; + this.storageReal = storageReal; + this.fullDate = fullDate; + this.outDate = outDate; + this.grainHeight = grainHeight; + this.grainVolume = grainVolume; + this.remark = remark; + this.updateUser = updateUser; + this.updateDate = updateDate; + } + + public Fz40DepotStore(Depot depot, String depotStatus) { + this.companyId = depot.getCompanyId(); + this.deptId = depot.getDeptId(); + this.depotId = depot.getId(); + this.storeType = depot.getStoreType(); + this.foodType = depot.getFoodType(); + this.foodVariety = depot.getFoodVariety(); + this.foodLevel = depot.getFoodLevel(); + this.foodLocation = depot.getFoodLocation(); + this.depotStatus = depotStatus; + this.foodYear = depot.getFoodYear(); + this.storageReal = depot.getStorageReal(); + this.storeDate = new Date(); + this.updateDate = new Date(); + } +} diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java new file mode 100644 index 0000000..a8aaf00 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1208.java @@ -0,0 +1,161 @@ +package com.fzzy.async.fzzy40.impl; + +import com.fzzy.api.Constant; +import com.fzzy.api.entity.Api1102; +import com.fzzy.api.entity.Api1105; +import com.fzzy.api.entity.Api1208; +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.Api1102Rep; +import com.fzzy.api.view.repository.Api1208Rep; +import com.fzzy.api.view.repository.ApiLogRep; +import com.fzzy.async.fzzy40.entity.Fz40DepotStore; +import com.fzzy.async.fzzy40.repository.Fzzy40Sync1208Rep; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.time.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.List; + +/** + * 绮搴撳瓨 + */ +@Slf4j +@Component +public class Fzzy40Sync1208 { + + @Autowired + private Fzzy40Sync1208Rep fzzySync1208Rep; + @Autowired + private ApiTriggerService apiTriggerService; + @Autowired + private Api1208Rep api1208Rep; + @Autowired + private ApiCommonService commonService; + @Autowired + private Api1102Rep api1102Rep; + @Autowired + private ApiLogRep apiLogRep; + + /** + * 鍚屾绮搴撳瓨 + * + * @param deptId + * @param start + * @param end + */ + public void syncData(String kqdm, String deptId, Date start, Date end) { + + log.info("-------------1208鎺ュ彛鏁版嵁寮�濮嬪悓姝�------------------"); + + //鍚屾鏁版嵁锛屽彧璁板綍澶辫触鐨勪俊鎭� + ApiLog apiLog = new ApiLog(); + apiLog.setType(ApiLog.TYPE_SYNC); + apiLog.setKqdm(deptId); + apiLog.setUploadTime(new Date()); + apiLog.setInteId(Constant.API_CODE_1208); + apiLog.setStatus(99); + apiLog.setId(ContextUtil.getUUID()); + try { + List<Fz40DepotStore> list = fzzySync1208Rep.listDepot(deptId, start, end); + + if (null == list || list.isEmpty()) { + + log.info("-------------娌℃湁鑾峰彇鍒扮伯椋熷簱瀛樹俊鎭�------------------"); + + return; + } + + //鏍规嵁搴撳尯浠g爜鑾峰彇鍗曚綅浠g爜 + Api1102 api1102 = api1102Rep.findById(kqdm).get(); + + Api1208 apiData; + Api1105 api1105; + for (Fz40DepotStore fz40DepotStore : list) { + + //鑾峰彇璐т綅淇℃伅 + api1105 = commonService.getApi1105Cache(fz40DepotStore.getDepotId()); + if (null == api1105) { + continue; + } + + apiData = new Api1208(); + apiData.setHwdm(api1105.getHwdm()); + + //绮鍝佺 + String mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSPZ, fz40DepotStore.getFoodVariety()); + apiData.setLspzdm(mappingCode); + + //绮鎬ц川 + mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSXZ, fz40DepotStore.getFoodType()); + apiData.setLsxzdm(mappingCode); + + //绮绛夌骇 + mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_LSDJ, fz40DepotStore.getFoodLevel()); + apiData.setLsdjdm(mappingCode); + + apiData.setShnd(fz40DepotStore.getFoodYear()); + + //浜у湴浠g爜 + String cd = commonService.getFoodLocationIdFromCache(fz40DepotStore.getFoodLocation()); + apiData.setCd(cd); + + apiData.setBgy(api1105.getBgy()); + //绮潈褰掑睘鍗曚綅 + apiData.setLqgsdwdm(api1102.getDwdm()); + //绮潈琛屾斂鍖哄垝浠g爜 + apiData.setLqxzqhdm(api1102.getDwdm().substring(2, 8)); + //绠$悊鏂瑰紡-榛樿鐩村偍 + apiData.setGlfs("01"); + //鏀跺偍鍦扮偣-榛樿搴撳唴 + apiData.setScdd("1"); + //鍌ㄧ伯鏂瑰紡 + apiData.setClfs(fz40DepotStore.getStoreType()); + + //璐т綅鐘舵�� + mappingCode = apiTriggerService.getMappingCode(Constant.TRIGGER_P_HWZT, fz40DepotStore.getDepotStatus()); + apiData.setHwzt(mappingCode); + if(null == fz40DepotStore.getStoreDate()){ + fz40DepotStore.setStoreDate(new Date()); + } + //鍏ヤ粨鏃堕棿 + apiData.setRcsj(fz40DepotStore.getStoreDate()); + //灏佷粨鏃ユ湡 + if("3".equals(apiData.getHwzt())){ + apiData.setFcrq(DateUtils.addDays(fz40DepotStore.getStoreDate(), 10)); + } + //鍑轰粨瀹屾垚鏃堕棿 + if("1".equals(apiData.getHwzt())){ + apiData.setCcwcsj(DateUtils.addDays(fz40DepotStore.getStoreDate(), 5)); + } + //鍥藉埆 + apiData.setGb("156"); + apiData.setSjsl(fz40DepotStore.getStorageReal()); + apiData.setJjsl(fz40DepotStore.getStorageReal()); + apiData.setSjzlxg(6); + apiData.setLdtj(10000); + + apiData.setZhgxsj(new Date()); + + //涓氬姟id銆佸簱鍖虹紪鐮併�佸悓姝ユ椂闂� + apiData.setBizId(fz40DepotStore.getId()); + apiData.setKqdm(kqdm); + apiData.setSyncTime(new Date()); + + //搴撳瓨姣忔鏂板 + apiData.setCzbz(Constant.CZBZ_I); + apiData.setId(ContextUtil.getCurTimeMillis()); + //淇濆瓨鏁版嵁 + api1208Rep.save(apiData); + } + } 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/Fzzy40Sync1208Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1208Rep.java new file mode 100644 index 0000000..c87ecb1 --- /dev/null +++ b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1208Rep.java @@ -0,0 +1,23 @@ +package com.fzzy.async.fzzy40.repository; + +import com.fzzy.async.fzzy40.entity.Fz40DepotStore; +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; + +/** + * 绮璐攢-绮搴撳瓨 + */ +public interface Fzzy40Sync1208Rep extends JpaRepository<Fz40DepotStore, String> { + + /** + * 鏍规嵁淇℃伅鑾峰彇浠撳簱淇℃伅 + * + * @return + */ + @Query("from Fz40DepotStore where deptId=:deptId and createDate >=:start and createDate <:end order by createDate ") + List<Fz40DepotStore> listDepot(@Param("deptId") String deptId, @Param("start") Date start, @Param("end") Date end); +} -- Gitblit v1.9.3