Commit 433fdc01 by huluobin

update

parent aeee3783
...@@ -43,6 +43,30 @@ ...@@ -43,6 +43,30 @@
<artifactId>bailuntec-cost-api</artifactId> <artifactId>bailuntec-cost-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
<dependency> <dependency>
<groupId>com.bailuntec</groupId> <groupId>com.bailuntec</groupId>
<artifactId>bailuntec-api</artifactId> <artifactId>bailuntec-api</artifactId>
...@@ -176,13 +200,6 @@ ...@@ -176,13 +200,6 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- POI begin -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${org.apache.poi}</version>
</dependency>
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
......
...@@ -10,6 +10,7 @@ import lombok.Data; ...@@ -10,6 +10,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -55,6 +56,7 @@ public class OaDepartment implements Serializable { ...@@ -55,6 +56,7 @@ public class OaDepartment implements Serializable {
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
private Integer sort; private Integer sort;
private BigDecimal departmentMinimumReviewAmount;
@ApiModelProperty(value = "创建人id") @ApiModelProperty(value = "创建人id")
private Integer createUserId; private Integer createUserId;
...@@ -74,4 +76,6 @@ public class OaDepartment implements Serializable { ...@@ -74,4 +76,6 @@ public class OaDepartment implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<CostReviewer> costReviewerList; private List<CostReviewer> costReviewerList;
} }
...@@ -92,7 +92,10 @@ public class CostTemplate implements Serializable { ...@@ -92,7 +92,10 @@ public class CostTemplate implements Serializable {
} }
public boolean shouldFinalCheck(BigDecimal amount) { public boolean shouldFinalCheck(BigDecimal amount) {
return amount.compareTo(finalMinimumReviewAmount) >= 0; return finalMinimumReviewAmount.compareTo(BigDecimal.ZERO) > 0 && amount.compareTo(finalMinimumReviewAmount) >= 0;
} }
public boolean shouldDepartmentCheck(BigDecimal amount, BigDecimal departmentMinimumReviewAmount) {
return departmentMinimumReviewAmount.compareTo(BigDecimal.ZERO) > 0 && amount.compareTo(departmentMinimumReviewAmount) >= 0;
}
} }
...@@ -103,19 +103,8 @@ public class CostTemplateCol implements Serializable { ...@@ -103,19 +103,8 @@ public class CostTemplateCol implements Serializable {
default: default:
return true; return true;
} }
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
} }
/**
* 表单必填校准
*
* @param costDomain
* @return
*/
public Boolean formCheck(CostDomain costDomain) {
return true;
}
} }
package com.blt.other.module.cost.service.impl.costcheck; package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException; import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.model.CostReviewer; import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaDepartment;
import com.blt.other.module.auth.model.OaUser; import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.auth.service.IOaUserService; import com.blt.other.module.auth.service.IOaUserService;
import com.blt.other.module.cost.model.CostDomain; import com.blt.other.module.cost.model.CostDomain;
...@@ -26,7 +28,8 @@ public class DepartmentCheckState extends CostState { ...@@ -26,7 +28,8 @@ public class DepartmentCheckState extends CostState {
@Autowired @Autowired
FinancialCheckState financialCheckState; FinancialCheckState financialCheckState;
@Resource
OaDepartmentMapper oaDepartmentMapper;
@Resource @Resource
IOaUserService oaUserService; IOaUserService oaUserService;
...@@ -56,6 +59,24 @@ public class DepartmentCheckState extends CostState { ...@@ -56,6 +59,24 @@ public class DepartmentCheckState extends CostState {
return; return;
} }
//如果不需要审核 直接通过
OaUser oaUser = oaUserService.getById(currentUserId);
OaDepartment oaDepartment = oaDepartmentMapper.selectByDepartmentId(oaUser.getPrimaryDepartmentId());
if (costTemplate.shouldDepartmentCheck(costDomain.getAmount(),oaDepartment.getDepartmentMinimumReviewAmount())) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDao.updateById(costDomain);
//流转状态
nextState(financialCheckState);
costSubscribe.subscribe(costContext);
costLogService.saveByManage(costDomain.getCostNo(), "部门审核自动通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
return;
}
//需要自动审核 //需要自动审核
if (costTemplate.shouldDepartmentAutoCheck()) { if (costTemplate.shouldDepartmentAutoCheck()) {
//自动审核通过 //自动审核通过
......
package com.blt.other;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSON;
import com.bailuntec.common.SpringContextUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.blt.other.module.auth.dao.CostReviewerMapper;
import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.database.model.CostCompanyDomain;
import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/12 2:27 下午
*/
public class CostCompanyDomainListener extends AnalysisEventListener<CostCompanyExcel> {
private static final Logger LOGGER = LoggerFactory.getLogger(CostCompanyDomain.class);
/**
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
*/
private static final int BATCH_COUNT = 5;
List<CostCompanyExcel> list = new ArrayList<>();
@Override
public void invoke(CostCompanyExcel data, AnalysisContext context) {
LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data));
list.add(data);
if (list.size() >= BATCH_COUNT) {
syncData();
list.clear();
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
syncData();
LOGGER.info("所有数据解析完成!");
}
/**
* 加上存储数据库
*/
private void syncData() {
LOGGER.info("{}条数据,开始存储数据库!", list.size());
list.forEach(costCompanyExcel -> {
CostCompanyDao costCompanyDao = SpringContextUtil.getBean(CostCompanyDao.class);
CostReviewerMapper costReviewerMapper = SpringContextUtil.getBean(CostReviewerMapper.class);
OaUserMapper oaUserMapper = SpringContextUtil.getBean(OaUserMapper.class);
CostCompanyDomain costCompanyDomain = costCompanyDao.selectByNo(costCompanyExcel.getCompanyNo());
costReviewerMapper.delete(new LambdaQueryWrapper<CostReviewer>()
.eq(CostReviewer::getType, CostReviewer.financialReviewer)
.eq(CostReviewer::getReferId, costCompanyDomain.getId()));
costReviewerMapper.delete(new LambdaQueryWrapper<CostReviewer>()
.eq(CostReviewer::getType, CostReviewer.finalReviewer)
.eq(CostReviewer::getReferId, costCompanyDomain.getId()));
Lists.newArrayList(costCompanyExcel.getFinancialCheckUserName().split("、")).forEach(
name -> {
OaUser oaUser = oaUserMapper.selectByUserName(name);
CostReviewer costReviewer = CostReviewer.builder()
.reviewerUserId(oaUser.getOaUserId())
.reviewerUserName(oaUser.getUserName())
.referId(costCompanyDomain.getId())
.type(CostReviewer.financialReviewer)
.build();
costReviewerMapper.insert(costReviewer);
}
);
OaUser oaUser = oaUserMapper.selectByUserName(costCompanyExcel.getFinalCheckUserName());
CostReviewer costReviewer = CostReviewer.builder()
.reviewerUserId(oaUser.getOaUserId())
.reviewerUserName(oaUser.getUserName())
.referId(costCompanyDomain.getId())
.type(CostReviewer.finalReviewer)
.build();
costReviewerMapper.insert(costReviewer);
});
LOGGER.info("存储数据库成功!");
}
}
package com.blt.other;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/11/12 2:27 下午
*/
@Data
public class CostCompanyExcel implements Serializable {
@ExcelProperty("编码")
private String companyNo;
@ExcelProperty("财务主体")
private String companyName;
@ExcelProperty("财务审核人")
private String financialCheckUserName;
@ExcelProperty("最终审核人")
private String finalCheckUserName;
}
package com.blt.other; package com.blt.other;
import com.alibaba.excel.EasyExcel;
import com.bailuntec.api.bailuntec.oa.OaApi; import com.bailuntec.api.bailuntec.oa.OaApi;
import com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp; import com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp;
import com.bailuntec.api.bailuntec.oa.response.OaUserResp; import com.bailuntec.api.bailuntec.oa.response.OaUserResp;
...@@ -7,6 +8,8 @@ import com.blt.other.module.auth.model.OaDepartment; ...@@ -7,6 +8,8 @@ import com.blt.other.module.auth.model.OaDepartment;
import com.blt.other.module.auth.model.OaUser; import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.auth.service.IOaDepartmentService; import com.blt.other.module.auth.service.IOaDepartmentService;
import com.blt.other.module.auth.service.IOaUserService; import com.blt.other.module.auth.service.IOaUserService;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.database.model.CostCompanyDomain;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -14,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest; ...@@ -14,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -31,7 +35,7 @@ public class OtherApplicationTests { ...@@ -31,7 +35,7 @@ public class OtherApplicationTests {
@Autowired @Autowired
private IOaDepartmentService oaDepartmentService; private IOaDepartmentService oaDepartmentService;
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
@Test @Test
public void syncOa() { public void syncOa() {
List<OaUserResp> oaUserRespList = oaApi.getAllUser(); List<OaUserResp> oaUserRespList = oaApi.getAllUser();
...@@ -86,5 +90,16 @@ public class OtherApplicationTests { ...@@ -86,5 +90,16 @@ public class OtherApplicationTests {
} }
return getPrimaryDepartment(departmentMap, departmentMap.get(oaDepartment.getParentId())); return getPrimaryDepartment(departmentMap, departmentMap.get(oaDepartment.getParentId()));
} }
@Resource
CostCompanyDao costCompanyDao;
@Test
public void importMallProduct() {
String filePath = "/Users/huluobin/Library/Containers/com.tencent.WeWorkMac/Data/Library/Application Support/WXWork/Data/1688853793439460/Cache/File/2020-11/cost_company_updated(1).xlsx";
EasyExcel.read(filePath, CostCompanyExcel.class, new CostCompanyDomainListener()).sheet().doRead();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment