Browse Source

客户物品

master
廉洪喜 2 years ago
parent
commit
e4ba073eaf
  1. 13
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customeritem/CustomeritemController.java
  2. 75
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customeritem/vo/CustomeritemImportErrorVO.java
  3. 4
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/customeritem/CustomeritemConvert.java
  4. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java
  5. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customeritem/CustomeritemService.java
  6. 77
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customeritem/CustomeritemServiceImpl.java

13
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customeritem/CustomeritemController.java

@ -8,14 +8,9 @@ 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.customerdock.vo.CustomerdockRespVO;
import com.win.module.wms.controller.customeritem.vo.*;
import com.win.module.wms.controller.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.convert.customerdock.CustomerdockConvert;
import com.win.module.wms.convert.customeritem.CustomeritemConvert;
import com.win.module.wms.convert.itembasic.ItembasicConvert;
import com.win.module.wms.dal.dataobject.customeritem.CustomeritemDO;
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO;
import com.win.module.wms.enums.DictTypeConstants;
import com.win.module.wms.service.customeritem.CustomeritemService;
import io.swagger.v3.oas.annotations.Operation;
@ -176,16 +171,18 @@ public class CustomeritemController {
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
})
@PreAuthorize("@ss.hasPermission('wms:customeritem:import')")
public void importExcel(HttpServletResponse response,
public CommonResult<Map<String, Object>> importExcel(HttpServletResponse response,
@RequestParam("file") MultipartFile file,
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<CustomeritemImportExcelVO> list = ExcelUtils.read(file, CustomeritemImportExcelVO.class);
List<CustomeritemImportExcelVO> errorList = customeritemService.CustomeritemimportCustomeritemList(list, mode, updatePart);
List<CustomeritemImportErrorVO> errorList = customeritemService.CustomeritemimportCustomeritemList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {
String url = ExcelUtils.writeLocalFile("客户物品导入错误数据" + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xls", "错误列表", errorList);
returnMap.put("errorFile", url);
}}
}
return success(returnMap);
}
}

75
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/customeritem/vo/CustomeritemImportErrorVO.java

@ -0,0 +1,75 @@
package com.win.module.wms.controller.customeritem.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 CustomeritemImportErrorVO {
@ExcelProperty("客户代码")
private String customerCode;
@ExcelProperty("物料代码")
private String itemCode;
@ExcelProperty("客户物料代码")
private String customerItemCode;
@ExcelProperty(value = "客户计量单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String cusotmerUom;
@ExcelProperty("转换率")
private String convertRate;
@ExcelProperty(value = "客户包装单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.PACK_UNIT)
private String packUnit;
@ExcelProperty("客户包装量")
private BigDecimal packQty;
@ExcelProperty(value = "客户替代包装单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.PACK_UNIT)
private String altPackUnit;
@ExcelProperty("客户替代包装量")
private String altPackQty;
@ExcelProperty("每器具包装数")
private Integer packQtyOfContainer;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.TRUE_FALSE)
private String available;
@ExcelProperty(value = "生效时间")
@ColumnWidth(value = 16)
private LocalDateTime activeTime;
@ExcelProperty(value = "失效时间")
@ColumnWidth(value = 16)
private LocalDateTime expireTime;
@ExcelProperty(value = "备注")
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/customeritem/CustomeritemConvert.java

@ -1,6 +1,8 @@
package com.win.module.wms.convert.customeritem;
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.customeritem.vo.*;
import com.win.module.wms.dal.dataobject.customeritem.CustomeritemDO;
import org.mapstruct.Mapper;
@ -32,4 +34,6 @@ public interface CustomeritemConvert {
List<CustomeritemExcelVO> convertList02(List<CustomeritemDO> list);
CustomeritemImportErrorVO convert2(CustomeritemDO bean);
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/bom/BomServiceImpl.java

@ -137,6 +137,8 @@ public class BomServiceImpl implements BomService {
return message.toString();
}
@Override
public List<BomImportErrorVO> importBomList(List<BomImportExcelVo> datas, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(datas)) {

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customeritem/CustomeritemService.java

@ -77,7 +77,7 @@ public interface CustomeritemService {
*/
List<CustomeritemDO> getCustomeritemList(CustomeritemExportReqVO exportReqVO);
List<CustomeritemImportExcelVO> CustomeritemimportCustomeritemList(List<CustomeritemImportExcelVO> customeritems, Integer mode, Boolean updatePart);
List<CustomeritemImportErrorVO> CustomeritemimportCustomeritemList(List<CustomeritemImportExcelVO> customeritems, Integer mode, Boolean updatePart);
/**
* 查询客户物品是否存在

77
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/customeritem/CustomeritemServiceImpl.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.customeritem.vo.*;
import com.win.module.wms.convert.bom.BomConvert;
import com.win.module.wms.convert.customeritem.CustomeritemConvert;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import com.win.module.wms.dal.dataobject.customeritem.CustomeritemDO;
import com.win.module.wms.dal.mysql.customeritem.CustomeritemMapper;
import org.springframework.stereotype.Service;
@ -93,74 +95,81 @@ public class CustomeritemServiceImpl implements CustomeritemService {
public List<CustomeritemDO> getCustomeritemList(CustomeritemExportReqVO exportReqVO) {
return customeritemMapper.selectList(exportReqVO);
}
@Override
public List<CustomeritemImportExcelVO> CustomeritemimportCustomeritemList(List<CustomeritemImportExcelVO> customeritems, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(customeritems)) {
throw exception(CUSTOMERITEM_IMPORT_LIST_IS_EMPTY);
}
List<CustomeritemImportExcelVO> errorList = new ArrayList<>();
customeritems.forEach(customeritem -> {
String massage = "";
// 校验,判断是否有不符合的原因
if(mode != null){
try {
validateCustomerExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
private String validateCustomeritemImport( CustomeritemDO customeritem ){
StringBuilder message = new StringBuilder();
try {
validateItemCodeExists(null,customeritem.getCustomerItemCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateCustomerCodeExists(customeritem.getCustomerCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validatePackUnitExists(customeritem.getPackUnit());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validatePackQtyExists(customeritem.getPackQty());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validatePackQtyOfContainerExists(customeritem.getPackQtyOfContainer());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateAvailableExists(customeritem.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
return message.toString();
}
if(StrUtil.isNotEmpty(massage)){
massage.substring(0,massage.length()-1);
errorList.add(customeritem);
public CustomeritemDO existcustomeritem( CustomeritemDO customeritem){
QueryWrapper<CustomeritemDO> queryWrapper = new QueryWrapper();
queryWrapper.eq("customer_code",customeritem.getCustomerCode());
queryWrapper.eq("item_code",customeritem.getItemCode());
CustomeritemDO customeritemDO = customeritemMapper.selectOne(queryWrapper);
return customeritemDO;
}
@Override
public List<CustomeritemImportErrorVO> CustomeritemimportCustomeritemList(List<CustomeritemImportExcelVO> customeritems, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(customeritems)) {
throw exception(CUSTOMERITEM_IMPORT_LIST_IS_EMPTY);
}
if(errorList == null){
List<CustomeritemImportErrorVO> errorList = new ArrayList<>();
customeritems.forEach(customeritem -> {
CustomeritemDO customeritemDO = CustomeritemConvert.INSTANCE.convert(customeritem);
String message = this.validateCustomeritemImport(customeritemDO);
boolean flag = true;
if(!message.isEmpty()){
CustomeritemImportErrorVO importErrorVO = CustomeritemConvert.INSTANCE.convert2(customeritemDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
if(flag) {
// 判断如果不存在,在进行插入
CustomeritemDO existConfigurationSetting = null;
CustomeritemDO existConfigurationSetting = existcustomeritem(customeritemDO);
if (existConfigurationSetting == null && mode != 3) {
customeritemMapper.insert(CustomeritemConvert.INSTANCE.convert(customeritem));
}
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
CustomeritemDO customeritemDO = CustomeritemConvert.INSTANCE.convert(customeritem);
} else if (existConfigurationSetting != null && mode != 2) {
// 如果存在,判断是否允许更新
customeritemDO.setId(existConfigurationSetting.getId());
customeritemMapper.updateById(customeritemDO);
}
}
});
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}

Loading…
Cancel
Save