提交 8532945f authored 作者: inroi's avatar inroi

微调

上级 9aa49810
...@@ -105,7 +105,7 @@ public class CategoryDao { ...@@ -105,7 +105,7 @@ public class CategoryDao {
if (where != null) { if (where != null) {
where = where + " AND " + key + "='" + value + "'"; where = where + " AND " + key + "='" + value + "'";
} else { } else {
where = key + " IN (" + value + ")"; where = key + " IN ('" + value + "')";
} }
} }
} }
...@@ -227,7 +227,6 @@ public class CategoryDao { ...@@ -227,7 +227,6 @@ public class CategoryDao {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public List<List<Object>> selectByIds(String sFormId, Map<String, String> key, Map<String, String> where) { public List<List<Object>> selectByIds(String sFormId, Map<String, String> key, Map<String, String> where) {
List<List<Object>> list = null; List<List<Object>> list = null;
try { try {
...@@ -683,6 +682,27 @@ public class CategoryDao { ...@@ -683,6 +682,27 @@ public class CategoryDao {
return responseStatus; return responseStatus;
} }
public String excuteOperation(String sFormId, List<Map<String, String>> whereList, String kingDeeLogName) {
String result = null;
try {
if (this.result) {
String content = "{\"CreateOrgId\":0,\"PkEntryIds\": " + JsonUtils.toString(whereList);
result = client.excuteOperation(sFormId, "ToClose", content);
//记录修改金蝶云数据的请求和响应信息
KingdeeLogUtil kingdeeLogUtil = new KingdeeLogUtil();
kingdeeLogUtil.KingdeeLog2(content, result, kingDeeLogName);
} else {
throw new KingdeeConnectException(loginResult);
}
} catch (KingdeeConnectException e) {
throw new KingdeeConnectException(loginResult);
} catch (Exception e) {
e.printStackTrace();
throw new KingdeeConnectException(KingDeeConstant.URL, baseCommonService);
}
return result;
}
public String addReturnResult(String KingdeeLogName, String sFormId, String json) { public String addReturnResult(String KingdeeLogName, String sFormId, String json) {
String result2 = null; String result2 = null;
JSONObject responseStatus = null; JSONObject responseStatus = null;
......
package org.jeecg.modules.iost.ims.Util; package org.jeecg.modules.iost.ims.Util;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
...@@ -20,8 +21,25 @@ public class ImsUtil { ...@@ -20,8 +21,25 @@ public class ImsUtil {
return xml; return xml;
} }
public static boolean isError(String json) {
Map<String, Object> map = JsonUtils.toMap(json, String.class, Object.class);
if (CollectionUtils.isEmpty(map)) {
return true;
}
Map<String, Object> tempMap = JsonUtils.toMap(JsonUtils.toString(map.get("Result")), String.class, Object.class);
Map<String, Object> responseMap = JsonUtils.toMap(JsonUtils.toString(tempMap.get("ResponseStatus")), String.class, Object.class);
List<Object> errorList = JsonUtils.toList(JsonUtils.toString(responseMap.get("Errors")), Object.class);
return !CollectionUtils.isEmpty(errorList);
}
public static String getMessage(Object object) { public static String getMessage(Object object) {
Map<String, Object> map = JsonUtils.toMap(JsonUtils.toString(object), String.class, Object.class); Map<String, Object> map = JsonUtils.toMap(JsonUtils.toString(object), String.class, Object.class);
if (CollectionUtils.isEmpty(map)) {
return object.toString();
}
String result = JsonUtils.toString(map.get("Result")); String result = JsonUtils.toString(map.get("Result"));
Map<String, Object> toMap = JsonUtils.toMap(result, String.class, Object.class); Map<String, Object> toMap = JsonUtils.toMap(result, String.class, Object.class);
......
...@@ -109,6 +109,8 @@ public class WebService { ...@@ -109,6 +109,8 @@ public class WebService {
IImsDeptService iImsDeptService; IImsDeptService iImsDeptService;
@Autowired @Autowired
IImsSupplierService iImsSupplierService; IImsSupplierService iImsSupplierService;
@Autowired
IImsProduceOrderCloseService iImsProduceOrderCloseService;
@Autowired @Autowired
ImsAllotServiceImpl imsAllotService; ImsAllotServiceImpl imsAllotService;
...@@ -279,6 +281,9 @@ public class WebService { ...@@ -279,6 +281,9 @@ public class WebService {
//采购拒收 //采购拒收
} else if (request.getCode().equals("R400")) { } else if (request.getCode().equals("R400")) {
result = iImsPoRejectionService.setData(request.getData(), request.getCode()); result = iImsPoRejectionService.setData(request.getData(), request.getCode());
//工单关单
} else if (request.getCode().equals("R500")) {
result = iImsProduceOrderCloseService.setData(request.getData(), request.getCode());
} else { } else {
return Result.fail("操作失败!", "该code类型不存在!", request.getCode()); return Result.fail("操作失败!", "该code类型不存在!", request.getCode());
} }
......
package org.jeecg.modules.iost.ims.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 工单关单
* @Author: jeecg-boot
* @Date: 2022-01-07
* @Version: V1.0
*/
@Data
@TableName("ims_produce_order_close")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="ims_produce_order_close对象", description="工单关单")
public class ImsProduceOrderClose implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**唯一序号*/
@Excel(name = "唯一序号", width = 15)
@ApiModelProperty(value = "唯一序号")
private String queueId;
/**交易时间*/
@Excel(name = "交易时间", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
@ApiModelProperty(value = "交易时间")
private Date trxDate;
/**ERP工单编码*/
@Excel(name = "ERP工单编码", width = 15)
@ApiModelProperty(value = "ERP工单编码")
private String erpMo;
/**ERP工单行号*/
@Excel(name = "ERP工单行号", width = 15)
@ApiModelProperty(value = "ERP工单行号")
private Integer erpMoSeq;
/**是否委外(Y/N)*/
@Excel(name = "是否委外(Y/N)", width = 15)
@ApiModelProperty(value = "是否委外(Y/N)")
private String isOuts;
/**备注*/
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private String remark;
}
package org.jeecg.modules.iost.ims.kingdeeapi;
import lombok.Data;
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.*;
import java.util.stream.Collectors;
/**
* @author Inori
*/
@Data
@Component
public class ImsProduceOrderCloseApi {
@Autowired
private CategoryDao categoryDao;
private String sFormId;
private String kingDeeLogName;
public ImsProduceOrderCloseApi() {
//子单据Formid
sFormId = "PRD_MO";
//金蝶云修改操作日志-nam
kingDeeLogName = "工单关单";
}
public String addReturnResult(List<Map<String, Object>> list, String sFormId) {
String erpMo = list.stream().map(m -> String.valueOf(m.get("ERP_MO"))).distinct().collect(Collectors.joining(","));
Map<String, String> key = new LinkedHashMap<>();
//单据头实体主键
key.put("FID", "FID");
key.put("FBillNo", "FBillNo");
key.put("FTreeEntity_FSeq", "FTreeEntity_FSeq");
key.put("FTreeEntity_FEntryId", "FTreeEntity_FEntryId");
List<List<Object>> fList = selectByList(sFormId, key, erpMo);
if (CollectionUtils.isEmpty(fList)) {
return "数据不存在";
}
List<List<Object>> tempList = new ArrayList<>();
for (Map<String, Object> map : list) {
for (List<Object> objectList : fList) {
System.out.println(objectList);
if (map.get("ERP_MO").equals(String.valueOf(objectList.get(1))) && map.get("ERP_MO_SEQ").equals(String.valueOf(objectList.get(2)))) {
tempList.add(objectList);
}
}
}
List<Map<String, String>> whereList = new ArrayList<>();
List<String> temp01List = tempList.stream().map(m -> String.valueOf(m.get(0))).distinct().collect(Collectors.toList());
for (String fid : temp01List) {
List<List<Object>> temp02List = tempList.stream().filter(m -> fid.equals(String.valueOf(m.get(0)))).collect(Collectors.toList());
String entryIds = temp02List.stream().map(m -> String.valueOf(m.get(3))).collect(Collectors.joining(","));
Map<String, String> map = new HashMap<>();
map.put("Id", fid);
map.put("EntryIds", entryIds);
whereList.add(map);
}
return categoryDao.excuteOperation(sFormId, whereList, "工单关单");
}
private List<List<Object>> selectByList(String sFormId, Map<String, String> key, String erpMo) {
return categoryDao.selectByIds(sFormId, key, new HashMap<String, String>(2) {{
put("FBillNo", erpMo);
}});
}
}
package org.jeecg.modules.iost.ims.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.iost.ims.entity.ImsProduceOrderClose;
/**
* @Description: 工单关单
* @Author: jeecg-boot
* @Date: 2022-01-07
* @Version: V1.0
*/
@Mapper
public interface ImsProduceOrderCloseMapper extends BaseMapper<ImsProduceOrderClose> {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.iost.ims.mapper.ImsProduceOrderCloseMapper">
</mapper>
\ No newline at end of file
package org.jeecg.modules.iost.ims.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.iost.ims.entity.ImsProduceOrderClose;
import java.util.List;
import java.util.Map;
/**
* @author Inori
*/
public interface IImsProduceOrderCloseService extends IService<ImsProduceOrderClose> {
String setData(List<Map<String, Object>> needLists, String code);
}
...@@ -58,7 +58,7 @@ public class ImsMtrlRejectServiceImpl extends ServiceImpl<ImsMtrlRejectMapper, I ...@@ -58,7 +58,7 @@ public class ImsMtrlRejectServiceImpl extends ServiceImpl<ImsMtrlRejectMapper, I
for (Map<String, Object> maps : needLists) { for (Map<String, Object> maps : needLists) {
qidList.add(maps.get("QUEUE_ID").toString()); qidList.add(maps.get("QUEUE_ID").toString());
} }
QueryWrapper<ImsMtrlReject> qw = new QueryWrapper(); QueryWrapper<ImsMtrlReject> qw = new QueryWrapper<>();
qw.in("queue_id", qidList); qw.in("queue_id", qidList);
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
int length = qidList.size(); int length = qidList.size();
...@@ -138,7 +138,7 @@ public class ImsMtrlRejectServiceImpl extends ServiceImpl<ImsMtrlRejectMapper, I ...@@ -138,7 +138,7 @@ public class ImsMtrlRejectServiceImpl extends ServiceImpl<ImsMtrlRejectMapper, I
} }
//保存实体类 //保存实体类
this.saveBatch(ImsMtrlRejects); this.saveBatch(ImsMtrlRejects);
return ImsMtrlRejects.stream().map(ImsMtrlReject::getFbillNo).distinct().collect(Collectors.joining()); return ImsMtrlRejects.stream().map(ImsMtrlReject::getFbillNo).distinct().collect(Collectors.joining(","));
} }
public List<String> ResultSplitFour(org.jeecg.modules.iost.ims.entity.KingdeeResultObject.AddResultObject.Result AddResult) { public List<String> ResultSplitFour(org.jeecg.modules.iost.ims.entity.KingdeeResultObject.AddResultObject.Result AddResult) {
......
package org.jeecg.modules.iost.ims.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.exception.KingdeeRepeatException;
import org.jeecg.common.exception.kingdeeException;
import org.jeecg.modules.iost.ims.Util.ImsLogUtil;
import org.jeecg.modules.iost.ims.Util.ImsUtil;
import org.jeecg.modules.iost.ims.Util.MapUtils;
import org.jeecg.modules.iost.ims.entity.ImsProduceOrderClose;
import org.jeecg.modules.iost.ims.kingdeeapi.ImsProduceOrderCloseApi;
import org.jeecg.modules.iost.ims.mapper.ImsProduceOrderCloseMapper;
import org.jeecg.modules.iost.ims.service.IImsProduceOrderCloseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Inori
*/
@Service
public class ImsProduceOrderCloseServiceImpl extends ServiceImpl<ImsProduceOrderCloseMapper, ImsProduceOrderClose> implements IImsProduceOrderCloseService {
@Autowired
private ImsProduceOrderCloseApi imsProduceOrderCloseApi;
private String imsLogName;
private String DocType;
public ImsProduceOrderCloseServiceImpl() {
this.imsLogName = "工单关单"; //ims日志-name
this.DocType = "BS0057"; //调用者传入的标识
}
@Override
public String setData(List<Map<String, Object>> needLists, String code) {
List<ImsProduceOrderClose> ImsProduceOrderCloses = new ArrayList<>();
//拼接唯一序号重复的返回结果
List<String> queueIdRepeatResult = new ArrayList<>();
//请求参数的inputDTOXml里面json格式的参数传入ims同步日志(imslog)
ImsLogUtil imsLogUtil = new ImsLogUtil();
imsLogUtil.ImsRequestLog(JSON.toJSONString(needLists), imsLogName, DocType);
List<String> qidList = new ArrayList<>();
for (Map<String, Object> maps : needLists) {
qidList.add(maps.get("QUEUE_ID").toString());
}
QueryWrapper<ImsProduceOrderClose> qw = new QueryWrapper<>();
qw.in("queue_id", qidList);
StringBuilder builder = new StringBuilder();
int length = qidList.size();
for (int i = 0; i < length; i++) {
if (i == 0) {
builder.append("'").append(qidList.get(i)).append("'");
} else {
builder.append(",").append("'" + qidList.get(i) + "'");
}
}
qw.orderByAsc("FIELD(queue_id," + builder.toString() + ")");
List<ImsProduceOrderClose> repeatLists = this.getBaseMapper().selectList(qw);
if (!CollectionUtils.isEmpty(repeatLists)) {
queueIdRepeatResult = resultSplitOne(repeatLists);
}
if (!CollectionUtils.isEmpty(queueIdRepeatResult)) {
throw new KingdeeRepeatException("操作失败!", queueIdRepeatResult.get(0), code);
}
List<Map<String, Object>> temp01List = needLists.stream().filter(m -> "Y".equals(m.get("IS_OUTS"))).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(temp01List)) {
String result01 = imsProduceOrderCloseApi.addReturnResult(temp01List, "SUB_SUBREQORDER");
if (ImsUtil.isError(result01)) {
throw new kingdeeException("操作失败!", Stream.of(ImsUtil.getMessage(result01)).collect(Collectors.toList()), code);
}
}
List<Map<String, Object>> temp02List = needLists.stream().filter(m -> "N".equals(m.get("IS_OUTS"))).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(temp02List)) {
String result02 = imsProduceOrderCloseApi.addReturnResult(temp02List, "PRD_MO");
if (ImsUtil.isError(result02)) {
throw new kingdeeException("操作失败!", Stream.of(ImsUtil.getMessage(result02)).collect(Collectors.toList()), code);
}
}
for (Map<String, Object> needMap : needLists) {
Map<String, Object> map = MapUtils.mapsChange(needMap);
ImsProduceOrderCloses.add(JSON.parseObject(JSON.toJSONString(map), ImsProduceOrderClose.class));
}
this.saveBatch(ImsProduceOrderCloses);
return needLists.stream().map(m -> String.valueOf(m.get("ERP_MO"))).distinct().collect(Collectors.joining(","));
}
public List<String> resultSplitOne(List<ImsProduceOrderClose> repeatLists) {
String result;
LinkedHashSet<String> hashSet = new LinkedHashSet<>();
for (ImsProduceOrderClose imsProduceOrderClose : repeatLists) {
String queueId = String.valueOf(imsProduceOrderClose.getQueueId());
result = "QUEUE_ID为(" + queueId + ")的数据已经提交过!";
hashSet.add(result);
}
return new ArrayList<>(hashSet);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论