|
@@ -15,13 +15,16 @@ import com.ruoyi.lnst.domain.LnstJcxx;
|
|
|
import com.ruoyi.lnst.domain.LnstMchnt;
|
|
|
import com.ruoyi.lnst.domain.ZwywJclrYcxx;
|
|
|
import com.ruoyi.lnst.mapper.LnstJcxxMapper;
|
|
|
+import com.ruoyi.lnst.mapper.LnstMchntMapper;
|
|
|
import com.ruoyi.lnst.mapper.ZwywJclrYcxxMapper;
|
|
|
import com.ruoyi.lnst.mapper.ZwywLrJbxxMapper;
|
|
|
import com.ruoyi.lnst.service.IZwywJclrYcxxService;
|
|
|
import com.ruoyi.system.mapper.SysDeptJlMapper;
|
|
|
import com.ruoyi.system.utils.SubCodeUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -52,6 +55,9 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
@Autowired
|
|
|
private LnstJcxxMapper lnstJcxxMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LnstMchntMapper lnstMchntMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
|
|
|
@@ -177,21 +183,15 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
return zwywJclrYcxxMapper.deleteBatchIds(Arrays.asList(ids));
|
|
|
}
|
|
|
|
|
|
- public Map<String,String> updateYcInfo(String startDate, String endDate, String storeCode, String startRecId) {
|
|
|
+ public Map<String,String> updateYcInfo(String startDate, String endDate, String startRecId, String storeCode,LnstMchnt lnstMchnt) {
|
|
|
+ if(StringUtils.isBlank(storeCode)) storeCode = "";
|
|
|
if(StringUtils.isBlank(startRecId)) startRecId = "0";
|
|
|
- if(StringUtils.isBlank(startDate)) startDate = DateUtils.getDate() + " 00:00:00";
|
|
|
- if(StringUtils.isBlank(endDate)) endDate = DateUtils.getDate() + " 23:59:59";
|
|
|
-
|
|
|
- LnstMchnt lnstMchnt = new LnstMchnt();
|
|
|
- lnstMchnt.setMchnt("10002253"); // 通榆
|
|
|
- lnstMchnt.setSrc("A38J");
|
|
|
- lnstMchnt.setSignkey("A43360BD94184BA29562A01478CDA7E5");
|
|
|
-// lnstMchnt.setMchnt("10002534");
|
|
|
-// lnstMchnt.setSrc("ZEO6");
|
|
|
-// lnstMchnt.setSignkey("87BE995B2A5D482FBE9BDD16631303C2");
|
|
|
+ if(StringUtils.isBlank(startDate)) startDate = DateUtils.getDate();
|
|
|
+ if(StringUtils.isBlank(endDate)) endDate = DateUtils.getDate();
|
|
|
+ startDate = startDate + " 00:00:00";
|
|
|
+ endDate = endDate + " 23:59:59";
|
|
|
|
|
|
// 存入redis
|
|
|
-
|
|
|
JSONObject res = ylSyncYcTb(storeCode, "01", "3", startRecId, lnstMchnt,startDate,endDate);
|
|
|
|
|
|
List<ZwywJclrYcxx> redisYcList = redisService.getCacheObject(redisName+lnstMchnt.getMchnt());
|
|
@@ -199,23 +199,23 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
List<String> codes = new ArrayList<>();
|
|
|
List<String> cards = new ArrayList<>();
|
|
|
|
|
|
- if(StringUtils.isNotNull(redisYcList)){
|
|
|
- String transList = res.getString("transList");
|
|
|
+ String transList = res.getString("transList");
|
|
|
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(transList); // 使用fastjson库将字符串转换成JSONArray
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(transList); // 使用fastjson库将字符串转换成JSONArray
|
|
|
if(StringUtils.isNotNull(jsonArray)){
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
com.alibaba.fastjson2.JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
codes.add(jsonObject.getString("memberCode"));
|
|
|
cards.add(jsonObject.getString("cardCode"));
|
|
|
-// System.out.println(" 银联流水号:" + jsonObject.getString("transSsn"));
|
|
|
- for (int j = 0; j < redisYcList.size(); j++) {
|
|
|
- if (redisYcList.get(j).getTrainSsn().equals(jsonObject.getString("transSsn"))) {
|
|
|
- jsonArray.remove(i);
|
|
|
- codes.remove(jsonObject.getString("memberCode"));
|
|
|
- cards.remove(jsonObject.getString("cardCode"));
|
|
|
- i--; // 减1以保持索引的有效性
|
|
|
- break;
|
|
|
+ if(StringUtils.isNotNull(redisYcList)){
|
|
|
+ for (int j = 0; j < redisYcList.size(); j++) {
|
|
|
+ if (redisYcList.get(j).getTrainSsn().equals(jsonObject.getString("transSsn"))) {
|
|
|
+ jsonArray.remove(i);
|
|
|
+ codes.remove(jsonObject.getString("memberCode"));
|
|
|
+ cards.remove(jsonObject.getString("cardCode"));
|
|
|
+ i--; // 减1以保持索引的有效性
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -225,12 +225,6 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
res.remove("transList");
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-// JSONArray jsonArrayAA = JSONArray.parseArray(res.getString("transList"));
|
|
|
-// for (int i = 0; i < jsonArrayAA.size(); i++) {
|
|
|
-// com.alibaba.fastjson2.JSONObject yyyy = jsonArrayAA.getJSONObject(i);
|
|
|
-//// System.out.println("调整后的流水号: " + yyyy.getString("transSsn") +" code:"+yyyy.getString("memberCode") +" card:"+yyyy.getString("cardCode") );
|
|
|
-// }
|
|
|
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
|
@@ -241,11 +235,10 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
query.setYlcode(codes.stream().collect(Collectors.joining(",")));
|
|
|
query.setYlcard(cards.stream().collect(Collectors.joining(",")));
|
|
|
List<InLnstLrxx> lrxxList = zwywLrJbxxMapper.selectYcLrxxByPara3(query);
|
|
|
-// System.out.println("系统中用餐老人数: " + lrxxList.size());
|
|
|
|
|
|
// 获取transList数组
|
|
|
- String transList = res.getString("transList");
|
|
|
- JSONArray jsonArray = JSONArray.parseArray(transList); // 使用fastjson库将字符串转换成JSONArray
|
|
|
+// String transList = res.getString("transList");
|
|
|
+// JSONArray jsonArray = JSONArray.parseArray(transList); // 使用fastjson库将字符串转换成JSONArray
|
|
|
List<ZwywJclrYcxx> ycxxList = new ArrayList<>(); // 创建一个列表来存储用餐信息
|
|
|
// 遍历JSONArray
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
@@ -254,7 +247,7 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
com.alibaba.fastjson2.JSONObject jsonObject = jsonArray.getJSONObject(i); // 获取每个对象
|
|
|
|
|
|
for (LnstJcxx lnstJcxx : lnstJcxxList) {
|
|
|
- if(jsonObject.getString("storeCode").equals(lnstJcxx.getYlstbm()) && jsonObject.getString("storeName").equals(lnstJcxx.getStmc())){
|
|
|
+ if(jsonObject.getString("storeCode").equals(lnstJcxx.getYlstbm())){
|
|
|
ycxx.setStbm(lnstJcxx.getStbm());
|
|
|
ycxx.setStmc(lnstJcxx.getStmc());
|
|
|
break;
|
|
@@ -291,17 +284,16 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
}
|
|
|
}
|
|
|
// 将storeCode添加到列表中
|
|
|
- if(StringUtils.isNotNull(ycxx.getXb()) && StringUtils.isNotNull(ycxx.getStmc())){
|
|
|
-// System.out.println("银联记录,园区下没有门店名称,不知道在哪个店消费,所以不进用餐记录表【getStmc】。");
|
|
|
+ if(StringUtils.isNotNull(ycxx.getXb()) && StringUtils.isNotNull(ycxx.getStbm())){
|
|
|
ycxxList.add(ycxx);
|
|
|
}
|
|
|
}
|
|
|
- System.out.println("ycxxListycxxList: " + ycxxList.size());
|
|
|
if(ycxxList.size()>0){
|
|
|
zwywJclrYcxxMapper.batchYcxxList(ycxxList);
|
|
|
- LambdaQueryWrapper<ZwywJclrYcxx> lqw = new LambdaQueryWrapper<ZwywJclrYcxx>().eq(ZwywJclrYcxx::getStbm,ycxxList.get(0).getStbm());
|
|
|
+ LambdaQueryWrapper<ZwywJclrYcxx> lqw = new LambdaQueryWrapper<ZwywJclrYcxx>().likeRight(ZwywJclrYcxx::getStbm,ycxxList.get(0).getStbm().substring(0,6));
|
|
|
+ lqw.between(ZwywJclrYcxx::getYcsj, startDate.replace("-","").substring(0,8) + "000000", endDate.replace("-","").substring(0,8) + "235959");
|
|
|
List<ZwywJclrYcxx> mchntYcList = zwywJclrYcxxMapper.selectList(lqw);
|
|
|
- // 这里要insert该园区&和传入的用餐时间全量记录。
|
|
|
+ // 这里要查询该园区&和传入的用餐时间全量记录。
|
|
|
redisService.setCacheObject(redisName+lnstMchnt.getMchnt(),mchntYcList,EXPIRE_TIME, TimeUnit.SECONDS);
|
|
|
}
|
|
|
}
|
|
@@ -314,10 +306,12 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public int getYlJsonInMysql(String startDate, String endDate, String storeCode) {
|
|
|
+ @Async
|
|
|
+ public int processTwo(String startDate, String endDate, String storeCode, LnstMchnt lnstMchnt) {
|
|
|
String startRecId = "0"; // 初始记录ID
|
|
|
while (true) {
|
|
|
- Map<String,String> result = updateYcInfo(startDate,endDate,startRecId,storeCode);
|
|
|
+ System.out.println("传入的起始ID:" + startRecId);
|
|
|
+ Map<String,String> result = updateYcInfo(startDate,endDate,startRecId,storeCode,lnstMchnt);
|
|
|
String finishFlag = result.get("finishFlag");
|
|
|
if ("1".equals(finishFlag)) {
|
|
|
System.out.println("数据拉取完成。");
|
|
@@ -326,6 +320,27 @@ public class ZwywJclrYcxxServiceImpl implements IZwywJclrYcxxService {
|
|
|
startRecId = result.get("nextStartRecId"); // 更新下一次的起始记录ID
|
|
|
System.out.println("继续拉取数据,下一次起始记录ID: " + startRecId);
|
|
|
}
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public int getYlJsonInMysql(String startDate, String endDate, String storeCode, String mchnt) {
|
|
|
+ LnstMchnt lnstMchnt = new LnstMchnt();
|
|
|
+ if(StringUtils.isNotBlank(mchnt)) lnstMchnt.setMchnt(mchnt);
|
|
|
+ List<LnstMchnt> mcnhtList = lnstMchntMapper.selectMchntListByGroup(lnstMchnt);
|
|
|
+
|
|
|
+ if(mcnhtList.size()==0){
|
|
|
+ throw new ServiceException("传入园区编码参数有误!");
|
|
|
+ }
|
|
|
+ else if(mcnhtList.size()==1){
|
|
|
+ processTwo(startDate,endDate,storeCode,mcnhtList.get(0));
|
|
|
+ }else {
|
|
|
+ for (LnstMchnt listYQ : mcnhtList) {
|
|
|
+ processTwo(startDate,endDate,storeCode,listYQ);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return 1;
|
|
|
}
|
|
|
|