SupplyJudgementBillsService.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.jeeplus.modules.supply.judgementBills.service;
  2. import com.google.common.collect.Lists;
  3. import com.jeeplus.common.utils.StringUtils;
  4. import com.jeeplus.core.persistence.Page;
  5. import com.jeeplus.core.service.CrudService;
  6. import com.jeeplus.modules.supply.judgementBills.entity.SupplyJudgementBills;
  7. import com.jeeplus.modules.supply.judgementBills.mapper.SupplyJudgementBillsMapper;
  8. import com.jeeplus.modules.supply.utils.CommonUtil;
  9. import org.springframework.stereotype.Service;
  10. import org.springframework.transaction.annotation.Transactional;
  11. import java.util.*;
  12. /**
  13. * 审定单service
  14. * @author: 徐滕
  15. * @create: 2022-02-28 15:59
  16. **/
  17. @Service
  18. @Transactional(readOnly = true)
  19. public class SupplyJudgementBillsService extends CrudService<SupplyJudgementBillsMapper, SupplyJudgementBills> {
  20. @Override
  21. public Page<SupplyJudgementBills> findPage(Page<SupplyJudgementBills> page, SupplyJudgementBills supplyJudgementBills) {
  22. return super.findPage(page, supplyJudgementBills);
  23. }
  24. /**
  25. * 导入物料库Excel数据
  26. * @param judgementBillsList
  27. * @return
  28. */
  29. @Transactional(readOnly = false)
  30. public Map disposeJudgementBills(List<SupplyJudgementBills> judgementBillsList){
  31. Map map = new HashMap();
  32. Set set = new HashSet<>();
  33. Iterator<SupplyJudgementBills> it = judgementBillsList.iterator();
  34. //删除项目编号为空的数据信息
  35. while(it.hasNext()){
  36. SupplyJudgementBills info = it.next();
  37. if(StringUtils.isBlank(info.getMaterialNumber())){//判定物料编码是否为空
  38. map.put("success",false);
  39. map.put("message","存在物料编码为空的数据,请确认后重新提交");
  40. return map;
  41. } else if(StringUtils.isBlank(info.getExamineCount())){//判定审定数量是否为空
  42. map.put("success",false);
  43. map.put("message","存在审定数量为空的数据,请确认后重新提交");
  44. return map;
  45. } else if(StringUtils.isBlank(info.getProjectDefinition())){//判定项目定义号是否为空
  46. map.put("success",false);
  47. map.put("message","存在项目定义号为空的数据,请确认后重新提交");
  48. return map;
  49. }else {
  50. //将项目定义号添加到set中
  51. set.add(info.getProjectDefinition());
  52. info.preInsert();
  53. }
  54. }
  55. //查询项目定义号对应的项目信息
  56. List<String> projectDefinitionList = new ArrayList(set);
  57. List<String> projectDefinitionInfoList = mapper.getProjectDefinitionList(projectDefinitionList);
  58. //判断项目信息和数据库中的项目信息数量是否一致,不一致则找到对应信息并进行提示
  59. if(projectDefinitionList.size() != projectDefinitionInfoList.size()){
  60. String nonentityProjectDefinitions = CommonUtil.comparisonProjectDefinition(projectDefinitionInfoList,projectDefinitionList);
  61. map.put("success",false);
  62. map.put("message","查询不到项目定义号为:" + nonentityProjectDefinitions + " 的项目信息。请先上传对应项目信息");
  63. return map;
  64. }
  65. //批量处理
  66. disposeStockOutList(judgementBillsList);
  67. map.put("success",true);
  68. return map;
  69. }
  70. /**
  71. * 批量处理物料库数据信息
  72. * @param judgementBillsList
  73. * @return
  74. */
  75. @Transactional(readOnly = false)
  76. public String disposeStockOutList(List<SupplyJudgementBills> judgementBillsList){
  77. //分批处理
  78. if(null!=judgementBillsList && judgementBillsList.size()>0){
  79. int pointsDataLimit = 1000;//限制条数
  80. Integer size = judgementBillsList.size();
  81. //判断是否有必要分批
  82. if(pointsDataLimit<size){
  83. int part = size/pointsDataLimit;//分批数
  84. //
  85. for (int i = 0; i < part; i++) {
  86. //1000条
  87. List<SupplyJudgementBills> listPage = judgementBillsList.subList(0, pointsDataLimit);
  88. mapper.insertList(listPage);
  89. //剔除
  90. judgementBillsList.subList(0, pointsDataLimit).clear();
  91. }
  92. if(!judgementBillsList.isEmpty()){
  93. mapper.insertList(judgementBillsList);
  94. }
  95. }else{
  96. mapper.insertList(judgementBillsList);
  97. }
  98. }
  99. return null;
  100. }
  101. /**
  102. * 批量删除
  103. * @param idList
  104. */
  105. @Transactional(readOnly = false)
  106. public void deleteByIdList(List<String> idList){
  107. mapper.deleteByIdList(idList);
  108. }
  109. }