Browse Source

班组

master
廉洪喜 2 years ago
parent
commit
1c0fe3f0a7
  1. 3
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/ShiftController.java
  2. 63
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/vo/ShiftImportErrorVO.java
  3. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/vo/ShiftImportExcelVo.java
  4. 4
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/shift/ShiftConvert.java
  5. 2
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/shift/ShiftService.java
  6. 114
      win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/shift/ShiftServiceImpl.java

3
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/ShiftController.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.carrier.vo.CarrierRespVO;
import com.win.module.wms.controller.itembasic.vo.ItembasicExcelVO;
import com.win.module.wms.controller.shift.vo.*;
@ -177,7 +178,7 @@ public class ShiftController {
@RequestParam(value = "mode") Integer mode,
@RequestParam(value = "updatePart", required = false, defaultValue = "false") Boolean updatePart) throws Exception {
List<ShiftImportExcelVo> list = ExcelUtils.read(file, ShiftImportExcelVo.class);
List<ShiftImportExcelVo> errorList = shiftService.importShiftList(list, mode, updatePart);
List<ShiftImportErrorVO> errorList = shiftService.importShiftList(list, mode, updatePart);
Map<String, Object> returnMap = new HashMap<>();
returnMap.put("errorCount", errorList.size());
if(!errorList.isEmpty()) {

63
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/vo/ShiftImportErrorVO.java

@ -0,0 +1,63 @@
package com.win.module.wms.controller.shift.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 ShiftImportErrorVO {
@ExcelProperty("代码")
private String code;
@ExcelProperty("名称")
private String name;
@ExcelProperty("描述")
private String description;
@ExcelProperty(value = "开始时间")
@ColumnWidth(value = 16)
private LocalDateTime beginTime;
@ExcelProperty(value = "结束时间")
@ColumnWidth(value = 16)
private LocalDateTime entTime;
@ExcelProperty(value = "生效时间")
@ColumnWidth(value = 16)
private LocalDateTime activeTime;
@ExcelProperty(value = "失效时间")
@ColumnWidth(value = 16)
private LocalDateTime expireTime;
@ExcelProperty(value = "备注")
private String remark;
@ExcelProperty(value = "是否跨天", converter = DictConvert.class)
@DictFormat(DictTypeConstants.TRUE_FALSE)
private String endAtNextDay;
@ExcelProperty(value = "是否可用", converter = DictConvert.class)
@DictFormat(DictTypeConstants.TRUE_FALSE)
private String available;
@ExcelProperty(value = "导入状态", index = 0)
private String importStatus;
@ExcelProperty(value = "导入说明", index = 1)
private String importRemark;
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/controller/shift/vo/ShiftImportExcelVo.java

@ -53,7 +53,7 @@ public class ShiftImportExcelVo {
@ColumnWidth(value = 16)
private LocalDateTime expireTime;
@ExcelProperty(value = "备注")
@ExcelProperty("备注")
private String remark;
@ExcelProperty(value = "是否跨天", converter = DictConvert.class)

4
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/convert/shift/ShiftConvert.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.shift.vo.ShiftCreateReqVO;
import com.win.module.wms.controller.shift.vo.ShiftExcelVO;
import com.win.module.wms.controller.shift.vo.ShiftRespVO;
@ -36,4 +38,6 @@ public interface ShiftConvert {
ShiftDO convert(ShiftImportExcelVo bean);
ShiftImportErrorVO convert2(ShiftDO bean);
}

2
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/shift/ShiftService.java

@ -84,6 +84,6 @@ public interface ShiftService {
*/
List<ShiftDO> getShiftList(ShiftExportReqVO exportReqVO);
List<ShiftImportExcelVo> importShiftList(List<ShiftImportExcelVo> importTeam, Integer mode, boolean updatePart);
List<ShiftImportErrorVO> importShiftList(List<ShiftImportExcelVo> importTeam, Integer mode, boolean updatePart);
}

114
win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/shift/ShiftServiceImpl.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.shift.vo.*;
import com.win.module.wms.convert.bom.BomConvert;
import com.win.module.wms.convert.shift.ShiftConvert;
import com.win.module.wms.dal.dataobject.bom.BomDO;
import com.win.module.wms.dal.dataobject.shift.ShiftDO;
import com.win.module.wms.dal.mysql.shift.ShiftMapper;
import org.springframework.stereotype.Service;
@ -102,68 +104,70 @@ public class ShiftServiceImpl implements ShiftService {
return shiftMapper.selectSenior(conditions);
}
private String validateShiftImport( ShiftDO shift ){
StringBuilder message = new StringBuilder();
try {
validateShiftExists(null);
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateCodeExists(null, shift.getCode());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateBeginTimeExists(shift.getBeginTime());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateEndTimeExists(shift.getEntTime());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateEndatnextDayExists(shift.getEndAtNextDay());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
try {
validateAvailableExists(shift.getAvailable());
} catch (ServiceException ex) {
message.append(ex.getMessage()).append(",");
}
return message.toString();
}
public List<ShiftImportExcelVo> importShiftList(List<ShiftImportExcelVo> shifts, Integer mode, boolean updatePart) {
public List<ShiftImportErrorVO> importShiftList(List<ShiftImportExcelVo> shifts, Integer mode, boolean updatePart) {
if (CollUtil.isEmpty(shifts)) {
throw exception(SHIFT_IMPORT_LIST_IS_EMPTY);
}
List<ShiftImportExcelVo> errorList = new ArrayList<>();
List<ShiftImportErrorVO> errorList = new ArrayList<>();
shifts.forEach(shift -> {
// 校验,判断是否有不符合的原因
String massage = "";
if(mode != null) {
try {
validateShiftExists(null);
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateCodeExists(null, shift.getCode());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateBeginTimeExists(shift.getBeginTime());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateEndTimeExists(shift.getEntTime());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateEndatnextDayExists(shift.getEndAtNextDay());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
try {
validateAvailableExists(shift.getAvailable());
} catch (ServiceException ex) {
massage += ex.getMessage() + ",";
}
if (StrUtil.isNotEmpty(massage)) {
massage.substring(0, massage.length() - 1);
errorList.add(shift);
}
if (errorList == null) {
// 判断如果不存在,在进行插入
ShiftDO existShift = shiftMapper.selectByCode(shift.getCode());
if (existShift == null && mode != 3) {
shiftMapper.insert(ShiftConvert.INSTANCE.convert(shift));
} else if (existShift != null && mode != 2) {// 如果存在,判断是否允许更新
ShiftDO shiftDO = ShiftConvert.INSTANCE.convert(shift);
shiftDO.setId(existShift.getId());
shiftMapper.updateById(shiftDO);
}
}
ShiftDO shiftDO = ShiftConvert.INSTANCE.convert(shift);
String message = this.validateShiftImport(shiftDO);
boolean flag = true;
if(!message.isEmpty()){
ShiftImportErrorVO importErrorVO = ShiftConvert.INSTANCE.convert2(shiftDO);
importErrorVO.setImportStatus("失败");
importErrorVO.setImportRemark(message.substring(0, message.length() - 1));
errorList.add(importErrorVO);
flag = false;
}
if(flag){
// 判断如果不存在,在进行插入
ShiftDO existShift = shiftMapper.selectByCode(shift.getCode());
if (existShift == null && mode != 3) {
shiftMapper.insert(ShiftConvert.INSTANCE.convert(shift));
} else if (existShift != null && mode != 2) {
// 如果存在,判断是否允许更新
shiftDO.setId(existShift.getId());
shiftMapper.updateById(shiftDO);
}
}
});
//错误不为空并非部分更新,手工回滚
if(!errorList.isEmpty() && !updatePart) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return errorList;
}

Loading…
Cancel
Save