|
@ -8,10 +8,14 @@ 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.accountcalendar.vo.*; |
|
|
import com.win.module.wms.controller.accountcalendar.vo.*; |
|
|
|
|
|
import com.win.module.wms.controller.bom.vo.BomImportErrorVO; |
|
|
import com.win.module.wms.convert.accountcalendar.AccountcalendarConvert; |
|
|
import com.win.module.wms.convert.accountcalendar.AccountcalendarConvert; |
|
|
|
|
|
import com.win.module.wms.convert.bom.BomConvert; |
|
|
import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; |
|
|
import com.win.module.wms.dal.dataobject.accountcalendar.AccountcalendarDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.bom.BomDO; |
|
|
import com.win.module.wms.dal.mysql.accountcalendar.AccountcalendarMapper; |
|
|
import com.win.module.wms.dal.mysql.accountcalendar.AccountcalendarMapper; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
@ -37,14 +41,15 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { |
|
|
private AccountcalendarMapper accountcalendarMapper; |
|
|
private AccountcalendarMapper accountcalendarMapper; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
public Long createAccountcalendar(AccountcalendarCreateReqVO createReqVO) { |
|
|
public Long createAccountcalendar(AccountcalendarCreateReqVO createReqVO) { |
|
|
validateAccountcalendarForCreateOrUpdate(createReqVO.getId(),createReqVO.getAvailable()); |
|
|
validateAccountcalendarForCreateOrUpdate(createReqVO.getId(),createReqVO.getAvailable()); |
|
|
// 插入
|
|
|
// 插入
|
|
|
AccountcalendarDO accountcalendar = AccountcalendarConvert.INSTANCE.convert(createReqVO); |
|
|
AccountcalendarDO accountCalendar = AccountcalendarConvert.INSTANCE.convert(createReqVO); |
|
|
validateAccountcalendarForCreateOrUpdate(null,createReqVO.getAvailable()); |
|
|
validateAccountcalendarForCreateOrUpdate(null,createReqVO.getAvailable()); |
|
|
accountcalendarMapper.insert(accountcalendar); |
|
|
accountcalendarMapper.insert(accountCalendar); |
|
|
// 返回
|
|
|
// 返回
|
|
|
return accountcalendar.getId(); |
|
|
return accountCalendar.getId(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -88,47 +93,50 @@ public class AccountcalendarServiceImpl implements AccountcalendarService { |
|
|
return accountcalendarMapper.selectList(exportReqVO); |
|
|
return accountcalendarMapper.selectList(exportReqVO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<AccountcalendarImportExcelVo> importAccountcalendarList(List<AccountcalendarImportExcelVo> importAccountcalendars, Integer mode, boolean updatePart) { |
|
|
public String validateAccountcalendarImport(AccountcalendarDO importAccountcalendar){ |
|
|
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
|
|
|
try { |
|
|
|
|
|
validateAccountcalendarExists(null); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
try { |
|
|
|
|
|
validateAvailableExists(importAccountcalendar.getAvailable()); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
return message.toString(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<AccountcalendarImportErrorVO> importAccountcalendarList(List<AccountcalendarImportExcelVo> importAccountcalendars, Integer mode, boolean updatePart) { |
|
|
if (CollUtil.isEmpty(importAccountcalendars)) { |
|
|
if (CollUtil.isEmpty(importAccountcalendars)) { |
|
|
throw exception(ACCOUNTCALENDAR_IMPORT_LIST_IS_EMPTY); |
|
|
throw exception(ACCOUNTCALENDAR_IMPORT_LIST_IS_EMPTY); |
|
|
} |
|
|
} |
|
|
List<AccountcalendarImportExcelVo> errorList = new ArrayList<>(); |
|
|
List<AccountcalendarImportErrorVO> errorList = new ArrayList<>(); |
|
|
importAccountcalendars.forEach(importAccountcalendar -> { |
|
|
importAccountcalendars.forEach(importAccountcalendar -> { |
|
|
String massage = ""; |
|
|
AccountcalendarDO accountcalendarDO = AccountcalendarConvert.INSTANCE.convert(importAccountcalendar); |
|
|
// 校验,判断是否有不符合的原因
|
|
|
String massage = this.validateAccountcalendarImport(accountcalendarDO); |
|
|
if(mode != null){ |
|
|
boolean flag = true; |
|
|
try { |
|
|
if(!massage.isEmpty()){ |
|
|
validateAccountcalendarExists(null); |
|
|
AccountcalendarImportErrorVO importErrorVO =AccountcalendarConvert.INSTANCE.convert2(accountcalendarDO); |
|
|
} catch (ServiceException ex) { |
|
|
importErrorVO.setImportStatus("失败"); |
|
|
massage += ex.getMessage() + ","; |
|
|
importErrorVO.setImportRemark(massage.substring(0, massage.length() - 1)); |
|
|
} |
|
|
errorList.add(importErrorVO); |
|
|
try { |
|
|
flag = false; |
|
|
validateAvailableExists(importAccountcalendar.getAvailable()); |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
massage += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
if(StrUtil.isNotEmpty(massage)){ |
|
|
if(flag){ |
|
|
massage.substring(0,massage.length()-1); |
|
|
|
|
|
errorList.add(importAccountcalendar); |
|
|
|
|
|
} |
|
|
if ( mode != 3) { |
|
|
if(errorList == null){ |
|
|
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
|
|
AccountcalendarDO existAccountcalendar = new AccountcalendarDO(); |
|
|
|
|
|
if (existAccountcalendar == null&& mode != 3) { |
|
|
|
|
|
accountcalendarMapper.insert(AccountcalendarConvert.INSTANCE.convert(importAccountcalendar)); |
|
|
accountcalendarMapper.insert(AccountcalendarConvert.INSTANCE.convert(importAccountcalendar)); |
|
|
} |
|
|
} |
|
|
else if (existAccountcalendar != null && mode != 2) {// 如果存在,判断是否允许更新
|
|
|
else if ( mode != 2) { |
|
|
AccountcalendarDO accountcalendarDO = AccountcalendarConvert.INSTANCE.convert(importAccountcalendar); |
|
|
// 如果存在,判断是否允许更新
|
|
|
accountcalendarDO.setId(existAccountcalendar.getId()); |
|
|
|
|
|
accountcalendarMapper.updateById(accountcalendarDO); |
|
|
accountcalendarMapper.updateById(accountcalendarDO); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
|
|
} |
|
|
|
|
|
return errorList; |
|
|
return errorList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|