Browse Source

Merge branch 'edu_financial'

river 4 years ago
parent
commit
092ce009ef

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/FinancialExpenditureDao.java

@@ -11,7 +11,7 @@ import java.util.Map;
 
 public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpenditure> {
 
-    void batchInsert(@Param("financialExpenditures") List<FinancialExpenditure> financialExpenditures);
+    int batchInsert(@Param("financialExpenditures") List<FinancialExpenditure> financialExpenditures);
 
     int findFinancialExpenditureCount(Map<String, Object> params);
 
@@ -36,4 +36,4 @@ public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpendit
      * @time 11:38
      */
     List<String> countBydingTalk(@Param("collect") List<Object> collect);
-}
+}

+ 46 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/FinancialExpenditure.java

@@ -23,10 +23,10 @@ public class FinancialExpenditure {
 	@ApiModelProperty(value = "钉钉流程编号",required = false)
 	private String dingtalkProcessNo;
 	/**  */
-	@ApiModelProperty(value = "分部",required = false)
+	@ApiModelProperty(value = "分部id",required = false)
 	private Integer organId;
 	/**  */
-	@ApiModelProperty(value = "学校/合作单位",required = false)
+	@ApiModelProperty(value = "学校/合作单位id",required = false)
 	private Integer cooperationOrganId;
 	/**  */
 	@ApiModelProperty(value = "申请人",required = false)
@@ -49,6 +49,18 @@ public class FinancialExpenditure {
 	/**  */
 	@ApiModelProperty(value = "事由",required = false)
 	private String cause;
+
+	@ApiModelProperty(value = "分部",required = false)
+	private String organName;
+
+	@ApiModelProperty(value = "学校/合作单位",required = false)
+	private String cooperationOrganName;
+
+	@ApiModelProperty(value = "费用类型Str",required = false)
+	private String feeType;
+
+	@ApiModelProperty(value = "费用项目str",required = false)
+	private String feeProjectItem;
 	/**  */
 	private Date createTime;
 	/**  */
@@ -183,4 +195,36 @@ public class FinancialExpenditure {
 	public void setType(ExpenditureTypeEnum type) {
 		this.type = type;
 	}
+
+	public String getOrganName() {
+		return organName;
+	}
+
+	public void setOrganName(String organName) {
+		this.organName = organName;
+	}
+
+	public String getCooperationOrganName() {
+		return cooperationOrganName;
+	}
+
+	public void setCooperationOrganName(String cooperationOrganName) {
+		this.cooperationOrganName = cooperationOrganName;
+	}
+
+	public String getFeeType() {
+		return feeType;
+	}
+
+	public void setFeeType(String feeType) {
+		this.feeType = feeType;
+	}
+
+	public String getFeeProjectItem() {
+		return feeProjectItem;
+	}
+
+	public void setFeeProjectItem(String feeProjectItem) {
+		this.feeProjectItem = feeProjectItem;
+	}
 }

+ 14 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/FinancialExpenditureService.java

@@ -13,26 +13,35 @@ import java.util.List;
 
 public interface FinancialExpenditureService extends BaseService<Long, FinancialExpenditure> {
     /**
+     * @param file:
+     * @return java.lang.Object
      * @describe 导入财务支出
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @author zouxuan
      * @date 2020/9/7
      * @time 18:31
-     * @param file:
-     * @return java.lang.Object
      */
     List<FinancialExpenditure> importFinancialExpenditure(MultipartFile file) throws Exception;
 
     PageInfo<FinancialExpenditureDto> queryFinancialExpenditurePage(FinancialExpenditureQueryInfo queryInfo);
 
     /**
+     * @param ids:
+     * @return void
      * @describe 批量删除
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @author zouxuan
      * @date 2020/9/9
      * @time 11:44
-     * @param ids:
-     * @return void
      */
     void batchDel(String ids);
-}
+
+
+    /**
+     * 批量插入支出记录
+     *
+     * @param financialExpenditures
+     * @return
+     */
+    List<FinancialExpenditure> batchAdd(List<FinancialExpenditure> financialExpenditures);
+}

+ 157 - 148
mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java

@@ -37,157 +37,166 @@ import java.util.stream.Collectors;
 
 @Service
 public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, FinancialExpenditure> implements FinancialExpenditureService {
-	
-	@Autowired
-	private FinancialExpenditureDao financialExpenditureDao;
 
-	@Override
-	public BaseDAO<Long, FinancialExpenditure> getDAO() {
-		return financialExpenditureDao;
-	}
+    @Autowired
+    private FinancialExpenditureDao financialExpenditureDao;
 
-	private static final Logger LOGGER = LoggerFactory.getLogger(FinancialExpenditureServiceImpl.class);
+    @Override
+    public BaseDAO<Long, FinancialExpenditure> getDAO() {
+        return financialExpenditureDao;
+    }
 
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public List<FinancialExpenditure> importFinancialExpenditure(MultipartFile file) throws Exception {
-		Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
-		InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
-		Map<String,String> columns = IniFileUtil.readIniFile(inputStream,TemplateTypeEnum.FINANCIAL_EXPENDITURE.getMsg());
-		List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
-		Map<String, Integer> organMap = getMap("organization", "name_", "id_", true, String.class, Integer.class);
-		Map<String, Integer> cooperationOrganMap = getMap("cooperation_organ", "name_", "id_", true, String.class, Integer.class);
-		StringBuffer sb = new StringBuffer();
-		for (String e : sheetsListMap.keySet()) {
-			List<Map<String, Object>> sheet = sheetsListMap.get(e);
-			List<Object> collect = sheet.stream().map(m -> m.get("钉钉流程编号")).collect(Collectors.toList());
-			if(collect == null || collect.size() == 0){
-				continue;
-			}
-			valueIsNull: for (int j = 0; j < sheet.size(); j++) {
-				int rowNum = j + 2;
-				Map<String, Object> row = sheet.get(j);
-				if (row.size() == 0) {
-					continue;
-				}
-				JSONObject objectMap = new JSONObject();
-				for (String s : row.keySet()) {
-					if(!columns.containsKey(s)){
-						continue;
-					}
-					String columnValue = columns.get(s);
-					if (columnValue.equals("type")) {
-						for (ExpenditureTypeEnum expenditureType : ExpenditureTypeEnum.values()) {
-							if (expenditureType.getDesc().equals(row.get(s).toString())) {
-								objectMap.put(columnValue, expenditureType);
-								break;
-							}
-						}
-						continue;
-					}
-					if (columnValue.equals("dingtalkProcessNo")) {
-						if (StringUtils.isEmpty(row.get(s).toString())) {
-							sb.append("第" + rowNum).append("行数据导入失败:钉钉流程编号不可为空;");
-							continue valueIsNull;
-						} else {
-							objectMap.put("incomeType", row.get(s));
-						}
-					}
-					if (columnValue.equals("feeProject")) {
-						for (FeeProjectEnum feeProject : FeeProjectEnum.values()) {
-							if (feeProject.getDesc().equals(row.get(s).toString())) {
-								objectMap.put(columnValue, feeProject);
-								break;
-							}
-						}
-						continue;
-					}
-					if (columnValue.equals("amount")) {
-						if(StringUtils.isEmpty(row.get(s).toString())){
-							sb.append("第" + rowNum).append("行数据导入失败:费用不可为空;");
-							continue valueIsNull;
-						}else {
-							objectMap.put("amount", row.get(s));
-						}
-						continue;
-					}
-					if (columnValue.equals("organName") && StringUtils.isNotEmpty(row.get(s).toString())) {
-						Integer integer = organMap.get(row.get(s));
-						if(integer == null){
-							sb.append("第" + rowNum).append("行数据导入失败:分部校验失败;");
-							continue valueIsNull;
-						}else {
-							objectMap.put("organId", integer);
-						}
-						continue;
-					}
-					if (columnValue.equals("cooperationOrganName") && StringUtils.isNotEmpty(row.get(s).toString())) {
-						Integer integer = cooperationOrganMap.get(row.get(s));
-						if(integer == null){
-							sb.append("第" + rowNum).append("行数据导入失败:合作单位校验失败;");
-							continue valueIsNull;
-						}else {
-							objectMap.put("cooperationOrganId", integer);
-						}
-						continue;
-					}
-					if (columnValue.equals("paymentTime") && StringUtils.isNotEmpty(row.get(s).toString())) {
-						String toString = row.get(s).toString();
-						if(StringUtils.isNotEmpty(toString)){
-							Date date = DateUtil.stringToDate(toString, DateUtil.DEFAULT_PATTERN);
-							if(date == null){
-								throw new BizException("导入数据错误  付款时间格式错误");
-							}else {
-								objectMap.put(columnValue, DateUtil.format(date,DateUtil.DEFAULT_PATTERN));
-							}
-						}
-						continue;
-					}
-					objectMap.put(columnValue, row.get(s));
-				}
-				FinancialExpenditure financialExpenditure = null;
-				try {
-					financialExpenditure = JSONObject.parseObject(objectMap.toJSONString(),FinancialExpenditure.class);
-					financialExpenditures.add(financialExpenditure);
-				} catch (Exception ex) {
-					throw new BizException("导入数据出错,请检查Excel表格");
-				}
-			}
-		}
-		if(sb.length() > 0){
-			throw new BizException(sb.toString());
-		}
-		if(financialExpenditures.size() != 0){
-			financialExpenditureDao.batchInsert(financialExpenditures);
-		}
-		return financialExpenditures;
-	}
+    private static final Logger LOGGER = LoggerFactory.getLogger(FinancialExpenditureServiceImpl.class);
 
-	@Override
-	public PageInfo<FinancialExpenditureDto> queryFinancialExpenditurePage(FinancialExpenditureQueryInfo queryInfo){
-		PageInfo<FinancialExpenditureDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
-		Map<String, Object> params = new HashMap<>();
-		MapUtil.populateMap(params, queryInfo);
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public List<FinancialExpenditure> importFinancialExpenditure(MultipartFile file) throws Exception {
+        Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
+        InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
+        Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.FINANCIAL_EXPENDITURE.getMsg());
+        List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
+        Map<String, Integer> organMap = getMap("organization", "name_", "id_", true, String.class, Integer.class);
+        Map<String, Integer> cooperationOrganMap = getMap("cooperation_organ", "name_", "id_", true, String.class, Integer.class);
+        StringBuffer sb = new StringBuffer();
+        for (String e : sheetsListMap.keySet()) {
+            List<Map<String, Object>> sheet = sheetsListMap.get(e);
+            List<Object> collect = sheet.stream().map(m -> m.get("钉钉流程编号")).collect(Collectors.toList());
+            if (collect == null || collect.size() == 0) {
+                continue;
+            }
+            valueIsNull:
+            for (int j = 0; j < sheet.size(); j++) {
+                int rowNum = j + 2;
+                Map<String, Object> row = sheet.get(j);
+                if (row.size() == 0) {
+                    continue;
+                }
+                JSONObject objectMap = new JSONObject();
+                for (String s : row.keySet()) {
+                    if (!columns.containsKey(s)) {
+                        continue;
+                    }
+                    String columnValue = columns.get(s);
+                    if (columnValue.equals("type")) {
+                        for (ExpenditureTypeEnum expenditureType : ExpenditureTypeEnum.values()) {
+                            if (expenditureType.getDesc().equals(row.get(s).toString())) {
+                                objectMap.put(columnValue, expenditureType);
+                                break;
+                            }
+                        }
+                        continue;
+                    }
+                    if (columnValue.equals("dingtalkProcessNo")) {
+                        if (StringUtils.isEmpty(row.get(s).toString())) {
+                            sb.append("第" + rowNum).append("行数据导入失败:钉钉流程编号不可为空;");
+                            continue valueIsNull;
+                        } else {
+                            objectMap.put("incomeType", row.get(s));
+                        }
+                    }
+                    if (columnValue.equals("feeProject")) {
+                        for (FeeProjectEnum feeProject : FeeProjectEnum.values()) {
+                            if (feeProject.getDesc().equals(row.get(s).toString())) {
+                                objectMap.put(columnValue, feeProject);
+                                break;
+                            }
+                        }
+                        continue;
+                    }
+                    if (columnValue.equals("amount")) {
+                        if (StringUtils.isEmpty(row.get(s).toString())) {
+                            sb.append("第" + rowNum).append("行数据导入失败:费用不可为空;");
+                            continue valueIsNull;
+                        } else {
+                            objectMap.put("amount", row.get(s));
+                        }
+                        continue;
+                    }
+                    if (columnValue.equals("organName") && StringUtils.isNotEmpty(row.get(s).toString())) {
+                        Integer integer = organMap.get(row.get(s));
+                        if (integer == null) {
+                            sb.append("第" + rowNum).append("行数据导入失败:分部校验失败;");
+                            continue valueIsNull;
+                        } else {
+                            objectMap.put("organId", integer);
+                        }
+                        continue;
+                    }
+                    if (columnValue.equals("cooperationOrganName") && StringUtils.isNotEmpty(row.get(s).toString())) {
+                        Integer integer = cooperationOrganMap.get(row.get(s));
+                        if (integer == null) {
+                            sb.append("第" + rowNum).append("行数据导入失败:合作单位校验失败;");
+                            continue valueIsNull;
+                        } else {
+                            objectMap.put("cooperationOrganId", integer);
+                        }
+                        continue;
+                    }
+                    if (columnValue.equals("paymentTime") && StringUtils.isNotEmpty(row.get(s).toString())) {
+                        String toString = row.get(s).toString();
+                        if (StringUtils.isNotEmpty(toString)) {
+                            Date date = DateUtil.stringToDate(toString, DateUtil.DEFAULT_PATTERN);
+                            if (date == null) {
+                                throw new BizException("导入数据错误  付款时间格式错误");
+                            } else {
+                                objectMap.put(columnValue, DateUtil.format(date, DateUtil.DEFAULT_PATTERN));
+                            }
+                        }
+                        continue;
+                    }
+                    objectMap.put(columnValue, row.get(s));
+                }
+                FinancialExpenditure financialExpenditure = null;
+                try {
+                    financialExpenditure = JSONObject.parseObject(objectMap.toJSONString(), FinancialExpenditure.class);
+                    financialExpenditures.add(financialExpenditure);
+                } catch (Exception ex) {
+                    throw new BizException("导入数据出错,请检查Excel表格");
+                }
+            }
+        }
+        if (sb.length() > 0) {
+            throw new BizException(sb.toString());
+        }
+        if (financialExpenditures.size() != 0) {
+            financialExpenditureDao.batchInsert(financialExpenditures);
+        }
+        return financialExpenditures;
+    }
 
-		List<FinancialExpenditureDto> dataList = null;
-		int count = financialExpenditureDao.findFinancialExpenditureCount(params);
-		if (count > 0) {
-			pageInfo.setTotal(count);
-			params.put("offset", pageInfo.getOffset());
-			dataList = financialExpenditureDao.queryFinancialExpenditurePage(params);
-		}
-		if (count == 0) {
-			dataList = new ArrayList<>();
-		}
-		pageInfo.setRows(dataList);
-		return pageInfo;
-	}
+    @Override
+    public PageInfo<FinancialExpenditureDto> queryFinancialExpenditurePage(FinancialExpenditureQueryInfo queryInfo) {
+        PageInfo<FinancialExpenditureDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
 
-	@Override
-	public void batchDel(String ids) {
-		if(StringUtils.isEmpty(ids)){
-			throw new BizException("参数校验失败");
-		}
-		financialExpenditureDao.batchDel(ids);
-	}
-}
+        List<FinancialExpenditureDto> dataList = null;
+        int count = financialExpenditureDao.findFinancialExpenditureCount(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = financialExpenditureDao.queryFinancialExpenditurePage(params);
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    public void batchDel(String ids) {
+        if (StringUtils.isEmpty(ids)) {
+            throw new BizException("参数校验失败");
+        }
+        financialExpenditureDao.batchDel(ids);
+    }
+
+    @Override
+    public List<FinancialExpenditure> batchAdd(List<FinancialExpenditure> financialExpenditures) {
+        financialExpenditureDao.batchInsert(financialExpenditures);
+        return financialExpenditures;
+    }
+
+
+}

+ 3 - 1
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -54,7 +54,9 @@
                 #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
-    <insert id="batchInsert">
+    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true"
+            keyColumn="id"
+            keyProperty="id">
         INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
         organ_id_,cooperation_organ_id_,apply_user_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_)
         VALUES

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/config/ResourceServerConfig.java

@@ -35,7 +35,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 				.hasIpAddress("0.0.0.0/0")
 				.antMatchers("/v2/api-docs", "/classGroup/highClassGroups", "/code/*", "/api/*", "/appVersionInfo/queryByPlatform", "/eduDegree/*",
 						"/uploadFile", "/eduContracts/queryProduceContract","/activity/doubleEleven2020Statis","/replacementInstrument/queryPage",
-						"/replacementInstrumentActivity/queryReplacementsStat","/eduStudentRegistration/queryPreApplyList","/eduSubject/findSubSubjects").permitAll().anyRequest().authenticated().and().httpBasic();
+						"/replacementInstrumentActivity/queryReplacementsStat","/eduStudentRegistration/queryPreApplyList","/eduSubject/findSubSubjects","/eduFinancialExpenditure/batchAdd").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 
 	@Override

+ 58 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EduFinancialExpenditureController.java

@@ -0,0 +1,58 @@
+package com.ym.mec.web.controller.education;
+
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.CooperationOrganDao;
+import com.ym.mec.biz.dal.dao.OrganizationDao;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
+import com.ym.mec.biz.dal.entity.Organization;
+import com.ym.mec.biz.dal.entity.StudentVisit;
+import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
+import com.ym.mec.biz.dal.enums.FeeProjectEnum;
+import com.ym.mec.biz.service.FinancialExpenditureService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+@Api(tags = "支出记录(教务端)")
+@RequestMapping("eduFinancialExpenditure")
+@RestController
+public class EduFinancialExpenditureController extends BaseController {
+    @Autowired
+    private FinancialExpenditureService financialExpenditureService;
+    @Autowired
+    private OrganizationDao organizationDao;
+    @Autowired
+    private CooperationOrganDao cooperationOrganDao;
+
+    @ApiOperation(value = "批量添加支出记录")
+    @PostMapping(value = "/batchAdd")
+    public HttpResponseResult<List<FinancialExpenditure>> batchAdd(@RequestBody List<FinancialExpenditure> financialExpenditures) {
+        List<Organization> organs = organizationDao.findAllOrgans();
+        Map<String, Integer> organMap = organs.stream().collect(Collectors.toMap(Organization::getName, Organization::getId));
+        List<CooperationOrgan> cooperationOrgans = cooperationOrganDao.getAllCooperationOrgan();
+        Map<String, Integer> cooperationOrganMap = cooperationOrgans.stream().collect(Collectors.toMap(e -> e.getName() + e.getOrganId(), e -> e.getId()));
+        for (FinancialExpenditure financialExpenditure : financialExpenditures) {
+            if (organMap.containsKey(financialExpenditure.getOrganName())) {
+                financialExpenditure.setOrganId(organMap.get(financialExpenditure.getOrganName()));
+            }
+            if (cooperationOrganMap.containsKey(financialExpenditure.getCooperationOrganName() + financialExpenditure.getOrganId())) {
+                Integer cooperationOrganId = cooperationOrganMap.get(financialExpenditure.getCooperationOrganName() + financialExpenditure.getOrganId());
+                financialExpenditure.setCooperationOrganId(cooperationOrganId);
+            }
+            financialExpenditure.setType(ExpenditureTypeEnum.valueOf(financialExpenditure.getFeeType()));
+            financialExpenditure.setFeeProject(FeeProjectEnum.valueOf(financialExpenditure.getFeeProjectItem()));
+        }
+        return succeed(financialExpenditureService.batchAdd(financialExpenditures));
+    }
+}