|
@@ -9,6 +9,7 @@ import com.jeeplus.test.reimbursementAccountant.mapper.AccountantReimbursementSy
|
|
|
import com.jeeplus.test.reimbursementAccountant.service.AccountantReimbursementBusinessService;
|
|
|
import com.jeeplus.test.reimbursementAccountant.service.AccountantReimbursementSysService;
|
|
|
import com.jeeplus.test.reimbursementAccountant.utils.MyBeanUtils;
|
|
|
+import com.jeeplus.test.reimbursementsys.domain.dto.ReimbursementDTO;
|
|
|
import com.jeeplus.test.reimbursementsys.utils.PublicUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -302,6 +303,7 @@ public class AccountantReimbursementSysServiceImpl implements AccountantReimburs
|
|
|
info.setBusinessCode("");
|
|
|
}
|
|
|
invoiceNumberSet.add(info.getInvoiceNumber());
|
|
|
+ info.setExistence("0");
|
|
|
}
|
|
|
//如果发票编号数量不等于总数量,则表示所传数据中存在重复的发票编号,则进行抛出
|
|
|
if(invoiceNumberSet.size() != reimbursementList.size()){
|
|
@@ -314,10 +316,20 @@ public class AccountantReimbursementSysServiceImpl implements AccountantReimburs
|
|
|
//查询发票号是否存在,若含有已存在发票号,则直接进行抛出
|
|
|
List<String> oldInvoiceNumberList = mapper.selectOldInvoiceNumber(invoiceNumberList);
|
|
|
if(oldInvoiceNumberList.size()>0){
|
|
|
- String oldInvoiceNumber = String.join(",", oldInvoiceNumberList);
|
|
|
+
|
|
|
+ //将查出来的已存在的发票号整理为字符串
|
|
|
+ String oldInvoiceNumberListStr = String.join(",", oldInvoiceNumberList);
|
|
|
+ //找到上传的发票信息中已存在的报告号 并对其存在状态进行修改
|
|
|
+ for (AccountantReimbursementDTO info : reimbursementList) {
|
|
|
+ if(oldInvoiceNumberListStr.contains(info.getInvoiceNumber())){
|
|
|
+ info.setExistence("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*String oldInvoiceNumber = String.join(",", oldInvoiceNumberList);
|
|
|
map.put("success", false);
|
|
|
map.put("message", "发票号码:" + oldInvoiceNumber + " 已存在。无法再次上传");
|
|
|
- return map;
|
|
|
+ return map;*/
|
|
|
}
|
|
|
|
|
|
//业务编号对应的数据集合
|
|
@@ -376,11 +388,24 @@ public class AccountantReimbursementSysServiceImpl implements AccountantReimburs
|
|
|
iterator.remove();
|
|
|
}
|
|
|
}
|
|
|
- if(businessCodeInfoList.size()>0){
|
|
|
- mapper.insertBusinessCodeList(businessCodeInfoList);
|
|
|
+
|
|
|
+ //对数据进行分组
|
|
|
+ Map<String, List<AccountantReimbursementDTO>> existenceCodeListMap = dataDisposeOnSaveByExistence(businessCodeInfoList);
|
|
|
+ for (String key : existenceCodeListMap.keySet()) {
|
|
|
+ switch(key){
|
|
|
+ case "0":
|
|
|
+ List<AccountantReimbursementDTO> noExistenceList = existenceCodeListMap.get(key);
|
|
|
+ if(noExistenceList.size()>0){
|
|
|
+ mapper.insertBusinessCodeList(noExistenceList);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
//业务编号对应的数据集合
|
|
|
List<AccountantReimbursementDTO> invoiceInfoList = Lists.newArrayList();
|
|
|
|
|
@@ -412,8 +437,28 @@ public class AccountantReimbursementSysServiceImpl implements AccountantReimburs
|
|
|
for (AccountantReimbursementDTO childrenInfo : invoiceInfoList) {
|
|
|
childrenInfo.preInsert();
|
|
|
}
|
|
|
- //新增
|
|
|
- mapper.insertInvoiceList(invoiceInfoList);
|
|
|
+
|
|
|
+ //对发票数据进行分组(根据存在状态)
|
|
|
+ Map<String, List<AccountantReimbursementDTO>> existenceListMap = dataDisposeOnSaveByExistence(invoiceInfoList);
|
|
|
+ for (String key : existenceListMap.keySet()) {
|
|
|
+ switch(key){
|
|
|
+ case "0":
|
|
|
+ List<AccountantReimbursementDTO> noExistenceList = existenceListMap.get(key);
|
|
|
+ //新增
|
|
|
+ mapper.insertInvoiceList(noExistenceList);
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ List<AccountantReimbursementDTO> existenceList = existenceListMap.get(key);
|
|
|
+ for (AccountantReimbursementDTO info : existenceList) {
|
|
|
+ //更新收款时间
|
|
|
+ if(StringUtils.isNotBlank(info.getGatheringTime())){
|
|
|
+ info.preUpdate();
|
|
|
+ mapper.updateInvoiceGatheringTime(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
map.put("success", true);
|
|
|
map.put("message", "数据上传成功");
|
|
@@ -699,4 +744,35 @@ public class AccountantReimbursementSysServiceImpl implements AccountantReimburs
|
|
|
return userSignSerialMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 文件数据分组
|
|
|
+ * @param dataList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, List<AccountantReimbursementDTO>> dataDisposeOnSaveByExistence(List<AccountantReimbursementDTO> dataList) {
|
|
|
+ Map<String, List<AccountantReimbursementDTO>> result = listMapOnSaveByExistence(dataList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, List<AccountantReimbursementDTO>> listMapOnSaveByExistence(List<AccountantReimbursementDTO> list) {
|
|
|
+ Map<String, List<AccountantReimbursementDTO>> userSignSerialMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ // 分组
|
|
|
+ for (AccountantReimbursementDTO vo : list) {
|
|
|
+ List<AccountantReimbursementDTO> tempList = userSignSerialMap.get(vo.getExistence());
|
|
|
+ /*如果取不到数据,那么直接new一个空的ArrayList**/
|
|
|
+ if (tempList == null) {
|
|
|
+ tempList = new ArrayList<>();
|
|
|
+ tempList.add(vo);
|
|
|
+ userSignSerialMap.put(vo.getExistence(), tempList);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ /*某个vo之前已经存放过了,则直接追加数据到原来的List里**/
|
|
|
+ tempList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userSignSerialMap;
|
|
|
+ }
|
|
|
+
|
|
|
}
|