Commit d26d8ca8 by lijingjing

WMS推送数据接口修改;

parent b3eed0e1
...@@ -19,6 +19,8 @@ public class ServiceProperties { ...@@ -19,6 +19,8 @@ public class ServiceProperties {
*/ */
private String soffice; private String soffice;
private String libOfficeUrl;
private String url; private String url;
private String apiUrl; private String apiUrl;
...@@ -107,7 +109,19 @@ public class ServiceProperties { ...@@ -107,7 +109,19 @@ public class ServiceProperties {
this.provinceItemUrl = provinceItemUrl; this.provinceItemUrl = provinceItemUrl;
} }
public String getLibOfficeUrl() {
return libOfficeUrl;
}
public void setLibOfficeUrl(String libOfficeUrl) {
this.libOfficeUrl = libOfficeUrl;
}
public String buildWmsUrl(String method) { public String buildWmsUrl(String method) {
return this.wmsUrl + method; return this.wmsUrl + method;
} }
public String buildErpUrl(String method) {
return this.erpUrl + method;
}
} }
package com.patzn.cloud.service.lims.hmhj.common;
import com.fasterxml.jackson.core.type.TypeReference;
import com.patzn.cloud.commons.toolkit.JacksonUtils;
import com.patzn.cloud.service.hmhj.model.ErpRespResult;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import java.util.Map;
import java.util.Objects;
/**
* @author Meazty
*/
public class ErpRequest {
private static final Logger logger = LoggerFactory.getLogger(ErpRequest.class);
public static ErpRespResult sendPost(String url, Map<String, ?> params, HttpHeaders headers) {
try {
String resultStr = RestTemplateUtils.sendPost(url, params, headers);
if (StringUtils.isBlank(resultStr)) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendPost ✦✦✦✈ DPS响应结果为空!");
return ErpRespResult.failure("DPS响应结果为空!");
}
ErpRespResult result = JacksonUtils.readValue(resultStr, new TypeReference<ErpRespResult>() {
});
if (Objects.isNull(result)) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求DPS接口失败:{}", JacksonUtils.toJSONString(result));
return ErpRespResult.failure("请求DPS接口失败!");
}
return result;
} catch (Exception e) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求DPS接口异常:", e);
return ErpRespResult.failure("请求DPS接口异常!");
}
}
public static <T> ErpRespResult<T> sendGet(String url, Map<String, ?> params, TypeReference<ErpRespResult<T>> typeReference) {
try {
String resultStr = RestTemplateUtils.sendGet(url, params);
if (StringUtils.isBlank(resultStr)) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendGet ✦✦✦✈ DPS响应结果为空!");
return ErpRespResult.failure("DPS响应结果为空!");
}
ErpRespResult<T> result = JacksonUtils.readValue(resultStr, typeReference);
if (Objects.isNull(result)) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendGet ✦✦✦✈ 请求DPS接口失败:{}", JacksonUtils.toJSONString(result));
return ErpRespResult.failure("请求DPS接口失败!");
}
return result;
} catch (Exception e) {
logger.error("✦✦✦✦ ErpRequest ✦✦✦✦ sendGet ✦✦✦✈ 请求DPS接口异常:", e);
return ErpRespResult.failure("请求DPS接口异常!");
}
}
}
...@@ -81,8 +81,16 @@ public class RestTemplateUtils { ...@@ -81,8 +81,16 @@ public class RestTemplateUtils {
return send(url, urlParam, body, method, headers); return send(url, urlParam, body, method, headers);
} }
public static String sendJson(String url, Map<String, ?> body) { public static String sendPost(String url, Map<String, ?> body) {
return sendJson(url, null, body, HttpMethod.POST, new HttpHeaders()); return sendPost(url, body, new HttpHeaders());
}
public static String sendPost(String url, Map<String, ?> body, HttpHeaders headers) {
return sendJson(url, null, body, HttpMethod.POST, headers);
}
public static String sendGet(String url, Map<String, ?> params) {
return sendSimple(url, params);
} }
public static String sendJson(String url, Map<String, ?> urlParam, Map<String, ?> body) { public static String sendJson(String url, Map<String, ?> urlParam, Map<String, ?> body) {
......
...@@ -16,44 +16,44 @@ public class WmsRequest { ...@@ -16,44 +16,44 @@ public class WmsRequest {
private static final Logger logger = LoggerFactory.getLogger(WmsRequest.class); private static final Logger logger = LoggerFactory.getLogger(WmsRequest.class);
public static <T> T sendJson(String url, Map<String, ?> params, TypeReference<WmsRespResult<T>> typeReference) { public static <T> T sendPost(String url, Map<String, ?> params, TypeReference<WmsRespResult<T>> typeReference) {
try { try {
String resultStr = RestTemplateUtils.sendJson(url, params); String resultStr = RestTemplateUtils.sendPost(url, params);
if (StringUtils.isBlank(resultStr)) { if (StringUtils.isBlank(resultStr)) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ WMS响应结果为空!"); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ WMS响应结果为空!");
return null; return null;
} }
WmsRespResult<T> result = JacksonUtils.readValue(resultStr, typeReference); WmsRespResult<T> result = JacksonUtils.readValue(resultStr, typeReference);
if (!WmsRespResult.isSuccess(result)) { if (!result.success()) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ 请求WMS接口失败:{}", JacksonUtils.toJSONString(result)); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求WMS接口失败:{}", JacksonUtils.toJSONString(result));
return null; return null;
} }
T data = result.getData(); T data = result.getData();
logger.info("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ [url, params]: {}", JacksonUtils.toJSONString(data.toString())); logger.info("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ [url, params]: {}", JacksonUtils.toJSONString(data.toString()));
return data; return data;
} catch (Exception e) { } catch (Exception e) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ 请求WMS接口异常:", e); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求WMS接口异常:", e);
} }
return null; return null;
} }
public static WmsRespResult sendJson(String url, Map<String, ?> params) { public static WmsRespResult sendPost(String url, Map<String, ?> params) {
try { try {
String resultStr = RestTemplateUtils.sendJson(url, params); String resultStr = RestTemplateUtils.sendPost(url, params);
if (StringUtils.isBlank(resultStr)) { if (StringUtils.isBlank(resultStr)) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ WMS响应结果为空!"); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ WMS响应结果为空!");
return null; return WmsRespResult.failure("WMS响应结果为空!");
} }
WmsRespResult result = JacksonUtils.readValue(resultStr, new TypeReference<WmsRespResult>() { WmsRespResult result = JacksonUtils.readValue(resultStr, new TypeReference<WmsRespResult>() {
}); });
if (!WmsRespResult.isSuccess(result)) { if (!result.success()) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ 请求WMS接口失败:{}", JacksonUtils.toJSONString(result)); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求WMS接口失败:{}", JacksonUtils.toJSONString(result));
return null; return WmsRespResult.failure(result.getDescription());
} }
return result; return result;
} catch (Exception e) { } catch (Exception e) {
logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendJson ✦✦✦✈ 请求WMS接口异常:", e); logger.error("✦✦✦✦ WmsRequest ✦✦✦✦ sendPost ✦✦✦✈ 请求WMS接口异常:", e);
return WmsRespResult.failure("请求WMS接口异常");
} }
return null;
} }
} }
...@@ -14,10 +14,16 @@ public class HttpConst { ...@@ -14,10 +14,16 @@ public class HttpConst {
/** /**
* 委托编码同步接口 * 委托编码同步接口
*/ */
public static final String WMS_SYNC_WTBH = "/SyncWTbh"; public static final String WMS_SYNC_WTBH = "SyncWTbh";
public static final String WMS_SYNC_STOCK = "/SyncStock"; /**
* 库存信息查询
*/
public static final String WMS_SYNC_GET_UNIT_LOADS = "GetUnitLoads";
public static final String WMS_SYNC_STOCK_SITUATION = "/SyncStockSituation"; /**
* 大屏信息
*/
public static final String WMS_SYNC_GET_SCREEN = "GetDataShow";
} }
...@@ -83,4 +83,5 @@ public class WmsStockDeliveryController extends ServiceController { ...@@ -83,4 +83,5 @@ public class WmsStockDeliveryController extends ServiceController {
public RestResult<Boolean> syncStockDelivery(@RequestBody WmsStockDeliveryData data) { public RestResult<Boolean> syncStockDelivery(@RequestBody WmsStockDeliveryData data) {
return success(wmsStockDeliveryService.syncStockDelivery(data)); return success(wmsStockDeliveryService.syncStockDelivery(data));
} }
} }
...@@ -151,4 +151,6 @@ public interface IEntrustSampleService extends IBaseService<EntrustSample> { ...@@ -151,4 +151,6 @@ public interface IEntrustSampleService extends IBaseService<EntrustSample> {
List<Long> getEntrustIdsBySampleCodes(List<String> sampleCodes); List<Long> getEntrustIdsBySampleCodes(List<String> sampleCodes);
void postWmsEntrustData(List<Entrust> entrustList); void postWmsEntrustData(List<Entrust> entrustList);
List<EntrustSample> listByEntrustIds(List<Long> entrustIds);
} }
...@@ -40,4 +40,5 @@ public interface IWmsStockDeliveryService extends IBaseService<WmsStockDelivery> ...@@ -40,4 +40,5 @@ public interface IWmsStockDeliveryService extends IBaseService<WmsStockDelivery>
* @return the boolean * @return the boolean
*/ */
boolean syncStockDelivery(WmsStockDeliveryData data); boolean syncStockDelivery(WmsStockDeliveryData data);
} }
...@@ -92,7 +92,7 @@ public class EntrustReportServiceImpl extends BaseServiceImpl<EntrustReportMappe ...@@ -92,7 +92,7 @@ public class EntrustReportServiceImpl extends BaseServiceImpl<EntrustReportMappe
@Resource @Resource
private IItemComparisonService itemComparisonService; private IItemComparisonService itemComparisonService;
@Value("${libreOffice.url}") @Value("${service.lib-office-url}")
private String libreOfficeUrl; private String libreOfficeUrl;
@Override @Override
......
...@@ -2419,6 +2419,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe ...@@ -2419,6 +2419,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}); });
} }
@Override
public List<EntrustSample> listByEntrustIds(List<Long> entrustIds) {
if (CollectionUtils.isEmpty(entrustIds)) {
return Collections.emptyList();
}
return list(Condition.<EntrustSample>wrapper().in("entrust_id", entrustIds));
}
private void doSendWmsEntrustData(String code, EntrustSample sample) { private void doSendWmsEntrustData(String code, EntrustSample sample) {
logger.info("✦✦✦✦ EntrustSampleServiceImpl ✦✦✦✦ doSendWmsEntrustData ✦✦✦✈ 开始推送委托数据至WMS系统!"); logger.info("✦✦✦✦ EntrustSampleServiceImpl ✦✦✦✦ doSendWmsEntrustData ✦✦✦✈ 开始推送委托数据至WMS系统!");
String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_WTBH); String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_WTBH);
...@@ -2428,7 +2436,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe ...@@ -2428,7 +2436,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
map.put("MaterialName", sample.getName()); map.put("MaterialName", sample.getName());
map.put("MaterialCode", sample.getNameCode()); map.put("MaterialCode", sample.getNameCode());
map.put("CreateDate", new Date()); map.put("CreateDate", new Date());
WmsRespResult result = WmsRequest.sendJson(url, map); WmsRespResult result = WmsRequest.sendPost(url, map);
if (Objects.nonNull(result)) { if (Objects.nonNull(result)) {
logger.info("✦✦✦✦ EntrustSampleServiceImpl ✦✦✦✦ doSendWmsEntrustData ✦✦✦✈ 委托信息推送WMS数据成功!"); logger.info("✦✦✦✦ EntrustSampleServiceImpl ✦✦✦✦ doSendWmsEntrustData ✦✦✦✈ 委托信息推送WMS数据成功!");
return; return;
......
...@@ -1700,11 +1700,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -1700,11 +1700,15 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
logger.error("进入提交委托流程......"); logger.error("进入提交委托流程......");
RestAssert.fail(null == ids || 0 == ids.length, "请选择要提交的委托!"); RestAssert.fail(null == ids || 0 == ids.length, "请选择要提交的委托!");
List<Entrust> entrustList = getBatchIds(Arrays.asList(ids)); List<Entrust> entrustList = getBatchIds(Arrays.asList(ids));
List<Long> specialIds = new ArrayList<>(), normalIds = new ArrayList<>(); List<Long> specialIds = new ArrayList<>(),
normalIds = new ArrayList<>();
List<Long> sendUserIdList = new ArrayList<>(); List<Long> sendUserIdList = new ArrayList<>();
List<EntrustSample> samples = entrustSampleService.listByEntrustIds(Arrays.asList(ids));
Map<Long, List<EntrustSample>> entrustSampleMap = new HashMap<>(8);
Optional.ofNullable(samples).ifPresent(dl -> dl.forEach(d -> MapMergeUtils.getorCreateMapArrayList(d.getEntrustId(), entrustSampleMap, d)));
for (Entrust entrust : entrustList) { for (Entrust entrust : entrustList) {
RestAssert.fail(!Objects.equals(entrust.getFlowStatus(), EntrustFlowEnum.DRAFT.name()), "只能提交草稿状态的委托!"); RestAssert.fail(!Objects.equals(entrust.getFlowStatus(), EntrustFlowEnum.DRAFT.name()), "只能提交草稿状态的委托!");
List<EntrustSample> sampleList = entrustSampleService.getByEntrustId(entrust.getId()); List<EntrustSample> sampleList = entrustSampleMap.get(entrust.getId());
RestAssert.fail(CollectionUtils.isEmpty(sampleList), String.format("委托编号为的【%s】样品为空!", entrust.getCode())); RestAssert.fail(CollectionUtils.isEmpty(sampleList), String.format("委托编号为的【%s】样品为空!", entrust.getCode()));
// 若存在任何一个样品的编号为空,那么需要自动生成其编号 // 若存在任何一个样品的编号为空,那么需要自动生成其编号
for (EntrustSample sample : sampleList) { for (EntrustSample sample : sampleList) {
......
...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.toolkit.CollectionUtils; ...@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.patzn.cloud.commons.api.RestAssert; import com.patzn.cloud.commons.api.RestAssert;
import com.patzn.cloud.commons.service.impl.BaseServiceImpl; import com.patzn.cloud.commons.service.impl.BaseServiceImpl;
import com.patzn.cloud.commons.toolkit.JacksonUtils;
import com.patzn.cloud.commons.toolkit.MapMergeUtils; import com.patzn.cloud.commons.toolkit.MapMergeUtils;
import com.patzn.cloud.service.hmhj.dto.*; import com.patzn.cloud.service.hmhj.dto.*;
import com.patzn.cloud.service.hmhj.entity.CenterCost; import com.patzn.cloud.service.hmhj.entity.CenterCost;
...@@ -272,7 +271,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta ...@@ -272,7 +271,7 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
@Override @Override
public List<WmsInventory> getInventoryList(WmsInventoryDTO dto) { public List<WmsInventory> getInventoryList(WmsInventoryDTO dto) {
List<WmsInventory> dataList = new ArrayList<>(); List<WmsInventory> dataList = new ArrayList<>();
String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_STOCK_SITUATION); String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_GET_SCREEN);
// 设置请求参数 // 设置请求参数
HashMap<String, Object> map = new HashMap<>(2); HashMap<String, Object> map = new HashMap<>(2);
...@@ -292,9 +291,8 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta ...@@ -292,9 +291,8 @@ public class StatisticsServiceImpl extends BaseServiceImpl<StatisticsMapper, Sta
map.put("Unit", dto.getUnit()); map.put("Unit", dto.getUnit());
} }
url = "https://mock.apifox.cn/m1/1293503-0-default/v1/stock/data";
try { try {
List<WmsInventoryData> inventoryList = WmsRequest.sendJson(url, map, new TypeReference<WmsRespResult<List<WmsInventoryData>>>() { List<WmsInventoryData> inventoryList = WmsRequest.sendPost(url, map, new TypeReference<WmsRespResult<List<WmsInventoryData>>>() {
}); });
if (CollectionUtils.isNotEmpty(inventoryList)) { if (CollectionUtils.isNotEmpty(inventoryList)) {
return inventoryList.stream().map(d -> d.convert(WmsInventory.class)).collect(Collectors.toList()); return inventoryList.stream().map(d -> d.convert(WmsInventory.class)).collect(Collectors.toList());
......
...@@ -68,10 +68,10 @@ public class WmsStockServiceImpl extends BaseServiceImpl<WmsStockMapper, WmsStoc ...@@ -68,10 +68,10 @@ public class WmsStockServiceImpl extends BaseServiceImpl<WmsStockMapper, WmsStoc
@Override @Override
public void syncWmsStockData() { public void syncWmsStockData() {
String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_STOCK); String url = serviceProperties.buildWmsUrl(HttpConst.WMS_SYNC_GET_UNIT_LOADS);
// 设置请求参数 // 设置请求参数
HashMap<String, Object> map = new HashMap<>(2); HashMap<String, Object> map = new HashMap<>(2);
List<WmsStockData> dataList = WmsRequest.sendJson(url, map, new TypeReference<WmsRespResult<List<WmsStockData>>>() { List<WmsStockData> dataList = WmsRequest.sendPost(url, map, new TypeReference<WmsRespResult<List<WmsStockData>>>() {
}); });
if (CollectionUtils.isEmpty(dataList)) { if (CollectionUtils.isEmpty(dataList)) {
logger.error("✦✦✦✦ WmsStockServiceImpl ✦✦✦✦ syncWmsStockData ✦✦✦✈ 出入库数据为空!"); logger.error("✦✦✦✦ WmsStockServiceImpl ✦✦✦✦ syncWmsStockData ✦✦✦✈ 出入库数据为空!");
......
...@@ -49,9 +49,6 @@ oss: ...@@ -49,9 +49,6 @@ oss:
jobs: jobs:
admin-address: http://api.dev.patzn.com:7000/print admin-address: http://api.dev.patzn.com:7000/print
#libreOffice 安装信息
libreOffice:
url: C:/Program Files/LibreOffice
# ribbon 路由配置 # ribbon 路由配置
food.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule food.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule
print.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule print.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule
......
...@@ -13,7 +13,7 @@ service: ...@@ -13,7 +13,7 @@ service:
province-item-url: http://60.216.97.250:8087/ province-item-url: http://60.216.97.250:8087/
soffice: /opt/libreoffice6.2/program/soffice soffice: /opt/libreoffice6.2/program/soffice
static-url: static.hmlims.com:9000 static-url: static.hmlims.com:9000
erp-url: http://192.168.0.216:5050/api/LimsData/SaveData erp-url: http://192.168.0.216:5050/api/LimsData/
erp-token: VkI+Gi2pizx9uaX+xP+nXAgJKfcBevaruxijYtXXQdU577BLv3jdoLpnQ13BZ5hdPTD90jLmvlr7ygxh18kuLdD9Ha9MdTXIxWJKbNbBn6fnrHU/9lsXBnOVyOEB1DIXW0VQniyjuobU5qolBr2Y99NTQ/l9giZlXGVXAE+1WvY= erp-token: VkI+Gi2pizx9uaX+xP+nXAgJKfcBevaruxijYtXXQdU577BLv3jdoLpnQ13BZ5hdPTD90jLmvlr7ygxh18kuLdD9Ha9MdTXIxWJKbNbBn6fnrHU/9lsXBnOVyOEB1DIXW0VQniyjuobU5qolBr2Y99NTQ/l9giZlXGVXAE+1WvY=
spring: spring:
datasource: datasource:
...@@ -66,9 +66,6 @@ oss: ...@@ -66,9 +66,6 @@ oss:
grid-fs: true grid-fs: true
bucket-name: base bucket-name: base
#libreOffice 安装信息
libreOffice:
url: D:/Program Files/LibreOffice
### jobs ### jobs
jobs: jobs:
admin-address: http://api.hmlims.com:9000/print admin-address: http://api.hmlims.com:9000/print
\ No newline at end of file
...@@ -7,8 +7,6 @@ swagger: ...@@ -7,8 +7,6 @@ swagger:
service: service:
api-url: http://api.dev.patzn.com:7000 api-url: http://api.dev.patzn.com:7000
url: http://api.dev.patzn.com:7000 url: http://api.dev.patzn.com:7000
erp-url: http://192.168.0.19:5050/api/LimsData/SaveData
erp-token: VkI+Gi2pizx9uaX+xP+nXAgJKfcBevaruxijYtXXQdU577BLv3jdoLpnQ13BZ5hdPTD90jLmvlr7ygxh18kuLdD9Ha9MdTXIxWJKbNbBn6fnrHU/9lsXBnOVyOEB1DIXW0VQniyjuobU5qolBr2Y99NTQ/l9giZlXGVXAE+1WvY=
spring: spring:
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
...@@ -54,9 +52,6 @@ oss: ...@@ -54,9 +52,6 @@ oss:
jobs: jobs:
admin-address: http://api.dev.patzn.com:7000/print admin-address: http://api.dev.patzn.com:7000/print
#libreOffice 安装信息
libreOffice:
url: C:/Program Files/LibreOffice
# ribbon 路由配置 # ribbon 路由配置
food.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule food.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule
print.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule print.ribbon.NFLoadBalancerRuleClassName: com.patzn.cloud.zuul.LocalRule
......
...@@ -7,15 +7,16 @@ server: ...@@ -7,15 +7,16 @@ server:
enabled: true enabled: true
mime-types: application/json mime-types: application/json
service: service:
soffice: /opt/libreoffice6.2/program/soffice
url: http://api.dev.patzn.com:7000 url: http://api.dev.patzn.com:7000
api-url: http://api.dev.patzn.com:7000
erp-url: http://192.168.0.216:5050/api/LimsData/
wms-url: http://192.168.207.103:9001/InterfaceAddr/
soffice: /opt/libreoffice6.2/program/soffice
food-url: http://food.hmlims.com:9000 food-url: http://food.hmlims.com:9000
static-url: static.hmlims.com:9000 static-url: static.hmlims.com:9000
lib-office-url: D:/Program Files/LibreOffice
province-item-url: http://60.216.97.250:8087/ province-item-url: http://60.216.97.250:8087/
api-url: http://api.dev.patzn.com:7000
erp-url: http://192.168.0.216:5050/api/LimsData/SaveData
erp-token: VkI+Gi2pizx9uaX+xP+nXAgJKfcBevaruxijYtXXQdU577BLv3jdoLpnQ13BZ5hdPTD90jLmvlr7ygxh18kuLdD9Ha9MdTXIxWJKbNbBn6fnrHU/9lsXBnOVyOEB1DIXW0VQniyjuobU5qolBr2Y99NTQ/l9giZlXGVXAE+1WvY= erp-token: VkI+Gi2pizx9uaX+xP+nXAgJKfcBevaruxijYtXXQdU577BLv3jdoLpnQ13BZ5hdPTD90jLmvlr7ygxh18kuLdD9Ha9MdTXIxWJKbNbBn6fnrHU/9lsXBnOVyOEB1DIXW0VQniyjuobU5qolBr2Y99NTQ/l9giZlXGVXAE+1WvY=
wms-url: http://192.168.207.103:9001/LIMS
spring: spring:
# 环境 dev|test|pro # 环境 dev|test|pro
profiles: profiles:
......
package com.patzn.cloud.service.lims.test;
import org.apache.commons.lang.StringUtils;
public class IDWorkTest {
public static void main(String[] args) {
System.out.println(getCodeByCqCode("Y2204262017C"));
System.out.println(getCodeByCqCode("2110164032C12"));
System.out.println(getCodeByCqCode("Y2201086159C1"));
System.out.println(getCodeByCqCode("Y2112052110C2"));
}
private static String getCodeByCqCode(String code) {
//Y2204262017C
//2110164032C12
//Y2201086159C1
//Y2112052110C2
if (StringUtils.isBlank(code)) {
return code;
}
code = code.startsWith("Y") ? code : "Y" + code;
code = code.substring(0, 7) + "-" + code.substring(7, 11);
return code;
}
}
package com.patzn.cloud.service.lims.test;
import com.patzn.cloud.commons.toolkit.JacksonUtils;
import com.patzn.cloud.service.hmhj.entity.WmsStock;
import com.patzn.cloud.service.hmhj.vo.WmsStockData;
public class JsonObjectTest {
public static void main(String[] args) {
// language=JSON
String json = "{\"ContainerCode\": \"1111\",\"Wtbh\": \"2033333323\"}";
WmsStockData stock = JacksonUtils.readValue(json, WmsStockData.class);
System.out.println(stock.getContainerCode());
System.out.println(stock.getWtbh());
}
}
package com.patzn.cloud.service.lims.test;
import com.patzn.cloud.service.lims.common.StringHandleUtils;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Test {
public static void main(String[] args) {
System.out.println(getTestValue("65.475", 2));
System.out.println(getTestValue("0.1952", 2));
System.out.println(getTestValue("0.2056", 2));
}
private static String getTestValue(String value, int roundNum) {
if (StringUtils.isNotBlank(value)) {
if (!StringHandleUtils.validateNumber(value)) {
if (value.startsWith("!")) {
value = value.substring(1);
} else {
return value;
}
}
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)<0.499999,ROUND(A1,B1),
// IF(ABS(TRUNC(A1,B1+5)*10^B1-TRUNC(A1,B1+5)*10^B1)>0.500001,ROUND(A1,B1),
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1)))
int beginIndex = value.lastIndexOf(".") + 1, valueLength = value.length();
String intVal = value.substring(0, value.indexOf(".") + 1);
int remindLength = valueLength - beginIndex;
String truncValue = "", zeroStr = "000000000";
// bdA = TRUNC(A1,B1+5)*10^B1
if (remindLength >= roundNum + 5) {
truncValue = intVal + value.substring(beginIndex, beginIndex + roundNum + 5);
} else {
truncValue = intVal + value.substring(beginIndex) + zeroStr.substring(0, roundNum + 5 - remindLength);
}
BigDecimal bdDiff = new BigDecimal(truncValue).scaleByPowerOfTen(roundNum);
// bdB = TRUNC(A1,B1+5)*10^B1
if (remindLength >= roundNum) {
truncValue = intVal + value.substring(beginIndex, beginIndex + roundNum);
} else {
truncValue = intVal + value.substring(beginIndex) + zeroStr.substring(0, roundNum - remindLength);
}
bdDiff = bdDiff.subtract(new BigDecimal(truncValue).scaleByPowerOfTen(roundNum)).abs();
// 若 < 0.499999 或 大于 0.500001
if (bdDiff.compareTo(new BigDecimal("0.499999")) < 0 || bdDiff.compareTo(new BigDecimal("0.500001")) > 0) {
return new BigDecimal(value).setScale(roundNum, RoundingMode.HALF_EVEN).toPlainString();
}
// 处理第三种情况
// CEILING(ABS(TRUNC(A1,B1+1)-0.5*10^(-B1),2*10^(-B1)*SIGN(A1))
if (remindLength >= roundNum + 1) {
truncValue = intVal + value.substring(beginIndex, beginIndex + roundNum + 1);
} else {
truncValue = intVal + value.substring(beginIndex) + zeroStr.substring(0, roundNum + 1 - remindLength);
}
bdDiff = new BigDecimal(truncValue);
bdDiff = bdDiff.subtract(new BigDecimal("0.5").scaleByPowerOfTen(-roundNum)).abs();
int signValue = Double.valueOf(value).compareTo(0.0);
BigDecimal significance = new BigDecimal("2").scaleByPowerOfTen(-roundNum).multiply(BigDecimal.valueOf(signValue)).abs();
// ceiling
BigDecimal[] result = bdDiff.divideAndRemainder(significance);
if (result[1].compareTo(BigDecimal.ZERO) == 0) {
return bdDiff.setScale(roundNum).toPlainString();
} else {
return result[0].add(BigDecimal.ONE).multiply(significance).setScale(roundNum).toPlainString();
}
}
return value;
}
private static String rounding(String value, Integer roundNum) {
if (StringUtils.isNotBlank(value)) {
if (!StringHandleUtils.validateNumber(value)) {
if (value.startsWith("!")) {
value = value.substring(1);
} else {
return value;
}
}
BigDecimal bd1 = new BigDecimal(value);
BigDecimal bd2 = bd1.setScale(roundNum, BigDecimal.ROUND_HALF_EVEN);
return bd2.toPlainString();
}
return "";
}
}
package com.patzn.cloud.service.lims.test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class TestThreadLocal {
public static ExecutorService executorService = Executors.newFixedThreadPool(16);
private static SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static void main(String[] args) throws InterruptedException {
for (int i=0;i<1000;i++){
executorService.submit(new Runnable() {
@Override
public void run() {
String format = simpleDateFormat.format(new Date());
try {
Date parse = simpleDateFormat.parse("2021-09-01 00:00:00");
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println(format);
}
});
}
Thread.sleep(3000);
executorService.shutdownNow();
}
}
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