Prechádzať zdrojové kódy

2024年5月20日17:34:22

纪新园 1 rok pred
rodič
commit
cf2ba65a7c
16 zmenil súbory, kde vykonal 843 pridanie a 165 odobranie
  1. 0 1
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/acc/vo/AccountsDetail.java
  2. 1 0
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenter.java
  3. 128 114
      blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/genleg/entity/FinPeriod.java
  4. 5 2
      blade-service/blade-los/src/main/java/org/springblade/los/basic/acc/mapper/AccountsMapper.xml
  5. 11 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/controller/LosBFeesTemplateController.java
  6. 2 0
      blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/ILosBFeesTemplateService.java
  7. 46 11
      blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/impl/LosBFeesTemplateServiceImpl.java
  8. 4 4
      blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/TemplateImportServiceImpl.java
  9. 46 0
      blade-service/blade-los/src/main/java/org/springblade/los/excel/ReviewFailedExcel.java
  10. 41 0
      blade-service/blade-los/src/main/java/org/springblade/los/excel/UnbookkeptExcel.java
  11. 6 7
      blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java
  12. 1 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/controller/FinGenlegCalcController.java
  13. 25 23
      blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/controller/FinPeriodController.java
  14. 15 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/IFinPeriodService.java
  15. 509 3
      blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/impl/FinPeriodServiceImpl.java
  16. 3 0
      blade-service/blade-los/src/main/java/org/springblade/los/finance/vouchers/service/impl/FinVouchersServiceImpl.java

+ 0 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/basic/acc/vo/AccountsDetail.java

@@ -16,7 +16,6 @@
  */
 package org.springblade.los.basic.acc.vo;
 
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;

+ 1 - 0
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/fee/entity/FeeCenter.java

@@ -882,3 +882,4 @@ public class FeeCenter implements Serializable {
 
 
 }
+

+ 128 - 114
blade-service-api/blade-los-api/src/main/java/org/springblade/los/finance/genleg/entity/FinPeriod.java

@@ -16,14 +16,15 @@
  */
 package org.springblade.los.finance.genleg.entity;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.io.Serializable;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 业务-财务期间实体类
@@ -39,115 +40,128 @@ public class FinPeriod implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	/**
-	* 主键
-	*/
-		@ApiModelProperty(value = "主键")
-		private Long id;
-	/**
-	* 分公司 Id
-	*/
-		@ApiModelProperty(value = "分公司 Id")
-		private Long branchId;
-	/**
-	* 创建人 Id
-	*/
-		@ApiModelProperty(value = "创建人 Id")
-		private Long createUser;
-	/**
-	* 创建人
-	*/
-		@ApiModelProperty(value = "创建人")
-		private String createUserName;
-	/**
-	* 创建部门 Id
-	*/
-		@ApiModelProperty(value = "创建部门 Id")
-		private Long createDept;
-	/**
-	* 创建部门
-	*/
-		@ApiModelProperty(value = "创建部门")
-		private String createDeptName;
-	/**
-	* 创建时间
-	*/
-		@ApiModelProperty(value = "创建时间")
-		private LocalDateTime createTime;
-	/**
-	* 修改人 Id
-	*/
-		@ApiModelProperty(value = "修改人 Id")
-		private Long updateUser;
-	/**
-	* 修改人
-	*/
-		@ApiModelProperty(value = "修改人")
-		private String updateUserName;
-	/**
-	* 修改时间
-	*/
-		@ApiModelProperty(value = "修改时间")
-		private LocalDateTime updateTime;
-	/**
-	* 期间类型,财务期间可以用 FIN
-	*/
-		@ApiModelProperty(value = "期间类型,财务期间可以用 FIN")
-		private String periodType;
-	/**
-	* 期间子类型,财务期间可以用 VOUCHER
-	*/
-		@ApiModelProperty(value = "期间子类型,财务期间可以用 VOUCHER")
-		private String periodSubtype;
-	/**
-	* 期间年
-	*/
-		@ApiModelProperty(value = "期间年")
-		private Integer periodYear;
-	/**
-	* 期间月
-	*/
-		@ApiModelProperty(value = "期间月")
-		private Integer periodMonth;
-	/**
-	* 期间开始日期
-	*/
-		@ApiModelProperty(value = "期间开始日期")
-		private LocalDate beginDate;
-	/**
-	* 期间结束日期
-	*/
-		@ApiModelProperty(value = "期间结束日期")
-		private LocalDate endDate;
-	/**
-	* 是否已结转(0 否 1是)
-	*/
-		@ApiModelProperty(value = "是否已结转(0 否 1是)")
-		private Integer isClosed;
-	/**
-	* 结转日期
-	*/
-		@ApiModelProperty(value = "结转日期")
-		private LocalDate closeDate;
-	/**
-	* 版本
-	*/
-		@ApiModelProperty(value = "版本")
-		private String version;
-	/**
-	* 状态(0 正常 1停用)
-	*/
-		@ApiModelProperty(value = "状态(0 正常 1停用)")
-		private Integer status;
-	/**
-	* 是否已删除(0 否 1是)
-	*/
-		@ApiModelProperty(value = "是否已删除(0 否 1是)")
-		private Integer isDeleted;
-	/**
-	* 备注
-	*/
-		@ApiModelProperty(value = "备注")
-		private String remarks;
+	 * 主键
+	 */
+	@ApiModelProperty(value = "主键")
+	private Long id;
+	/**
+	 * 分公司 Id
+	 */
+	@ApiModelProperty(value = "分公司 Id")
+	private String branchId;
+	/**
+	 * 创建人 Id
+	 */
+	@ApiModelProperty(value = "创建人 Id")
+	private Long createUser;
+	/**
+	 * 创建人
+	 */
+	@ApiModelProperty(value = "创建人")
+	private String createUserName;
+	/**
+	 * 创建部门 Id
+	 */
+	@ApiModelProperty(value = "创建部门 Id")
+	private String createDept;
+	/**
+	 * 创建部门
+	 */
+	@ApiModelProperty(value = "创建部门")
+	private String createDeptName;
+	/**
+	 * 创建时间
+	 */
+	@ApiModelProperty(value = "创建时间")
+	private Date createTime;
+	/**
+	 * 修改人 Id
+	 */
+	@ApiModelProperty(value = "修改人 Id")
+	private Long updateUser;
+	/**
+	 * 修改人
+	 */
+	@ApiModelProperty(value = "修改人")
+	private String updateUserName;
+	/**
+	 * 修改时间
+	 */
+	@ApiModelProperty(value = "修改时间")
+	private Date updateTime;
+	/**
+	 * 期间类型,财务期间可以用 FIN
+	 */
+	@ApiModelProperty(value = "期间类型,财务期间可以用 FIN")
+	private String periodType;
+	/**
+	 * 期间子类型,财务期间可以用 VOUCHER
+	 */
+	@ApiModelProperty(value = "期间子类型,财务期间可以用 VOUCHER")
+	private String periodSubtype;
+	/**
+	 * 期间年
+	 */
+	@ApiModelProperty(value = "期间年")
+	private Integer periodYear;
+	/**
+	 * 期间月
+	 */
+	@ApiModelProperty(value = "期间月")
+	private Integer periodMonth;
+	/**
+	 * 期间开始日期
+	 */
+	@ApiModelProperty(value = "期间开始日期")
+	private Date beginDate;
+	/**
+	 * 期间结束日期
+	 */
+	@ApiModelProperty(value = "期间结束日期")
+	private Date endDate;
+	/**
+	 * 是否已结转(0 否 1是)
+	 */
+	@ApiModelProperty(value = "是否已结转(0 否 1是)")
+	private Integer isClosed;
+	/**
+	 * 结转日期
+	 */
+	@ApiModelProperty(value = "结转日期")
+	@TableField(updateStrategy = FieldStrategy.IGNORED)
+	private Date closeDate;
+	/**
+	 * 版本
+	 */
+	@ApiModelProperty(value = "版本")
+	private String version;
+	/**
+	 * 状态(0 正常 1停用)
+	 */
+	@ApiModelProperty(value = "状态(0 正常 1停用)")
+	private Integer status;
+	/**
+	 * 是否已删除(0 否 1是)
+	 */
+	@ApiModelProperty(value = "是否已删除(0 否 1是)")
+	private Integer isDeleted;
+	/**
+	 * 备注
+	 */
+	@ApiModelProperty(value = "备注")
+	private String remarks;
+
+	/**
+	 * 租户
+	 */
+	@ApiModelProperty(value = "租户")
+	private String tenantId;
+
+	/**
+	 * 是否锁定 (0 否 1是)
+	 */
+	@ApiModelProperty(value = "是否锁定")
+	private Integer lockingStatus;
 
 
 }

+ 5 - 2
blade-service/blade-los/src/main/java/org/springblade/los/basic/acc/mapper/AccountsMapper.xml

@@ -138,11 +138,14 @@
         <if test="accountsDetail.curCode!=null and accountsDetail.curCode!=''">
             and item.cur_code = #{accountsDetail.curCode}
         </if>
+        <if test="accountsDetail.accountYear!=null and accountsDetail.accountYear!=''">
+            and item.account_year = #{accountsDetail.accountYear}
+        </if>
         <if test="accountsDetail.startDate!=null and accountsDetail.startDate!=''">
-            and item.voucher_date &gt;= #{accountsDetail.startDate}
+            and item.account_month &gt;= #{accountsDetail.startDate}
         </if>
         <if test="accountsDetail.endDate!=null and accountsDetail.endDate!=''">
-            and item.voucher_date &lt;= #{accountsDetail.endDate}
+            and item.account_month &lt;= #{accountsDetail.endDate}
         </if>
         <if test="accountsDetail.startCode!=null and accountsDetail.startCode!=''">
             and ac.code &gt;= #{accountsDetail.startCode}

+ 11 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/controller/LosBFeesTemplateController.java

@@ -214,5 +214,16 @@ public class LosBFeesTemplateController extends BladeController {
 		return R.data(pages);
 	}
 
+	/**
+	 * 复制
+	 */
+	@GetMapping("/copy")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入losBFeesTemplate")
+	public R<LosBFeesTemplate> copy(LosBFeesTemplate losBFeesTemplate) {
+		LosBFeesTemplate detail = losBFeesTemplateService.copy(losBFeesTemplate);
+		return R.data(detail);
+	}
+
 
 }

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/ILosBFeesTemplateService.java

@@ -62,4 +62,6 @@ public interface ILosBFeesTemplateService extends IService<LosBFeesTemplate> {
 	 * @return
 	 */
 	LosBFeesTemplate detail(LosBFeesTemplate losBFeesTemplate);
+
+	LosBFeesTemplate copy(LosBFeesTemplate losBFeesTemplate);
 }

+ 46 - 11
blade-service/blade-los/src/main/java/org/springblade/los/basic/fees/service/impl/LosBFeesTemplateServiceImpl.java

@@ -26,13 +26,13 @@ import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.los.Util.IDeptUtils;
-import org.springblade.los.excel.LosBFeesTemplateExcel;
 import org.springblade.los.basic.fees.entity.FeesTemplateItems;
 import org.springblade.los.basic.fees.entity.LosBFeesTemplate;
 import org.springblade.los.basic.fees.mapper.LosBFeesTemplateMapper;
 import org.springblade.los.basic.fees.service.IFeesTemplateItemsService;
 import org.springblade.los.basic.fees.service.ILosBFeesTemplateService;
 import org.springblade.los.basic.fees.vo.LosBFeesTemplateVO;
+import org.springblade.los.excel.LosBFeesTemplateExcel;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -81,9 +81,9 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 				losBFeesTemplate.setCreateUser(AuthUtil.getUserId());
 				losBFeesTemplate.setCreateUserName(AuthUtil.getUserName());
 				//获取部门ids对应中文名
-				if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
-					losBFeesTemplate.setCreateDept(deptUtils.getDeptPid()+"");
-					R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid()+"");
+				if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
+					losBFeesTemplate.setCreateDept(deptUtils.getDeptPid() + "");
+					R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid() + "");
 					if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
 						losBFeesTemplate.setCreateDeptName(String.join(",", res.getData()));
 					}
@@ -106,9 +106,9 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 		String deptId = "";
 		String deptName = "";
 		//获取部门ids对应中文名
-		if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
-			deptId = deptUtils.getDeptPid()+"";
-			R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid()+"");
+		if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
+			deptId = deptUtils.getDeptPid() + "";
+			R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid() + "");
 			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
 				deptName = String.join(",", res.getData());
 			}
@@ -117,7 +117,7 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 			losBFeesTemplate.setCreateTime(new Date());
 			losBFeesTemplate.setCreateUser(AuthUtil.getUserId());
 			losBFeesTemplate.setCreateUserName(AuthUtil.getUserName());
-			if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
+			if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
 				losBFeesTemplate.setCreateDept(deptId);
 				losBFeesTemplate.setCreateDeptName(deptName);
 			}
@@ -130,18 +130,18 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 		if (ObjectUtils.isNotNull(losBFeesTemplate.getFeesTemplateItemsList())) {
 			for (FeesTemplateItems item : losBFeesTemplate.getFeesTemplateItemsList()) {
 				item.setPid(losBFeesTemplate.getId());
-				if (ObjectUtils.isNotNull(item.getCorpType())){
+				if (ObjectUtils.isNotNull(item.getCorpType())) {
 					item.setCorpId(0L);
 					item.setCorpCnName("");
 					item.setCorpEnName("");
-				}else{
+				} else {
 					item.setCorpType("");
 				}
 				if (item.getId() == null) {
 					item.setCreateTime(new Date());
 					item.setCreateUser(AuthUtil.getUserId());
 					item.setCreateUserName(AuthUtil.getUserName());
-					if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
+					if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
 						item.setCreateDept(deptId);
 						item.setCreateDeptName(deptName);
 					}
@@ -170,4 +170,39 @@ public class LosBFeesTemplateServiceImpl extends ServiceImpl<LosBFeesTemplateMap
 		return detail;
 	}
 
+	@Override
+	public LosBFeesTemplate copy(LosBFeesTemplate losBFeesTemplate) {
+		if (losBFeesTemplate.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		LosBFeesTemplate detail = baseMapper.selectById(losBFeesTemplate.getId());
+		detail.setId(null);
+		detail.setCreateDept(null);
+		detail.setCreateDeptName(null);
+		detail.setCreateTime(null);
+		detail.setCreateUserName(null);
+		detail.setCreateUser(null);
+		detail.setUpdateTime(null);
+		detail.setUpdateUser(null);
+		detail.setUpdateUserName(null);
+		List<FeesTemplateItems> feesTemplateItemsList = feesTemplateItemsService.list(new LambdaQueryWrapper<FeesTemplateItems>()
+			.eq(FeesTemplateItems::getIsDeleted, 0)
+			.eq(FeesTemplateItems::getTenantId, AuthUtil.getTenantId())
+			.eq(FeesTemplateItems::getPid, losBFeesTemplate.getId()));
+		for (FeesTemplateItems item : feesTemplateItemsList) {
+			item.setId(null);
+			item.setPid(null);
+			item.setCreateDept(null);
+			item.setCreateDeptName(null);
+			item.setCreateTime(null);
+			item.setCreateUserName(null);
+			item.setCreateUser(null);
+			item.setUpdateTime(null);
+			item.setUpdateUser(null);
+			item.setUpdateUserName(null);
+		}
+		detail.setFeesTemplateItemsList(feesTemplateItemsList);
+		return detail;
+	}
+
 }

+ 4 - 4
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/TemplateImportServiceImpl.java

@@ -107,7 +107,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
 			String vslVoy = sheet.getRow(18).getCell(4).getStringCellValue();
 			if (vslVoy.contains("/")) {
 				String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
-				String voy = vslVoy.substring(vslVoy.indexOf("/"));
+				String voy = vslVoy.substring(vslVoy.indexOf("/") + 1);
 				bills.setVesselEnName(vsl);
 				bills.setVoyageNo(voy);
 				System.out.println("vsl:" + vsl);
@@ -254,7 +254,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
 		for (Field field : fields) {
 			try {
 				field.setAccessible(true); // 使得私有属性也可以访问
-				if (field.getType() == String.class){
+				if (field.getType() == String.class) {
 					Object value = field.get(bills);
 					if (value == null) {
 						field.set(bills, "");
@@ -363,7 +363,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
 		for (Field field : fields) {
 			try {
 				field.setAccessible(true); // 使得私有属性也可以访问
-				if (field.getType() == String.class){
+				if (field.getType() == String.class) {
 					Object value = field.get(bills);
 					if (value == null) {
 						field.set(bills, "");
@@ -465,7 +465,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
 		for (Field field : fields) {
 			try {
 				field.setAccessible(true); // 使得私有属性也可以访问
-				if (field.getType() == String.class){
+				if (field.getType() == String.class) {
 					Object value = field.get(bills);
 					if (value == null) {
 						field.set(bills, "");

+ 46 - 0
blade-service/blade-los/src/main/java/org/springblade/los/excel/ReviewFailedExcel.java

@@ -0,0 +1,46 @@
+package org.springblade.los.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author :jixinyuan
+ * @date : 2024/5/20
+ */
+@Data
+public class ReviewFailedExcel {
+
+	/**
+	 * 业务模块
+	 */
+	@ExcelProperty(value = "业务模块")
+	private String businessType;
+	/**
+	 * 单据号
+	 */
+	@ExcelProperty(value = "单据号")
+	private String billNo;
+	/**
+	 * 业务日期
+	 */
+	@ExcelProperty(value = "业务日期")
+	private Date businessDate;
+	/**
+	 * 提单号
+	 */
+	@ExcelProperty(value = "提单号")
+	private String mblno;
+	/**
+	 * 操作员
+	 */
+	@ExcelProperty(value = "操作员")
+	private String operator;
+	/**
+	 * 业务员
+	 */
+	@ExcelProperty(value = "业务员")
+	private String salesperson;
+
+}

+ 41 - 0
blade-service/blade-los/src/main/java/org/springblade/los/excel/UnbookkeptExcel.java

@@ -0,0 +1,41 @@
+package org.springblade.los.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author :jixinyuan
+ * @date : 2024/5/20
+ */
+@Data
+public class UnbookkeptExcel {
+
+	/**
+	 * 年
+	 */
+	@ExcelProperty(value = "年")
+	private String year;
+	/**
+	 * 月
+	 */
+	@ExcelProperty(value = "月")
+	private String month;
+	/**
+	 * 凭证号
+	 */
+	@ExcelProperty(value = "凭证号")
+	private String voucherNumber;
+	/**
+	 * 凭证日期
+	 */
+	@ExcelProperty(value = "凭证日期")
+	private Date voucherDate;
+	/**
+	 * 制单人
+	 */
+	@ExcelProperty(value = "制单人")
+	private String operator;
+
+}

+ 6 - 7
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java

@@ -49,7 +49,6 @@ import org.springblade.los.finance.stl.mapper.FinStlBillsItemsMapper;
 import org.springblade.los.finance.stl.mapper.FinStlBillsMapper;
 import org.springblade.los.finance.vouchers.entity.FinVouchersItems;
 import org.springblade.los.finance.vouchers.mapper.FinVouchersItemsMapper;
-import org.springblade.los.finance.vouchers.mapper.FinVouchersMapper;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -106,9 +105,9 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 			finAccBills.setCreateUser(AuthUtil.getUserId());
 			finAccBills.setCreateUserName(AuthUtil.getUserName());
 			//获取部门ids对应中文名
-			if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
-				finAccBills.setCreateDept(deptUtils.getDeptPid()+"");
-				R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid()+"");
+			if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
+				finAccBills.setCreateDept(deptUtils.getDeptPid() + "");
+				R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid() + "");
 				if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
 					finAccBills.setCreateDeptName(String.join(",", res.getData()));
 				}
@@ -135,9 +134,9 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 		String deptName = "";
 		String branchId = deptUtils.getDeptPid() + "";
 		//获取部门ids对应中文名
-		if (ObjectUtils.isNotNull(deptUtils.getDeptPid()+"")) {
-			deptId = deptUtils.getDeptPid()+"";
-			R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid()+"");
+		if (ObjectUtils.isNotNull(deptUtils.getDeptPid() + "")) {
+			deptId = deptUtils.getDeptPid() + "";
+			R<List<String>> res = sysClient.getDeptNames(deptUtils.getDeptPid() + "");
 			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
 				deptName = String.join(",", res.getData());
 			}

+ 1 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/controller/FinGenlegCalcController.java

@@ -225,6 +225,7 @@ public class FinGenlegCalcController extends BladeController {
 	 * 初始化(年)
 	 */
 	@GetMapping("/initialization")
+	@RepeatSubmit
 	public R<List<FinGenlegCalc>> initialization() {
 		List<FinGenlegCalc> pages = finGenlegCalcService.initialization();
 		return R.data(pages);

+ 25 - 23
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/controller/FinPeriodController.java

@@ -16,24 +16,24 @@
  */
 package org.springblade.los.finance.genleg.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
-import javax.validation.Valid;
-
 import org.springblade.common.annotation.RepeatSubmit;
+import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
-import org.springframework.web.bind.annotation.*;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.los.finance.genleg.entity.FinPeriod;
-import org.springblade.los.finance.genleg.vo.FinPeriodVO;
 import org.springblade.los.finance.genleg.service.IFinPeriodService;
-import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.los.finance.genleg.vo.FinPeriodVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
 
 /**
  * 业务-财务期间 控制器
@@ -110,7 +110,7 @@ public class FinPeriodController extends BladeController {
 	@ApiOperation(value = "新增或修改", notes = "传入finPeriod")
 	@RepeatSubmit
 	public R submit(@Valid @RequestBody FinPeriod finPeriod) {
-		return R.status(finPeriodService.saveOrUpdate(finPeriod));
+		return finPeriodService.submit(finPeriod);
 	}
 
 
@@ -129,39 +129,41 @@ public class FinPeriodController extends BladeController {
 	@ApiOperationSupport(order = 9)
 	@ApiOperation(value = "初始化期间", notes = "传入periodType, periodSubtype")
 	public R init(@Valid @RequestBody FinPeriod finPeriod) {
-
-		return R.status(true);
+		return finPeriodService.init(finPeriod);
 	}
 
-	@PostMapping("/open")
+	@PostMapping("/locking")
 	@ApiOperationSupport(order = 9)
-	@ApiOperation(value = "期间开账", notes = "传入periodType, periodSubtype, periodYear, periodMonth")
-	public R open(@Valid @RequestBody FinPeriod finPeriod) {
-		// query.
+	@ApiOperation(value = "业务锁定", notes = "传入id")
+	public R locking(@Valid @RequestBody FinPeriod finPeriod) {
+		return finPeriodService.locking(finPeriod);
+	}
 
-		return R.status(true);
+	@PostMapping("/revokeLocking")
+	@ApiOperationSupport(order = 9)
+	@ApiOperation(value = "撤销业务锁定", notes = "传入id")
+	public R revokeLocking(@Valid @RequestBody FinPeriod finPeriod) {
+		return finPeriodService.revokeLocking(finPeriod);
 	}
-	@GetMapping("/current_period")
+
+	@GetMapping("/currentPeriod")
 	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "查询当前活动期间", notes = "传入periodType, periodSubtype")
-	public R current_period(FinPeriod finPeriod, Query query) {
-
-		return R.status(true);
+	public R currentPeriod(FinPeriod finPeriod, Query query) {
+		return finPeriodService.currentPeriod(query, finPeriod);
 	}
 
 	@PostMapping("/close")
 	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "结转当前活动期间,同时开启下一期间", notes = "传入periodType,periodSubtype, 可选 periodYear, periodMonth")
 	public R close(@Valid @RequestBody FinPeriod finPeriod) {
-
-		return R.status(true);
+		return finPeriodService.close(finPeriod);
 	}
 
 	@PostMapping("/unclose")
 	@ApiOperationSupport(order = 10)
 	@ApiOperation(value = "反结转当前活动期间", notes = "传入periodType,periodSubtype, 可选 periodYear, periodMonth")
 	public R unclose(@Valid @RequestBody FinPeriod finPeriod) {
-
-		return R.status(true);
+		return finPeriodService.unclose(finPeriod);
 	}
 }

+ 15 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/IFinPeriodService.java

@@ -16,6 +16,8 @@
  */
 package org.springblade.los.finance.genleg.service;
 
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
 import org.springblade.los.finance.genleg.entity.FinPeriod;
 import org.springblade.los.finance.genleg.vo.FinPeriodVO;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -38,4 +40,17 @@ public interface IFinPeriodService extends IService<FinPeriod> {
 	 */
 	IPage<FinPeriodVO> selectFinPeriodPage(IPage<FinPeriodVO> page, FinPeriodVO finPeriod);
 
+    R init(FinPeriod finPeriod);
+
+	R locking(FinPeriod finPeriod);
+
+	R currentPeriod(Query query,FinPeriod finPeriod);
+
+	R close(FinPeriod finPeriod);
+
+	R unclose(FinPeriod finPeriod);
+
+	R submit(FinPeriod finPeriod);
+
+	R revokeLocking(FinPeriod finPeriod);
 }

+ 509 - 3
blade-service/blade-los/src/main/java/org/springblade/los/finance/genleg/service/impl/FinPeriodServiceImpl.java

@@ -16,13 +16,45 @@
  */
 package org.springblade.los.finance.genleg.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.seata.spring.annotation.GlobalTransactional;
+import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
+import org.springblade.los.Util.IDeptUtils;
+import org.springblade.los.business.aea.entity.AeaBills;
+import org.springblade.los.business.aea.service.IAeaBillsService;
+import org.springblade.los.business.amends.entity.Amends;
+import org.springblade.los.business.amends.service.IAmendsService;
+import org.springblade.los.business.customsDeclaration.entity.CustomsDeclaration;
+import org.springblade.los.business.customsDeclaration.service.ICustomsDeclarationService;
+import org.springblade.los.business.sea.entity.Bills;
+import org.springblade.los.business.sea.service.IBillsService;
+import org.springblade.los.excel.ReviewFailedExcel;
+import org.springblade.los.excel.UnbookkeptExcel;
 import org.springblade.los.finance.genleg.entity.FinPeriod;
-import org.springblade.los.finance.genleg.vo.FinPeriodVO;
 import org.springblade.los.finance.genleg.mapper.FinPeriodMapper;
 import org.springblade.los.finance.genleg.service.IFinPeriodService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.los.finance.genleg.vo.FinPeriodVO;
+import org.springblade.los.finance.stl.entity.FinStlBills;
+import org.springblade.los.finance.stl.service.IFinStlBillsService;
+import org.springblade.los.finance.vouchers.entity.FinVouchers;
+import org.springblade.los.finance.vouchers.service.IFinVouchersService;
+import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 业务-财务期间 服务实现类
@@ -31,11 +63,485 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
  * @since 2024-02-29
  */
 @Service
+@AllArgsConstructor
 public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod> implements IFinPeriodService {
 
+
+	private final ISysClient sysClient;
+
+	private final IDeptUtils deptUtils;
+
+	private final IBillsService billsService;
+
+	private final IAeaBillsService aeaBillsService;
+
+	private final IAmendsService amendsService;
+
+	private final ICustomsDeclarationService customsDeclarationService;
+
+	private final IFinStlBillsService finStlBillsService;
+
+	private final IFinVouchersService finVouchersService;
+
 	@Override
 	public IPage<FinPeriodVO> selectFinPeriodPage(IPage<FinPeriodVO> page, FinPeriodVO finPeriod) {
 		return page.setRecords(baseMapper.selectFinPeriodPage(page, finPeriod));
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
+	public R init(FinPeriod finPeriod) {
+		String deptId = "";
+		String deptName = "";
+		String branchId = deptUtils.getDeptPid() + "";
+		//获取部门ids对应中文名
+		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+			deptId = AuthUtil.getDeptId();
+			R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				deptName = String.join(",", res.getData());
+			}
+		}
+		if (baseMapper.selectCount(new LambdaQueryWrapper<FinPeriod>()
+			.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+			.eq(FinPeriod::getIsDeleted, 0)
+			.eq(FinPeriod::getBranchId, branchId)) > 0) {
+			throw new RuntimeException("本年度已有账期,请勿重复生成");
+		}
+		if (finPeriod.getId() == null) {
+			if (ObjectUtils.isNotNull(finPeriod.getBeginDate())) {
+				LocalDate date = finPeriod.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+				finPeriod.setPeriodYear(date.getYear());
+				finPeriod.setPeriodMonth(date.lengthOfMonth());
+			} else {
+				LocalDate date = LocalDate.now();
+				finPeriod.setPeriodYear(date.getYear());
+				finPeriod.setPeriodMonth(date.lengthOfMonth());
+				// 获取当前月的第一天
+				LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
+				// 获取当前月的最后一天
+				LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
+				finPeriod.setBeginDate(Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+				finPeriod.setEndDate(Date.from(lastDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+			}
+			finPeriod.setCreateTime(new Date());
+			finPeriod.setCreateUser(AuthUtil.getUserId());
+			finPeriod.setCreateUserName(AuthUtil.getUserName());
+			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+				finPeriod.setCreateDept(deptId);
+				finPeriod.setBranchId(branchId);
+				finPeriod.setCreateDeptName(deptName);
+			}
+		} else {
+			finPeriod.setUpdateUser(AuthUtil.getUserId());
+			finPeriod.setUpdateTime(new Date());
+			finPeriod.setUpdateUserName(AuthUtil.getUserName());
+		}
+		this.saveOrUpdate(finPeriod);
+		return R.data(finPeriod);
+	}
+
+	@Override
+	public R locking(FinPeriod finPeriod) {
+		if (finPeriod.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		FinPeriod detail = baseMapper.selectById(finPeriod.getId());
+		if (1 == detail.getLockingStatus()) {
+			throw new RuntimeException("该期间已锁定,请勿重复锁定!");
+		}
+		List<ReviewFailedExcel> reviewFailedExcelList = new ArrayList<>();
+		List<UnbookkeptExcel> unbookkeptExcelList = new ArrayList<>();
+		List<Bills> billsList = billsService.list(new LambdaQueryWrapper<Bills>()
+			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(Bills::getIsDeleted, 0)
+			.eq(Bills::getBranchId, detail.getBranchId())
+			.apply("((business_type = 'SE' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
+				"or (business_type = 'SI' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"));
+		if (!billsList.isEmpty()) {
+			List<Bills> bills = billsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
+			for (Bills item : bills) {
+				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+				if ("SE".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("海运出口");
+				} else {
+					reviewFailedExcel.setBusinessType("海运进口");
+				}
+				reviewFailedExcel.setBillNo(item.getBillNo());
+				reviewFailedExcel.setBusinessDate(item.getBillDate());
+				reviewFailedExcel.setMblno(item.getMblno());
+				reviewFailedExcel.setOperator(item.getOperatorName());
+				if ("SALES".equals(item.getSrcType())) {
+					reviewFailedExcel.setSalesperson(item.getSrcCnName());
+				}
+				reviewFailedExcelList.add(reviewFailedExcel);
+			}
+		}
+		List<AeaBills> aeaBillsList = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
+			.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
+			.eq(AeaBills::getIsDeleted, 0)
+			.eq(AeaBills::getBranchId, detail.getBranchId())
+			.apply("((business_type = 'AE' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
+				"or (business_type = 'AI' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"));
+		if (!aeaBillsList.isEmpty()) {
+			List<AeaBills> aeaBills = aeaBillsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
+			for (AeaBills item : aeaBills) {
+				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+				if ("AE".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("空运出口");
+				} else {
+					reviewFailedExcel.setBusinessType("空运进口");
+				}
+				reviewFailedExcel.setBillNo(item.getBillNo());
+				reviewFailedExcel.setBusinessDate(item.getBillDate());
+				reviewFailedExcel.setMblno(item.getMblno());
+				reviewFailedExcel.setOperator(item.getOperatorName());
+				if ("SALES".equals(item.getSrcType())) {
+					reviewFailedExcel.setSalesperson(item.getSrcCnName());
+				}
+				reviewFailedExcelList.add(reviewFailedExcel);
+			}
+		}
+		List<Amends> amendsList = amendsService.list(new LambdaQueryWrapper<Amends>()
+			.eq(Amends::getTenantId, AuthUtil.getTenantId())
+			.eq(Amends::getIsDeleted, 0)
+			.eq(Amends::getBranchId, detail.getBranchId())
+			.apply("((business_type = 'SEA' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
+				"or (business_type = 'SIA' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))" +
+				"or (business_type = 'AEA' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + "))" +
+				"or (business_type = 'AIA' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"
+			));
+		if (!amendsList.isEmpty()) {
+			List<Amends> bills = amendsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
+			List<Bills> billsList1 = new ArrayList<>();
+			List<AeaBills> aeaBillsList1 = new ArrayList<>();
+			if (!bills.isEmpty()) {
+				List<Long> billsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
+				if (!billsId.isEmpty()) {
+					billsList1 = billsService.list(new LambdaQueryWrapper<Bills>()
+						.eq(Bills::getTenantId, AuthUtil.getTenantId())
+						.eq(Bills::getIsDeleted, 0)
+						.eq(Bills::getBranchId, detail.getBranchId())
+						.in(Bills::getId, billsId)
+					);
+				}
+				List<Long> aeaBillsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
+				if (!aeaBillsId.isEmpty()) {
+					aeaBillsList1 = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
+						.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
+						.eq(AeaBills::getIsDeleted, 0)
+						.eq(AeaBills::getBranchId, detail.getBranchId())
+						.in(AeaBills::getId, aeaBillsId));
+				}
+			}
+			for (Amends item : bills) {
+				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+				if ("AEA".equals(item.getBusinessType())) {
+					if (!aeaBillsList1.isEmpty()) {
+						AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
+						}
+					}
+					reviewFailedExcel.setBusinessType("空运出口Amends");
+				} else if ("AIA".equals(item.getBusinessType())) {
+					if (!aeaBillsList1.isEmpty()) {
+						AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
+						}
+					}
+					reviewFailedExcel.setBusinessType("空运进口Amends");
+				} else if ("SIA".equals(item.getBusinessType())) {
+					if (!billsList1.isEmpty()) {
+						Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
+						}
+					}
+					reviewFailedExcel.setBusinessType("海运进口Amends");
+				} else if ("SEA".equals(item.getBusinessType())) {
+					if (!billsList1.isEmpty()) {
+						Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
+						if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
+							reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
+						}
+					}
+					reviewFailedExcel.setBusinessType("海运出口Amends");
+				}
+				reviewFailedExcel.setBillNo(item.getBillNo());
+				reviewFailedExcel.setBusinessDate(item.getBillDate());
+				reviewFailedExcel.setMblno(item.getMblno());
+				reviewFailedExcel.setOperator(item.getOperatorName());
+				reviewFailedExcelList.add(reviewFailedExcel);
+			}
+		}
+		List<CustomsDeclaration> customsDeclarationList = customsDeclarationService.list(new LambdaQueryWrapper<CustomsDeclaration>()
+			.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
+			.eq(CustomsDeclaration::getIsDeleted, 0)
+			.eq(CustomsDeclaration::getBranchId, detail.getBranchId())
+			.gt(CustomsDeclaration::getDeclareDate, detail.getBeginDate())
+			.lt(CustomsDeclaration::getDeclareDate, detail.getEndDate())
+		);
+		if (!customsDeclarationList.isEmpty()) {
+			List<CustomsDeclaration> bills = customsDeclarationList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
+			for (CustomsDeclaration item : bills) {
+				ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+				if ("BGSE".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("海运报关");
+				} else if ("BGSI".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("海运报关");
+				} else if ("BGAE".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("空运报关");
+				} else if ("BGAI".equals(item.getBusinessType())) {
+					reviewFailedExcel.setBusinessType("空运报关");
+				}
+				reviewFailedExcel.setBillNo(item.getBillNo());
+				reviewFailedExcel.setBusinessDate(item.getBillDate());
+				reviewFailedExcel.setMblno(item.getMblno());
+				reviewFailedExcel.setOperator(item.getCreateUserName());
+				if ("SALES".equals(item.getSrcType())) {
+					reviewFailedExcel.setSalesperson(item.getSrcCnName());
+				}
+				reviewFailedExcelList.add(reviewFailedExcel);
+			}
+		}
+		List<FinStlBills> finStlBillsList = finStlBillsService.list(new LambdaQueryWrapper<FinStlBills>()
+			.eq(FinStlBills::getTenantId, AuthUtil.getTenantId())
+			.eq(FinStlBills::getIsDeleted, 0)
+			.eq(FinStlBills::getBusinessType, "STL")
+			.eq(FinStlBills::getBranchId, detail.getBranchId())
+			.gt(FinStlBills::getBillDate, detail.getBeginDate())
+			.lt(FinStlBills::getBillDate, detail.getEndDate())
+		);
+		if (!finStlBillsList.isEmpty()) {
+			List<FinStlBills> bills = finStlBillsList.stream().filter(e -> e.getBillStatus().equals("3")).collect(Collectors.toList());
+			if (!bills.isEmpty()) {
+				List<Long> ids = bills.stream().map(FinStlBills::getId).collect(Collectors.toList());
+				if (!ids.isEmpty()) {
+					List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
+						.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+						.eq(FinVouchers::getIsDeleted, 0)
+						.eq(FinVouchers::getBranchId, detail.getBranchId())
+						.in(FinVouchers::getSrcId, ids)
+						.gt(FinVouchers::getVoucherDate, detail.getBeginDate())
+						.lt(FinVouchers::getVoucherDate, detail.getEndDate()));
+					for (FinStlBills item : bills) {
+						FinVouchers finVouchers = finVouchersList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
+						if (finVouchers == null) {
+							ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
+							reviewFailedExcel.setBusinessType("结算中心");
+							reviewFailedExcel.setBillNo(item.getBillNo());
+							reviewFailedExcel.setBusinessDate(item.getBillDate());
+							reviewFailedExcel.setMblno(item.getMblno());
+							reviewFailedExcel.setOperator(item.getCreateUserName());
+							reviewFailedExcel.setSalesperson(item.getSalesName());
+							reviewFailedExcelList.add(reviewFailedExcel);
+						} else {
+							UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
+							unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
+							unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
+							unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
+							unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
+							unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
+							unbookkeptExcelList.add(unbookkeptExcel);
+						}
+					}
+				}
+			}
+		}
+		if (!reviewFailedExcelList.isEmpty()) {
+			return R.data(reviewFailedExcelList, "审核未通过");
+		}
+		if (!unbookkeptExcelList.isEmpty()) {
+			return R.data(reviewFailedExcelList, "凭证未记账");
+		}
+		detail.setUpdateTime(new Date());
+		detail.setUpdateUserName(AuthUtil.getUserName());
+		detail.setUpdateUser(AuthUtil.getUserId());
+		detail.setLockingStatus(1);
+		baseMapper.updateById(finPeriod);
+		return R.data(finPeriod);
+	}
+
+	@Override
+	public R currentPeriod(Query query, FinPeriod finPeriod) {
+		return null;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
+	public R close(FinPeriod finPeriod) {
+		if (finPeriod.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		FinPeriod detail = baseMapper.selectById(finPeriod.getId());
+		if (0 == detail.getLockingStatus()) {
+			throw new RuntimeException("该期间未锁定,请先锁定在结转!");
+		}
+		if (1 == detail.getIsClosed()) {
+			throw new RuntimeException("该期间已结转,请勿重复结转!");
+		}
+		detail.setUpdateTime(new Date());
+		detail.setUpdateUserName(AuthUtil.getUserName());
+		detail.setUpdateUser(AuthUtil.getUserId());
+		detail.setIsClosed(1);
+		detail.setCloseDate(new Date());
+		baseMapper.updateById(finPeriod);
+
+		List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
+			.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
+			.eq(FinVouchers::getIsDeleted, 0)
+			.eq(FinVouchers::getBranchId, detail.getBranchId())
+			.eq(FinVouchers::getVoucherSource, "SYSTEM")
+			.eq(FinVouchers::getAccountYear, detail.getPeriodYear())
+			.eq(FinVouchers::getAccountMonth, detail.getPeriodMonth())
+			.gt(FinVouchers::getVoucherDate, detail.getBeginDate())
+			.lt(FinVouchers::getVoucherDate, detail.getEndDate()));
+		if (finVouchersList.size() != 2) {
+			throw new RuntimeException("请先生成本期汇兑损益,期间损益凭证在进行结转");
+		}
+		FinPeriod finPeriodNew = new FinPeriod();
+		if (ObjectUtils.isNotNull(finPeriod.getBeginDate())) {
+			finPeriodNew.setBeginDate(finPeriod.getBeginDate());
+			finPeriodNew.setEndDate(finPeriod.getEndDate());
+		} else {
+			LocalDate date = detail.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+			// 获取下个月的第一天
+			LocalDate firstDayOfNextMonth = date.with(TemporalAdjusters.firstDayOfNextMonth());
+			// 获取下个月的最后一天
+			LocalDate lastDayOfNextMonth;
+			if (firstDayOfNextMonth.getMonthValue() == 12) {
+				lastDayOfNextMonth = firstDayOfNextMonth.withDayOfMonth(31);
+			} else {
+				lastDayOfNextMonth = firstDayOfNextMonth.with(TemporalAdjusters.lastDayOfMonth());
+			}
+			finPeriodNew.setBeginDate(Date.from(firstDayOfNextMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+			finPeriodNew.setEndDate(Date.from(lastDayOfNextMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+		}
+		this.submit(finPeriodNew);
+		return R.data(finPeriod);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
+	public R unclose(FinPeriod finPeriod) {
+		if (finPeriod.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		FinPeriod detail = baseMapper.selectById(finPeriod.getId());
+		if (0 == detail.getIsClosed()) {
+			throw new RuntimeException("该期间未结转,操作失败!");
+		}
+		detail.setUpdateTime(new Date());
+		detail.setUpdateUserName(AuthUtil.getUserName());
+		detail.setUpdateUser(AuthUtil.getUserId());
+		detail.setIsClosed(0);
+		detail.setCloseDate(null);
+		baseMapper.updateById(finPeriod);
+		LocalDate date = detail.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+		// 获取下个月的第一天
+		LocalDate firstDayOfNextMonth = date.with(TemporalAdjusters.firstDayOfNextMonth());
+		// 获取下个月的最后一天
+		LocalDate lastDayOfNextMonth;
+		if (firstDayOfNextMonth.getMonthValue() == 12) {
+			lastDayOfNextMonth = firstDayOfNextMonth.withDayOfMonth(31);
+		} else {
+			lastDayOfNextMonth = firstDayOfNextMonth.with(TemporalAdjusters.lastDayOfMonth());
+		}
+		FinPeriod finPeriodNew = baseMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
+			.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+			.eq(FinPeriod::getIsDeleted, 0)
+			.eq(FinPeriod::getBranchId, detail.getBranchId())
+			.eq(FinPeriod::getIsClosed, 1)
+			.eq(FinPeriod::getBeginDate, firstDayOfNextMonth)
+			.eq(FinPeriod::getEndDate, lastDayOfNextMonth));
+		if (finPeriodNew != null) {
+			baseMapper.deleteById(finPeriodNew.getId());
+		} else {
+			List<FinPeriod> finPeriodList = baseMapper.selectList(new LambdaQueryWrapper<FinPeriod>()
+				.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+				.eq(FinPeriod::getIsDeleted, 0)
+				.eq(FinPeriod::getBranchId, detail.getBranchId()));
+			if (finPeriodList.size() != 1) {
+				throw new RuntimeException("未查到下期数据,操作失败!");
+			}
+		}
+		return R.data(finPeriod);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
+	public R submit(FinPeriod finPeriod) {
+		String deptId = "";
+		String deptName = "";
+		String branchId = deptUtils.getDeptPid() + "";
+		//获取部门ids对应中文名
+		if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+			deptId = AuthUtil.getDeptId();
+			R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				deptName = String.join(",", res.getData());
+			}
+		}
+		if (baseMapper.selectCount(new LambdaQueryWrapper<FinPeriod>()
+			.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
+			.eq(FinPeriod::getIsDeleted, 0)
+			.eq(FinPeriod::getBranchId, branchId)) > 0) {
+			throw new RuntimeException("本年度已有账期,请勿重复生成");
+		}
+		if (finPeriod.getId() == null) {
+			if (ObjectUtils.isNotNull(finPeriod.getBeginDate())) {
+				LocalDate date = finPeriod.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+				finPeriod.setPeriodYear(date.getYear());
+				finPeriod.setPeriodMonth(date.lengthOfMonth());
+			} else {
+				LocalDate date = LocalDate.now();
+				finPeriod.setPeriodYear(date.getYear());
+				finPeriod.setPeriodMonth(date.lengthOfMonth());
+				// 获取当前月的第一天
+				LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
+				// 获取当前月的最后一天
+				LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
+				finPeriod.setBeginDate(Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+				finPeriod.setEndDate(Date.from(lastDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+			}
+			finPeriod.setCreateTime(new Date());
+			finPeriod.setCreateUser(AuthUtil.getUserId());
+			finPeriod.setCreateUserName(AuthUtil.getUserName());
+			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
+				finPeriod.setCreateDept(deptId);
+				finPeriod.setBranchId(branchId);
+				finPeriod.setCreateDeptName(deptName);
+			}
+		} else {
+			finPeriod.setUpdateUser(AuthUtil.getUserId());
+			finPeriod.setUpdateTime(new Date());
+			finPeriod.setUpdateUserName(AuthUtil.getUserName());
+		}
+		this.saveOrUpdate(finPeriod);
+		return R.data(finPeriod);
+	}
+
+	@Override
+	public R revokeLocking(FinPeriod finPeriod) {
+		if (finPeriod.getId() == null) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		FinPeriod detail = baseMapper.selectById(finPeriod.getId());
+		if (0 == detail.getLockingStatus()) {
+			throw new RuntimeException("该期间未锁定,操作失败!");
+		}
+		detail.setUpdateTime(new Date());
+		detail.setUpdateUserName(AuthUtil.getUserName());
+		detail.setUpdateUser(AuthUtil.getUserId());
+		detail.setLockingStatus(0);
+		baseMapper.updateById(finPeriod);
+		return R.data(finPeriod);
+	}
+
 }

+ 3 - 0
blade-service/blade-los/src/main/java/org/springblade/los/finance/vouchers/service/impl/FinVouchersServiceImpl.java

@@ -193,6 +193,9 @@ public class FinVouchersServiceImpl extends ServiceImpl<FinVouchersMapper, FinVo
 						item.setAmountCrUsd(item.getQuantityCr().multiply(item.getPrice()));
 					}
 				}*/
+				item.setAccountYear(finVouchers.getAccountYear());
+				item.setAccountMonth(finVouchers.getAccountMonth());
+				item.setAccountDay(finVouchers.getAccountDay());
 				if (item.getId() == null) {
 					item.setCreateTime(new Date());
 					item.setCreateUser(AuthUtil.getUserId());