|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
+import com.jeeplus.test.reimbursementAccountant.utils.MyBeanUtils;
|
|
|
import com.jeeplus.test.reimbursementProject.domain.dto.ProjectReimbursementDTO;
|
|
|
import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementDTO;
|
|
|
import com.jeeplus.test.reimbursementsys.mapper.ReimbursementSysMapper;
|
|
@@ -33,6 +34,12 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
+ public IPage<ReimbursementDTO> findList(Page<ReimbursementDTO> page, ReimbursementDTO reimbursement) {
|
|
|
+ IPage<ReimbursementDTO> list = mapper.findList(page, reimbursement);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ReimbursementDTO queryBusinessById(String id) {
|
|
|
ReimbursementDTO reimbursementDTO = mapper.queryBusinessById(id);
|
|
|
//如果没有随即类型,则将随即类型默认为非随机(即指定业务编码)
|
|
@@ -47,6 +54,17 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
return mapper.queryInvoiceById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ReimbursementDTO queryBusinessByInvoiceId(String id) {
|
|
|
+ //根据发票id查询业务具体信息
|
|
|
+ ReimbursementDTO reimbursementDTO = mapper.queryBusinessByInvoiceId(id);
|
|
|
+ //如果没有随即类型,则将随即类型默认为非随机(即指定业务编码)
|
|
|
+ if(null != reimbursementDTO && StringUtils.isBlank(reimbursementDTO.getRandomType())){
|
|
|
+ reimbursementDTO.setRandomType("0");
|
|
|
+ }
|
|
|
+ return reimbursementDTO;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public IPage<ReimbursementDTO> treeData(Page<ReimbursementDTO> page, ReimbursementDTO reimbursement) {
|
|
@@ -59,6 +77,7 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
null != reimbursement.getEndDate() ||
|
|
|
StringUtils.isNotBlank(reimbursement.getBeginIncome()) ||
|
|
|
StringUtils.isNotBlank(reimbursement.getEndIncome()) ||
|
|
|
+ StringUtils.isNotBlank(reimbursement.getReimbursementBatch()) ||
|
|
|
StringUtils.isNotBlank(reimbursement.getFirmName())){
|
|
|
List<ReimbursementDTO> invoiceList = mapper.getInvoiceList(reimbursement);
|
|
|
//如果存在发票信息,则根据发票的父节点查询对应的业务信息
|
|
@@ -79,7 +98,14 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
for (String key : invoiceListMap.keySet()) {
|
|
|
if (info.getId().equals(key)) {
|
|
|
List<ReimbursementDTO> children = invoiceListMap.get(key);
|
|
|
- info.setChildren(children);
|
|
|
+ if(StringUtils.isNotBlank(info.getBusinessCode()) || "1".equals(info.getBatchFlag())){
|
|
|
+ info.setChildren(children);
|
|
|
+ info.setBusinessFlag("0");
|
|
|
+ }else{
|
|
|
+ //空业务编码添加状态
|
|
|
+ info.setBusinessFlag("1");
|
|
|
+ MyBeanUtils.copyBeanNotNull2Bean(children.get(0), info);//将编辑表单中的非NULL值覆盖数据库记录中的值
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
ReimbursementDTO businessById = reimbursementBusinessService.getBusinessById(info.getId());
|
|
@@ -112,7 +138,14 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
for (String key : invoiceListMap.keySet()) {
|
|
|
if (info.getId().equals(key)) {
|
|
|
List<ReimbursementDTO> children = invoiceListMap.get(key);
|
|
|
- info.setChildren(children);
|
|
|
+ if(StringUtils.isNotBlank(info.getBusinessCode()) || "1".equals(info.getBatchFlag())){
|
|
|
+ info.setChildren(children);
|
|
|
+ info.setBusinessFlag("0");
|
|
|
+ }else{
|
|
|
+ //空业务编码添加状态
|
|
|
+ info.setBusinessFlag("1");
|
|
|
+ MyBeanUtils.copyBeanNotNull2Bean(children.get(0), info);//将编辑表单中的非NULL值覆盖数据库记录中的值
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
ReimbursementDTO businessById = reimbursementBusinessService.getBusinessById(info.getId());
|
|
@@ -305,10 +338,10 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
Calendar date = Calendar.getInstance();
|
|
|
String year = String.valueOf(date.get(Calendar.YEAR));
|
|
|
|
|
|
- //查询非空的业务编号数据在数据库中是否存在,若存在,返回已存在的业务编号集合
|
|
|
+ //查询非空的报销批次数据在数据库中是否存在,若存在,返回已存在的报销批次集合
|
|
|
List<ReimbursementDTO> oldBusinessCodeList = mapper.selectOldBusinessCodeByInfo(businessCodeList,year);
|
|
|
if (oldBusinessCodeList.size()>0){
|
|
|
- //如果数据库已存在部分业务编号信息,则去除该部分的业务编号信息
|
|
|
+ //如果数据库已存在部分报销批次信息,则去除该部分的报销批次信息
|
|
|
for (ReimbursementDTO oldBusinessCode: oldBusinessCodeList) {
|
|
|
Iterator iterator = businessCodeInfoList.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
@@ -321,12 +354,12 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //将空的业务编号 的信息添加到集合中
|
|
|
+ //将空的报销批次 的信息添加到集合中
|
|
|
businessCodeInfoList.addAll(businessCodeNullList);
|
|
|
List<ReimbursementDTO> newBusinessCodeInfoList = Lists.newArrayList();
|
|
|
newBusinessCodeInfoList.addAll(businessCodeInfoList);
|
|
|
|
|
|
- //对业务编号的数据进行新增保存
|
|
|
+ //对报销批次的数据进行新增保存
|
|
|
Iterator iterator = businessCodeInfoList.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
ReimbursementDTO data = (ReimbursementDTO) iterator.next();
|
|
@@ -345,12 +378,12 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- //业务编号对应的数据集合
|
|
|
+ //报销批次对应的数据集合
|
|
|
List<ReimbursementDTO> invoiceInfoList = Lists.newArrayList();
|
|
|
|
|
|
for (ReimbursementDTO info : newBusinessCodeInfoList) {
|
|
|
if(StringUtils.isNotBlank(info.getBusinessCode())){
|
|
|
- //处理业务编号不为空的数据
|
|
|
+ //处理报销批次不为空的数据
|
|
|
for (String key : businessCodeListMap.keySet()) {
|
|
|
if(info.getBusinessCode().equals(key)){
|
|
|
List<ReimbursementDTO> infoList = businessCodeListMap.get(key);
|
|
@@ -365,7 +398,7 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
- //处理业务编号为空的数据
|
|
|
+ //处理报销批次为空的数据
|
|
|
info.setParentId(info.getId());
|
|
|
String parentIds = "0," + info.getId() + ",";
|
|
|
info.setParentIds(parentIds);
|
|
@@ -576,6 +609,46 @@ public class ReimbursementSysServiceImpl implements ReimbursementSysService {
|
|
|
mapper.updateReimbursementRatio(reimbursement);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> addBatchReimbursement(List<String> idList) {
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
+ //根据发票id查询对应的发票信息
|
|
|
+ List<ReimbursementDTO> invoiceList = mapper.getInvoiceByIdList(idList);
|
|
|
+ if(invoiceList.size()>0){
|
|
|
+ String firstParentId = invoiceList.get(0).getParentId();
|
|
|
+ String firstParentIds = invoiceList.get(0).getParentIds();
|
|
|
+ Set<String> reimbursementIdSet = new HashSet<String>();
|
|
|
+ for (ReimbursementDTO info : invoiceList) {
|
|
|
+ reimbursementIdSet.add(info.getParentId());
|
|
|
+ }
|
|
|
+ reimbursementIdSet.remove(firstParentId);
|
|
|
+ //删除除第一个以外的所有业务信息
|
|
|
+ if(reimbursementIdSet.size()>0){
|
|
|
+ mapper.deleteBusinessByIdList(new ArrayList<>(reimbursementIdSet));
|
|
|
+ }
|
|
|
+ //将所有发票信息的父节点变更为存在的业务信息id
|
|
|
+ for (ReimbursementDTO info : invoiceList) {
|
|
|
+ info.setParentId(firstParentId);
|
|
|
+ info.setParentIds(firstParentIds);
|
|
|
+ info.setBatchFlag("1");
|
|
|
+ info.preUpdate();
|
|
|
+ }
|
|
|
+ //批量修改发票信息
|
|
|
+ mapper.updateInvoiceList(invoiceList);
|
|
|
+ //修改业务信息(添加状态)
|
|
|
+ ReimbursementDTO info = new ReimbursementDTO();
|
|
|
+ info.setId(firstParentId);
|
|
|
+ info.setBatchFlag("1");
|
|
|
+ info.preUpdate();
|
|
|
+ mapper.updateById(info);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ map.put("success", false);
|
|
|
+ map.put("message", "未查询到符合条件的发票信息");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 文件数据分组
|
|
|
* @param dataList
|