|
|
@@ -0,0 +1,152 @@
|
|
|
+package com.poteviohealth.cgp.statistics.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.io.IoUtil;
|
|
|
+import com.poteviohealth.cgp.common.controller.BaseWebController;
|
|
|
+import com.poteviohealth.cgp.common.integrated.StringParams;
|
|
|
+import com.poteviohealth.cgp.common.model.VaultsResponse;
|
|
|
+import com.poteviohealth.cgp.statistics.job.OrderFaceJobHandler;
|
|
|
+import com.poteviohealth.cgp.statistics.mapper.WatermarkImgMapper;
|
|
|
+import com.poteviohealth.cgp.statistics.model.indto.PriceUploadDto;
|
|
|
+import com.poteviohealth.cgp.statistics.model.outdto.DistinctionDTO;
|
|
|
+import com.poteviohealth.cgp.statistics.service.IDistinctionService;
|
|
|
+import com.poteviohealth.cgp.statistics.utils.OssUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 运维 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author potevio
|
|
|
+ * @since 2019-07-18
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/statistics/web/devops")
|
|
|
+@Api(value = "DevOpsController", tags = "运维", produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
+public class DevOpsController extends BaseWebController {
|
|
|
+ @Value("${sync.dbName}")
|
|
|
+ private String dbName;
|
|
|
+ @Resource
|
|
|
+ private OssUtils ossUtils;
|
|
|
+ @Resource
|
|
|
+ private IDistinctionService distinctionService;
|
|
|
+ @Resource
|
|
|
+ private OrderController orderController;
|
|
|
+ @Resource
|
|
|
+ private WatermarkImgMapper watermarkImgMapper;
|
|
|
+ @Resource
|
|
|
+ private OrderFaceJobHandler orderFaceJobHandler;
|
|
|
+
|
|
|
+ @RequestMapping(value = "/executeJob", method = {RequestMethod.POST})
|
|
|
+ @ResponseBody
|
|
|
+ public VaultsResponse<String> executeJob(){
|
|
|
+ orderFaceJobHandler.execute("{}");
|
|
|
+ return VaultsResponse.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/uploadExamPhoto", method = {RequestMethod.POST})
|
|
|
+ @ResponseBody
|
|
|
+ public VaultsResponse<List<String>> uploadExamPhoto(@RequestBody StringParams param){
|
|
|
+ String area = param.getId();
|
|
|
+ File base = new File("D:\\数据处理\\dongtai\\体检照片\\"+area);
|
|
|
+ File[] nameFiles = base.listFiles();
|
|
|
+ Map<String, PriceUploadDto> nameMap = this.toNameOrder(6, area);
|
|
|
+ Random rand = new Random();
|
|
|
+ int min = 0;
|
|
|
+ int max = 10;
|
|
|
+ List<String> errorUsers = new ArrayList<>();
|
|
|
+ for (File nameFile:nameFiles){
|
|
|
+ String name = nameFile.getName();
|
|
|
+ System.out.println("user:"+ name);
|
|
|
+ try {
|
|
|
+ File[] files = nameFile.listFiles();
|
|
|
+ PriceUploadDto order = nameMap.get(name);
|
|
|
+ if (order == null){
|
|
|
+ String error = "no user:" + name;
|
|
|
+ System.out.println(error);
|
|
|
+ errorUsers.add(error);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Long orderId = order.getOrderId();
|
|
|
+ List<PriceUploadDto> list = new ArrayList<>();
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ int idx = 1;
|
|
|
+ for (int i=0; i<files.length; i++){
|
|
|
+ File file = files[i];
|
|
|
+ DistinctionDTO dto = distinctionService.checkImg(file, orderId, Collections.emptyList());
|
|
|
+ FileInputStream inputStream = new FileInputStream(file);
|
|
|
+ VaultsResponse<String> vaultsResponse = ossUtils.uploadOneFile(file.getName(),orderId,inputStream);
|
|
|
+ dto.setUrl(vaultsResponse.getData());
|
|
|
+ IoUtil.close(inputStream);
|
|
|
+
|
|
|
+ PriceUploadDto uploadDto = new PriceUploadDto();
|
|
|
+ uploadDto.setOrderId(orderId);
|
|
|
+ uploadDto.setUid(dto.getUid());
|
|
|
+ uploadDto.setUrl(dto.getUrl());
|
|
|
+ if (i==0){//开始时间
|
|
|
+ int delta = rand.nextInt(max - min + 1) + min;
|
|
|
+ c.setTime(format.parse(order.getDate()));
|
|
|
+ c.add(Calendar.SECOND, -37 * 3-delta);
|
|
|
+ }else if (i==3){//结束时间
|
|
|
+ int delta = rand.nextInt(max - min + 1) + min;
|
|
|
+ c.setTime(format.parse(order.getType()));
|
|
|
+ c.add(Calendar.SECOND, -37 * (files.length -1)-delta);
|
|
|
+ idx = 7;
|
|
|
+ }else{
|
|
|
+ c.add(Calendar.SECOND, 37);
|
|
|
+ ++idx;
|
|
|
+ }
|
|
|
+ uploadDto.setDate(format.format(c.getTime()));
|
|
|
+ uploadDto.setIndex(idx);
|
|
|
+ uploadDto.setType("image");
|
|
|
+ uploadDto.setPunchAddress(order.getPunchAddress());
|
|
|
+ uploadDto.setPunchLatitude(order.getPunchLatitude());
|
|
|
+ uploadDto.setPunchLongitude(order.getPunchLongitude());
|
|
|
+ list.add(uploadDto);
|
|
|
+ }
|
|
|
+ orderController.orderFile(list);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ String error = "wrong user:" + name;
|
|
|
+ System.out.println(error);
|
|
|
+ errorUsers.add(error);
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return VaultsResponse.success(errorUsers);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, PriceUploadDto> toNameOrder(Integer operatorId, String area){
|
|
|
+ List<PriceUploadDto> list = watermarkImgMapper.listExamOrders(operatorId, dbName, area);
|
|
|
+ return list.stream().collect(Collectors.toMap(PriceUploadDto::getUid, Function.identity()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args){
|
|
|
+ String area = "tz";
|
|
|
+ File base = new File("D:\\数据处理\\dongtai\\体检照片\\"+area);
|
|
|
+ File[] nameFiles = base.listFiles();
|
|
|
+ for (File nameFile:nameFiles) {
|
|
|
+ File[] files = nameFile.listFiles();
|
|
|
+ for (File f : files) {
|
|
|
+ if (f.isDirectory()) {
|
|
|
+ System.out.println(f.getAbsolutePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|