|
|
@ -4,10 +4,11 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.KingDeeBillId; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.KingDeeBillUrl; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.KingDeeResult; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.KingDeeCode; |
|
|
|
import com.yxt.anrui.fin.api.kingdee.bdmaterial.BdMaterial; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.FinKingDeeService; |
|
|
|
import com.yxt.anrui.fin.biz.kingdee.KingDeeConfig; |
|
|
|
import com.yxt.anrui.portal.api.sysmapping.SysMappingInfoQueryBatch; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import org.slf4j.Logger; |
|
|
@ -25,42 +26,120 @@ import java.util.Map; |
|
|
|
public class BdMaterialService extends FinKingDeeService { |
|
|
|
private static Logger log= LoggerFactory.getLogger(BdMaterialService.class); |
|
|
|
/** |
|
|
|
* 保存物料 list |
|
|
|
* @param bdMaterial |
|
|
|
* 批量暂存物料 list |
|
|
|
* @param bdMaterials |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<String> draftBdMaterialList(List<BdMaterial> bdMaterial) { |
|
|
|
public ResultBean<String> draftBdMaterialList(List<BdMaterial> bdMaterials) { |
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
// bdMaterial=BdMaterial.createBdMaterial();
|
|
|
|
Map<String, Object> data = getStringObjectMap(bdMaterials); |
|
|
|
List<String> list_r=new ArrayList<>(); |
|
|
|
for(BdMaterial b:bdMaterials) { |
|
|
|
//物料信息转map参数
|
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(b); |
|
|
|
//业务表的主表数据集合
|
|
|
|
Map<String, String> map_fEntityModel_ = createMapParams(stringObjectMap); |
|
|
|
ResultBean<String> stringResultBean = setMappingInfosParams(map_fEntityModel_, data,getKeyItems()); |
|
|
|
if(!stringResultBean.getSuccess()){ |
|
|
|
return stringResultBean; |
|
|
|
} |
|
|
|
map_fEntityModel_.put("IsDeleteEntry", "True"); |
|
|
|
map_fEntityModel_.put("FMATERIALID", 0 + ""); |
|
|
|
map_fEntityModel_.put("FMaterialGroup","02"); |
|
|
|
map_fEntityModel_.put("F_PAEZ_Base","02"); |
|
|
|
rb= draftBdMaterial(map_fEntityModel_); |
|
|
|
if (rb.getSuccess()) { |
|
|
|
list_r.add(rb.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(JSONObject.toJSONString(list_r)); |
|
|
|
} |
|
|
|
private Map<String, Object> getStringObjectMap(List<BdMaterial> bdMaterials) { |
|
|
|
List<Map<String, Object>> som=new ArrayList<>(); |
|
|
|
bdMaterials.forEach(bdMaterial -> { |
|
|
|
som.add(BeanUtil.beanToMap(bdMaterial)); |
|
|
|
}); |
|
|
|
// "存货类别 FCategoryID,物料分组 FMaterialGroup,车辆类型 F_PAEZ_Base 车辆系别 F_PAEZ_Base2 车辆马力 F_PAEZ_Base3 车辆驱动 F_PAEZ_Base4"
|
|
|
|
List<KeyItem> params = getKeyItems(); |
|
|
|
List<Map<String, List<SysMappingInfoQueryBatch>>> list = makeMappingInfosParams(som,params,"FName", |
|
|
|
"物料","CWXT"); |
|
|
|
ResultBean<Map<String, Object>> sysMappingInfoVoResultBeanBatch = getMappingInfosParams(list); |
|
|
|
Map<String, Object> data = sysMappingInfoVoResultBeanBatch.getData(); |
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
private List<KeyItem> getKeyItems() { |
|
|
|
List<KeyItem> params=new ArrayList<>(); |
|
|
|
params.add(new KeyItem("FCategoryID","存货类别") ); |
|
|
|
/* params.add(new KeyItem("FMaterialGroup","物料分组") ); |
|
|
|
params.add(new KeyItem("F_PAEZ_Base","车辆类型") ); |
|
|
|
params.add(new KeyItem("F_PAEZ_Base2","车辆系别") ); |
|
|
|
params.add(new KeyItem("F_PAEZ_Base3","车辆马力") ); |
|
|
|
params.add(new KeyItem("F_PAEZ_Base4","车辆驱动") );*/ |
|
|
|
return params; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量修改物料 list |
|
|
|
* @param bdMaterials |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<String> saveBdMaterialList(List<BdMaterial> bdMaterials) { |
|
|
|
// bdMaterial=BdMaterial.createBdMaterial();
|
|
|
|
List<String> list=new ArrayList<>(); |
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
for(BdMaterial b:bdMaterial) { |
|
|
|
rb= draftBdMaterial(b); |
|
|
|
Map<String, Object> data = getStringObjectMap(bdMaterials); |
|
|
|
List<String> list_r=new ArrayList<>(); |
|
|
|
for(BdMaterial b:bdMaterials) { |
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(b); |
|
|
|
if(StringUtils.isBlank(b.getOldFName())){ |
|
|
|
return rb.setMsg("FMATERIALID不能为空"); |
|
|
|
} |
|
|
|
ResultBean<String> stringResultBean = null; |
|
|
|
try { |
|
|
|
stringResultBean = unAudit(b); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
if(!stringResultBean.getSuccess()){ |
|
|
|
return stringResultBean; |
|
|
|
} |
|
|
|
String FMATERIALID=stringResultBean.getData(); |
|
|
|
Map<String,String> map_fEntityModel_=createMapParams(stringObjectMap); |
|
|
|
ResultBean<String> stringResultBean1 = setMappingInfosParams(map_fEntityModel_, data,getKeyItems()); |
|
|
|
if(!stringResultBean1.getSuccess()){ |
|
|
|
return stringResultBean1; |
|
|
|
} |
|
|
|
map_fEntityModel_.put("IsDeleteEntry","False"); |
|
|
|
map_fEntityModel_.put("FMATERIALID",FMATERIALID); |
|
|
|
map_fEntityModel_.put("FMaterialGroup","02"); |
|
|
|
map_fEntityModel_.put("F_PAEZ_Base","02"); |
|
|
|
rb= saveBdMaterial(map_fEntityModel_); |
|
|
|
if (rb.getSuccess()) { |
|
|
|
list.add(rb.getData()); |
|
|
|
list_r.add(rb.getData()); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
return rb.success().setData(JSONObject.toJSONString(list_r)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 暂存物料 |
|
|
|
* @param bdMaterial |
|
|
|
* 调用金蝶接口暂存物料 |
|
|
|
* @param map_fEntityModel_ |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<String> draftBdMaterial(BdMaterial bdMaterial) { |
|
|
|
private ResultBean<String> draftBdMaterial( Map<String, String> map_fEntityModel_) { |
|
|
|
// bdMaterial=BdMaterial.createBdMaterial();
|
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
//物料信息转map参数
|
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(bdMaterial); |
|
|
|
//业务表的主表数据集合
|
|
|
|
Map<String,String> map_fEntityModel_=createMapParams(stringObjectMap); |
|
|
|
map_fEntityModel_.put("IsDeleteEntry","True"); |
|
|
|
map_fEntityModel_.put("FMATERIALID",0+""); |
|
|
|
String kingDeeData = BdMaterialCastToKingDeeBillFields.getKingDeeData(map_fEntityModel_); |
|
|
|
try { |
|
|
|
ResultBean<String> draft = draft(kingDeeData); |
|
|
|
if (!draft.getSuccess()) return rb.setMsg("物料保存失败!"); |
|
|
|
String data = draft.getData(); |
|
|
|
submitAuditAllocate(bdMaterial, data); |
|
|
|
ResultBean<String> submit = submitAuditAllocate(data); |
|
|
|
if (!submit.getSuccess()) return rb.setCode(KingDeeCode.SUBMIT.getCode()).setData(submit.getData()); |
|
|
|
ResultBean<String> audit = audit(data); |
|
|
|
if (!audit.getSuccess()) return rb.setCode(KingDeeCode.AUDIT.getCode()).setData(audit.getData()); |
|
|
|
ResultBean<String> allocate = allocate(map_fEntityModel_.get("TOrgIds"), data); |
|
|
|
if (!allocate.getSuccess()) return rb.setCode(KingDeeCode.ALLOCATE.getCode()).setData(allocate.getData()); |
|
|
|
return draft; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
@ -70,30 +149,19 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改物料的信息 |
|
|
|
* @param bdMaterial |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<String> saveBdMaterial(BdMaterial bdMaterial) { |
|
|
|
private ResultBean<String> saveBdMaterial( Map<String,String> map_fEntityModel_) { |
|
|
|
// bdMaterial=BdMaterial.createBdMaterial();
|
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
//物料信息转map参数
|
|
|
|
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(bdMaterial); |
|
|
|
if(StringUtils.isBlank(bdMaterial.getOldFName())){ |
|
|
|
return rb.setMsg("FMATERIALID不能为空"); |
|
|
|
} |
|
|
|
try{ |
|
|
|
ResultBean<String> stringResultBean = hasMaterial(bdMaterial); |
|
|
|
if(!stringResultBean.getSuccess()){ |
|
|
|
return stringResultBean; |
|
|
|
} |
|
|
|
String FMATERIALID=stringResultBean.getData(); |
|
|
|
Map<String,String> map_fEntityModel_=createMapParams(stringObjectMap); |
|
|
|
map_fEntityModel_.put("IsDeleteEntry","False"); |
|
|
|
map_fEntityModel_.put("FMATERIALID",FMATERIALID); |
|
|
|
ResultBean<String> save = save(map_fEntityModel_); |
|
|
|
String data = save.getData(); |
|
|
|
if (submit( data)) return rb.setMsg("物料提交失败!"); |
|
|
|
if (audit( data)) return rb.setMsg("物料审核失败!"); |
|
|
|
ResultBean<String> submit = submitAuditAllocate( data); |
|
|
|
if (!submit.getSuccess()) return rb.setCode(KingDeeCode.SUBMIT.getCode()).setMsg(KingDeeCode.SUBMIT.getMsg()); |
|
|
|
ResultBean<String> audit = audit(data); |
|
|
|
if (!audit.getSuccess()) return rb.setCode(KingDeeCode.AUDIT.getCode()).setMsg(KingDeeCode.AUDIT.getMsg()); |
|
|
|
return save; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
@ -113,16 +181,16 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
kingDeeData, KingDeeConfig.userName_administrator,KingDeeConfig.password_administrator, KingDeeBillUrl.DRAFT_URL.getURL()); |
|
|
|
if(!stringResultBean.getSuccess()){ |
|
|
|
log.info("物料保存失败!"); |
|
|
|
return rb; |
|
|
|
return rb.setMsg("物料保存失败!"); |
|
|
|
} |
|
|
|
String data1 = stringResultBean.getData(); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data1); |
|
|
|
String data = stringResultBean.getData(); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data); |
|
|
|
JSONObject result = (JSONObject)jsonObject.get("Result"); |
|
|
|
JSONObject responseStatus = (JSONObject)result.get("ResponseStatus"); |
|
|
|
boolean isSuccess = (boolean) responseStatus.get("IsSuccess"); |
|
|
|
if(!isSuccess){ |
|
|
|
log.info("物料保存失败!"); |
|
|
|
return rb; |
|
|
|
log.info("物料编码重复!"); |
|
|
|
return rb.setCode(KingDeeCode.REPEAT.getCode()); |
|
|
|
} |
|
|
|
log.info("物料保存成功!"); |
|
|
|
return stringResultBean; |
|
|
@ -141,7 +209,7 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
kingDeeData, KingDeeBillUrl.SAVE_URL.getURL()); |
|
|
|
if(!stringResultBean.getSuccess()){ |
|
|
|
log.info("物料保存失败!"); |
|
|
|
return rb; |
|
|
|
return rb.setMsg("物料保存失败!"); |
|
|
|
} |
|
|
|
String data1 = stringResultBean.getData(); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data1); |
|
|
@ -149,8 +217,8 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
JSONObject responseStatus = (JSONObject)result.get("ResponseStatus"); |
|
|
|
boolean isSuccess = (boolean) responseStatus.get("IsSuccess"); |
|
|
|
if(!isSuccess){ |
|
|
|
log.info("物料保存失败!"); |
|
|
|
return rb; |
|
|
|
log.info("物料编码重复!"); |
|
|
|
return rb.setCode(KingDeeCode.REPEAT.getCode()).setMsg(KingDeeCode.REPEAT.getMsg()); |
|
|
|
} |
|
|
|
log.info("物料保存成功!"); |
|
|
|
return stringResultBean; |
|
|
@ -162,32 +230,30 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
private ResultBean submitAuditAllocate(BdMaterial bdMaterial, String data) throws Exception { |
|
|
|
private ResultBean<String> submitAuditAllocate(String data) throws Exception { |
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
if (submit( data)) return rb.setMsg("物料提交失败!"); |
|
|
|
if (audit( data)) return rb.setMsg("物料审核失败!"); |
|
|
|
if (allocate(bdMaterial, data)) return rb.setMsg("物料分配失败!"); |
|
|
|
ResultBean<String> submit = submit(data); |
|
|
|
if (!submit.getSuccess()) return rb.setCode(KingDeeCode.SUBMIT.getCode()).setData(submit.getData()); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 分配 |
|
|
|
* @param bdMaterial |
|
|
|
* @param tOrgIds |
|
|
|
* @param data |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
private boolean allocate(BdMaterial bdMaterial, String data) throws Exception { |
|
|
|
String allocate = getAllocate(data, bdMaterial.getTOrgIds(),KingDeeBillId.BD_MATERIAL.getID()); |
|
|
|
private ResultBean<String> allocate(String tOrgIds, String data) throws Exception { |
|
|
|
String allocate = getAllocate(data,tOrgIds,KingDeeBillId.BD_MATERIAL.getID()); |
|
|
|
ResultBean<String> resultBean3 =accessKingDeeInterface( |
|
|
|
KingDeeBillId.BD_MATERIAL.getID(), allocate, |
|
|
|
KingDeeBillUrl.ALLOCATE_URL.getURL());// allocateKingDeeBillData(KingDeeBillId.BD_MATERIAL.getID(), allocate);
|
|
|
|
if(!resultBean3.getSuccess()){ |
|
|
|
log.info("物料分配失败!"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
log.info("物料分配成功!"); |
|
|
|
return false; |
|
|
|
return resultBean3; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -196,16 +262,15 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
private boolean audit( String data) throws Exception { |
|
|
|
private ResultBean<String> audit( String data) throws Exception { |
|
|
|
String auditKD = getAuditKD(data,KingDeeBillId.BD_MATERIAL.getID()); |
|
|
|
ResultBean<String> resultBean2 = accessKingDeeInterface( |
|
|
|
KingDeeBillId.BD_MATERIAL.getID(), auditKD,KingDeeBillUrl.AUDIT_URL.getURL());//auditKingDeeBillData(KingDeeBillId.BD_MATERIAL.getID(), auditKD);
|
|
|
|
if(!resultBean2.getSuccess()){ |
|
|
|
log.info("物料审核失败!"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
log.info("物料审核成功!"); |
|
|
|
return false; |
|
|
|
return resultBean2; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -214,16 +279,15 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
private boolean submit( String data) throws Exception { |
|
|
|
private ResultBean<String> submit( String data) throws Exception { |
|
|
|
String submitKD = getSubmitKD(data,KingDeeBillId.BD_MATERIAL.getID()); |
|
|
|
ResultBean<String> resultBean1 = accessKingDeeInterface(KingDeeBillId.BD_MATERIAL.getID(), |
|
|
|
submitKD,KingDeeBillUrl.SUBMIT_URL.getURL());//submitKingDeeBillData(KingDeeBillId.BD_MATERIAL.getID(), submitKD);
|
|
|
|
if(!resultBean1.getSuccess()){ |
|
|
|
log.info("物料提交失败!"); |
|
|
|
return true; |
|
|
|
} |
|
|
|
log.info("物料提交成功!"); |
|
|
|
return false; |
|
|
|
return resultBean1; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -232,19 +296,19 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
public ResultBean<String> hasMaterial(BdMaterial bdMaterial) throws Exception { |
|
|
|
public ResultBean<String> unAudit(BdMaterial bdMaterial) throws Exception { |
|
|
|
ResultBean<String> rb=ResultBean.fireFail(); |
|
|
|
JSONObject result = view(bdMaterial); |
|
|
|
JSONObject responseStatus = (JSONObject)result.get("ResponseStatus"); |
|
|
|
if(responseStatus!=null){//不存在该物料 //新增物料
|
|
|
|
return rb.setMsg("不存在该物料"); |
|
|
|
return rb.setCode(KingDeeCode.NOTEXIST.getCode()).setMsg(KingDeeCode.NOTEXIST.getMsg()); |
|
|
|
}else{ //存在该物料
|
|
|
|
JSONObject result2 = (JSONObject)result.get("Result"); |
|
|
|
String DocumentStatus = (String)result2.get("DocumentStatus");//单据状态 A 创建, B 审核中,C 已审核 ,D 重新审核
|
|
|
|
String Id=result2.get("Id").toString(); |
|
|
|
boolean audit = isAudit(DocumentStatus, Id); |
|
|
|
if(!audit){ |
|
|
|
return rb.setMsg("物料反审核失败!"); |
|
|
|
return rb.setCode(KingDeeCode.UNAUDIT.getCode()).setMsg(KingDeeCode.UNAUDIT.getMsg()); |
|
|
|
} |
|
|
|
log.info("Id:{}",Id); |
|
|
|
return rb.success().setData(Id); |
|
|
@ -288,5 +352,4 @@ public class BdMaterialService extends FinKingDeeService { |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|