luoyb
2021-03-10 182edd4941ef74c3e98813c2a28ac774c262a22d
febs-server/febs-server-hr/src/main/java/cc/mrbird/febs/server/hr/service/impl/EmpAccessoryServiceImpl.java
@@ -22,6 +22,7 @@
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Or;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -41,6 +42,7 @@
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * 附件管理 Service实现
@@ -51,6 +53,7 @@
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
@Slf4j
public class EmpAccessoryServiceImpl extends ServiceImpl<EmpAccessoryMapper, EmpAccessory> implements IEmpAccessoryService {
    private final ILabelService labelService;
    private final EmpAccessoryMapper empAccessoryMapper;
@@ -154,8 +157,13 @@
        queryWrapper.in("c.dept_Id", remoteDeptService.userRightDepts().split(StringConstant.COMMA));
        queryWrapper.orderByAsc("a.deptName,a.empName,a.certificateNumb");
        Page<EmpAccessory> page = new Page<>(request.getPageNum(), request.getPageSize());
        String querySql = empAccessoryMapper.getQuerySql();
        IPage<Map<String, Object>> mapIPage = empAccessoryMapper.selectPageVo(page, queryWrapper, querySql);
       // String querySql = empAccessoryMapper.getQuerySql();
       //List<Label> labelList = labelService.findLabels(new Label());
        IPage<Map<String, Object>> mapIPage = empAccessoryMapper.selectPageVo(page, queryWrapper);
        mapIPage.getRecords().parallelStream().forEach(i->{
            List<Map<String, Object>> mapList = this.baseMapper.getEmpAccessoryNumber((Long) i.get("empId"));
            mapList.parallelStream().forEach(j->i.put(j.get("labelCode").toString(),Integer.parseInt(j.get("number").toString())));
        });
        return mapIPage;
    }
@@ -299,4 +307,55 @@
        wrapper.eq(EmpAccessory::getLabelid, labelId);
        return this.count(wrapper);
    }
    @Override
    public void autoInstall(String fileids) {
        File[] list = FileUtil.ls(fileids);
        for (File file : list) {
            String[] fileName = file.getName().split("_");
            if (fileName.length<2){
                log.error(file.getName());
                continue;
            }
            List<EmpBaseInfo> empBaseInfo = empBaseInfoService.list(new LambdaQueryWrapper<EmpBaseInfo>().eq(EmpBaseInfo::getCertificateNumb, fileName[1]).ne(EmpBaseInfo::getDelFlag, 1));
            if (null == empBaseInfo ||0 == empBaseInfo.size()) {
                continue;
            }
            File[] childlist = FileUtil.ls(fileids+"/"+file.getName());
            for (File file1 : childlist) {
                EmpAccessory accessory = new EmpAccessory();
                if (file1.getName().indexOf("体检")>=0){
                    accessory.setLabelid(142445218121729L);
                }else if (file1.getName().indexOf("合同")>=0){
                    accessory.setLabelid(142445285230593L);
                }else if (file1.getName().indexOf("入职")>=0||file1.getName().indexOf("务工")>=0){
                    accessory.setLabelid(143073554221057L);
                }else if (file1.getName().indexOf("身份")>=0){
                    accessory.setLabelid(143007818991617L);
                }else if (file1.getName().indexOf("银行卡")>=0){
                    accessory.setLabelid(143073768130561L);
                }else if (file1.getName().indexOf("证")>=0){
                    accessory.setLabelid(143073812170753L);
                }else{
                    accessory.setLabelid(142445180372993L);
                }
                accessory.setCreatetime(new Date());
                accessory.setCreator(FebsUtil.getUserId());
                accessory.setDelFlag(0);
                accessory.setEmpid(empBaseInfo.get(0).getEmpId());
                accessory.setFilesaddress(file1.getName());
                if (file1.getName().indexOf(".") > 0) {
                    accessory.setFilesformat( file1.getName().substring(file1.getName().indexOf(".")+1));
                }
                accessory.setAccessoryid(SequenceUtil.generateId(0L, ModuleCode.HR_FIlE));
                accessory.setFilesname(file1.getName());
                accessory.setModifier(FebsUtil.getUserId());
                accessory.setModifytime(new Date());
                accessory.setVersion(0);
                this.save(accessory);
            }
        }
    }
}