|
|
@@ -1,9 +1,9 @@
|
|
|
package com.uas.erp.schedular.mall.task;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.uas.erp.schedular.b2b.domain.Customer;
|
|
|
-import com.uas.erp.schedular.b2b.domain.Purchase;
|
|
|
import com.uas.erp.schedular.b2b.domain.Vendor;
|
|
|
import com.uas.erp.schedular.diymall.domain.Order;
|
|
|
import com.uas.erp.schedular.diymall.domain.OrderInvoice;
|
|
|
@@ -17,8 +17,6 @@ import com.uas.erp.schedular.mall.domain.OrderDeliver;
|
|
|
import com.uas.erp.schedular.mall.domain.PagingInfo;
|
|
|
import com.uas.erp.schedular.task.support.TaskMapping;
|
|
|
import com.uas.erp.schedular.util.ContextHolder;
|
|
|
-import com.uas.erp.schedular.util.ObjectUtil;
|
|
|
-import com.uas.erp.schedular.util.StringUtil;
|
|
|
import com.usoft.security.utils.OpenApiSignUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -86,6 +84,7 @@ public class OrderTask extends AbstractTask {
|
|
|
}
|
|
|
String pocodes = sb.substring(0, sb.length() - 1);
|
|
|
jdbcTemplate.execute("UPDATE SALE SET SA_SENDPOSTSTATUS = '已上传' WHERE SA_KIND = '商城订单' AND SA_POCODE IN (" + pocodes +")");
|
|
|
+ postERPUUToMall(pocodes, master.getMa_uu(), master.getMa_accesssecret());
|
|
|
}else {
|
|
|
List<DeliverError> deliverErrorList = deliverResp.getDeliverError();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
@@ -100,6 +99,36 @@ public class OrderTask extends AbstractTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void postERPUUToMall(String PoCodes, Long secretId, String accesssecret) {
|
|
|
+ try {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("secretId", secretId);
|
|
|
+ json.put("signature", "");
|
|
|
+ List<Map<String, Object>> orderInfoList = jdbcTemplate.queryForList("SELECT SA_POCODE, CU_UU FROM SALE LEFT JOIN CUSTOMER ON SA_CUSTCODE = CU_CODE WHERE SA_POCODE IN (" + PoCodes +")");
|
|
|
+ JSONArray orderUpdateList = new JSONArray();
|
|
|
+ for (Map<String, Object> map : orderInfoList) {
|
|
|
+ JSONObject orderUpdate = new JSONObject();
|
|
|
+ orderUpdate.put("orderCode", map.get("SA_POCODE"));
|
|
|
+ orderUpdate.put("erpEnuu", map.get("CU_UU"));
|
|
|
+ orderUpdateList.add(orderUpdate);
|
|
|
+ }
|
|
|
+ json.put("orderUpdate", orderUpdateList);
|
|
|
+ String signatureValue = OpenApiSignUtil.sign(json.toString(), accesssecret);
|
|
|
+ json.put("signature", signatureValue);
|
|
|
+ RestTemplate restTemp = new RestTemplate(new HttpsClientRequestFactory());
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
|
|
+ HttpEntity<String> requestEntity = new HttpEntity<String>(json.toJSONString(), headers);
|
|
|
+ String response = restTemp.postForObject(BASEPATH_TRADE + "/openapi/trade/order/batch/update", requestEntity, String.class);
|
|
|
+ JSONObject respObject = JSON.parseObject(response).getJSONObject("respHeader");
|
|
|
+ if (respObject.getInteger("code") != 0) {
|
|
|
+ LOGGER.info("同步客户至优软商城失败:【" + respObject.getString("msg") + "】");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@TaskMapping(title = "下载已过账销售订单,生成采购/销售/入库/出货单据", cron = "0 0 1 * * ?")
|
|
|
public void downloadOrder() throws NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException {
|
|
|
// Master master = ContextHolder.getMaster();
|
|
|
@@ -147,6 +176,7 @@ public class OrderTask extends AbstractTask {
|
|
|
* @param orderList
|
|
|
*/
|
|
|
private void generateOrder(List<Order> orderList) {
|
|
|
+ LOGGER.info("订单数据orderList={}", JSON.toJSONString(orderList));
|
|
|
for (Order order : orderList) {
|
|
|
//此单是否已下载过
|
|
|
int count = jdbcTemplate.getInt("SELECT COUNT(*) FROM SALE WHERE SA_POCODE = ?", order.getCode());
|
|
|
@@ -469,7 +499,6 @@ public class OrderTask extends AbstractTask {
|
|
|
RestTemplate restTemp = new RestTemplate(new HttpsClientRequestFactory());
|
|
|
restTemp.setUriTemplateHandler(uriTemplateHandler);
|
|
|
String result = restTemp.getForObject(requestURL, String.class);
|
|
|
- LOGGER.info("result={}", result);
|
|
|
OrdersInfo ordersInfo = JSON.parseObject(result, OrdersInfo.class);
|
|
|
return ordersInfo;
|
|
|
}
|