导出人员二维码
This commit is contained in:
parent
f100ff9cc4
commit
85d6b6094c
@ -692,5 +692,14 @@ public class WorkerInfoController {
|
||||
return Result.success(workerInfoService.statsEnterpriseRisk(map));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出人员二维码图片", notes = "导出人员二维码图片", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/exportQrCode")
|
||||
public Result exportQrCode(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
workerInfoService.exportQrCode(param);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -150,4 +150,6 @@ public interface IWorkerInfoService extends IService<WorkerInfo> {
|
||||
void updateScoreSendAuth(HashMap<String, Object> map);
|
||||
|
||||
void updateWorkerById(WorkerInfo workerInfo);
|
||||
|
||||
void exportQrCode(Map<String, Object> param);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@ -2194,6 +2195,25 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportQrCode(Map<String, Object> param) {
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
IPage<WorkerInfo> page = selectWorkerInfoList(new MapBuilder<String, Object>().put("projectSn", projectSn).put("pageNo", 1).put("pageSize", 99999).build());
|
||||
List<WorkerInfo> records = page.getRecords();
|
||||
Map<Long, List<WorkerInfo>> enterpriseMap = records.stream().collect(Collectors.groupingBy(WorkerInfo::getEnterpriseId));
|
||||
for (Map.Entry<Long, List<WorkerInfo>> entry : enterpriseMap.entrySet()) {
|
||||
List<WorkerInfo> list = entry.getValue();
|
||||
String dirPath = basePath + "/" + entry.getValue().get(0).getEnterpriseName();
|
||||
FileUtil.mkdir(dirPath);
|
||||
for (WorkerInfo wi : list) {
|
||||
String url = wi.getEnterpriseName() + "-" + wi.getWorkerName() + "-" + wi.getIdCard() + ".jpg";
|
||||
String path = dirPath + "/" + url;
|
||||
QrCodeUtil.generate(String.valueOf(wi.getId()), 300, 300, FileUtil.file(path));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 真正递归的方法
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user