|
@@ -37,6 +37,7 @@ import com.jeeplus.sys.feign.IWorkAttachmentApi;
|
|
|
//import com.jeeplus.sys.service.UserService;
|
|
|
import com.jeeplus.sys.service.dto.RoleDTO;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -44,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
@@ -688,4 +690,84 @@ public class CwFinanceInvoiceService extends ServiceImpl<CwFinanceInvoiceMapper,
|
|
|
}
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对到处数据进行处理
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<CwFinanceInvoiceDTO> disposeExportList(List<CwFinanceInvoiceDTO> list){
|
|
|
+ List<CwFinanceInvoiceDTO> resultList = Lists.newArrayList();
|
|
|
+ //对数据进行分组
|
|
|
+ Map<String, List<CwFinanceInvoiceDTO>> temporaryListMap = dataMessageDispose(list);
|
|
|
+
|
|
|
+
|
|
|
+ for (String key : temporaryListMap.keySet()) {
|
|
|
+ List<CwFinanceInvoiceDTO> mapList = temporaryListMap.get(key);
|
|
|
+ if (mapList.size() <= 1) {
|
|
|
+ if (mapList.size() == 1 && (StringUtils.isBlank(mapList.get(0).getBaseAccount()) || "0".equals(mapList.get(0).getBaseAccount()))) {
|
|
|
+ mapList.get(0).setBaseAccount(mapList.get(0).getAccount());
|
|
|
+ }
|
|
|
+ resultList.addAll(mapList);
|
|
|
+ }else{
|
|
|
+ Boolean flag = false;
|
|
|
+
|
|
|
+ for (CwFinanceInvoiceDTO invoiceDTO : mapList) {
|
|
|
+ flag = true;
|
|
|
+ if (!StringUtils.isBlank(invoiceDTO.getBaseAccount()) && !"0".equals(invoiceDTO.getBaseAccount())) {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (flag) {
|
|
|
+ mapList.get(0).setBaseAccount(mapList.get(0).getAccount());
|
|
|
+ } else {
|
|
|
+ for (CwFinanceInvoiceDTO invoiceDTO : mapList) {
|
|
|
+ BigDecimal accountB = new BigDecimal(invoiceDTO.getAccount());
|
|
|
+ BigDecimal accountDetailB = new BigDecimal(invoiceDTO.getAccountDetail());
|
|
|
+ BigDecimal baseAccountB = new BigDecimal(invoiceDTO.getBaseAccount());
|
|
|
+
|
|
|
+ if((baseAccountB.compareTo(accountB) < 0 && baseAccountB.compareTo(accountDetailB) < 0)) {
|
|
|
+
|
|
|
+ } else if (accountB.compareTo(accountDetailB) < 0) {
|
|
|
+ invoiceDTO.setBaseAccount(invoiceDTO.getAccount());
|
|
|
+ } else if(accountDetailB.compareTo(accountB) < 0){
|
|
|
+ invoiceDTO.setBaseAccount(invoiceDTO.getAccountDetail());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultList.addAll(mapList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分组
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, List<CwFinanceInvoiceDTO>> dataMessageDispose(List<CwFinanceInvoiceDTO> list) {
|
|
|
+ Map<String, List<CwFinanceInvoiceDTO>> infoMap = new HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ // 分组
|
|
|
+ for (CwFinanceInvoiceDTO vo : list) {
|
|
|
+ List<CwFinanceInvoiceDTO> tempList = infoMap.get(vo.getNo());
|
|
|
+ /*如果取不到数据,那么直接new一个空的ArrayList**/
|
|
|
+ if (tempList == null) {
|
|
|
+ tempList = new ArrayList<>();
|
|
|
+ tempList.add(vo);
|
|
|
+ infoMap.put(vo.getNo(), tempList);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ /*某个vo之前已经存放过了,则直接追加数据到原来的List里**/
|
|
|
+ tempList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return infoMap;
|
|
|
+ }
|
|
|
+
|
|
|
}
|