|
@ -7,8 +7,11 @@ import com.win.framework.common.exception.ServiceException; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
import com.win.framework.datapermission.core.util.DataPermissionUtils; |
|
|
|
|
|
import com.win.module.wms.controller.bom.vo.BomImportErrorVO; |
|
|
import com.win.module.wms.controller.systemcalendar.vo.*; |
|
|
import com.win.module.wms.controller.systemcalendar.vo.*; |
|
|
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
import com.win.module.wms.convert.systemcalendar.SystemcalendarConvert; |
|
|
import com.win.module.wms.convert.systemcalendar.SystemcalendarConvert; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
import com.win.module.wms.dal.dataobject.systemcalendar.SystemcalendarDO; |
|
|
import com.win.module.wms.dal.dataobject.systemcalendar.SystemcalendarDO; |
|
|
import com.win.module.wms.dal.mysql.systemcalendar.SystemcalendarMapper; |
|
|
import com.win.module.wms.dal.mysql.systemcalendar.SystemcalendarMapper; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
@ -83,53 +86,57 @@ public class SystemcalendarServiceImpl implements SystemcalendarService { |
|
|
public List<SystemcalendarDO> getSystemcalendarList(SystemcalendarExportReqVO exportReqVO) { |
|
|
public List<SystemcalendarDO> getSystemcalendarList(SystemcalendarExportReqVO exportReqVO) { |
|
|
return systemcalendarMapper.selectList(exportReqVO); |
|
|
return systemcalendarMapper.selectList(exportReqVO); |
|
|
} |
|
|
} |
|
|
public List<SystemcalendarImportExcelVo> importSystemcalendarList(List<SystemcalendarImportExcelVo> systemcalendars, Integer mode, boolean updatePart) { |
|
|
|
|
|
|
|
|
private String validateSystemcalendarImport( SystemcalendarDO systemcalendar ){ |
|
|
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
|
|
try { |
|
|
|
|
|
validateSystemcalendarExists(null); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
validateMoubleExists(systemcalendar.getModule()); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
validateAvailableExists(systemcalendar.getAvailable()); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
return message.toString(); |
|
|
|
|
|
} |
|
|
|
|
|
public List<SystemcalendarImportErrorVO> importSystemcalendarList(List<SystemcalendarImportExcelVo> systemcalendars, Integer mode, boolean updatePart) { |
|
|
if (CollUtil.isEmpty(systemcalendars)) { |
|
|
if (CollUtil.isEmpty(systemcalendars)) { |
|
|
throw exception(SYSTEMCALENDAR_IMPORT_LIST_IS_EMPTY); |
|
|
throw exception(SYSTEMCALENDAR_IMPORT_LIST_IS_EMPTY); |
|
|
} |
|
|
} |
|
|
List<SystemcalendarImportExcelVo> errorList = new ArrayList<>(); |
|
|
List<SystemcalendarImportErrorVO> errorList = new ArrayList<>(); |
|
|
systemcalendars.forEach(systemcalendar -> { |
|
|
systemcalendars.forEach(systemcalendar -> { |
|
|
|
|
|
SystemcalendarDO SystemcalendarDO = SystemcalendarConvert.INSTANCE.convert(systemcalendar); |
|
|
// 校验,判断是否有不符合的原因
|
|
|
// 校验,判断是否有不符合的原因
|
|
|
String massage = ""; |
|
|
String message = this.validateSystemcalendarImport(SystemcalendarDO); |
|
|
if (mode != null) { |
|
|
boolean flag = true; |
|
|
try { |
|
|
if(!message.isEmpty()){ |
|
|
validateSystemcalendarExists(null); |
|
|
SystemcalendarImportErrorVO importErrorVO = SystemcalendarConvert.INSTANCE.convert2(SystemcalendarDO); |
|
|
} catch (ServiceException ex) { |
|
|
importErrorVO.setImportStatus("失败"); |
|
|
massage += ex.getMessage() + ","; |
|
|
importErrorVO.setImportRemark(message.substring(0, message.length() - 1)); |
|
|
} |
|
|
errorList.add(importErrorVO); |
|
|
|
|
|
flag = false; |
|
|
try { |
|
|
} |
|
|
validateMoubleExists(systemcalendar.getModule()); |
|
|
if(flag){ |
|
|
} catch (ServiceException ex) { |
|
|
SystemcalendarDO existSystemcalendar = systemcalendarMapper.selectByModule(SystemcalendarDO.getModule()); |
|
|
massage += ex.getMessage() + ","; |
|
|
if (existSystemcalendar == null && mode != 3) { |
|
|
} |
|
|
systemcalendarMapper.insert(SystemcalendarConvert.INSTANCE.convert(systemcalendar)); |
|
|
try { |
|
|
} else if (existSystemcalendar != null && mode != 2) { |
|
|
validateAvailableExists(systemcalendar.getAvailable()); |
|
|
// 如果存在,判断是否允许更新
|
|
|
} catch (ServiceException ex) { |
|
|
SystemcalendarDO systemcalendarDO = SystemcalendarConvert.INSTANCE.convert(systemcalendar); |
|
|
massage += ex.getMessage() + ","; |
|
|
systemcalendarDO.setId(existSystemcalendar.getId()); |
|
|
} |
|
|
systemcalendarMapper.updateById(systemcalendarDO); |
|
|
if (StrUtil.isNotEmpty(massage)) { |
|
|
|
|
|
massage.substring(0, massage.length() - 1); |
|
|
|
|
|
errorList.add(systemcalendar); |
|
|
|
|
|
} |
|
|
|
|
|
if (errorList == null) { |
|
|
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
|
|
SystemcalendarDO existSystemcalendar = null; |
|
|
|
|
|
if (existSystemcalendar == null && mode != 3) { |
|
|
|
|
|
systemcalendarMapper.insert(SystemcalendarConvert.INSTANCE.convert(systemcalendar)); |
|
|
|
|
|
} else if (existSystemcalendar != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
|
|
|
SystemcalendarDO systemcalendarDO = SystemcalendarConvert.INSTANCE.convert(systemcalendar); |
|
|
|
|
|
systemcalendarDO.setId(existSystemcalendar.getId()); |
|
|
|
|
|
systemcalendarMapper.updateById(systemcalendarDO); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
|
} |
|
|
|
|
|
return errorList; |
|
|
return errorList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -158,7 +165,16 @@ public class SystemcalendarServiceImpl implements SystemcalendarService { |
|
|
if (mouble == null) { |
|
|
if (mouble == null) { |
|
|
throw exception(SYSTEMCALENDAR_MOUBLE_NOT_EXISTS); |
|
|
throw exception(SYSTEMCALENDAR_MOUBLE_NOT_EXISTS); |
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
SystemcalendarDO systemcalendarDO = systemcalendarMapper.selectByModule(mouble); |
|
|
|
|
|
if(systemcalendarDO!=null){ |
|
|
|
|
|
throw exception(SYSTEMCALENDAR_MOUBLE_NOT_EXISTS); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@VisibleForTesting |
|
|
@VisibleForTesting |
|
|
private void validateAvailableExists(String available) { |
|
|
private void validateAvailableExists(String available) { |
|
|
if (available == null) { |
|
|
if (available == null) { |
|
|