瀏覽代碼

生成数据逻辑修改

yanliming 1 年之前
父節點
當前提交
757bc9b3ba

+ 3 - 3
common/src/main/java/com/jpsoft/employment/modules/base/dao/FundIncomeInfoDAO.java

@@ -17,8 +17,8 @@ public interface FundIncomeInfoDAO {
 	FundIncomeInfo get(String id);
 	int delete(String id);
 	List<FundIncomeInfo> list();
-	List<FundIncomeInfo> findByYear(@Param("startDate")String startDate,@Param("endDate")String endDate);
-	BigDecimal sumBySerialNumber(@Param("serialNumber") String serialNumber,@Param("curMonth") String curMonth);
-	BigDecimal sumBudgetRevenue(@Param("serialNumber")String serialNumber,@Param("startDate")String startDate,@Param("endDate")String endDate);
+	List<FundIncomeInfo> findByYear(@Param("startDate")String startDate,@Param("endDate")String endDate,@Param("templateId")String templateId);
+	BigDecimal sumBySerialNumber(@Param("serialNumber") String serialNumber,@Param("curMonth") String curMonth,@Param("templateId")String templateId);
+	BigDecimal sumBudgetRevenue(@Param("serialNumber")String serialNumber,@Param("startDate")String startDate,@Param("endDate")String endDate,@Param("templateId")String templateId);
 	List<FundIncomeInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
 }

+ 2 - 2
common/src/main/java/com/jpsoft/employment/modules/base/service/FundIncomeInfoService.java

@@ -16,7 +16,7 @@ public interface FundIncomeInfoService {
 	int generateData(String templateId,String year,String subject) throws ParseException;
 	int delete(String id);
 	List<FundIncomeInfo> list();
-	BigDecimal sumBySerialNumber(String serialNumber,String curMonth);
-	BigDecimal sumBudgetRevenue(String serialNumber,String startDate,String endDate);
+	BigDecimal sumBySerialNumber(String serialNumber,String curMonth,String templateId);
+	BigDecimal sumBudgetRevenue(String serialNumber,String startDate,String endDate,String templateId);
 	Page<FundIncomeInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 }

+ 5 - 5
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/FundIncomeInfoServiceImpl.java

@@ -65,7 +65,7 @@ public class FundIncomeInfoServiceImpl implements FundIncomeInfoService {
         String startDate = year + "-01" + "-01";
         String endDate = year + "-12" + "-31";
 
-        List<FundIncomeInfo> fundIncomeInfoList = fundIncomeInfoDAO.findByYear(startDate,endDate);
+        List<FundIncomeInfo> fundIncomeInfoList = fundIncomeInfoDAO.findByYear(startDate,endDate,templateId);
 
         for (FundIncomeInfo item : fundIncomeInfoList) {
             item.setDelFlag(true);
@@ -144,14 +144,14 @@ public class FundIncomeInfoServiceImpl implements FundIncomeInfoService {
 
 
     @Override
-    public BigDecimal sumBySerialNumber(String serialNumber, String curMonth) {
-        return fundIncomeInfoDAO.sumBySerialNumber(serialNumber, curMonth);
+    public BigDecimal sumBySerialNumber(String serialNumber, String curMonth,String templateId) {
+        return fundIncomeInfoDAO.sumBySerialNumber(serialNumber, curMonth, templateId);
     }
 
 
     @Override
-    public BigDecimal sumBudgetRevenue(String serialNumber, String startDate, String endDate) {
-        return fundIncomeInfoDAO.sumBudgetRevenue(serialNumber, startDate, endDate);
+    public BigDecimal sumBudgetRevenue(String serialNumber, String startDate, String endDate,String templateId) {
+        return fundIncomeInfoDAO.sumBudgetRevenue(serialNumber, startDate, endDate,templateId);
     }
 
     @Override

+ 6 - 0
common/src/main/resources/mapper/base/FundIncomeInfo.xml

@@ -160,6 +160,7 @@
 			where del_flag=false
 			and year_>=#{startDate}
 			and year_<=#{endDate}
+			and template_id=#{templateId}
 			order by create_time
 		]]>
 	</select>
@@ -169,6 +170,7 @@
 			where del_flag=false
 			and serial_number=#{serialNumber}
 			and year_<=#{curMonth}
+			and template_id=#{templateId}
 			order by create_time
 		]]>
 	</select>
@@ -179,6 +181,7 @@
 			and serial_number like #{serialNumber}
 			and year_>=#{startDate}
 			and year_<=#{endDate}
+			and template_id=#{templateId}
 			order by create_time
 		]]>
 	</select>
@@ -198,6 +201,9 @@
 					and year_<=#{searchParams.endDate}
 				]]>
 			</if>
+			<if test="searchParams.templateId != null">
+				and template_id = #{searchParams.templateId}
+			</if>
 			<if test="searchParams.name != null">
 				and name_ like #{searchParams.name}
 			</if>

+ 1 - 1
common/src/main/resources/mapper/base/TemplateInfo.xml

@@ -96,7 +96,7 @@
 	<select id="list" resultMap="TemplateInfoMap">
 		select * from base_template_info
 		where del_flag = false and status_='1'
-		order by create_time asc
+		order by create_time desc
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="TemplateInfoMap">
 		<![CDATA[

+ 50 - 7
web/src/main/java/com/jpsoft/employment/modules/base/controller/FundIncomeInfoController.java

@@ -182,6 +182,45 @@ public class FundIncomeInfoController {
         return msgResult;
     }
 
+
+
+    @ApiOperation(value = "批量保存")
+    @PostMapping("batchSave")
+    public MessageResult<FundIncomeInfo> batchSave(@RequestBody List<FundIncomeInfo> list, @RequestAttribute String subject) {
+        MessageResult<FundIncomeInfo> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (FundIncomeInfo fundIncomeInfo:list) {
+                fundIncomeInfo.setUpdateBy(subject);
+                fundIncomeInfo.setUpdateTime(new Date());
+
+                if (StringUtils.isNotEmpty(fundIncomeInfo.getEndDateStr())) {
+                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+                    fundIncomeInfo.setEndDate(sdf.parse(fundIncomeInfo.getEndDateStr()));
+                }
+
+                affectCount += fundIncomeInfoService.update(fundIncomeInfo);
+            }
+
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value = "删除用户")
     @PostMapping("delete/{id}")
     public MessageResult<FundIncomeInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
@@ -278,7 +317,7 @@ public class FundIncomeInfoController {
     @ApiOperation(value = "列表")
     @RequestMapping(value = "pageList", method = RequestMethod.POST)
     public MessageResult<Object> pageList(
-            String yearMonth, String name,
+            String yearMonth, String name,String templateId,
             @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
             @RequestParam(value = "pageSize", defaultValue = "20000") int pageSize,
             @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
@@ -314,6 +353,10 @@ public class FundIncomeInfoController {
                 searchParams.put("name", "%" + name + "%");
             }
 
+            if (StringUtils.isNotEmpty(templateId)) {
+                searchParams.put("templateId", templateId);
+            }
+
 
             Page<FundIncomeInfo> page = fundIncomeInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
@@ -333,7 +376,7 @@ public class FundIncomeInfoController {
                 if (fundIncomeInfo.getIsSum() != null) {
                     if (fundIncomeInfo.getIsSum()) {
                         String serialNumber = fundIncomeInfo.getSerialNumber();
-                        BigDecimal sumBudget = fundIncomeInfoService.sumBudgetRevenue(serialNumber + ".%", startDate, endDate);
+                        BigDecimal sumBudget = fundIncomeInfoService.sumBudgetRevenue(serialNumber + ".%", startDate, endDate, templateId);
                         budgetRevenue = sumBudget;
                     }
                 }
@@ -352,7 +395,7 @@ public class FundIncomeInfoController {
                 String year = "";
 
                 if (fundIncomeInfo.getYear() != null) {
-                    year = sdf3.format(fundIncomeInfo.getYear());
+                    year = sdf.format(fundIncomeInfo.getYear());
                 }
 
                 if (fundIncomeInfo.getCreateTime() != null) {
@@ -430,12 +473,12 @@ public class FundIncomeInfoController {
                 map.put("bak", fundIncomeInfo.getBak());
                 map.put("year", year);
 
-                BigDecimal total = fundIncomeInfoService.sumBySerialNumber(fundIncomeInfo.getSerialNumber(), curMonth);
+                BigDecimal total = fundIncomeInfoService.sumBySerialNumber(fundIncomeInfo.getSerialNumber(), curMonth, templateId);
 
                 map.put("total", total);
 
                 BigDecimal accumulatedArrears = fundIncomeInfo.getBudgetRevenue();
-                if (total != null) {
+                if (total != null && accumulatedArrears != null) {
                     accumulatedArrears = accumulatedArrears.subtract(total);
                 }
 
@@ -479,7 +522,7 @@ public class FundIncomeInfoController {
         Row rowTitle = sheet.createRow(0);
 
         String[] titles = new String[]{"序号", "项目名称", "预算收入", "账户名称", "本月到账资金", "实际总收入", "累计欠费",
-                "收入时间区间", "收入类型", "终止日", "收入实现部门", "会计主体名称", "备注", "所属年"};
+                "收入时间区间", "收入类型", "终止日", "收入实现部门", "会计主体名称", "备注", "所属年"};
 
         for (int i = 0; i < titles.length; i++) {
             Cell cell = rowTitle.createCell(i);
@@ -506,7 +549,7 @@ public class FundIncomeInfoController {
             row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("incomeDepartment"), ""));
             row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("accountingName"), ""));
             row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("bak"), ""));
-            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("year"), ""));
+            row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("yearMonthStr"), ""));
         }
 
         ByteArrayOutputStream output = new ByteArrayOutputStream();

+ 2 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/TemplateInfoController.java

@@ -32,6 +32,7 @@ public class TemplateInfoController {
         MessageResult<TemplateInfo> msgResult = new MessageResult<>();
 
         TemplateInfo templateInfo = new TemplateInfo();
+        templateInfo.setType("1");
 
         msgResult.setData(templateInfo);
         msgResult.setResult(true);
@@ -49,6 +50,7 @@ public class TemplateInfoController {
 			templateInfo.setDelFlag(false);
             templateInfo.setCreateBy(subject);
             templateInfo.setCreateTime(new Date());
+            templateInfo.setStatus("0");
 
 
             int affectCount = templateInfoService.insert(templateInfo);