Merge branch 'refs/heads/feature/DM/nflg-bom' into feature/DM/nflg-bom-transition
# Conflicts: # nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialService.java
This commit is contained in:
commit
abd0a2d6c2
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.product.bomnew.service;
|
package com.nflg.product.bomnew.service;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
|
@ -17,6 +18,7 @@ import com.nflg.product.bomnew.config.NacosConfig;
|
||||||
import com.nflg.product.bomnew.constant.MaterialMainGetTypeEnum;
|
import com.nflg.product.bomnew.constant.MaterialMainGetTypeEnum;
|
||||||
import com.nflg.product.bomnew.constant.MaterialRelCategoryCodeEnum;
|
import com.nflg.product.bomnew.constant.MaterialRelCategoryCodeEnum;
|
||||||
import com.nflg.product.bomnew.pojo.dto.*;
|
import com.nflg.product.bomnew.pojo.dto.*;
|
||||||
|
import com.nflg.product.bomnew.pojo.entity.MaterialCategoryEntity;
|
||||||
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
|
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
|
||||||
import com.nflg.product.bomnew.util.FlowUtil;
|
import com.nflg.product.bomnew.util.FlowUtil;
|
||||||
import com.nflg.product.bomnew.util.HttpUtils;
|
import com.nflg.product.bomnew.util.HttpUtils;
|
||||||
|
|
@ -53,6 +55,9 @@ public class MaterialService {
|
||||||
@Qualifier("syncOAThreadPool")
|
@Qualifier("syncOAThreadPool")
|
||||||
ThreadPoolTaskExecutor syncOAThreadPool;
|
ThreadPoolTaskExecutor syncOAThreadPool;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
MaterialCategoryService materialCategoryService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 申请物料
|
* 申请物料
|
||||||
*
|
*
|
||||||
|
|
@ -173,6 +178,9 @@ public class MaterialService {
|
||||||
public Map<String, AddVirtrualMaterialDTO> batchAddMaterial(List<AddVirtrualMaterialDTO> mds, LoginUserInfoDTO userInfo) {
|
public Map<String, AddVirtrualMaterialDTO> batchAddMaterial(List<AddVirtrualMaterialDTO> mds, LoginUserInfoDTO userInfo) {
|
||||||
List<MaterialMainEntity> resultList=new ArrayList<>();
|
List<MaterialMainEntity> resultList=new ArrayList<>();
|
||||||
|
|
||||||
|
Set<String> categoryCodeList = mds.stream().map(AddVirtrualMaterialDTO::getMaterialCategoryCode).collect(Collectors.toSet());
|
||||||
|
List<MaterialCategoryEntity> categoryEntityList = materialCategoryService.lambdaQuery().in(MaterialCategoryEntity::getCategoryCode, categoryCodeList).list();
|
||||||
|
|
||||||
List<AddMaterialMainDTO> syncOaEnts=new ArrayList<>();
|
List<AddMaterialMainDTO> syncOaEnts=new ArrayList<>();
|
||||||
Map<String,AddVirtrualMaterialDTO> result = new HashMap<>();
|
Map<String,AddVirtrualMaterialDTO> result = new HashMap<>();
|
||||||
for (AddVirtrualMaterialDTO md :mds) {
|
for (AddVirtrualMaterialDTO md :mds) {
|
||||||
|
|
@ -189,29 +197,41 @@ public class MaterialService {
|
||||||
ma.setUpdatedBy(userInfo.getUserCode());
|
ma.setUpdatedBy(userInfo.getUserCode());
|
||||||
ma.setUpdatedTime(LocalDateTime.now());
|
ma.setUpdatedTime(LocalDateTime.now());
|
||||||
ma.setMaterialClass(0);
|
ma.setMaterialClass(0);
|
||||||
ma.setProcessState(0);
|
// ma.setProcessState(0);
|
||||||
ma.setApplyUserCode(userInfo.getRealName());
|
ma.setApplyUserCode(userInfo.getRealName());
|
||||||
ma.setApplyDeptName(userInfo.getDepartName());
|
ma.setApplyDeptName(userInfo.getDepartName());
|
||||||
ma.setMaterialUnit("PC");
|
ma.setMaterialUnit("PC");
|
||||||
// ma.setProcessState(10);
|
ma.setProcessState(10);
|
||||||
if(StrUtil.isNotBlank(md.getProjectType())){
|
if(StrUtil.isNotBlank(md.getProjectType())){
|
||||||
ma.setProjectType(md.getProjectType());
|
ma.setProjectType(md.getProjectType());
|
||||||
}
|
}
|
||||||
resultList.add(ma);
|
resultList.add(ma);
|
||||||
|
|
||||||
// AddMaterialMainDTO ent=new AddMaterialMainDTO();
|
AddMaterialMainDTO ent = new AddMaterialMainDTO();
|
||||||
// BeanUtil.copyProperties(ma,ent);
|
BeanUtil.copyProperties(ma, ent);
|
||||||
// ent.setRelCategoryCode(relMaterialCategory);
|
ent.setRelCategoryCode(relMaterialCategory);
|
||||||
// ent.setReuseOfOnceState(0);
|
ent.setReuseOfOnceState(0);
|
||||||
// syncOaEnts.add(ent);
|
|
||||||
|
Optional<MaterialCategoryEntity> optional = categoryEntityList.stream().filter(item -> item.getCategoryCode().equals(md.getMaterialCategoryCode())).findFirst();
|
||||||
|
optional.ifPresent(item -> {
|
||||||
|
List<String> parentRowIdList = Arrays.stream(item.getParentTree().split(",")).collect(Collectors.toList());
|
||||||
|
List<MaterialCategoryEntity> list = materialCategoryService.lambdaQuery().in(MaterialCategoryEntity::getRowId, parentRowIdList).list();
|
||||||
|
List<String> categoryNameList = list.stream().map(MaterialCategoryEntity::getCategoryName).collect(Collectors.toList());
|
||||||
|
String categoryTreeName = String.join("/", categoryNameList);
|
||||||
|
ent.setCategoryNameTree(categoryTreeName);
|
||||||
|
ent.setRelCategoryCode(item.getRelCategoryCode());
|
||||||
|
});
|
||||||
|
|
||||||
|
syncOaEnts.add(ent);
|
||||||
|
|
||||||
md.setMaterialNo(ma.getMaterialNo());
|
md.setMaterialNo(ma.getMaterialNo());
|
||||||
result.put(md.getKey(),md);
|
result.put(md.getKey(),md);
|
||||||
}
|
}
|
||||||
materialMainService.saveOrUpdateBatch(resultList);
|
materialMainService.saveOrUpdateBatch(resultList);
|
||||||
// initCategoryInfo(syncOaEnts);
|
initCategoryInfo(syncOaEnts);
|
||||||
//同步OA
|
//同步OA
|
||||||
CompletableFuture.runAsync(() -> sysnToOa(syncOaEnts, userInfo), syncOAThreadPool);
|
//sysnToOa(syncOaEnts);
|
||||||
|
CompletableFuture.runAsync(() -> sysnToOa(syncOaEnts),syncOAThreadPool);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,6 +328,7 @@ public class MaterialService {
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void sysnToOa(List<AddMaterialMainDTO> data, LoginUserInfoDTO userInfo) {
|
public void sysnToOa(List<AddMaterialMainDTO> data, LoginUserInfoDTO userInfo) {
|
||||||
|
try {
|
||||||
Map<String, Object> result = getHttpMap(userInfo.getUserCode());
|
Map<String, Object> result = getHttpMap(userInfo.getUserCode());
|
||||||
|
|
||||||
List<Map<String, String>> list = new ArrayList<>();
|
List<Map<String, String>> list = new ArrayList<>();
|
||||||
|
|
@ -363,7 +384,6 @@ public class MaterialService {
|
||||||
result.put("List", list);
|
result.put("List", list);
|
||||||
log.info("物料申请-JSON:" + JSONArray.toJSONString(list));
|
log.info("物料申请-JSON:" + JSONArray.toJSONString(list));
|
||||||
HttpUtils httpUtils = new HttpUtils();
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
try {
|
|
||||||
String url = NacosConfig.getNacosConfig().getOaUrl();
|
String url = NacosConfig.getNacosConfig().getOaUrl();
|
||||||
String reqResult = httpUtils.doPost(url, JSON.toJSONString(result));
|
String reqResult = httpUtils.doPost(url, JSON.toJSONString(result));
|
||||||
JSONObject jsonObject = JSONObject.parseObject(reqResult);
|
JSONObject jsonObject = JSONObject.parseObject(reqResult);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue