|
|
@@ -1,12 +1,18 @@
|
|
|
package com.jpsoft.employment.modules.base.service.impl;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import com.jpsoft.employment.modules.base.dao.FundIncomeInfoDAO;
|
|
|
+import com.jpsoft.employment.modules.base.dao.TemplateInfoDAO;
|
|
|
import com.jpsoft.employment.modules.base.dto.TemplateOptionDTO;
|
|
|
+import com.jpsoft.employment.modules.base.entity.FundIncomeInfo;
|
|
|
+import com.jpsoft.employment.modules.base.entity.TemplateInfo;
|
|
|
import com.jpsoft.employment.modules.common.utils.StringUtils;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -23,6 +29,12 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
|
|
|
@Resource(name = "templateOptionDAO")
|
|
|
private TemplateOptionDAO templateOptionDAO;
|
|
|
|
|
|
+ @Resource(name = "fundIncomeInfoDAO")
|
|
|
+ private FundIncomeInfoDAO fundIncomeInfoDAO;
|
|
|
+
|
|
|
+ @Resource(name = "templateInfoDAO")
|
|
|
+ private TemplateInfoDAO templateInfoDAO;
|
|
|
+
|
|
|
@Override
|
|
|
public TemplateOption get(String id) {
|
|
|
// TODO Auto-generated method stub
|
|
|
@@ -37,12 +49,88 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
|
|
|
return templateOptionDAO.insert(model);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int insertAndFundIncome(TemplateOption model) throws ParseException {
|
|
|
+ // TODO Auto-generated method stub
|
|
|
+ int count = templateOptionDAO.insert(model);
|
|
|
+
|
|
|
+ TemplateInfo templateInfo = templateInfoDAO.get(model.getTemplateId());
|
|
|
+
|
|
|
+ SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ //生成一年的数据
|
|
|
+ for (int i = 1; i <= 12; i++) {
|
|
|
+ String yearMonth = templateInfo.getYear();
|
|
|
+ if (i < 10) {
|
|
|
+ yearMonth += "-0" + String.valueOf(i) + "-01";
|
|
|
+ } else {
|
|
|
+ yearMonth += "-" + String.valueOf(i) + "-01";
|
|
|
+ }
|
|
|
+
|
|
|
+ FundIncomeInfo fundIncomeInfo = new FundIncomeInfo();
|
|
|
+ fundIncomeInfo.setId(UUID.randomUUID().toString());
|
|
|
+ fundIncomeInfo.setName(model.getName());
|
|
|
+ fundIncomeInfo.setDelFlag(false);
|
|
|
+ fundIncomeInfo.setCreateBy(model.getCreateBy());
|
|
|
+ fundIncomeInfo.setCreateTime(model.getCreateTime());
|
|
|
+ fundIncomeInfo.setSerialNumber(model.getSerialNum());
|
|
|
+ fundIncomeInfo.setYear(sdf2.parse(yearMonth));
|
|
|
+ fundIncomeInfo.setIndex(model.getIndex());
|
|
|
+ fundIncomeInfo.setBudgetRevenue(model.getBudgetRevenue());
|
|
|
+ fundIncomeInfo.setCurBudgetRevenue(model.getBudgetRevenue());
|
|
|
+ fundIncomeInfo.setTemplateId(model.getTemplateId());
|
|
|
+ fundIncomeInfo.setIncomeTimeRange(model.getIncomeTimeRange());
|
|
|
+ fundIncomeInfo.setEndDate(model.getEndDate());
|
|
|
+ fundIncomeInfo.setIncomeType(model.getIncomeType());
|
|
|
+ fundIncomeInfo.setChargePerson(model.getChargePerson());
|
|
|
+ fundIncomeInfo.setTemplateOptionId(model.getId());
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(templateInfo.getAttachment())) {
|
|
|
+ fundIncomeInfo.setAttachment(templateInfo.getAttachment());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (model.getIsSum() != null) {
|
|
|
+ fundIncomeInfo.setIsSum(model.getIsSum());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(model.getDepartmentIds())) {
|
|
|
+ fundIncomeInfo.setIncomeDepartment(model.getDepartmentIds());
|
|
|
+ }
|
|
|
+
|
|
|
+ count += fundIncomeInfoDAO.insert(fundIncomeInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public int update(TemplateOption model) {
|
|
|
// TODO Auto-generated method stub
|
|
|
return templateOptionDAO.update(model);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateNameAndFundIncome(TemplateOption model) {
|
|
|
+ int count = templateOptionDAO.update(model);
|
|
|
+ if (count > 0) {
|
|
|
+ List<FundIncomeInfo> fundIncomeInfoList = fundIncomeInfoDAO.findByTemplateOptionId(model.getId());
|
|
|
+
|
|
|
+ for (FundIncomeInfo fundIncomeInfo:fundIncomeInfoList) {
|
|
|
+ fundIncomeInfo.setUpdateTime(model.getUpdateTime());
|
|
|
+ fundIncomeInfo.setUpdateBy(model.getUpdateBy());
|
|
|
+ fundIncomeInfo.setName(model.getName());
|
|
|
+
|
|
|
+ fundIncomeInfoDAO.update(fundIncomeInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public int updateList(TemplateOptionDTO dto, String subject) {
|
|
|
String templateId = dto.getTemplateId();
|
|
|
@@ -73,8 +161,8 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
|
|
|
for (String departId : arr) {
|
|
|
departmentId += departId + ",";
|
|
|
}
|
|
|
- if(StringUtils.isNotEmpty(departmentId)){
|
|
|
- departmentId.substring(0,departmentId.lastIndexOf(","));
|
|
|
+ if (StringUtils.isNotEmpty(departmentId)) {
|
|
|
+ departmentId.substring(0, departmentId.lastIndexOf(","));
|
|
|
templateOption.setDepartmentIds(departmentId);
|
|
|
}
|
|
|
affectCount += templateOptionDAO.insert(templateOption);
|
|
|
@@ -114,6 +202,11 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
|
|
|
return templateOptionDAO.findByConditions(searchParams);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String findLastIndexByTemplateId(String templateId) {
|
|
|
+ return templateOptionDAO.findLastIndexByTemplateId(templateId);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Page<TemplateOption> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
|
|
|
Page<TemplateOption> page = PageHelper.startPage(pageNumber, pageSize, count).doSelectPage(() -> {
|