Browse Source

000000021

zhoulisky 6 months ago
parent
commit
5a20bbdfe4

+ 3 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/excel/listener/XmGoodsImportListener.java

@@ -8,6 +8,8 @@ import org.sky.core.tool.utils.DateUtil;
 import org.sky.scientific.excel.XmGoodsExcel;
 import org.sky.scientific.utils.ImportResult;
 import org.sky.scientific.utils.ValidationUtils;
+
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -50,7 +52,7 @@ public class XmGoodsImportListener extends BaseReadListener {
 		excel.setUnit(data.get(8));
 		excel.setUnitPrice(ValidationUtils.safeParseBigDecimal(data.get(9)));
 		excel.setUseQuantity(ValidationUtils.safeParseInteger(data.get(10)));
-		excel.setAmount(ValidationUtils.safeParseBigDecimal(data.get(11)));
+		excel.setAmount(BigDecimal.valueOf(excel.getUseQuantity()).multiply(excel.getUnitPrice()));
 
 		errors.addAll(ValidationUtils.validate(excel));
 		if (!errors.isEmpty()) {

+ 10 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AssetMapper.xml

@@ -175,8 +175,16 @@
     <select id="costSummary" resultType="org.sky.scientific.pojo.vo.CostSummaryVO" parameterType="org.sky.scientific.pojo.dto.CostSummaryDTO">
         SELECT
             m.month AS yearAndMonth,
-            ( select ROUND(IFNULL(sum(IFNULL(average_monthly_salary,0)) + sum(IFNULL(pension_insurance,0)) + sum(IFNULL(medical_insurance,0)) + sum(IFNULL(unemployment_insurance,0)) + sum(IFNULL(injury_insurance,0)) + sum(IFNULL(maternity_insurance,0)),0), 2) from kd_salary where tenant_id = #{tenantId} and year_and_month = m.month ) as ryrgfy,
-            (SELECT ROUND(IFNULL(sum(amount),0),2) FROM kd_xm_direct_cost WHERE tenant_id = #{tenantId} and year_and_month = m.month ) as zjtrfy,
+            (select ROUND(IFNULL(sum(IFNULL(average_monthly_salary,0)) + sum(IFNULL(pension_insurance,0)) + sum(IFNULL(medical_insurance,0)) + sum(IFNULL(unemployment_insurance,0)) + sum(IFNULL(injury_insurance,0)) + sum(IFNULL(maternity_insurance,0)),0), 2) from kd_salary where tenant_id = #{tenantId} and year_and_month = m.month ) as ryrgfy,
+            (SELECT ROUND(IFNULL(sum(amount),0),2)
+            from
+            (
+                SELECT sum(amount) as amount,year_and_month  from kd_xm_goods where tenant_id =  #{tenantId}
+                union
+                SELECT sum(amount) as amount,year_and_month from kd_xm_lease where tenant_id =  #{tenantId}
+                union
+                select sum(amount) as amount,year_and_month from kd_xm_direct_cost where tenant_id =  #{tenantId}
+            )cost where cost.year_and_month = m.month) as zjtrfy,
             (ROUND((SELECT IFNULL(sum(yanfa_tan_xiao),0) FROM yiqishebeiassetcostview WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(yanfa_fen_tan),0) FROM fangwujianzhuwuAssetCostView WHERE  tenant_id = #{tenantId} and year_and_month = m.month ) + (SELECT IFNULL(sum(ytxe*syzb),0) FROM kd_xm_cqdtfy WHERE  tenant_id = #{tenantId} and year_and_month = m.month),2)) as zjfyycqdtfy,
             (SELECT ROUND(IFNULL(sum(amount),0),2) FROM kd_xm_design_cost WHERE tenant_id = #{tenantId} and cost_type='设计费用' and year_and_month = m.month) as sjfy,
             (SELECT ROUND(IFNULL(sum(yanfaTanXiao),0),2) FROM wuxingAssetCostView WHERE  tenant_id = #{tenantId} and year_and_month = m.month) as wxzctxfy,

+ 1 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.xml

@@ -113,6 +113,7 @@
             FROM kd_xm temp
         ) xm ON m.xm_id = xm.xm_id
         WHERE m.year_and_month = #{ew.yearAndMonth}
+        <if test="ew.xmId!=null">and m.xm_id = #{ew.xmId}</if>
         <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.XMMC like concat('%',#{ew.xmmc},'%')</if>
         <if test="ew.name!=null and ew.name!=''">and t.name like concat('%',#{ew.name},'%')</if>
         <if test="ew.number!=null and ew.number!=''">and t.number like concat('%',#{ew.number},'%')</if>

+ 2 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AssetServiceImpl.java

@@ -34,6 +34,7 @@ import org.sky.scientific.pojo.vo.AssetVO;
 import org.sky.scientific.pojo.vo.CostSummaryVO;
 import org.sky.scientific.pojo.vo.XmAssetCostSummary;
 import org.sky.scientific.service.IAssetService;
+import org.sky.scientific.service.IXmDirectCostService;
 import org.sky.system.cache.DictCache;
 import org.sky.system.pojo.entity.Dict;
 import org.springframework.stereotype.Service;
@@ -59,6 +60,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 @AllArgsConstructor
 public class AssetServiceImpl extends BaseServiceImpl<AssetMapper, AssetEntity> implements IAssetService {
 
+	private final IXmDirectCostService directCostService;
 	private final XmAssetHoursMapper hoursMapper;
 	private final XmFixedAssetMapper fixedAssetMapper;
 	private final XmIntangibleAssetMapper intangibleAssetMapper;

+ 40 - 27
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SubjectServiceImpl.java

@@ -31,6 +31,7 @@ import org.sky.scientific.pojo.entity.SubjectEnterprise;
 import org.sky.scientific.pojo.entity.XmCostDetailsEntity;
 import org.sky.scientific.pojo.vo.SubjectVO;
 import org.sky.scientific.service.ISubjectService;
+import org.sky.scientific.utils.ExportUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -147,36 +148,37 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
 	public void exportSubject(HttpServletResponse response, SubjectQueryDto dto) {
 
 		List<SubjectVO> list = this.lazyList(dto);
-		List<JSONObject> resultList = new ArrayList<>();
-		traverseSubjectTree(list.get(0), null, null, null, null, 1, resultList);
+		if (Func.isEmpty(list)) {
+			ExportUtil.processWithNoData(response);
+		} else {
+			List<JSONObject> resultList = new ArrayList<>();
+			traverseSubjectTree(list.get(0), null, null, null, null, 1, resultList);
 
-		AtomicInteger index = new AtomicInteger(1);
- 		for (JSONObject obj : resultList) {
- 			obj.put("xh", index.getAndIncrement() + "");
- 		}
+			AtomicInteger index = new AtomicInteger(1);
+			for (JSONObject obj : resultList) {
+				obj.put("xh", index.getAndIncrement() + "");
+			}
 
-		InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/基础资源管理/系统预设会计科目.xls");
-		response.setContentType("application/vnd.ms-excel");
-		response.setCharacterEncoding("utf-8");
-		response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("系统预设会计科目.xls", Charsets.UTF_8));
-		ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
-			.withTemplate((templateFileName))
-			.excelType(ExcelTypeEnum.XLS)
-			.build();
+			InputStream templateFileName = this.getClass().getClassLoader().getResourceAsStream("export-template/基础资源管理/系统预设会计科目.xls");
+			response.setContentType("application/vnd.ms-excel");
+			response.setCharacterEncoding("utf-8");
+			response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("系统预设会计科目.xlsx", Charsets.UTF_8));
+			ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
+				.withTemplate((templateFileName))
+				.excelType(ExcelTypeEnum.XLS)
+				.build();
 
-		WriteSheet writeSheet = EasyExcel.writerSheet().build();
-		//设置list集合数据
-		excelWriter.fill(resultList, writeSheet);
-		excelWriter.finish();
-		if (templateFileName != null) {
-			templateFileName.close();
+			WriteSheet writeSheet = EasyExcel.writerSheet().build();
+			//设置list集合数据
+			excelWriter.fill(resultList, writeSheet);
+			excelWriter.finish();
+			if (templateFileName != null) {
+				templateFileName.close();
+			}
 		}
 	}
 
-	private static void traverseSubjectTree(SubjectVO currentNode,
-											String l1, String l2,
-											String l3, String l4,int currentLevel,
-											List<JSONObject> result) {
+	private static void traverseSubjectTree(SubjectVO currentNode, String l1, String l2, String l3, String l4, int currentLevel, List<JSONObject> result) {
 		if (currentNode == null) {
 			return;
 		}
@@ -208,15 +210,26 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
 		node.put("l2", newL2);
 		node.put("l3", newL3);
 		node.put("l4", newL4);
-
+		List<String> nameList = new ArrayList<>();
+		if (Func.isNotEmpty(newL1)) nameList.add(newL1);
+		if (Func.isNotEmpty(newL2)) nameList.add(newL2);
+		if (Func.isNotEmpty(newL3)) nameList.add(newL3);
+		if (Func.isNotEmpty(newL4)) nameList.add(newL4);
 		node.put("code", currentNode.getCode());
-		node.put("name", currentNode.getName());
+		if (currentLevel == 4 && Func.isNotEmpty(nameList)) {
+			node.put("name", String.join("\\", nameList));
+		} else {
+			node.put("name", null);
+		}
+		node.put("adSubject", currentNode.getAdSubjectEnable() == 1 ? node.get("name") : null);
+		node.put("rdSubject", currentNode.getRdSubjectEnable() == 1 ? node.get("name") : null);
+
 		result.add(node);
 
 		// 递归处理子节点
 		if (currentNode.getChildren() != null && !currentNode.getChildren().isEmpty()) {
 			for (SubjectVO child : currentNode.getChildren()) {
-				traverseSubjectTree(child, newL1, newL2, newL3, newL4, currentLevel+1, result);
+				traverseSubjectTree(child, newL1, newL2, newL3, newL4, currentLevel + 1, result);
 			}
 		}
 	}

+ 5 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmDirectCostServiceImpl.java

@@ -157,6 +157,11 @@ public class XmDirectCostServiceImpl extends BaseServiceImpl<XmDirectCostMapper,
 			list = baseMapper.tourufeiyonghuizongbiao(dto);
 		} else if (dto.getYearAndMonth().length() == 4) {
 			list = baseMapper.tourufeiyonghuizongbiaoByYear(dto);
+		}else {
+			throw new ServiceException("参数yearAndMonth格式错误,只能是yyyy或者yyyyMM");
+		}
+		for (XmDirectCostSummary summary : list) {
+			summary.setTotal(summary.getCailiaofy().add(summary.getRanliaofy()).add(summary.getDonglify()).add(summary.getYiqishebeify()).add(summary.getFawuzulinfy()).add(summary.getFy6()).add(summary.getFy7()).add(summary.getFy8()));
 		}
 		return list;
 	}

+ 1 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmLeaseServiceImpl.java

@@ -133,6 +133,7 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
 		if (judged != null) {
 			throw new ServiceException(judged);
 		}
+		xmLease.setAmount(xmLease.getUnitPrice().multiply(BigDecimal.valueOf(xmLease.getQuantity())));
 		return this.saveOrUpdate(xmLease);
 	}
 

BIN
kd-service/kd-scientific/src/main/resources/export-template/基础资源管理/系统预设会计科目.xls


BIN
kd-service/kd-scientific/src/main/resources/export-template/基础资源管理/系统预设会计科目.xlsx