Commit 68a5d03d authored by 赵汉亭's avatar 赵汉亭

固定资产主数据接口完成

parent 4c42be93
...@@ -2,9 +2,11 @@ package com.huigou.topsun.sap.fixedAssets.application.impl; ...@@ -2,9 +2,11 @@ package com.huigou.topsun.sap.fixedAssets.application.impl;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.SystemCache;
import com.huigou.context.Operator; import com.huigou.context.Operator;
import com.huigou.data.query.model.QueryDescriptor; import com.huigou.data.query.model.QueryDescriptor;
import com.huigou.data.query.model.QueryModel; import com.huigou.data.query.model.QueryModel;
import com.huigou.topsun.sap.common.HttpClient;
import com.huigou.topsun.sap.fixedAssets.application.SapFixedAssetsApplication; import com.huigou.topsun.sap.fixedAssets.application.SapFixedAssetsApplication;
import com.huigou.topsun.sap.fixedAssets.domain.SapFixedAssets; import com.huigou.topsun.sap.fixedAssets.domain.SapFixedAssets;
import com.huigou.topsun.sap.fixedAssets.domain.query.SapFixedAssetsQueryRequest; import com.huigou.topsun.sap.fixedAssets.domain.query.SapFixedAssetsQueryRequest;
...@@ -21,11 +23,9 @@ import org.springframework.beans.BeanUtils; ...@@ -21,11 +23,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.net.SocketTimeoutException; import java.io.IOException;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/** /**
* @Auther: xin.lu * @Auther: xin.lu
...@@ -38,6 +38,9 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe ...@@ -38,6 +38,9 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe
@Autowired @Autowired
private SapFixedAssetsRepository sapFixedAssetsRepository; private SapFixedAssetsRepository sapFixedAssetsRepository;
@Autowired
private HttpClient httpClient;
@Override @Override
public Map<String, Object> getFixedAssetsList(SapFixedAssetsQueryRequest sapFixedAssetsQueryRequest) { public Map<String, Object> getFixedAssetsList(SapFixedAssetsQueryRequest sapFixedAssetsQueryRequest) {
QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "sapFixedAssets"); QueryDescriptor queryDescriptor = this.sqlExecutorDao.getQuery(QUERY_XML_FILE_PATH, "sapFixedAssets");
...@@ -68,7 +71,7 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe ...@@ -68,7 +71,7 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe
} else { } else {
// 新增 // 新增
// 封装填报时间 // 封装填报时间
BeanUtils.copyProperties(operator,sapFixedAssets); BeanUtils.copyProperties(operator, sapFixedAssets);
// sapFixedAssets.setStatusId(BizBillStatus.APPLYING.getId()); // sapFixedAssets.setStatusId(BizBillStatus.APPLYING.getId());
sapFixedAssets.setZflg(1); sapFixedAssets.setZflg(1);
sapFixedAssets = sapFixedAssetsRepository.saveAndFlush(sapFixedAssets); sapFixedAssets = sapFixedAssetsRepository.saveAndFlush(sapFixedAssets);
...@@ -83,10 +86,19 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe ...@@ -83,10 +86,19 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe
BizBillStatus status = approvePassed() ? BizBillStatus.COMPLETED : BizBillStatus.ABORTED; BizBillStatus status = approvePassed() ? BizBillStatus.COMPLETED : BizBillStatus.ABORTED;
SapFixedAssets fixedAssets = sapFixedAssetsRepository.findOne(bizId); SapFixedAssets fixedAssets = sapFixedAssetsRepository.findOne(bizId);
fixedAssets.setStatusId(status.getId()); fixedAssets.setStatusId(status.getId());
sapFixedAssetsRepository.save(fixedAssets);
// 封装返回数据 // 封装返回数据
String returnJSON = getReturnVo(fixedAssets); String returnJSON = getReturnVo(fixedAssets);
String url = SystemCache.getParameter("sap.service.fixedAssets.url", String.class);
SapFixedAssets message;
try {
String execute = httpClient.execute(returnJSON, url);
message = new ObjectMapper().readValue(execute, SapFixedAssets.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
BeanUtils.copyProperties(message,fixedAssets);
sapFixedAssetsRepository.save(fixedAssets);
} }
/** /**
...@@ -139,7 +151,7 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe ...@@ -139,7 +151,7 @@ public class SapFixedAssetsApplicationImpl extends FlowBroker implements SapFixe
if (sapFixedAssets.isNew()) { if (sapFixedAssets.isNew()) {
sapFixedAssets.setStatusId(BizBillStatus.APPLYING.getId()); sapFixedAssets.setStatusId(BizBillStatus.APPLYING.getId());
sapFixedAssets.setZflg(1); sapFixedAssets.setZflg(1);
BeanUtils.copyProperties(operator,sapFixedAssets); BeanUtils.copyProperties(operator, sapFixedAssets);
sapFixedAssets.setZbpmn(sapFixedAssets.getBillCode()); sapFixedAssets.setZbpmn(sapFixedAssets.getBillCode());
} else { } else {
sapFixedAssets.setZflg(2); sapFixedAssets.setZflg(2);
......
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