|
|
@@ -29,6 +29,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@@ -43,23 +44,60 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
@Autowired
|
|
|
private DDConf ddConf;
|
|
|
|
|
|
+ private ConcurrentHashMap<String, LocalDateTime> tokenStore = new ConcurrentHashMap<>();
|
|
|
+
|
|
|
|
|
|
/*登录获取黑湖登录token*/
|
|
|
@Override
|
|
|
public McR HeiHuAccessToken() throws JacksonException {
|
|
|
- HashMap body = new HashMap();
|
|
|
- body.put("type",1);//type=1,登录方式为工厂代号+账号+密码
|
|
|
- body.put("code","648910");//工厂代号
|
|
|
- body.put("username","FGJK");//账号
|
|
|
- body.put("password","b715db070346a8a59e0eba5da27f8e4938536bb7867e09592326fde2");//密码加密
|
|
|
- HashMap header = new HashMap();
|
|
|
- header.put("X-CLIENT","lite-web");//固定
|
|
|
- header.put("Content-Type","application/json");
|
|
|
- String s = UtilHttp.doPost("https://liteweb.blacklake.cn/api/user/v1/users/_login", header, null, body);
|
|
|
- String data = new ObjectMapper().readTree(s).get("data").asText();
|
|
|
- return McR.success(data);
|
|
|
+ final String[] token = {""};
|
|
|
+ final boolean[] isHave = {false};
|
|
|
+ tokenStore.forEach((k, v) -> {
|
|
|
+ if (validateToken(k)) {
|
|
|
+ token[0] = k;
|
|
|
+ isHave[0] = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!isHave[0]) {
|
|
|
+ HashMap body = new HashMap();
|
|
|
+ body.put("type",1);//type=1,登录方式为工厂代号+账号+密码
|
|
|
+ body.put("code","648910");//工厂代号
|
|
|
+ body.put("username","FGJK");//账号
|
|
|
+ body.put("password","b715db070346a8a59e0eba5da27f8e4938536bb7867e09592326fde2");//密码加密
|
|
|
+ HashMap header = new HashMap();
|
|
|
+ header.put("X-CLIENT","lite-web");//固定
|
|
|
+ header.put("Content-Type","application/json");
|
|
|
+ String s = UtilHttp.doPost("https://liteweb.blacklake.cn/api/user/v1/users/_login", header, null, body);
|
|
|
+// String data = new ObjectMapper().readTree(s).get("data").asText();
|
|
|
+ token[0] = new ObjectMapper().readTree(s).get("data").asText();
|
|
|
+ addToken(token[0],70);
|
|
|
+ }
|
|
|
+
|
|
|
+ return McR.success(token[0]);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * token存储
|
|
|
+ * @param token
|
|
|
+ * @param expireHours
|
|
|
+ */
|
|
|
+ public void addToken(String token, int expireHours) {
|
|
|
+ LocalDateTime expirationTime = LocalDateTime.now().plusHours(expireHours);
|
|
|
+ tokenStore.put(token, expirationTime);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 清理过期token
|
|
|
+ * @param token
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean validateToken(String token) {
|
|
|
+ LocalDateTime expirationTime = tokenStore.get(token);
|
|
|
+ if (expirationTime == null || expirationTime.isBefore(LocalDateTime.now())) {
|
|
|
+ tokenStore.remove(token); // 清理过期 Token
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
/*抓取黑湖工单发起宜搭审批流程*/
|
|
|
@Override
|
|
|
public McR StartYidaAproval(String OrderNo,String fromUuid) throws JacksonException {
|
|
|
@@ -1178,6 +1216,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
}
|
|
|
else if(fieldIdNode != null && fieldIdNode.asInt() == 47771){
|
|
|
JsonNode valueNode = field.get("value");
|
|
|
+ log.info("销售订单类型:{}",valueNode.asText());
|
|
|
if("样品订单".equals(valueNode.asText())){
|
|
|
isSample = true;
|
|
|
}
|
|
|
@@ -1300,6 +1339,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
}
|
|
|
} else {
|
|
|
try {
|
|
|
+ log.info("采购订单编号:{}将不发起钉钉审批",orderCode);
|
|
|
HashMap body1 = new HashMap();
|
|
|
body1.put("orderCode",orderCode);//订单编号:orderCode
|
|
|
body1.put("vendorCode",dataArray.getJSONObject(0).getString("vendorCode"));//供应商编码:gysnumber
|
|
|
@@ -1329,6 +1369,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
}
|
|
|
|
|
|
List<Map<String, Object>> oldList = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> faxList = new ArrayList<>();
|
|
|
if (type.equals(targetValueUpdate)){
|
|
|
oldIds.forEach(h->{
|
|
|
List<Map> oldDataList = ydService.queryFormData_all(YDParam.builder()
|
|
|
@@ -1352,6 +1393,21 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
oldList.add(map);
|
|
|
});
|
|
|
}
|
|
|
+ List<Map> sonFaxList = ydService.queryDetails(YDParam.builder()
|
|
|
+ .appType(ydConf.getAppType()).systemToken(ydConf.getSystemToken())
|
|
|
+ .formInstanceId(UtilMap.getString(oldDataList.get(0),"textField_mmx9gycu"))
|
|
|
+ .formUuid("FORM-3A54B12BE3D241218A75242B935F2987YWV2")
|
|
|
+ .tableFieldId("tableField_ml7ch2pj")
|
|
|
+ .build());
|
|
|
+ if (ObjectUtil.isNotNull(sonFaxList) && sonFaxList.size() > 0){
|
|
|
+ sonFaxList.forEach(s->{
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ TABLEFIELD_ENUM2.forEach((k,v)->{
|
|
|
+ map.put(v,UtilMap.getString(s,k));
|
|
|
+ });
|
|
|
+ faxList.add(map);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -1369,6 +1425,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
List<Map<String, String>> orderSummaryListHigh = calculateOrderSummary(tabledataHigh);
|
|
|
formdataHigh.put("tableField_ml7ch2pj", orderSummaryListHigh);
|
|
|
formdataHigh.put("tableField_mmx6gata", oldList);
|
|
|
+ formdataHigh.put("tableField_mnekj8oq", faxList);
|
|
|
|
|
|
//数值统计毛利率
|
|
|
int szHigh = 0;
|
|
|
@@ -1404,6 +1461,7 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
//组装数据塞到采购明细表
|
|
|
formdataLow.put("tableField_ml6g7k5d", tabledataLow);
|
|
|
formdataLow.put("tableField_mmx6gata", oldList);
|
|
|
+ formdataHigh.put("tableField_mnekj8oq", faxList);
|
|
|
|
|
|
//组装数据塞到采购审批单号明细
|
|
|
List<Map<String, String>> orderSummaryListLow = calculateOrderSummary(tabledataLow);
|
|
|
@@ -1967,6 +2025,15 @@ public class HeiHuOrderServiceImpl implements HeiHuOrderService {
|
|
|
TABLEFIELD_ENUM.put("numberField_ml7c3yhz","numberField_mmx6gat8");
|
|
|
TABLEFIELD_ENUM.put("numberField_ml7c3yi0","numberField_mmx6gat9");
|
|
|
}
|
|
|
+ private static final Map<String,String> TABLEFIELD_ENUM2 =new HashMap<>();//修改后:修改前
|
|
|
+ static {
|
|
|
+ TABLEFIELD_ENUM2.put("textField_mnekj8ok","textField_ml7ch2pk");
|
|
|
+ TABLEFIELD_ENUM2.put("numberField_mnekj8ol","numberField_ml862225");
|
|
|
+ TABLEFIELD_ENUM2.put("numberField_mnekj8om","numberField_ml862226");
|
|
|
+ TABLEFIELD_ENUM2.put("numberField_mnekj8on","numberField_ml862228");
|
|
|
+ TABLEFIELD_ENUM2.put("numberField_mnekj8oo","numberField_ml86222d");
|
|
|
+
|
|
|
+ }
|
|
|
/**
|
|
|
* 根据orderCode对tabledata进行分类求和
|
|
|
* @param tableData 原始明细数据
|