|
@@ -81,6 +81,8 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
ExcelExportService excelExportService;
|
|
|
@Resource
|
|
|
UserCustomMapper userCustomMapper;
|
|
|
+ @Resource
|
|
|
+ WxCorpInfoService wxCorpInfoService;
|
|
|
|
|
|
@Resource
|
|
|
private ProjectMapper projectMapper;
|
|
@@ -135,7 +137,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg importData(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request) throws IOException, InvalidFormatException, UserNotFoundException {
|
|
|
+ public HttpRespMsg importData(Integer companyId, String yearMonth, Boolean syncUserCost, Boolean syncHistoryReport, MultipartFile multipartFile, HttpServletRequest request) throws Exception {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("TOKEN"));
|
|
|
//然后处理文件
|
|
@@ -161,6 +163,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
// XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
//要插入的账号列表
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",companyId));
|
|
|
List<Finance> financeList = new ArrayList<Finance>();
|
|
|
List<Finance> oldFinanceList = financeMapper.selectList(new QueryWrapper<Finance>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
|
//获取月成本列表
|
|
@@ -190,6 +193,54 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
financeConfig.setField3(cusColList.get(2).getFieldName());
|
|
|
financeConfig.setField3Calculate(cusColList.get(2).getNeedCalculate());
|
|
|
}
|
|
|
+ List<String> userNameList=new ArrayList<>();
|
|
|
+ for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
|
+ Row row = sheet.getRow(rowIndex);
|
|
|
+ if (row == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ExcelUtil.isRowEmpty(row)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //(工号-可配置) 姓名 工资 奖金 津贴 养老保险 医疗保险 失业保险 (新增工伤保险) 住房公积金 其他; 可能有自定义的项
|
|
|
+
|
|
|
+ Cell jobNumberCell = null;
|
|
|
+ int nameStartIndex = 0;
|
|
|
+ //是否配置了工号模式的模板
|
|
|
+ boolean includeJobNumber = (timeType.getFinanceJobnumEnabled() == 1);
|
|
|
+ if (includeJobNumber) {
|
|
|
+ jobNumberCell = row.getCell(0);
|
|
|
+ if (jobNumberCell != null) {
|
|
|
+ jobNumberCell.setCellType(CellType.STRING);
|
|
|
+ }
|
|
|
+ nameStartIndex = 1;
|
|
|
+ }
|
|
|
+ Cell nameCell = row.getCell(nameStartIndex + 0);
|
|
|
+ String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");
|
|
|
+ if(name.equals("姓名")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(!userNameList.contains(name)&&!name.equals("")){
|
|
|
+ userNameList.add(name);
|
|
|
+ }else {
|
|
|
+ if(includeJobNumber){
|
|
|
+ msg.setError("姓名为["+name+"]的人员存在重复,请完善工号信息!");
|
|
|
+ }else {
|
|
|
+ msg.setError("姓名为["+name+"]的人员存在重复,请联系服务商开启工号模式!");
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
+ if(userNameList.size() > 0 && wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
+ System.out.println("参与搜素的人员列表"+userNameList + userNameList.size());
|
|
|
+ respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
+ if(respMsg.code.equals("0")){
|
|
|
+ msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请完善工号信息!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<User> targetUserList= (List<User>) respMsg.data;
|
|
|
//由于第一行需要指明列对应的标题
|
|
|
for (int rowIndex = 0; rowIndex <= sheet.getLastRowNum(); rowIndex++) {
|
|
|
Row row = sheet.getRow(rowIndex);
|
|
@@ -238,7 +289,16 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
if (field3 != null)field3.setCellType(CellType.STRING);
|
|
|
|
|
|
finance.setCompanyId(companyId);
|
|
|
- finance.setName(name);
|
|
|
+ Optional<User> userOp;
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Optional<User> optional = targetUserList.stream().filter(tl -> tl.getName().equals(name)).findFirst();
|
|
|
+ userOp= userList.stream().filter(u ->((optional.isPresent()&&u.getCorpwxUserid()!=null&&u.getCorpwxUserid().equals(optional.get().getCorpwxUserid())))).findFirst();
|
|
|
+ }else {
|
|
|
+ userOp= userList.stream().filter(u -> u.getName().equals(name)).findFirst();
|
|
|
+ }
|
|
|
+ if(userOp.isPresent()){
|
|
|
+ finance.setName(userOp.get().getName());
|
|
|
+ }
|
|
|
if (includeJobNumber) {
|
|
|
finance.setJobNumber(jobNumberCell!=null?jobNumberCell.getStringCellValue():null);
|
|
|
if (StringUtils.isEmpty(finance.getJobNumber())) {
|
|
@@ -249,7 +309,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
|
|
|
|
Optional<User> first = userList.stream().filter(u -> includeJobNumber?
|
|
|
u.getJobNumber() != null && u.getJobNumber().equals(finance.getJobNumber())
|
|
|
- :u.getName().equals(name)).findFirst();
|
|
|
+ :u.getName().equals(userOp.isPresent()?userOp.get().getName():name)).findFirst();
|
|
|
if (first.isPresent()) {
|
|
|
finance.setUserId(first.get().getId());
|
|
|
BigDecimal total = new BigDecimal(0);
|