feature 1.物料导入的

release
zhenghaiyang@ele-cloud.com 2 years ago
parent bdc5082b98
commit 2bcdb6dce3
  1. 5
      order-management-consumer/pom.xml
  2. 44
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/controller/GroupCommodityCodeController.java
  3. 23
      order-management-consumer/src/main/java/com/dxhy/order/consumer/modules/commodity/domain/dto/CommodityCodeEntityExcel.java
  4. 1
      order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/ISDEnregyService.java
  5. 51
      order-management-consumer/src/main/java/com/dxhy/order/consumer/openapi/service/impl/SDEnregyServiceImpl.java

@ -542,6 +542,11 @@
<artifactId>wsdl4j</artifactId> <artifactId>wsdl4j</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel-core</artifactId>
<version>3.1.1</version>
</dependency>
<!-- axis 1.4 jar end --> <!-- axis 1.4 jar end -->
</dependencies> </dependencies>

@ -1,18 +1,27 @@
package com.dxhy.order.consumer.modules.commodity.controller; package com.dxhy.order.consumer.modules.commodity.controller;
import cn.hutool.json.JSONObject; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.dxhy.order.baseservice.module.base.service.BaseService;
import com.dxhy.order.consumer.modules.commodity.domain.dto.CommodityCodeEntityExcel;
import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO; import com.dxhy.order.consumer.modules.commodity.domain.dto.QueryGroupCommodityDTO;
import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO; import com.dxhy.order.consumer.modules.commodity.domain.dto.QuoteGroupCommodityDTO;
import com.dxhy.order.consumer.modules.commodity.domain.dto.SyncGroupCommodityDTO; import com.dxhy.order.consumer.modules.commodity.domain.dto.SyncGroupCommodityDTO;
import com.dxhy.order.consumer.modules.commodity.service.IGroupCommodityCodeService; import com.dxhy.order.consumer.modules.commodity.service.IGroupCommodityCodeService;
import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.MdmSyncGroupTaxCodeReqBO;
import com.dxhy.order.consumer.openapi.service.ISDEnregyService;
import com.dxhy.order.model.PageUtils; import com.dxhy.order.model.PageUtils;
import com.dxhy.order.model.R; import com.dxhy.order.model.R;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map; import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
/** /**
* @Description 集团物料库 * @Description 集团物料库
@ -28,6 +37,10 @@ public class GroupCommodityCodeController {
@Autowired @Autowired
private IGroupCommodityCodeService groupCommodityCodeService; private IGroupCommodityCodeService groupCommodityCodeService;
@Autowired
private ISDEnregyService sdEnregyService;
@Resource
private BaseService baseService;
@GetMapping("/list") @GetMapping("/list")
public R list(QueryGroupCommodityDTO queryGroupCommodityDTO) { public R list(QueryGroupCommodityDTO queryGroupCommodityDTO) {
@ -54,4 +67,31 @@ public class GroupCommodityCodeController {
public R sync(@RequestBody @Validated SyncGroupCommodityDTO dto) { public R sync(@RequestBody @Validated SyncGroupCommodityDTO dto) {
return groupCommodityCodeService.syncGroupCommodityDTO(dto); return groupCommodityCodeService.syncGroupCommodityDTO(dto);
} }
@RequestMapping("/uploadGroupCommodityDTO")
public R emailUpload(@RequestParam(value = "file") MultipartFile file) {
try {
List<CommodityCodeEntityExcel> entityExcelList = EasyExcel.read(file.getInputStream()).sheet().head(CommodityCodeEntityExcel.class).headRowNumber(1).doReadSync();
log.info("解析的数据:{}", JSONObject.toJSONString(entityExcelList));
if (entityExcelList == null || entityExcelList.isEmpty()) {
return R.error("数据解析失败");
}
List<MdmSyncGroupTaxCodeReqBO> taxxtbReqBOS = Lists.newArrayList();
for (CommodityCodeEntityExcel entityExcel : entityExcelList) {
MdmSyncGroupTaxCodeReqBO taxCodeReqBO = new MdmSyncGroupTaxCodeReqBO();
taxCodeReqBO.setCODE(entityExcel.getCODE());
taxCodeReqBO.setDESC1(entityExcel.getDESC1());
taxCodeReqBO.setDESC5(entityExcel.getDESC5());
taxCodeReqBO.setDESCSHORT(entityExcel.getDESCSHORT());
taxCodeReqBO.setUUID(baseService.getGenerateShotKey());
taxCodeReqBO.setCATEGORYNAME(entityExcel.getCATEGORYNAME());
taxCodeReqBO.setCATEGORYCODE(entityExcel.getCATEGORYCODE());
taxxtbReqBOS.add(taxCodeReqBO);
}
String str = sdEnregyService.syncMdmGroupTaxService(taxxtbReqBOS);
return R.ok().put("data",str);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} }

@ -0,0 +1,23 @@
package com.dxhy.order.consumer.modules.commodity.domain.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class CommodityCodeEntityExcel {
@ExcelProperty("CODE")
private String CODE;
@ExcelProperty("DESC1")
private String DESC1;
@ExcelProperty("DESC5")
private String DESC5;
@ExcelProperty("DESCSHORT")
private String DESCSHORT;
// 物料分类编码
@ExcelProperty("CATEGORYNAME")
private String CATEGORYNAME;
// 物料分类名称
@ExcelProperty("CATEGORYCODE")
private String CATEGORYCODE;
}

@ -47,6 +47,7 @@ public interface ISDEnregyService {
* @return * @return
*/ */
public R proactiveSyncMdmGroupTax(String code); public R proactiveSyncMdmGroupTax(String code);
String syncMdmGroupTaxService(List<MdmSyncGroupTaxCodeReqBO> taxxtbReqBOS);
/** /**
* 主动同步人员 * 主动同步人员

@ -20,7 +20,6 @@ import com.dxhy.order.consumer.openapi.protocol.AjaxResult;
import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.*; import com.dxhy.order.consumer.openapi.protocol.v6.sdenergy.*;
import com.dxhy.order.model.R; import com.dxhy.order.model.R;
import com.dxhy.order.utils.DistributedKeyMaker; import com.dxhy.order.utils.DistributedKeyMaker;
import com.dxhy.order.utils.HttpUtils;
import com.dxhy.order.utils.JsonUtils; import com.dxhy.order.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -202,7 +201,6 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract {
String resp = JsonUtils.getInstance().toJsonStringNullToEmpty(result); String resp = JsonUtils.getInstance().toJsonStringNullToEmpty(result);
return AjaxResult.success("success", resp); return AjaxResult.success("success", resp);
} }
/** /**
* 集团物料同步接口 * 集团物料同步接口
* *
@ -274,24 +272,26 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract {
} }
list.add(commodityCodeEntity); list.add(commodityCodeEntity);
} }
String respStr = "";
SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(requestBody, SDEnergyMdmBaseBO.class); if(StringUtils.isNotBlank(requestBody)){
SDEnergyMdmBaseBO result = buildResult( SDEnergyMdmBaseBO baseBO = JSONObject.parseObject(requestBody, SDEnergyMdmBaseBO.class);
baseBO, SDEnergyMdmBaseBO result = buildResult(
list, baseBO,
i -> { list,
CommodityCodeEntity t = (CommodityCodeEntity) i; i -> {
SDEnergyMdmBaseRespBO resp = new SDEnergyMdmBaseRespBO(); CommodityCodeEntity t = (CommodityCodeEntity) i;
resp.setCODE(t.getZxbm()); SDEnergyMdmBaseRespBO resp = new SDEnergyMdmBaseRespBO();
resp.setUUID(t.getUUID()); resp.setCODE(t.getZxbm());
resp.setSYNSTATUS(t.getSuccess() ? "0" : "1"); resp.setUUID(t.getUUID());
resp.setSYNRESULT(t.getSuccess() ? "success" : "failed"); resp.setSYNSTATUS(t.getSuccess() ? "0" : "1");
return resp; resp.setSYNRESULT(t.getSuccess() ? "success" : "failed");
} return resp;
); }
);
String resp = JsonUtils.getInstance().toJsonStringNullToEmpty(result);
return AjaxResult.success("success", resp); respStr = JsonUtils.getInstance().toJsonStringNullToEmpty(result);
}
return AjaxResult.success("success", respStr);
} }
/** /**
@ -454,6 +454,17 @@ public class SDEnregyServiceImpl extends SDEnregyServiceAbstract {
} }
} }
@Override
public String syncMdmGroupTaxService(List<MdmSyncGroupTaxCodeReqBO> taxxtbReqBOS){
AjaxResult syncResult = this.syncMdmGroupTax(taxxtbReqBOS,null);
if (syncResult.isSuccess()) {
return "";
} else {
// return R.error();
return null;
}
}
/** /**
* 主动同步购方信息 * 主动同步购方信息
* *

Loading…
Cancel
Save