提交 87f55f17 authored 作者: inroi's avatar inroi

对账单

上级 28df5e66
......@@ -20,18 +20,20 @@ public class ImsLogUtil {
//单例模式
private static ImsLogUtil uploadRooms;
//服务器加载Servlet的时候运行,并且只会被服务器执行一次。PostConstruct在构造函数之后执行,init()方法之前执行。
@PostConstruct
public void init() {
uploadRooms = this;
uploadRooms.iImslogService = this.iImslogService;
}
//添加IMS响应日志
public Boolean ImsLog(String request,String result,String name,String code,String message){
Imslog imslog=new Imslog();
Boolean flag=false;
if(null!=result){
Map maps = (Map)JSON.parse(result);
public Boolean ImsLog(String request, String result, String name, String code, String message) {
Imslog imslog = new Imslog();
Boolean flag = false;
if (null != result) {
Map maps = (Map) JSON.parse(result);
//设置日志信息
imslog.setName(name);
imslog.setRequest(request);
......@@ -39,16 +41,16 @@ public class ImsLogUtil {
imslog.setResponse(result);
imslog.setCreateTime(new Date());
imslog.setCode(code);
if (maps.get("resultCode").toString().equals("0000")){
flag=true;
if (maps.get("resultCode").toString().equals("0000")) {
flag = true;
imslog.setSuccess("true");
}else if (maps.get("resultCode").toString().equals("0001")){
flag=true;
} else if (maps.get("resultCode").toString().equals("0001")) {
flag = true;
imslog.setSuccess("Partial success");
}else {
} else {
imslog.setSuccess("false");
}
}else {
} else {
//设置日志信息
imslog.setName(name);
imslog.setRequest(request);
......@@ -64,11 +66,12 @@ public class ImsLogUtil {
/**
* 设置IMS请求日志
*
* @param data
* @param name
*/
public void ImsRequestLog(String data,String name,String OZTname,String code){
Imslog imslog=new Imslog();
public void ImsRequestLog(String data, String name, String OZTname, String code) {
Imslog imslog = new Imslog();
imslog.setCode(code);
imslog.setName(name);
imslog.setSuccess("true");
......
......@@ -33,6 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -132,6 +133,8 @@ public class WebApi {
IImsProduceOrderReadyService iImsProduceOrderReadyService;
@Autowired
IDeductionFormService deductionFormService;
@Autowired
IImsPurchaseWarehousingService iImsPurchaseWarehousingService;
/**
* 传入数据到金蝶云
*
......@@ -145,22 +148,24 @@ public class WebApi {
@ApiOperation(value = "IMS通用接口", notes = "IMS通用接口")
@PostMapping(value = "/GetData")
public Result<?> GetData(@RequestBody ImsRequest request) throws ParseException {
if (CollectionUtils.isEmpty(request.getData())) {
return Result.fail("操作失败", "查询参数不能全为空", request.getDocType());
}
Map<String, String> data = null;
/* //根据识别码调用响应的业务
//采购订单
if (request.getCode().equals("PO")) {
data = iImsPoService.getData(request.getData());
//ERP工单
}*/
if (data.containsKey("true") && data.get("true").equals("[]")) {
return Result.fail("操作失败", "对应参数下查询结果为空或参数值类型错误", request.getCode());
//如果有错误信息则返回
} else if (data.containsKey("false")) {
return Result.fail("操作失败", data.get("false"), request.getCode());
//采购入库单
if ("STK_InStock".equals(request.getDocType())) {
data = iImsPurchaseWarehousingService.getData(request.getData());
}
//采购退货单
if ("PO".equals(request.getDocType())) {
//data = iImsPoService.getData(request.getData());
}
if (data.containsKey("false")) {
return Result.fail("操作失败", data.get("false"), request.getDocType());
}
return Result.OK(data.get("true"), request.getCode());
return Result.OK(data.get("true"), request.getDocType());
}
......
package org.jeecg.modules.iost.ims.kingdeeapi;
import com.alibaba.fastjson.JSON;
import org.jeecg.modules.iost.ims.Dao.CategoryDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* @author Inori
*/
@Component
public class PurchaseWarehousingKingdeeApi {
@Autowired
private CategoryDao categoryDao;
private static final String S_FORM_ID = "PRD_MO";
private Map<String, String> key = new LinkedHashMap<>();
public PurchaseWarehousingKingdeeApi() {
/*查询字段*/
/* 单据头实体主键 */
key.put("FID", "FID");
/* 单据编号 */
key.put("FBillNo", "FBillNo");
/* 单据类型 */
key.put("FBillTypeID.Fname", "FBillTypeID.Fname");
/* 行号 */
key.put("FInStockEntry_FSeq", "FInStockEntry_FSeq");
/* 供应商 */
key.put("FSupplierId.Fnumber", "FSupplierId.Fnumber");
/* 入库时间 */
key.put("FDate", "FDate");
/* 税额 */
key.put("FBillTaxAmount", "FBillTaxAmount");
/* 未税金额 */
key.put("FBillAmount", "FBillAmount");
/* 含税否 */
key.put("FIsIncludedTax", "FIsIncludedTax");
/* 汇率 */
key.put("FExchangeRate", "FExchangeRate");
/* 税价合计 */
key.put("FBillAllAmount", "FBillAllAmount");
/* 付款条件 */
key.put("FPayConditionId.Fname", "FPayConditionId.Fname");
/* 币别 */
key.put("FSettleCurrId.Fname", "FSettleCurrId.Fname");
/* 结算方式 */
key.put("FSettleTypeId.Fname", "FSettleTypeId.Fname");
/* 物料编码 */
key.put("FMaterialId.Fnumber", "FMaterialId.Fnumber");
/* 实收数量 */
key.put("FRealQty", "FRealQty");
/* 单价 */
key.put("FPrice", "FPrice");
/* 含税单价 */
key.put("FTaxPrice", "FTaxPrice");
/* 库存单位 */
key.put("FUnitID.Fname", "FUnitID.Fname");
}
/**
* 获取金蝶云数据
*/
public List<Map<String, String>> selectAndLog(Map<String, String> map, String name) {
List<List<Object>> list = categoryDao.selectAndLog(S_FORM_ID, key, map, name);
return purchaseWarehousing(list);
}
/**
* 查询采购订单编号+行号
*/
public List<List<Object>> getPurchaseOrder(String id) {
List<List<Object>> lists = categoryDao.select("PRD_PPBOM", new LinkedHashMap<String, String>() {{
put("FPOOrderEntry_FSeq", "FPOOrderEntry_FSeq");
put("FBillNo", "FBillNo");
}}, new HashMap<String, String>() {{
put("FPOOrderEntry_FEntryID", id);
}});
if (CollectionUtils.isEmpty(lists)) {
return new ArrayList<>();
}
return lists;
}
List<Map<String, String>> purchaseWarehousing(List<List<Object>> list) {
List<Map<String, String>> result = new ArrayList<>();
if (!list.get(0).get(0).toString().contains("Errors")) {
} else {
//如果有错误信息则返回
Map<String, Object> o = (Map<String, Object>) list.get(0).get(0);
Object errors = o.get("Errors");
List parse3 = (List) JSON.parse(errors.toString());
Map parse4 = (Map) JSON.parse(parse3.get(0).toString());
Object message = parse4.get("Message");
Map<String, String> salesordermap = new HashMap<>();
salesordermap.put("false", message.toString());
result.add(salesordermap);
}
return result;
}
}
package org.jeecg.modules.iost.ims.service;
import java.util.Map;
/**
* @author Inori
*/
public interface IImsPurchaseWarehousingService {
Map<String, String> getData(Map<String, Object> map);
}
package org.jeecg.modules.iost.ims.service.impl;
import org.jeecg.modules.iost.ims.Util.ImsLogUtil;
import org.jeecg.modules.iost.ims.Util.JsonUtil;
import org.jeecg.modules.iost.ims.kingdeeapi.PurchaseWarehousingKingdeeApi;
import org.jeecg.modules.iost.ims.service.IImsPurchaseWarehousingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Inori
*/
@Service
public class ImsPurchaseWarehousingServiceImpl implements IImsPurchaseWarehousingService {
@Autowired
private PurchaseWarehousingKingdeeApi purchaseWarehousingKingdeeApi;
@Override
public Map<String, String> getData(Map<String, Object> map) {
//记录IMS日志
new ImsLogUtil().ImsRequestLog(JsonUtil.toString(map), "采购入库", "采购入库单查询", "STK_InStock");
Map<String, String> keyMap = new HashMap<>(4);
if (map.containsKey("FBillNo")) {
keyMap.put("FBillNo", map.get("FBillNo").toString());
}
if (map.containsKey("FSupplierId")) {
keyMap.put("FSupplierId.Fnumber", map.get("FSupplierId").toString());
}
if (map.containsKey("FDate")) {
keyMap.put("FDate", map.get("FDate").toString());
}
if (map.containsKey("FMaterialId")) {
keyMap.put("FMaterialId.Fumber", map.get("FMaterialId").toString());
}
List<Map<String, String>> list = purchaseWarehousingKingdeeApi.selectAndLog(keyMap, "");
Map<String, String> result = new HashMap<>();
result.put("true", JsonUtil.toString(list));
return result;
}
}
package org.jeecg.modules.iost.ims.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
......@@ -15,19 +13,18 @@ import java.util.Map;
@Data
@ApiModel(value = "接口请求对象", description = "接口请求对象")
public class ImsRequest implements Serializable {
/**
* 请求识别码
*/
@ApiModelProperty(value = "请求识别码")
// @JsonProperty("DocType")
private String code ;
private String docType;
/**
* 请求数据对象 data
*/
@ApiModelProperty(value = "请求数据对象")
// @JsonProperty("InputDTOXml")
private List<Map<String,Object>> data;
private Map<String, Object> data;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论