Commit a270b7d6 authored by wanghang's avatar wanghang

1

parent 48188b73
......@@ -6,9 +6,13 @@ log.db.url=jdbc:mysql://192.168.222.122:3406/topsun?serverTimezone=GMT%2B8&useUn
log.db.user=root
log.db.password=123456
hana.db.url=jdbc:mysql://127.0.0.1:3306/topsun?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
hana.db.user=topsun
hana.db.password=topsun
hana.db.url=jdbc:mysql://192.168.222.122:3406/topsun?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
hana.db.user=root
hana.db.password=123456
#hana.db.url=jdbc:mysql://127.0.0.1:3306/topsun?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
#hana.db.user=topsun
#hana.db.password=topsun
#pub.db.url=jdbc:mysql://127.0.0.1:3306/topsun?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
#pub.db.user=topsun
......
......@@ -7,14 +7,12 @@ $(document).ready(function () {
function initialize(){
$("#proofingApplyNgReReason").prop("placeholder","录入此列本单作废");
//若是作为详情页,则初始化bom
//若是作为流程页或详情页,则初始化bom
if($("#productId").val()!=null&&$("#productId").val()!=""){
showTable({proofingApplyId:$("#proofingApplyId").val()});
}
let isDetailPage = ($("#isDetailPage").val() === "true");
if (isDetailPage) {
showTable({proofingMakeId:$("#proofingMakeId").val()});
$("#jobPageTop").hide();
}
}
......
......@@ -146,7 +146,7 @@ function loadProofingApplyGrid(obj) {
heightDiff: -8,
checkbox: true,
fixedCellHeight: true,
selectRowButtonOnly: true
selectRowButtonOnly: true,
});
UICtrl.setSearchAreaToggle(obj.gridManager);
return obj;
......@@ -154,21 +154,6 @@ function loadProofingApplyGrid(obj) {
}
// function addObserver(eleId) {
// observer.observe(document.querySelector(eleId), mutationConfig);
// }
//
// const observer = new MutationObserver((mutations) => {
// mutations.forEach((mutation) => {
// if(mutation.type === 'childList' && mutation.addedNodes.length > 0 &&mutation.addedNodes[0].nodeName === "DIV") {
// debugger;
// }
// })
// })
// const mutationConfig = { attributes: true, childList: true, subtree: true}
/**
* 详情页初始化调用
* 获取申请或制造单的工艺工序等数据生成表格
......@@ -240,7 +225,7 @@ $(document).ready(function() {
technologyClickRequestProcess();
UICtrl.layout("#layout",{
leftWidth:2,
rightWidth:5,
rightWidth:4,
})
});
......
......@@ -33,9 +33,10 @@ function loadStatsIndicatorsDetailListGrid() {
required: false, type: "select",
data: {
type: 'system',
name: "sapMaterialSelect",
name: "queryCostCenter",
back: {
materialId: "ekostl",
kostl: "ekostl",
// ktext:"ekostlTextView",
null:"eaufnr"
}
},
......@@ -51,7 +52,6 @@ function loadStatsIndicatorsDetailListGrid() {
back: {
null:"ekostl",
materialId:"eaufnr"
}
},
}
......@@ -126,7 +126,6 @@ function getExtendedData(processAction) {
//不验证
$('#submitForm').attr('check', false);
}
debugger
const isAllData = $('#oldId') || !getId();
var extendedData = {};
var _grid = UICtrl.getGridManager('#statsIndicatorsDetailGrid');
......@@ -135,6 +134,7 @@ function getExtendedData(processAction) {
gridManager: _grid,
isAllData: isAllData
});
debugger
if (!datas) {
return false;
}else if (datas.some(item => item.ekostl === "" && item.eaufnr === "")){
......
package com.huigou.topsun.sap.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.SystemCache;
import com.huigou.topsun.sap.common.serializer.MessageSerializer;
import com.huigou.uasp.bmp.common.application.BaseApplication;
......@@ -36,7 +37,7 @@ public class DefaultHttpClient extends BaseApplication implements HttpClient {
}
@Override
public String execute(Map<String, Object> param,String url) throws IOException {
public String execute(Object param,String url) throws IOException {
//系统接口地址
// ip地址
String ip = SystemCache.getParameter("sap.service.ip", String.class);
......@@ -60,7 +61,8 @@ public class DefaultHttpClient extends BaseApplication implements HttpClient {
String usernameAndPassword = username + ":" + password;
post.addHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()));
//post.addHeader("token",SystemCache.getParameter("material.token",String.class));
String requestText = messageSerializer.serialize(param);
// String requestText = messageSerializer.serialize(param);
String requestText = new ObjectMapper().writeValueAsString(param);
LOG.info("requestText={}", requestText);
post.setEntity(new StringEntity(requestText, ContentType.APPLICATION_JSON));
LOG.info("post={}", post);
......
......@@ -19,5 +19,5 @@ public interface HttpClient {
* @throws IOException
*/
String execute(Map<String, Object> param,String url) throws IOException;
String execute(Object param,String url) throws IOException;
}
......@@ -24,4 +24,6 @@ public class MessageCodec implements MessageSerializer, MessageDeserializer {
message.getBody().putAll(body);
return message;
}
}
......@@ -5,6 +5,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.topsun.sap.common.DefaultHttpClient;
import com.huigou.topsun.sap.common.domain.Message;
import com.huigou.topsun.sap.common.serializer.MessageCodec;
import com.huigou.topsun.sap.statsIndicators.application.SapStatsIndicatorsApplication;
import com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicators;
import com.huigou.topsun.sap.statsIndicators.domain.SapStatsIndicatorsDetail;
......@@ -12,6 +15,7 @@ import com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsDeta
import com.huigou.topsun.sap.statsIndicators.domain.query.SapStatsIndicatorsQueryRequest;
import com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsDetailRepository;
import com.huigou.topsun.sap.statsIndicators.repository.SapStatsIndicatorsRepository;
import com.huigou.topsun.util.MyBaseUtil;
import com.huigou.uasp.bmp.common.BizBillStatus;
import com.huigou.uasp.bpm.FlowBroker;
import com.huigou.util.ClassHelper;
......@@ -20,12 +24,20 @@ import com.huigou.util.SDO;
import lombok.SneakyThrows;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -37,6 +49,10 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
@Autowired
private SapStatsIndicatorsDetailRepository sapStatsIndicatorsDetailRepository;
@Autowired
DefaultHttpClient defaultHttpClient;
@Autowired
MessageCodec messageCodec;
@SneakyThrows
@Transactional(propagation = Propagation.REQUIRES_NEW)
......@@ -76,6 +92,11 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
return ClassHelper.toMap(sapStatsIndicatorsRepository.getOne(bizId));
}
/**
* 流程实例结束
* @param delegateExecution
*/
@Override
protected void onEnd(DelegateExecution delegateExecution) {
super.onEnd(delegateExecution);
......@@ -85,10 +106,44 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
sapStatsIndicators.setStatusId(status.getId());
sapStatsIndicatorsRepository.save(sapStatsIndicators);
//远程调用sap接口
//审核完成、远程调用sap接口
List<SapStatsIndicatorsDetail> all = sapStatsIndicatorsDetailRepository.findAllByStatsIndicatorsId(bizId);
List<Map<String,Object>> list = new ArrayList<>();
ObjectMapper objectMapper = new ObjectMapper();
Map<String,Object> map = MyBaseUtil.convertToMap(sapStatsIndicators);
//封装参数
for (SapStatsIndicatorsDetail sapStatsIndicatorsDetail : all) {
Map<String,Object> detailMap = objectMapper.convertValue(sapStatsIndicatorsDetail, Map.class);
map.put("item",detailMap);
list.add(map);
}
//三次失败抛出异常
int retries = 0;
boolean success = false;
String url ="http://192.168.3.109:8000/sap/bc/erp_ep/cud_kb31n/kb31n?sap-client=200";
while (!success && retries < 3) {
try {
String execute = defaultHttpClient.execute(list,url);
TypeReference<List<Map<String, Object>>> typeRef = new TypeReference<List<Map<String, Object>>>() {};
List<Map<String, Object>> mapList = objectMapper.readValue(execute, typeRef);
Map<String, Object> resMap = mapList.get(0);
//Message message = messageCodec.deserialze(execute);
//Map<String, Object> body = message.getBody();
if ("s".equals(resMap.get("TYPE"))) {
success = true;
} else {
retries++;
}
} catch (IOException e) {
throw new RuntimeException("sap服务器无响应请稍后再试!");
}
}
if (!success) {
throw new RuntimeException("远程调用SAP接口失败");
}
}
@Override
......@@ -141,4 +196,6 @@ public class SapStatsIndicatorsApplicationImpl extends FlowBroker implements Sa
public void deleteStatsIndicatorsByIds(List<String> ids) {
ids.forEach(this::deleteStatsIndicatorsById);
}
}
\ No newline at end of file
package com.huigou.topsun.sap.statsIndicators.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.huigou.data.domain.model.FlowBillAbstractEntity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
......
package com.huigou.topsun.sap.statsIndicators.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
......@@ -29,11 +30,13 @@ public class SapStatsIndicatorsDetail {
strategy = "guid"
)
@Column(name = "stats_indicators_detail_id")
@JsonIgnore
private String statsIndicatorsDetailId;
/**
* 主表id
*/
@JsonIgnore
@Column(name = "stats_indicators_id")
private String statsIndicatorsId;
......
......@@ -9,6 +9,8 @@ import org.springframework.beans.FatalBeanException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
......@@ -122,6 +124,29 @@ public class MyBaseUtil {
}
}
/**
* 将一个对象转换为Map同时忽略它的基类
*
* @param object 要转换的对象
* @return 包含对象所有字段名和值的Map
*/
public static Map<String, Object> convertToMap(Object object) {
Map<String, Object> map = new HashMap<>();
Class<?> clazz = object.getClass();
Arrays.stream(clazz.getDeclaredFields())
.forEach(field -> {
field.setAccessible(true);
try {
String fieldName = field.getName();
Object fieldValue = field.get(object);
map.put(fieldName, fieldValue);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
});
return map;
}
public static void main(String[] args) {
......@@ -136,6 +161,9 @@ public class MyBaseUtil {
Map<String, Object> map = MyBaseUtil.convertBeansToMap(workInstructionMaterialInfo);
MyBaseUtil.processNonNullProperties(workInstructionBaseInfo,map);
Map<String, Object> map1 = MyBaseUtil.convertToMap(workInstructionBaseInfo);
System.out.println(map);
}
......
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