Browse Source

销售价格单

master
hongxi.lian 12 months ago
parent
commit
3c1dacd8a5
  1. 3
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/saleprice/SalepriceController.java
  2. 53
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/saleprice/vo/SalepriceImportErrorVO.java
  3. 4
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/saleprice/SalepriceConvert.java
  4. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/saleprice/SalepriceService.java
  5. 117
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/saleprice/SalepriceServiceImpl.java

3
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/saleprice/SalepriceController.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.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.controller.project.vo.ProjectRespVO;
import com.win.module.wms.controller.saleprice.vo.*;
@ -179,7 +180,7 @@ public class SalepriceController {
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<SalepriceImportExcelVo> list = ExcelUtils.read(file, SalepriceImportExcelVo.class);
List<SalepriceImportExcelVo> errorList = salepriceService.importSalepriceList(list, mode, updatePart);
List<SalepriceImportErrorVO> errorList = salepriceService.importSalepriceList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {

53
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/saleprice/vo/SalepriceImportErrorVO.java

@ -0,0 +1,53 @@
package com.win.module.wms.controller.saleprice.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 SalepriceImportErrorVO {
@ExcelProperty("客户代码")
private String customerCode;
@ExcelProperty("物料代码")
private String itemCode;
@ExcelProperty(value = "货币", converter = DictConvert.class)
@DictFormat(DictTypeConstants.CURRENCY)
private String currency;
@ExcelProperty("价格")
private BigDecimal price;
@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("备注")
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/saleprice/SalepriceConvert.java

@ -4,6 +4,8 @@ import java.util.*;
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.saleprice.vo.SalepriceCreateReqVO;
import com.win.module.wms.controller.saleprice.vo.SalepriceExcelVO;
import com.win.module.wms.controller.saleprice.vo.SalepriceRespVO;
@ -36,4 +38,6 @@ public interface SalepriceConvert {
SalepriceDO convert(SalepriceImportExcelVo bean);
SalepriceImportErrorVO convert2(SalepriceDO bean);
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/saleprice/SalepriceService.java

@ -79,7 +79,7 @@ public interface SalepriceService {
*/
List<SalepriceDO> getSalepriceList(SalepriceExportReqVO exportReqVO);
List<SalepriceImportExcelVo> importSalepriceList(List<SalepriceImportExcelVo> importTeam, Integer mode, boolean updatePart);
List<SalepriceImportErrorVO> importSalepriceList(List<SalepriceImportExcelVo> importTeam, Integer mode, boolean updatePart);
/**
* 查询销售价格单

117
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/saleprice/SalepriceServiceImpl.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.saleprice.vo.*;
import com.win.module.wms.convert.bom.BomConvert;
import com.win.module.wms.convert.saleprice.SalepriceConvert;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO;
import com.win.module.wms.dal.dataobject.saleprice.SalepriceDO;
import com.win.module.wms.dal.mysql.saleprice.SalepriceMapper;
@ -88,67 +90,72 @@ public class SalepriceServiceImpl implements SalepriceService {
return salepriceMapper.selectList(exportReqVO);
}
public List<SalepriceImportExcelVo> importSalepriceList(List<SalepriceImportExcelVo> saleprices, Integer mode, boolean updatePart) {
private String validateSalepriceImport( SalepriceDO saleprice ){
StringBuilder message = new StringBuilder();
try {
validateSalepriceExists(null);
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCodeExists(null, saleprice.getItemCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCustomerCodeExists(saleprice.getCustomerCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCurrencyExists(saleprice.getCurrency());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validatePriceExists(saleprice.getPrice());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateAvailableExists(saleprice.getAvailable());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
return message.toString();
}
public List<SalepriceImportErrorVO> importSalepriceList(List<SalepriceImportExcelVo> saleprices, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(saleprices)) {
throw exception(SALEPRICE_IMPORT_LIST_IS_EMPTY);
}
List<SalepriceImportExcelVo> errorList = new ArrayList<>();
List<SalepriceImportErrorVO> errorList = new ArrayList<>();
saleprices.forEach(saleprice -> {
SalepriceDO salepriceDO = SalepriceConvert.INSTANCE.convert(saleprice);
// 校验,判断是否有不符合的原因
String massage = "";
if (mode != null) {
try {
validateSalepriceExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCodeExists(null, saleprice.getItemCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCustomerCodeExists(saleprice.getCustomerCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCurrencyExists(saleprice.getCurrency());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validatePriceExists(saleprice.getPrice());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAvailableExists(saleprice.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
if (StrUtil.isNotEmpty(massage)) {
massage.substring(0, massage.length() - 1);
errorList.add(saleprice);
}
if (errorList == null) {
// 判断如果不存在,在进行插入
SalepriceDO existSaleprice = salepriceMapper.selectByItemCode(saleprice.getItemCode());
if (existSaleprice == null && mode != 3) {
salepriceMapper.insert(SalepriceConvert.INSTANCE.convert(saleprice));
} else if (existSaleprice != null && mode != 2) {// 如果存在,判断是否允许更新
SalepriceDO salepriceDO = SalepriceConvert.INSTANCE.convert(saleprice);
salepriceDO.setId(existSaleprice.getId());
salepriceMapper.updateById(salepriceDO);
}
}
}
String message =validateSalepriceImport(salepriceDO);
boolean flag = true;
if(!message.isEmpty()){
// 判断如果不存在,在进行插入
SalepriceImportErrorVO importErrorVO = SalepriceConvert.INSTANCE.convert2(salepriceDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
if(flag) {
// 判断如果不存在,在进行插入
SalepriceDO existSaleprice = salepriceMapper.selectByItemCode(saleprice.getItemCode());
if (existSaleprice == null && mode != 3) {
salepriceMapper.insert(SalepriceConvert.INSTANCE.convert(saleprice));
} else if (existSaleprice != null && mode != 2) {
// 如果存在,判断是否允许更新
salepriceDO.setId(existSaleprice.getId());
salepriceMapper.updateById(salepriceDO);
}
}
});
//错误不为空并非部分更新,手工回滚
if (!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}

Loading…
Cancel
Save