Browse Source

客户月台代码

master
廉洪喜 2 years ago
parent
commit
90eeb93586
  1. 3
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customerdock/CustomerdockController.java
  2. 68
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customerdock/vo/CustomerdockImportErrorVO.java
  3. 4
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/customerdock/CustomerdockConvert.java
  4. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customerdock/CustomerdockService.java
  5. 106
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customerdock/CustomerdockServiceImpl.java

3
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customerdock/CustomerdockController.java

@ -8,6 +8,7 @@ import com.win.framework.excel.core.util.ExcelUtils;
import com.win.framework.operatelog.core.annotations.OperateLog;
import com.win.module.system.api.user.AdminUserApi;
import com.win.module.system.api.user.dto.AdminUserRespDTO;
import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.customerdock.vo.*;
import com.win.module.wms.convert.customerdock.CustomerdockConvert;
import com.win.module.wms.dal.dataobject.customerdock.CustomerdockDO;
@ -161,7 +162,7 @@ public class CustomerdockController {
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<CustomerdockImportExcelVo> list = ExcelUtils.read(file, CustomerdockImportExcelVo.class);
List<CustomerdockImportExcelVo> errorList = customerdockService.importCustomerdockList(list, mode, updatePart);
List<CustomerdockImportErrorVO> errorList = customerdockService.importCustomerdockList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {

68
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customerdock/vo/CustomerdockImportErrorVO.java

@ -0,0 +1,68 @@
package com.win.module.wms.controller.customerdock.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.win.framework.excel.core.annotations.DictFormat;
import com.win.framework.excel.core.convert.DictConvert;
import com.win.module.wms.enums.DictTypeConstants;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Builder
@ToString(callSuper = true)
public class CustomerdockImportErrorVO {
@ExcelProperty("代码")
private String code;
@ExcelProperty("名称")
private String name;
@ExcelProperty("描述")
private String description;
@ExcelProperty("城市")
private String city;
@ExcelProperty("地址")
private String address;
@ExcelProperty("联系人姓名")
private String contactPerson;
@ExcelProperty("联系人电话")
private String contactPhone;
@ExcelProperty("客户代码")
private String customerCode;
@ExcelProperty("仓库")
private String warehouseCode;
@ExcelProperty("默认库位")
private String defaultLocationCode;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.TRUE_FALSE)
private String available;
@ExcelProperty("生效时间")
@ColumnWidth(value = 16)
private LocalDateTime activeTime;
@ExcelProperty("失效时间")
@ColumnWidth(value = 16)
private LocalDateTime expireTime;
@ExcelProperty("备注")
private String remark;
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 1)
private String importRemark;
}

4
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/customerdock/CustomerdockConvert.java

@ -1,6 +1,8 @@
package com.win.module.wms.convert.customerdock;
import com.win.framework.common.pojo.PageResult;
import com.win.module.wms.controller.bom.vo.BomImportErrorVO;
import com.win.module.wms.controller.bom.vo.BomImportExcelVo;
import com.win.module.wms.controller.customerdock.vo.*;
import com.win.module.wms.dal.dataobject.customerdock.CustomerdockDO;
import org.mapstruct.Mapper;
@ -31,4 +33,6 @@ public interface CustomerdockConvert {
List<CustomerdockExcelVO> convertList02(List<CustomerdockDO> list);
CustomerdockDO convert(CustomerdockImportExcelVo customerdock);
CustomerdockImportErrorVO convert2(CustomerdockDO bean);
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customerdock/CustomerdockService.java

@ -85,7 +85,7 @@ public interface CustomerdockService {
*/
List<CustomerdockDO> getCustomerdockList(CustomerdockExportReqVO exportReqVO);
List<CustomerdockImportExcelVo> importCustomerdockList(List<CustomerdockImportExcelVo> customerdocks, Integer mode, Boolean updatePart);
List<CustomerdockImportErrorVO> importCustomerdockList(List<CustomerdockImportExcelVo> customerdocks, Integer mode, Boolean updatePart);
/**
* 客户地点(月台)有效,状态正确

106
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customerdock/CustomerdockServiceImpl.java

@ -9,7 +9,9 @@ import com.win.framework.common.pojo.CustomConditions;
import com.win.framework.common.pojo.PageResult;
import com.win.framework.datapermission.core.util.DataPermissionUtils;
import com.win.module.wms.controller.customerdock.vo.*;
import com.win.module.wms.convert.bom.BomConvert;
import com.win.module.wms.convert.customerdock.CustomerdockConvert;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import com.win.module.wms.dal.dataobject.currencyexchange.CurrencyexchangeDO;
import com.win.module.wms.dal.dataobject.customerdock.CustomerdockDO;
import com.win.module.wms.dal.mysql.customerdock.CustomerdockMapper;
@ -99,61 +101,69 @@ public class CustomerdockServiceImpl implements CustomerdockService {
return customerdockMapper.selectList(exportReqVO);
}
private String validateCustomerdockImport( CustomerdockDO customerdock ){
StringBuilder message = new StringBuilder();
try {
validateCustomerExists(null);
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCodeExists(null,customerdock.getCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
} try {
validateCustomerCodeExists(customerdock.getCustomerCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateDefaultLocationCodeExists(customerdock.getDefaultLocationCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
} try {
validateAvailableExists(customerdock.getAvailable());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
return message.toString();
}
public CustomerdockDO existCustomerdockDO( CustomerdockDO customerdockDO){
QueryWrapper<CustomerdockDO> queryWrapper = new QueryWrapper();
queryWrapper.eq("code",customerdockDO.getCode());
queryWrapper.eq("customer_code",customerdockDO.getCustomerCode());
CustomerdockDO customerdock = customerdockMapper.selectOne(queryWrapper);
return customerdock;
}
@Override
public List<CustomerdockImportExcelVo> importCustomerdockList(List<CustomerdockImportExcelVo> customerdocks, Integer mode, Boolean updatePart) {
public List<CustomerdockImportErrorVO> importCustomerdockList(List<CustomerdockImportExcelVo> customerdocks, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(customerdocks)) {
throw exception(CUSTOMERDOCK_IMPORT_LIST_IS_EMPTY);
}
List<CustomerdockImportExcelVo> errorList = new ArrayList<>();
List<CustomerdockImportErrorVO> errorList = new ArrayList<>();
customerdocks.forEach(customerdock -> {
String massage = "";
// 校验,判断是否有不符合的原因
if(mode != null){
try {
validateCustomerExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCodeExists(null,customerdock.getCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
} try {
validateCustomerCodeExists(customerdock.getCustomerCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateDefaultLocationCodeExists(customerdock.getDefaultLocationCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
} try {
validateAvailableExists(customerdock.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
} if(StrUtil.isNotEmpty(massage)){
massage.substring(0,massage.length()-1);
errorList.add(customerdock);
}
if(errorList == null){
// 判断如果不存在,在进行插入
CurrencyexchangeDO existConfigurationSetting = null;
if (existConfigurationSetting == null&& mode != 3) {
customerdockMapper.insert(CustomerdockConvert.INSTANCE.convert(customerdock));
}
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
CustomerdockDO customerdockDO = CustomerdockConvert.INSTANCE.convert(customerdock);
customerdockDO.setId(existConfigurationSetting.getId());
customerdockMapper.updateById(customerdockDO);
}
CustomerdockDO customerdockDO = CustomerdockConvert.INSTANCE.convert(customerdock);
String message =validateCustomerdockImport(customerdockDO);
boolean flag = true;
if(!message.isEmpty()){
CustomerdockImportErrorVO importErrorVO = CustomerdockConvert.INSTANCE.convert2(customerdockDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
if(flag){
CustomerdockDO existcustomerdockDO = existCustomerdockDO(customerdockDO);
if(existcustomerdockDO==null&& mode !=3){
customerdockMapper.insert(customerdockDO);
} else if(existcustomerdockDO != null&& mode !=2){
customerdockDO.setId(existcustomerdockDO.getId());
customerdockMapper.updateById(customerdockDO);
}
}
});
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}

Loading…
Cancel
Save