代码更新
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BothCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.BOTH, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.anno.CacheConsts;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
@Value("${jetcache.defaultCacheType}")
|
||||
private String cacheType;
|
||||
|
||||
@Bean(name = "sysCacheManager")
|
||||
public NlCacheManager sysCacheManager() {
|
||||
CacheConsts.isUndefined(2);
|
||||
if (CacheType.BOTH.name().equals(cacheType)) return new BothCacheManager();
|
||||
if (CacheType.LOCAL.name().equals(cacheType)) return new LocalCacheManager();
|
||||
if (CacheType.REMOTE.name().equals(cacheType)) return new RemoteCacheManager();
|
||||
return new LocalCacheManager();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LocalCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.LOCAL, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public abstract class NlCacheManager {
|
||||
private Cache<Object, Object> defaultCache;
|
||||
private Cache<Object, Object> systemCache;
|
||||
public void test(){
|
||||
System.out.println(this.getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.nl.modules.cache;
|
||||
|
||||
import com.alicp.jetcache.Cache;
|
||||
import com.alicp.jetcache.anno.CacheType;
|
||||
import com.alicp.jetcache.anno.CreateCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RemoteCacheManager extends NlCacheManager {
|
||||
/**
|
||||
* 使用 @CreateCache 注解创建Cache实例;
|
||||
* 未定义默认值的参数,将使用yml中指定的全局配置;
|
||||
* 缓存在 Local,也可以配置成 both 开启两级缓存
|
||||
*/
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10)
|
||||
private Cache<Object, Object> defaultCache;
|
||||
@CreateCache(expire = 5 * 60, cacheType = CacheType.REMOTE, localLimit = 10)
|
||||
private Cache<Object, Object> systemCache;
|
||||
|
||||
@Override
|
||||
public void test() {
|
||||
System.out.println(this.getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package org.nl.modules.log;
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.UnsynchronizedAppenderBase;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import lombok.Data;
|
||||
import org.nl.utils.SpringContextHolder;
|
||||
import org.slf4j.Marker;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* https://www.cnblogs.com/lzghyh/p/14913230.html
|
||||
* https://juejin.cn/post/6844903488896385037
|
||||
* https://cloud.tencent.com/developer/article/1384035
|
||||
* https://www.freesion.com/article/229560377/
|
||||
* <p>
|
||||
* https://cloud.tencent.com/developer/article/1384035
|
||||
*/
|
||||
@Data
|
||||
public class MongoDBAppenderBase<E> extends UnsynchronizedAppenderBase<ILoggingEvent> {
|
||||
|
||||
@Override
|
||||
protected void append(ILoggingEvent eventObject) {
|
||||
|
||||
MongoTemplate mongoTemplate = SpringContextHolder.getBean(MongoTemplate.class);
|
||||
|
||||
if (mongoTemplate != null) {
|
||||
final BasicDBObject doc = new BasicDBObject();
|
||||
Marker marker = eventObject.getMarker();
|
||||
if (!ObjectUtil.isEmpty(marker)) {
|
||||
doc.append("marker", marker.getName());
|
||||
} else {
|
||||
doc.append("marker", "default");
|
||||
}
|
||||
try {
|
||||
doc.append("ip", InetAddress.getLocalHost().getHostAddress());
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
doc.append("level", eventObject.getLevel().toString());
|
||||
doc.append("logger", eventObject.getLoggerName());
|
||||
doc.append("thread", eventObject.getThreadName());
|
||||
doc.append("message", eventObject.getFormattedMessage());
|
||||
mongoTemplate.insert(doc, "log");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
|
||||
package org.nl.modules.log.rest;
|
||||
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.annotation.Log;
|
||||
import org.nl.modules.log.service.RootLogService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @date 2021-08-19
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "系统日志")
|
||||
@RequestMapping("/api/rootLog")
|
||||
@Slf4j
|
||||
public class RootLogController {
|
||||
|
||||
private final RootLogService rootLogService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询系统日志")
|
||||
@ApiOperation("查询系统日志")
|
||||
//@PreAuthorize("@el.check('point:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(rootLogService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package org.nl.modules.log.service;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统日志查询
|
||||
*/
|
||||
public interface RootLogService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package org.nl.modules.log.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.log.service.RootLogService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description 服务实现
|
||||
* @date 2021-08-19
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class RootLogServiceImpl implements RootLogService {
|
||||
|
||||
private final MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
//查询条件
|
||||
Query query = Query.query(Criteria.where("level").is("INFO"));
|
||||
|
||||
//根据条件得到的总条数
|
||||
long totalSize = mongoTemplate.count(query, Map.class, "log_root");
|
||||
|
||||
//处理分页
|
||||
query.skip(page.getPageNumber()).limit(page.getPageSize());
|
||||
List<Map> list = mongoTemplate.find(query, Map.class, "log_root");
|
||||
|
||||
//封装前端分页查询结果
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("content", list);
|
||||
result.put("totalElements", totalSize);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.nl.start.auto.initial.ApplicationAutoInitial;
|
||||
import org.nl.wms.ext.bigScreen.service.BigScreenService;
|
||||
import org.nl.wms.ext.bigScreen.service.dto.*;
|
||||
|
||||
@@ -18,11 +18,11 @@ spring:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
#url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
|
||||
username: ${DB_USER:root}
|
||||
#password: ${DB_PWD:P@ssw0rd}
|
||||
#password: ${DB_PWD:root}
|
||||
password: ${DB_PWD:password}
|
||||
password: ${DB_PWD:Root.123456}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: prod
|
||||
active: dev
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
@@ -21,36 +21,8 @@ https://juejin.cn/post/6844903775631572999
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
<charset>${log.charset}</charset>
|
||||
<!-- <charset>${log.charset}</charset>-->
|
||||
</encoder>
|
||||
|
||||
<!-- 转为JSON https://www.zoleet.com/details/328.html-->
|
||||
<!-- <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"appName": "logistics-core",
|
||||
"time": "%date{yyyy-MM-dd HH:mm:ss.SSS}",
|
||||
"level": "%level",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger",
|
||||
"method": "%method",
|
||||
"line": "%line",
|
||||
"message": "%message",
|
||||
"statck_trace": "%xEx"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>-->
|
||||
</appender>
|
||||
|
||||
<appender name="MONGO" class="org.nl.modules.log.MongoDBAppenderBase">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>info</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
|
||||
|
||||
@@ -1,369 +0,0 @@
|
||||
/*
|
||||
package org.nl.day01;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.exception.WDKException;
|
||||
import org.nl.wql.WQL;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
|
||||
*/
|
||||
/**
|
||||
* 根据输入天数day,获取距离今天day天数的字符串日期
|
||||
*
|
||||
* @param day
|
||||
* 距离今天天数
|
||||
* @return 如day为0 则输出2019-06-09当天日期
|
||||
*//*
|
||||
|
||||
public static String getDateStr(int day) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date todayDate = new Date();
|
||||
long beforeTime = (todayDate.getTime() / 1000) - 60 * 60 * 24 * day;
|
||||
todayDate.setTime(beforeTime * 1000);
|
||||
String beforeDate = formatter.format(todayDate);
|
||||
return beforeDate;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* 更新交货单
|
||||
*
|
||||
* @param ctx
|
||||
* @param account
|
||||
*//*
|
||||
|
||||
@WDKTransaction
|
||||
public void updateDeliveryOrderInfo(String code) {
|
||||
Date date1 = new Date();
|
||||
System.out.println("updateDeliveryOrderInfo发送数据-----------------");
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetDnZjwl";
|
||||
HashMap<String, String> form = new HashMap<>();
|
||||
// 获得前两天日期
|
||||
JSONObject ZfmGetSoResponse = null;
|
||||
if (code.equals("")) {
|
||||
form.put("IErdatFrm", getDateStr(1));
|
||||
form.put("IErdatTo",getDateStr(0));
|
||||
form.put("IVbeln", ""); // 非必填字段
|
||||
} else {
|
||||
form.put("IErdatFrm", "");
|
||||
form.put("IErdatTo", "");
|
||||
form.put("IVbeln", code); // 非必填字段
|
||||
}
|
||||
try {
|
||||
JSONObject ret = WebServiceUtil.process(url, method, form);
|
||||
System.out.println("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.optJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.optJSONObject("soap-env:Body");
|
||||
ZfmGetSoResponse = Body.optJSONObject("n0:ZfmGetDnZjwlResponse");
|
||||
String check = ZfmGetSoResponse.optString("OResultcode");
|
||||
if ("1005".equals(check)) {
|
||||
System.out.println(ZfmGetSoResponse.optString("OResultmsg"));
|
||||
return;
|
||||
} else if (!"1000".equals(check)) {
|
||||
throw new WDKException(ZfmGetSoResponse.optString("OResultmsg"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.optJSONObject("TZtdn");
|
||||
JSONArray item = TZtsalesorder.optJSONArray("item");
|
||||
|
||||
if (item.size() == 0 || TZtsalesorder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 发货通知单(未拆分)主表
|
||||
WQLObject wqlMst = WQLObject.getWQLObject("SAL_OD_DeliveryNotice");
|
||||
// 发货通知单明细(未拆分)表
|
||||
WQLObject wqlDtl = WQLObject.getWQLObject("SAL_OD_DeliveryNoticeDtl");
|
||||
// 交货单接口表
|
||||
WQLObject wqld = WQLObject.getWQLObject("SAP_OD_Delivery");
|
||||
|
||||
// 字典表单据类型
|
||||
WQLObject wqlDic = WQLObject.getWQLObject("PF_PB_SysDicInfo");
|
||||
JSONArray diclist = wqlDic.query("sysdic_type ='TC_SALE_SENDBIZTYPE' and sysdic_para2 !='' ")
|
||||
.getResultJSONArray(0);
|
||||
HashMap<String, String> DicMap = new HashMap<>();
|
||||
for (int i = 0; i < diclist.size(); i++) {
|
||||
JSONObject nowdiclist = diclist.getJSONObject(i);
|
||||
DicMap.put(nowdiclist.optString("sysdic_para2"), nowdiclist.optString("sysdic_code"));
|
||||
}
|
||||
//查询当前仓库
|
||||
JSONArray jaStor = WQL.getWO("QSTOST_MTATERUTIL_01")
|
||||
.addParam("flag", "6")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
HashMap<String, JSONObject> mapStor = new HashMap<>();
|
||||
for(int i=0;i<jaStor.size();i++){
|
||||
JSONObject jo = jaStor.optJSONObject(i);
|
||||
String stor_code = jo.optString("stor_code");
|
||||
if(!mapStor.containsKey(stor_code)){
|
||||
mapStor.put(stor_code, jo);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < item.size(); i++) {
|
||||
JSONObject nowitem = item.getJSONObject(i);
|
||||
//当前订单类型非智能车间
|
||||
if (!DicMap.containsKey(nowitem.optString("Lfart"))) {
|
||||
continue;
|
||||
}
|
||||
//当前仓库非智能车间
|
||||
if(!nowitem.optString("Lgort","").equals("") &&!mapStor.containsKey(nowitem.optString("Lgort",""))){
|
||||
continue;
|
||||
}
|
||||
// SAP_OD_Delivery
|
||||
JSONObject joto = wqld
|
||||
.query("Vbeln =? and Posnr = ?",
|
||||
new String[] { nowitem.optString("Vbeln"), nowitem.optString("Posnr") }, "")
|
||||
.uniqueResult(0);
|
||||
if (joto == null) {
|
||||
JSONObject jo = item.getJSONObject(i);
|
||||
String id = WDK.getUUID();
|
||||
jo.put("id", id);
|
||||
jo.put("create_time", WDK.getDateTime());
|
||||
String newStr = jo.optString("Matnr").replaceAll("^(0+)", "");
|
||||
jo.put("Matnr", newStr);
|
||||
jo.put("sysflag", 0);
|
||||
wqld.insert(jo);
|
||||
}
|
||||
}
|
||||
|
||||
// SAP_OD_Delivery
|
||||
// 查询所有未导入的单据
|
||||
JSONArray ja = WQL.getWO("QSTOST_MTATERUTIL_01")
|
||||
.addParam("flag", "5")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
System.out.println(ja.size());
|
||||
HashMap<String, JSONObject> mapMst = new HashMap<String, JSONObject>();
|
||||
for(int i=0;i<ja.size();i++){
|
||||
JSONObject jo = ja.optJSONObject(i);
|
||||
String vbeln = jo.optString("vbeln");
|
||||
//判断是否已存在该主表
|
||||
JSONObject joM = wqlMst.query("bill_code = '"+vbeln+"'").uniqueResult(0);
|
||||
//不存在
|
||||
if(joM == null || joM.isEmpty()){
|
||||
jo.put("detail_count", "0");
|
||||
jo.put("deliverynotice_uuid", WDK.getUUID());
|
||||
|
||||
jo.put("bill_type_scode", "22");
|
||||
jo.put("biztype_scode", DicMap.get(jo.optString("lfart")));
|
||||
jo.put("trans_type_uuid", "18"); // TODO 普通销售发货
|
||||
jo.put("bill_code", jo.optString("vbeln"));
|
||||
jo.put("bill_date", jo.optString("erdatps"));
|
||||
if(jo.optString("saleorg_uuid","").equals("")){
|
||||
jo.put("saleorg_uuid","94E889A7BDC54BCF8EAA2C46F96090E2");
|
||||
jo.put("saleorg_code",jo.optString("vkorg",""));
|
||||
jo.put("saleorg_name","铜管道事业部");
|
||||
}
|
||||
if(jo.optString("optor_uuid","").equals("")){
|
||||
jo.put("optor_uuid","7782D11F01D549999063379A9C2A3D86");
|
||||
}
|
||||
String lgort = jo.optString("lgort","");
|
||||
if(mapStor.containsKey(lgort)){
|
||||
JSONObject joStor = mapStor.get(lgort);
|
||||
jo.put("org_uuid", joStor.optString("org_uuid"));
|
||||
jo.put("org_code", joStor.optString("org_code"));
|
||||
jo.put("org_name", joStor.optString("org_name"));
|
||||
jo.put("store_point_uuid",joStor.optString("store_point_uuid"));
|
||||
jo.put("store_point_name", joStor.optString("store_point_name"));
|
||||
}else{
|
||||
jo.put("org_uuid", "94E889A7BDC54BCF8EAA2C46F96090E2");
|
||||
jo.put("org_code", "2012");
|
||||
jo.put("org_name", "铜管道事业部");
|
||||
jo.put("store_point_uuid","E864B2CBEA4F49C7B465704A50CFFFC8");// TODO
|
||||
jo.put("store_point_name", "铜管仓库库点");// TODO 库点
|
||||
}
|
||||
jo.put("currency_scode", "01");// TODO 默认人民币
|
||||
jo.put("exchange_rate", "0");
|
||||
jo.put("sale_type_scode", "01");// TODO 销售类型 默认 多种经营
|
||||
jo.put("create_mode_scode", "02");// 02外部接口产生
|
||||
jo.put("bill_status", "30");
|
||||
jo.put("print_count", "0");
|
||||
jo.put("delivery_address", jo.optString("streetdz"));
|
||||
|
||||
jo.put("source_bill_type", jo.optString("bill_type_scode",""));
|
||||
jo.put("source_bill_uuid", jo.optString("order_uuid",""));
|
||||
|
||||
jo.put("input_optuuid", "7782D11F01D549999063379A9C2A3D86");// TODO 接口制单人
|
||||
jo.put("input_optname", "订单管理员");
|
||||
jo.put("input_time", WDK.getDateTime());
|
||||
jo.put("syscreatoruuid", "7782D11F01D549999063379A9C2A3D86"); // 创建人
|
||||
jo.put("syscreatedate", WDK.getDateTime());
|
||||
jo.put("sysdeptuuid", "65D9D062414346CE9BFB39DC44803DAA"); // TODO 部门
|
||||
jo.put("syscompanyuuid", "94E889A7BDC54BCF8EAA2C46F96090E2");// TODO 公司
|
||||
jo.put("sysisdelete", "0");
|
||||
jo.put("is_allbillbom", "0");
|
||||
jo.put("is_workshop", "0");
|
||||
jo.put("is_insert", "1");
|
||||
}else{//存在
|
||||
jo = joM;
|
||||
jo.put("is_insert", "0");
|
||||
jo.put("is_workshop", "0");
|
||||
jo.put("sysupdatoruuid", "7782D11F01D549999063379A9C2A3D86");
|
||||
jo.put("sysupdatedate", WDK.getDateTime());
|
||||
}
|
||||
mapMst.put(vbeln, jo);
|
||||
}
|
||||
|
||||
//KG
|
||||
JSONObject job = WQLObject.getWQLObject("MD_PB_MeasureUnit").query("unit_name = ?", new String[] { "千克" }, "")
|
||||
.uniqueResult(0);// 计量单位
|
||||
|
||||
JSONArray materRows = WQL.getWO("QSTOST_MTATERUTIL_01")
|
||||
.addParam("flag", "8")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("'");
|
||||
for (int i = 0; i < materRows.size(); i++) {
|
||||
JSONObject jrow = materRows.getJSONObject(i);
|
||||
String matnr = jrow.optString("matnr").replaceAll("^(0+)", "");
|
||||
sb.append(matnr);
|
||||
sb.append("','");
|
||||
}
|
||||
sb.append("'");
|
||||
String roleIds = sb.toString();
|
||||
//获取当前mater集合
|
||||
JSONArray materja = WQL.getWO("QSTOST_MTATERUTIL_02")
|
||||
.addParam("flag", "6")
|
||||
.addParam("ids", roleIds)
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
HashMap<String, String> mapMater = new HashMap<>();
|
||||
for(int i=0;i<materja.size();i++){
|
||||
JSONObject jo = materja.optJSONObject(i);
|
||||
String material_code = jo.optString("material_code");
|
||||
if(!mapMater.containsKey(material_code)){
|
||||
mapMater.put(material_code, jo.optString("material_uuid"));
|
||||
}
|
||||
}
|
||||
//明细表
|
||||
JSONArray dtlRows = WQL.getWO("QSTOST_MTATERUTIL_01")
|
||||
.addParam("flag", "7")
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
StringBuilder sbdtl = new StringBuilder();
|
||||
sbdtl.append("'");
|
||||
for(int i=0;i<dtlRows.size();i++){
|
||||
JSONObject jo = dtlRows.optJSONObject(i);
|
||||
String vbeln = jo.optString("vbeln");
|
||||
if(!mapMst.containsKey(vbeln)){
|
||||
continue;
|
||||
}
|
||||
JSONObject joMst = mapMst.get(vbeln);
|
||||
|
||||
String uuid = WDK.getUUID();
|
||||
jo.put("deliverynoticedtl_uuid", uuid);
|
||||
jo.put("deliverynotice_uuid", joMst.optString("deliverynotice_uuid"));
|
||||
jo.put("seq_no", jo.optString("posnr"));
|
||||
|
||||
String newStr = jo.optString("matnr").replaceAll("^(0+)", "");
|
||||
if(!mapMater.containsKey(newStr)){
|
||||
continue;
|
||||
}
|
||||
joMst.put("detail_count", (joMst.optInt("detail_count")+1)+"");
|
||||
|
||||
mapMst.put(vbeln, joMst);
|
||||
jo.put("material_uuid", mapMater.get(newStr)); // TODO 假数据
|
||||
jo.put("material_code", newStr);
|
||||
jo.put("material_name", jo.optString("arktx"));
|
||||
|
||||
if (jo.optString("unit_uuid").equals("")) {
|
||||
throw new WDKException("单据编号" + vbeln + ",物料编码" + newStr + "计量单位异常,未在单位表查询到该单位:"
|
||||
+ jo.optString("vrkme"));
|
||||
}
|
||||
jo.put("base_unit_uuid", jo.optString("unit_uuid"));
|
||||
jo.put("base_unit_qty", "0");
|
||||
jo.put("aid_unit_uuid", jo.optString("unit_uuid"));
|
||||
jo.put("aid_unit_qty", "0");
|
||||
|
||||
jo.put("delivery_qty", jo.optString("lfimg"));
|
||||
// 发货和出库相关量
|
||||
jo.put("total_shippedqty", "0");
|
||||
jo.put("total_unshippedqty", jo.optString("lfimg"));
|
||||
jo.put("total_outqty", "0");
|
||||
jo.put("total_unoutqty", jo.optString("lfimg"));
|
||||
jo.put("total_dumpqty", "0");
|
||||
jo.put("total_undumpqty", jo.optString("lfimg"));
|
||||
|
||||
jo.put("tax_price", "0");
|
||||
jo.put("tax_rate", "0");
|
||||
jo.put("tax_amt", "0");
|
||||
jo.put("withtax_amt", "0");
|
||||
jo.put("notax_price", "0");
|
||||
jo.put("nowith_taxamt", "0");
|
||||
if (jo.optString("meins").equals("KG")) {
|
||||
jo.put("weight_unit_uuid", job.optString("measure_unit_uuid"));// 基本计量单位
|
||||
jo.put("weight_unit_name", job.optString("unit_name"));
|
||||
}
|
||||
|
||||
jo.put("net_weight", jo.optString("ntgew"));
|
||||
|
||||
jo.put("status", "30");
|
||||
|
||||
String lgort = jo.optString("lgort","");
|
||||
if(mapStor.containsKey(lgort)){
|
||||
JSONObject joStor = mapStor.get(lgort);
|
||||
jo.put("apply_org_uuid", joStor.optString("org_uuid"));
|
||||
jo.put("apply_org_name", joStor.optString("org_name"));
|
||||
}else{
|
||||
jo.put("apply_org_uuid", "94E889A7BDC54BCF8EAA2C46F96090E2");
|
||||
jo.put("apply_org_name", "铜管道事业部");
|
||||
}
|
||||
|
||||
jo.put("delivery_date", jo.optString("wadatist"));
|
||||
jo.put("ship_date", jo.optString("wadatist"));
|
||||
jo.put("is_notcontqty", "1");
|
||||
jo.put("is_notcontdate", "1");
|
||||
|
||||
// 销售订单单据号 行项目
|
||||
jo.put("ext_id", jo.optString("vgbel"));
|
||||
jo.put("ext_seqno", jo.optString("vgpos"));
|
||||
|
||||
jo.put("base_billdtl_uuid", uuid);
|
||||
jo.put("base_bill_type", jo.optString("lfart"));
|
||||
jo.put("base_bill_code", jo.optString("vbeln"));
|
||||
jo.put("is_workshop", "0");
|
||||
wqlDtl.insert(jo);
|
||||
sbdtl.append(jo.optString("id"));
|
||||
sbdtl.append("','");
|
||||
|
||||
}
|
||||
sbdtl.append("'");
|
||||
// 创建对象存取明细
|
||||
HashMap<String, String> mapCount2 = new HashMap<>();
|
||||
mapCount2.put("sysflag", "1");
|
||||
// 更新中间主表
|
||||
wqld.update(mapCount2, "id in("+sbdtl.toString()+")");
|
||||
|
||||
Set<Map.Entry<String, JSONObject>> entrySet = mapMst.entrySet();
|
||||
Iterator<Map.Entry<String, JSONObject>> iter = entrySet.iterator();
|
||||
//新增主表
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Map.Entry<String, JSONObject> entry = iter.next();
|
||||
JSONObject jo = entry.getValue();
|
||||
if(jo.optInt("detail_count")==0){
|
||||
continue;
|
||||
}
|
||||
if(jo.optString("is_insert").equals("1")){
|
||||
wqlMst.insert(entry.getValue());
|
||||
}else if(jo.optString("is_insert").equals("0")){
|
||||
wqlMst.update(entry.getValue());
|
||||
}
|
||||
}
|
||||
Date date2 = new Date();
|
||||
System.out.println("共计秒:"+(date2.getTime()-date1.getTime())/1000);
|
||||
System.out.println("销售发货通知数据同步成功!");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -1,62 +0,0 @@
|
||||
package org.nl.day01;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Test2 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/z_sd0002_send_mat_md/800/z_sd0002_send_mat_md/binding";
|
||||
String method = "ZSd0002SendMatMd"; //物料接口
|
||||
HashMap<String, String> form = new HashMap<String, String>();
|
||||
form.put("MatnrFr", "24018347S");
|
||||
form.put("MatnrTo", "24018347S");
|
||||
//非必填字段
|
||||
JSONObject ret = WebServiceUtil.process(url, method, form);
|
||||
System.out.println("getXML返回数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.optJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.optJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetSoResponse = Body.optJSONObject("n0:ZSd0002SendMatMdResponse");
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.optJSONObject("TZtsalesorder");
|
||||
/* JSONArray item = TZtsalesorder.optJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------" + ZfmGetSoResponse.optString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------" + item.size());*/
|
||||
|
||||
/*String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method="ZfmGetSo"; //获取销售订单
|
||||
HashMap<String,String> form = new HashMap<String,String>();
|
||||
form.put("IErdatFrm", "2022-05-01");
|
||||
form.put("IErdatTo", "2022-05-08");
|
||||
//非必填字段
|
||||
form.put("IVbeln", "");
|
||||
JSONObject ret = WebServiceUtil.process(url,method,form);
|
||||
System.out.println("getXML发送数据-----------------"+ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetSoResponse");
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtsalesorder");
|
||||
JSONArray item = TZtsalesorder.optJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------"+ZfmGetSoResponse.optString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------"+item.size());*/
|
||||
|
||||
|
||||
/* String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetDnZjwl"; //获取交货单
|
||||
HashMap<String, String> form = new HashMap<String, String>();
|
||||
form.put("IErdatFrm", "2019-05-01");
|
||||
form.put("IErdatTo", "2019-05-08");
|
||||
//非必填字段
|
||||
form.put("IVbeln", "");
|
||||
//非必填字段
|
||||
JSONObject ret = WebServiceUtil.process(url, method, form);
|
||||
System.out.println("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.optJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.optJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetDnZjwlResponse = Body.getJSONObject("n0:ZfmGetDnZjwlResponse");
|
||||
JSONObject TZtdn = ZfmGetDnZjwlResponse.getJSONObject("TZtdn");
|
||||
JSONArray item = TZtdn.getJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------" + ZfmGetDnZjwlResponse.getString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------" + item.size());*/
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package org.nl.day01;
|
||||
|
||||
public class Test4 {
|
||||
public static void main(String[] args) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package org.nl.day01;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.XML;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* 后端调用第三方webservice接口
|
||||
*
|
||||
* @author zds 2018-12-27 16:33:50
|
||||
*/
|
||||
public class WebServiceUtil {
|
||||
/**
|
||||
* @param url 第三方系统提供webservice的接口url
|
||||
* @param method 第三方系统提供webservice对应的方法名
|
||||
* @param form 第三方系统提供webservice对应的方法请求参数
|
||||
* @return 第三方系统返回的JSONObject调用结果
|
||||
* @throws Exception 工具类一般不处理具体异常,抛出由调用方处理,否则容易形成黑箱
|
||||
*/
|
||||
public static JSONObject process(String url, String method, HashMap<String, String> form) throws Exception {
|
||||
|
||||
|
||||
//第一步:创建服务地址
|
||||
URL netUrl = new URL(url);
|
||||
|
||||
//第二步:打开一个通向服务地址的连接
|
||||
HttpURLConnection connection = (HttpURLConnection) netUrl.openConnection();
|
||||
|
||||
//第三步:设置参数
|
||||
connection.setRequestMethod("POST");
|
||||
//设置超时时间
|
||||
connection.setConnectTimeout(50000);
|
||||
|
||||
//3.2设置数据格式:content-type
|
||||
connection.setRequestProperty("content-type", "text/xml;charset=utf-8");
|
||||
|
||||
//3.3设置输入输出,因为默认新创建的connection没有读写权限,
|
||||
connection.setDoInput(true);
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
|
||||
//第四步:组织SOAP数据,发送请求
|
||||
String soapXML = getXML(form, method);
|
||||
|
||||
//将信息以流的方式发送出去
|
||||
OutputStream os = connection.getOutputStream();
|
||||
|
||||
os.write(soapXML.getBytes());
|
||||
|
||||
//第五步:接收服务端响应,打印
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
|
||||
//返回结果
|
||||
String resultStr = null;
|
||||
if (200 == responseCode) {//表示服务端响应成功
|
||||
|
||||
//获取当前连接请求返回的数据流
|
||||
InputStream is = connection.getInputStream();
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(is, "utf-8");
|
||||
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String temp = null;
|
||||
|
||||
while (null != (temp = br.readLine())) {
|
||||
sb.append(temp);
|
||||
}
|
||||
|
||||
//打印结果
|
||||
String ret = sb.toString();
|
||||
if (ret.startsWith("<?"))
|
||||
ret = ret.replaceAll("\\<\\?.+\\?\\>", "<?xml version='1.0' encoding='UTF-8'?>");
|
||||
else
|
||||
ret = (new StringBuilder("<?xml version='1.0' encoding='UTF-8'?>")).append(ret).toString();
|
||||
|
||||
resultStr = XML.toJSONObject(ret).toString();
|
||||
|
||||
|
||||
is.close();
|
||||
isr.close();
|
||||
br.close();
|
||||
//关闭连接
|
||||
connection.disconnect();
|
||||
}
|
||||
os.close();
|
||||
return ObjectUtil.isEmpty(resultStr) ? null : JSONObject.fromObject(resultStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得要发送的webservice的xml形式的参数
|
||||
*
|
||||
* @param form查询条件
|
||||
* @return
|
||||
*/
|
||||
private static String getXML(HashMap<String, String> form, String method) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?> ");
|
||||
sb.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:soap:functions:mc-style\">");
|
||||
sb.append("<soapenv:Header/>");
|
||||
sb.append("<soapenv:Body>");
|
||||
sb.append("<urn:" + method + ">");
|
||||
if (method.contains("ZSd0002SendMatMd"))
|
||||
sb.append("<In>");
|
||||
// 设置请求参数
|
||||
for (Iterator<String> it = form.keySet().iterator(); it.hasNext(); ) {
|
||||
String key = it.next();
|
||||
String value = form.get(key);
|
||||
sb.append(" <" + key + ">" + value + "</" + key + ">");
|
||||
}
|
||||
if (method.contains("ZSd0002SendMatMd"))
|
||||
sb.append("</In>");
|
||||
sb.append("</urn:" + method + ">");
|
||||
sb.append("</soapenv:Body>");
|
||||
sb.append("</soapenv:Envelope>");
|
||||
System.out.println("getXML发送数据-----------------" + sb.toString());
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/z_sd0002_send_mat_md/800/z_sd0002_send_mat_md/binding";
|
||||
String method = "ZSd0002SendMatMd"; //物料接口
|
||||
HashMap<String, String> form = new HashMap<String, String>();
|
||||
form.put("MatnrFr", "24018862S");
|
||||
form.put("MatnrTo", "24018862S");
|
||||
//非必填字段
|
||||
JSONObject ret = WebServiceUtil.process(url, method, form);
|
||||
System.out.println("getXML返回数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.optJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.optJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetSoResponse = Body.optJSONObject("n0:ZSd0002SendMatMdResponse");
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.optJSONObject("TZtsalesorder");
|
||||
JSONArray item = TZtsalesorder.optJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------" + ZfmGetSoResponse.optString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------" + item.size());
|
||||
|
||||
/*String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method="ZfmGetSo"; //获取销售订单
|
||||
HashMap<String,String> form = new HashMap<String,String>();
|
||||
form.put("IErdatFrm", "2022-05-01");
|
||||
form.put("IErdatTo", "2022-05-08");
|
||||
//非必填字段
|
||||
form.put("IVbeln", "");
|
||||
JSONObject ret = WebServiceUtil.process(url,method,form);
|
||||
System.out.println("getXML发送数据-----------------"+ret.toString());
|
||||
JSONObject Envelope = ret.getJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.getJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetSoResponse = Body.getJSONObject("n0:ZfmGetSoResponse");
|
||||
JSONObject TZtsalesorder = ZfmGetSoResponse.getJSONObject("TZtsalesorder");
|
||||
JSONArray item = TZtsalesorder.optJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------"+ZfmGetSoResponse.optString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------"+item.size());*/
|
||||
|
||||
|
||||
/* String url = "http://192.168.0.82:8000/sap/bc/srt/rfc/sap/zfg_ecc_to_zhwl/800/zfg_ecc_to_zhwl/binding";
|
||||
String method = "ZfmGetDnZjwl"; //获取交货单
|
||||
HashMap<String, String> form = new HashMap<String, String>();
|
||||
form.put("IErdatFrm", "2019-05-01");
|
||||
form.put("IErdatTo", "2019-05-08");
|
||||
//非必填字段
|
||||
form.put("IVbeln", "");
|
||||
//非必填字段
|
||||
JSONObject ret = WebServiceUtil.process(url, method, form);
|
||||
System.out.println("getXML发送数据-----------------" + ret.toString());
|
||||
JSONObject Envelope = ret.optJSONObject("soap-env:Envelope");
|
||||
JSONObject Body = Envelope.optJSONObject("soap-env:Body");
|
||||
JSONObject ZfmGetDnZjwlResponse = Body.getJSONObject("n0:ZfmGetDnZjwlResponse");
|
||||
JSONObject TZtdn = ZfmGetDnZjwlResponse.getJSONObject("TZtdn");
|
||||
JSONArray item = TZtdn.getJSONArray("item");
|
||||
System.out.println("例子:查询结果字段OResultmsg-----------------" + ZfmGetDnZjwlResponse.getString("OResultmsg"));
|
||||
System.out.println("例子:查询结果数组size-----------------" + item.size());*/
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package org.nl.mongodb;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public class Test {
|
||||
|
||||
|
||||
public Page test2(Integer currentPage, Integer pageSize, Long loanApplyId) {
|
||||
/* //创建查询对象
|
||||
Query query = new Query();
|
||||
//设置起始数
|
||||
query.skip((currentPage - 1) * pageSize);
|
||||
//设置查询条数
|
||||
query.limit(pageSize);
|
||||
Criteria criteria = new Criteria();
|
||||
criteria.where("loanApplyId").is(loanApplyId);
|
||||
//查询当前页数据集合
|
||||
List<ApplyLog> ApplyLogList = mongoTemplate.find(query, ApplyLog.class);
|
||||
//查询总记录数
|
||||
int count = (int) mongoTemplate.count(query, ApplyLog.class);
|
||||
//创建分页实体对象
|
||||
Page<ApplyLog> page = new Page<>();
|
||||
//添加每页的集合、数据总条数、总页数
|
||||
page.setRecords(ApplyLogList);
|
||||
page.setSize(count);
|
||||
page.setTotal(count % pageSize == 0 ? 1 : count / pageSize + 1);
|
||||
return page;
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
public void test() {
|
||||
/* int pageNo = 1;
|
||||
int pageSize = 10;
|
||||
|
||||
// limit限定查询2条
|
||||
Query query = Query.query(Criteria.where("user").is("一灰灰blog").and("a").is("b").and("")).with(Sort.by("age")).limit(2);
|
||||
//Query query = Query.query(Criteria.where("user").is("一灰灰blog")).with(Sort.by("age")).limit(2);
|
||||
// Pageable pageable = PageRequest.of(page,size);
|
||||
List<Map> result = mongoTemplate.find(query, Map.class, "logdb");
|
||||
System.out.println("query: " + query + " | limitPageQuery " + result);
|
||||
|
||||
|
||||
// skip()方法来跳过指定数量的数据
|
||||
query = Query.query(Criteria.where("user").is("一灰灰blog")).with(Sort.by("age")).skip(2);
|
||||
result = mongoTemplate.find(query, Map.class, "logdb");
|
||||
System.out.println("query: " + query + " | skipPageQuery " + result);
|
||||
|
||||
|
||||
|
||||
Query query = new Query(new Criteria());
|
||||
query.with(Sort.by(Sort.Direction.DESC, "time"));
|
||||
mongoUtil.start(2, 2, query);
|
||||
List<Teacher> teachers = mongoTemplate.find(query, Teacher.class);
|
||||
long count = mongoTemplate.count(query, Teacher.class);
|
||||
PageHelper pageHelper = mongoUtil.pageHelper(count, teachers);*/
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user