Browse Source

基础数据 物品包装信息导入修改

master
廉洪喜 2 years ago
parent
commit
00816b42a9
  1. 24
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/ItempackagingController.java
  2. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingBaseVO.java
  3. 88
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingImportErrorVO.java
  4. 24
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingImportExcelVO.java
  5. 1
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/purchasePlan/vo/PurchasePlanDetailBaseVO.java
  6. 10
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/itempackaging/ItempackagingConvert.java
  7. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itempackaging/ItempackagingService.java
  8. 77
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itempackaging/ItempackagingServiceImpl.java
  9. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/purchasePlan/PurchasePlanDetailServiceImpl.java

24
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/ItempackagingController.java

@ -8,12 +8,8 @@ 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.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.controller.itembasic.vo.ItembasicRespVO;
import com.win.module.wms.controller.itempackaging.vo.*;
import com.win.module.wms.convert.itembasic.ItembasicConvert;
import com.win.module.wms.convert.itempackaging.ItempackagingConvert;
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO;
import com.win.module.wms.dal.dataobject.itempackaging.ItempackagingDO;
import com.win.module.wms.enums.DictTypeConstants;
import com.win.module.wms.service.itempackaging.ItempackagingService;
@ -173,17 +169,17 @@ public class ItempackagingController {
String[] uom = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(1, uom);
String[] description = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(2, description);;
mapDropDown.put(2, description);
String[] altPackUnit1 = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(5, altPackUnit1);;
mapDropDown.put(4, altPackUnit1);
String[] altPackUnit2 = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(7, altPackUnit2);;
mapDropDown.put(6, altPackUnit2);
String[] altPackUnit3 = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(9, altPackUnit3);;
mapDropDown.put(8, altPackUnit3);
String[] altPackUnit4 = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.UOM);
mapDropDown.put(11, altPackUnit4);;
mapDropDown.put(10, altPackUnit4);
String[] available = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRUE_FALSE);
mapDropDown.put(13, available);;
mapDropDown.put(12, available);
// 输出
ExcelUtils.write(response, "物品包装信息导入模板.xls", "物品包装信息列表", ItempackagingImportExcelVO.class, list,mapDropDown);
}
@ -196,16 +192,18 @@ public class ItempackagingController {
@Parameter(name = "updatePart", description = "部分更新,默认为 true", example = "true")
})
@PreAuthorize("@ss.hasPermission('wms:itempackaging: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<ItempackagingImportExcelVO> list = ExcelUtils.read(file, ItempackagingImportExcelVO.class);
List<ItempackagingImportExcelVO> errorList = itempackagingService.itempackagingimportDocumentList(list, mode, updatePart);
List<ItempackagingImportErrorVO> errorList = itempackagingService.itempackagingimportDocumentList(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);
}
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingBaseVO.java

@ -1,5 +1,6 @@
package com.win.module.wms.controller.itempackaging.vo;
import com.win.framework.excel.core.annotations.OnlyOne;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
@ -18,6 +19,7 @@ import static com.win.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY
public class ItempackagingBaseVO {
@Schema(description = "id", example = "id")
@OnlyOne
private Long id;
@Schema(description = "物品代码", requiredMode = Schema.RequiredMode.REQUIRED)

88
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingImportErrorVO.java

@ -0,0 +1,88 @@
package com.win.module.wms.controller.itempackaging.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;
/**
* 采购索赔申请子 Excel VO
*
* @author 超级管理员
*/
@Data
@Builder
@ToString(callSuper = true)
public class ItempackagingImportErrorVO {
@ExcelProperty("物品代码")
private String itemCode;
@ExcelProperty(value = "计量单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String uom;
@ExcelProperty(value = "包装单位", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String stdPackUnit;
@ExcelProperty("包装数量")
private BigDecimal stdPackQty;
@ExcelProperty(value = "替代包装单位1", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit1;
@ExcelProperty("替代包装量1")
private BigDecimal altPackQty1;
@ExcelProperty(value = "替代包装单位2", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit2;
@ExcelProperty("替代包装量2")
private BigDecimal altPackQty2;
@ExcelProperty(value = "替代包装单位3", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit3;
@ExcelProperty("替代包装量3")
private BigDecimal altPackQty3;
@ExcelProperty(value = "替代包装单位4", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit4;
@ExcelProperty("替代包装量4")
private BigDecimal altPackQty4;
@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;
}

24
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/itempackaging/vo/ItempackagingImportExcelVO.java

@ -35,33 +35,33 @@ public class ItempackagingImportExcelVO {
@ExcelProperty("包装数量")
private BigDecimal stdPackQty;
@ExcelProperty(value = "替代包装单位", converter = DictConvert.class)
@ExcelProperty(value = "替代包装单位1", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit1;
@ExcelProperty("替代包装量")
private String altPackQty1;
@ExcelProperty("替代包装量1")
private BigDecimal altPackQty1;
@ExcelProperty(value = "替代包装单位", converter = DictConvert.class)
@ExcelProperty(value = "替代包装单位2", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit2;
@ExcelProperty("替代包装量")
private String altPackQty2;
@ExcelProperty("替代包装量2")
private BigDecimal altPackQty2;
@ExcelProperty(value = "替代包装单位", converter = DictConvert.class)
@ExcelProperty(value = "替代包装单位3", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit3;
@ExcelProperty("替代包装量")
private String altPackQty3;
@ExcelProperty("替代包装量3")
private BigDecimal altPackQty3;
@ExcelProperty(value = "替代包装单位", converter = DictConvert.class)
@ExcelProperty(value = "替代包装单位4", converter = DictConvert.class)
@DictFormat(DictTypeConstants.UOM)
private String altPackUnit4;
@ExcelProperty("替代包装量")
private String altPackQty4;
@ExcelProperty("替代包装量4")
private BigDecimal altPackQty4;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.TRUE_FALSE)

1
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/purchasePlan/vo/PurchasePlanDetailBaseVO.java

@ -40,7 +40,6 @@ public class PurchasePlanDetailBaseVO {
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "创建时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;

10
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/itempackaging/ItempackagingConvert.java

@ -2,8 +2,15 @@ package com.win.module.wms.convert.itempackaging;
import com.win.framework.common.pojo.PageResult;
import com.win.module.wms.controller.itempackaging.vo.*;
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestMainCreateReqVO;
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestMainExcelVO;
import com.win.module.wms.controller.purchasereceiptRequest.vo.PurchasereceiptRequestMainImportErrorVO;
import com.win.module.wms.dal.dataobject.itempackaging.ItempackagingDO;
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestDetailDO;
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestMainDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
import java.util.List;
@ -31,4 +38,7 @@ public interface ItempackagingConvert {
List<ItempackagingExcelVO> convertList02(List<ItempackagingDO> list);
ItempackagingDO convert(ItempackagingImportExcelVO itempackaging);
ItempackagingImportErrorVO convert2(ItempackagingImportExcelVO bean);
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itempackaging/ItempackagingService.java

@ -78,7 +78,7 @@ public interface ItempackagingService {
*/
List<ItempackagingDO> getItempackagingList(ItempackagingExportReqVO exportReqVO);
List<ItempackagingImportExcelVO> itempackagingimportDocumentList(List<ItempackagingImportExcelVO> itempackagings, Integer mode, Boolean updatePart);
List<ItempackagingImportErrorVO> itempackagingimportDocumentList(List<ItempackagingImportExcelVO> list , Integer mode, Boolean updatePart);
/**
* BQ----QIP

77
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itempackaging/ItempackagingServiceImpl.java

@ -13,13 +13,11 @@ import com.win.module.wms.convert.itempackaging.ItempackagingConvert;
import com.win.module.wms.dal.dataobject.itempackaging.ItempackagingDO;
import com.win.module.wms.dal.mysql.itempackaging.ItempackagingMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -88,68 +86,64 @@ public class ItempackagingServiceImpl implements ItempackagingService {
public PageResult<ItempackagingDO> getItempackagingSenior(CustomConditions conditions) {
return itempackagingMapper.selectSenior(conditions);
}
@Override
public List<ItempackagingImportExcelVO> itempackagingimportDocumentList(List<ItempackagingImportExcelVO> itempackagings, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(itempackagings)) {
throw exception(ITEMPACKAGING_IMPORT_LIST_IS_EMPTY);
}
List<ItempackagingImportExcelVO> errorList = new ArrayList<>();
itempackagings.forEach(itempackaging -> {
String massage = "";
// 校验,判断是否有不符合的原因
if(mode != null){
private String validateItempackagingImport(ItempackagingDO itempackagingDO) {
StringBuilder message = new StringBuilder();
try {
validateItempackagingExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateItemCodeExists(null,itempackaging.getItemCode());
validateItemCodeExists(null,itempackagingDO.getItemCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateUomExists(itempackaging.getUom());
validateUomExists(itempackagingDO.getUom());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateStdPackUnitExists(itempackaging.getStdPackUnit());
validateStdPackUnitExists(itempackagingDO.getStdPackUnit());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateStdPackQtyExists(itempackaging.getStdPackQty());
validateStdPackQtyExists(itempackagingDO.getStdPackQty());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
message.append(ex.getMessage()).append(",");
}
try {
validateAvailableExists(itempackaging.getAvailable());
validateAvailableExists(itempackagingDO.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
message.append(ex.getMessage()).append(",");
}
if(StrUtil.isNotEmpty(massage)){
massage.substring(0,massage.length()-1);
errorList.add(itempackaging);
return message.toString();
}
if(errorList == null){
// 判断如果不存在,在进行插入
ItempackagingDO existConfigurationSetting = null;
if (existConfigurationSetting == null&& mode != 3) {
itempackagingMapper.insert(ItempackagingConvert.INSTANCE.convert(itempackaging));
}
else if (existConfigurationSetting != null && mode != 2) {// 如果存在,判断是否允许更新
ItempackagingDO itempackagingMapperDO = ItempackagingConvert.INSTANCE.convert(itempackaging);
itempackagingMapperDO.setId(existConfigurationSetting.getId());
itempackagingMapper.updateById(itempackagingMapperDO);
@Override
public List<ItempackagingImportErrorVO> itempackagingimportDocumentList(List<ItempackagingImportExcelVO> datas, Integer mode, Boolean updatePart) {
if (CollUtil.isEmpty(datas)) {
throw exception(ITEMPACKAGING_IMPORT_LIST_IS_EMPTY);
}
List<ItempackagingImportErrorVO> errorList = new ArrayList<>();
datas.forEach(createReqVO -> {
ItempackagingDO itempackagingDO = ItempackagingConvert.INSTANCE.convert(createReqVO);
String message = this.validateItempackagingImport(itempackagingDO);
// 是否有错误数据
boolean flag = true;
if(!message.isEmpty()){
ItempackagingImportErrorVO importErrorVO = ItempackagingConvert.INSTANCE.convert2(createReqVO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
//写入数据
if(flag) {
itempackagingMapper.insert(itempackagingDO);
}
});
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}
@ -220,6 +214,7 @@ public class ItempackagingServiceImpl implements ItempackagingService {
throw exception(ITEMPACKAGING_AVAILABLE_NOT_EXISTS);
}
}
@Override
public ItempackagingDO selectItemPackagingExist(String pitemCode){
QueryWrapper queryWrapper = new QueryWrapper();

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/purchasePlan/PurchasePlanDetailServiceImpl.java

@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.*;
import com.win.module.wms.dal.dataobject.purchasePlan.PurchasePlanDetailDO;
@ -36,6 +37,7 @@ public class PurchasePlanDetailServiceImpl implements PurchasePlanDetailService
public Long createPurchasePlanDetail(PurchasePlanDetailCreateReqVO createReqVO) {
// 插入
PurchasePlanDetailDO purchasePlanDetail = PurchasePlanDetailConvert.INSTANCE.convert(createReqVO);
purchasePlanDetail.setCreateTime(LocalDateTime.now());
purchasePlanDetailMapper.insert(purchasePlanDetail);
// 返回
return purchasePlanDetail.getId();

Loading…
Cancel
Save