Просмотр исходного кода

Merge branch 'test' of licailing/wenlvju into master

licailing 4 лет назад
Родитель
Сommit
07c7569d05

+ 1 - 1
src/main/h5/src/plugins/http.js

@@ -4,7 +4,7 @@ import qs from "qs";
 let baseUrl = "http://localhost:8080";
 switch (process.env.NODE_ENV) {
   case "development":
-    // baseUrl = "http://wlj.izouma.com";
+    // baseUrl = "https://wljtest.izouma.com";
     baseUrl = 'http://localhost:8080';
     break;
   case "test":

+ 5 - 0
src/main/h5/src/router/index.js

@@ -14,6 +14,11 @@ const routes = [
     name: "home",
     component: () => import("../views/Home.vue")
   },
+  {
+    path: "/trainingInstitution",
+    name: "trainingInstitution",
+    component: () => import("../views/TrainingInstitution.vue")
+  },
   {
     path: "/login",
     name: "login",

+ 407 - 0
src/main/h5/src/views/TrainingInstitution.vue

@@ -0,0 +1,407 @@
+<template>
+  <div class="page">
+    <van-form @submit="submit" :submit-on-enter="false">
+      <van-popover v-model="showPopover" trigger="click">
+        <template #reference>
+          <van-field
+            name="企业名称"
+            label="企业名称"
+            placeholder="请输入企业名称"
+            v-model="form.name"
+            :rules="[{ required: true, message: '请填写企业名称' }]"
+            @change="like"
+          />
+        </template>
+
+        <van-cell-group>
+          <van-cell
+            v-for="(item, index) in list"
+            :key="index"
+            :title="item"
+            @click="choose(item)"
+          />
+        </van-cell-group>
+      </van-popover>
+      <van-field
+        name="注册号"
+        label="注册号"
+        placeholder="请输入注册号"
+        v-model="form.uscc"
+        :rules="[{ required: true, message: '请填写注册号' }]"
+      />
+      <div style="margin:30px" v-if="!form.id">
+        <van-button class="submit" round block type="info" @click="byUscc">
+          查询
+        </van-button>
+      </div>
+      <template v-else>
+        <van-field
+          type="textarea"
+          name="经营范围"
+          label="经营范围"
+          placeholder="请输入经营范围"
+          v-model="form.businessScope"
+          autosize
+        />
+        <van-field
+          name="企业住所"
+          label="企业住所"
+          placeholder="请输入企业住所"
+          v-model="form.address"
+        />
+        <van-field
+          name="生产经营场所"
+          label="生产经营场所"
+          placeholder="请输入生产经营场所"
+          v-model="form.businessPremise"
+        />
+        <van-field
+          name="生产法人姓名"
+          label="生产法人姓名"
+          placeholder="请输入生产法人姓名"
+          v-model="form.privacyPolicy"
+        />
+        <!-- <van-field
+          type="tel"
+          maxlength="11"
+          name="生产短信号码"
+          label="生产短信号码"
+          placeholder="请输入短信号码"
+          v-model="form.phone"
+        /> -->
+        <van-field
+          type="digit"
+          name="企业联系方式"
+          label="企业联系方式"
+          placeholder="请输入企业联系方式"
+          v-model="form.contactPhone"
+        />
+        <van-field
+          name="所属管区"
+          label="所属管区"
+          placeholder="请输入所属管区"
+          v-model="form.district"
+        />
+        <van-field
+          name="注册资本"
+          label="注册资本(万)"
+          placeholder="请输入注册资本"
+          v-model="form.registeredCapital"
+        />
+        <van-field
+          name="单位性质"
+          label="单位性质"
+          placeholder="请输入单位性质"
+          v-model="form.category"
+        />
+        <van-field
+          name="专业种类"
+          label="专业种类"
+          placeholder="请输入专业种类"
+          v-model="form.specialty"
+        />
+        <van-field
+          type="digit"
+          name="培训点数量三楼及以下"
+          label="培训点数量三楼及以下"
+          placeholder="请输入培训点数量三楼及以下"
+          v-model="form.trainingSite"
+        />
+        <van-field
+          type="digit"
+          name="培训点数量四楼及以上"
+          label="培训点数量四楼及以上"
+          placeholder="请输入培训点数量四楼及以上"
+          v-model="form.trainingSiteFour"
+        />
+        <van-field
+          type="number"
+          name="总面积"
+          label="总面积"
+          placeholder="请输入总面积"
+          v-model="form.area"
+        />
+        <van-field
+          type="digit"
+          name="教室数量"
+          label="教室数量"
+          placeholder="请输入教室数量"
+          v-model="form.classroomNum"
+          :rules="[{ required: true, message: '请填写教室数量' }]"
+        />
+        <van-field
+          type="digit"
+          name="教师总数"
+          label="教师总数"
+          placeholder="请输入教师总数"
+          v-model="form.teacherNum"
+          :rules="[{ required: true, message: '请填写教师总数' }]"
+        />
+        <van-field
+          type="digit"
+          name="专职数量"
+          label="专职数量"
+          placeholder="请输入专职数量"
+          v-model="form.fullTimeNum"
+          :rules="[{ required: true, message: '请填写专职数量' }]"
+        />
+        <van-field
+          type="digit"
+          name="兼职数量"
+          label="兼职数量"
+          placeholder="请输入兼职数量"
+          v-model="form.partTimeNum"
+          :rules="[{ required: true, message: '请填写兼职数量' }]"
+        />
+        <van-field
+          type="digit"
+          name="音乐类"
+          label="音乐类"
+          placeholder="请输入音乐类"
+          v-model="form.musicNum"
+          :rules="[{ required: true, message: '请填写音乐类' }]"
+        />
+        <van-field
+          type="digit"
+          name="舞蹈类"
+          label="舞蹈类"
+          placeholder="请输入舞蹈类"
+          v-model="form.danceNum"
+          :rules="[{ required: true, message: '请填写舞蹈类' }]"
+        />
+        <van-field
+          type="digit"
+          name="美术类"
+          label="美术类"
+          placeholder="请输入美术类"
+          v-model="form.artNum"
+          :rules="[{ required: true, message: '请填写美术类' }]"
+        />
+        <van-field
+          type="digit"
+          name="戏剧戏曲"
+          label="戏剧戏曲"
+          placeholder="请输入戏剧戏曲"
+          v-model="form.theatreOperaNum"
+          :rules="[{ required: true, message: '请填写戏剧戏曲' }]"
+        />
+        <van-field
+          type="digit"
+          name="曲艺类"
+          label="曲艺类"
+          placeholder="请输入曲艺类"
+          v-model="form.folkMusicNum"
+          :rules="[{ required: true, message: '请填写曲艺类' }]"
+        />
+        <van-field
+          type="digit"
+          name="有教师资格证"
+          label="有教师资格证"
+          placeholder="请输入有教师资格证"
+          v-model="form.qualificationNum"
+          :rules="[{ required: true, message: '请填写有教师资格证' }]"
+        />
+        <van-field
+          type="digit"
+          name="年培训人数"
+          label="年培训人数"
+          placeholder="请输入年培训人数"
+          v-model="form.traineesPerYearNum"
+          :rules="[{ required: true, message: '请填写年培训人数' }]"
+        />
+        <van-field
+          name="是否是艺术水平考级考点"
+          label="是否是艺术水平考级考点"
+          placeholder="请输入是否是艺术水平考级考点"
+        >
+          <template #input>
+            <van-radio-group v-model="form.examPoint" direction="horizontal">
+              <van-radio :name="true"> 是</van-radio>
+              <van-radio :name="false">否</van-radio>
+            </van-radio-group>
+          </template>
+        </van-field>
+        <van-field
+          name="艺术水平考级机构名称"
+          label="艺术水平考级机构名称"
+          placeholder="请输入艺术水平考级机构名称"
+          v-model="form.gradingOrganization"
+        />
+        <van-field
+          type="textarea"
+          name="备注"
+          label="备注"
+          placeholder="请输入备注"
+          v-model="form.remark"
+        />
+
+        <div class="bottom">
+          <van-button
+            @click="saveWeb"
+            class="preview"
+            color="#ffcf6a"
+            block
+            round
+            native-type="button"
+            style="margin-right:12px"
+            >暂存</van-button
+          >
+          <van-button
+            class="submit"
+            round
+            block
+            type="info"
+            native-type="submit"
+            >提交</van-button
+          >
+        </div>
+      </template>
+    </van-form>
+  </div>
+</template>
+
+<script>
+export default {
+  data() {
+    return {
+      form: {
+        examPoint: false
+      },
+      list: [],
+      showPopover: false
+    };
+  },
+
+  mounted() {
+    let data = JSON.parse(
+      window.localStorage.getItem("trainingInstitution") || "{}"
+    );
+    this.form = data;
+  },
+  methods: {
+    like(info, key = "") {
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true,
+        duration: 0
+      });
+      this.showPopover = false;
+      let data = { search: this.form.name, size: 4, query: {} };
+      if (key) {
+        data.query[key] = this.form[key];
+      }
+      this.$http
+        .post("/trainingInstitution/name", data, { body: "json" })
+        .then(res => {
+          this.$toast.clear();
+          this.list = res.content;
+          setTimeout(() => {
+            this.$nextTick(() => {
+              this.showPopover = true;
+            });
+          }, 500);
+        });
+    },
+    byUscc() {
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true,
+        duration: 0
+      });
+      this.$http
+        .post(
+          `/trainingInstitution/byUscc?name=${this.form.name}&uscc=${this.form.uscc}`
+        )
+        .then(res => {
+          this.$toast.clear();
+          this.form = { ...res };
+        })
+        .catch(e => {
+          this.$toast(e.error);
+        });
+    },
+    choose(info) {
+      this.form.name = info;
+      // this.form = { examPoint: false, ...info };
+      this.showPopover = false;
+    },
+    submit() {
+      if (!this.form.id) {
+        return;
+      }
+      this.$toast.loading({
+        message: "加载中...",
+        forbidClick: true,
+        duration: 0
+      });
+      let data = { ...this.form };
+      this.$http
+        .post("/trainingInstitution/save", data, { body: "json" })
+        .then(res => {
+          this.$toast.clear();
+          window.localStorage.removeItem("trainingInstitution");
+          this.$dialog({
+            title: "提交成功",
+            message: "信息已经提交成功,感谢您的配合。",
+            showConfirmButton: false
+          });
+        })
+        .catch(e => {
+          this.$toast(e.error);
+        });
+    },
+    saveWeb() {
+      let data = JSON.stringify({ ...this.form });
+      window.localStorage.setItem("trainingInstitution", data);
+      this.$toast.success("暂存成功");
+    }
+  }
+};
+</script>
+
+<style lang="less" scoped>
+.page {
+  position: relative;
+  padding-bottom: 100px;
+}
+/deep/.van-field {
+  margin: 16px 16px 0;
+  width: calc(100vw - 32px);
+  border-radius: 12px;
+  flex-direction: column;
+
+  .van-field__label {
+    font-size: 18px;
+    font-weight: bold;
+    color: #313233;
+    line-height: 28px;
+    width: auto;
+  }
+  .van-field__value {
+    margin-top: 14px;
+    font-size: 16px;
+    line-height: 32px;
+  }
+}
+
+.bottom {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  padding: 6px 26px calc(env(safe-area-inset-bottom) + 6px);
+  background-color: #fff;
+  z-index: 20;
+
+  display: flex;
+
+  .preview {
+    min-width: 82px;
+    width: 82px;
+  }
+  .submit {
+    flex-grow: 1;
+    // margin-left: 13px;
+  }
+}
+</style>

+ 4 - 4
src/main/java/com/izouma/wenlvju/domain/TrainingInstitution.java

@@ -56,19 +56,19 @@ public class TrainingInstitution extends BaseEntity {
     @ApiModelProperty(value = "企业联系方式")
     private String contactPhone;
 
-    @ExcelProperty(value = "企业联系方式")
+    @ExcelProperty(value = "所属管区")
     @ApiModelProperty(value = "所属管区")
     private String district;
 
-    @ExcelProperty(value = "企业联系方式")
+    @ExcelProperty(value = "注册资本(万)")
     @ApiModelProperty(value = "注册资本(万)")
     private BigDecimal registeredCapital;
 
-    @ExcelProperty(value = "企业联系方式")
+    @ExcelProperty(value = "单位性质")
     @ApiModelProperty(value = "单位性质")
     private String category;
 
-    @ExcelProperty(value = "企业联系方式")
+    @ExcelProperty(value = "专业种类")
     @ApiModelProperty(value = "专业种类")
     private String specialty;
 

+ 37 - 0
src/main/java/com/izouma/wenlvju/dto/TrainingInstitutionDTO.java

@@ -0,0 +1,37 @@
+package com.izouma.wenlvju.dto;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.izouma.wenlvju.domain.TrainingInstitution;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@ApiModel("培训机构")
+public class TrainingInstitutionDTO {
+    @ExcelProperty(value = "编号")
+    private Long id;
+
+    @ExcelProperty(value = "企业名称")
+    @ApiModelProperty("企业名称")
+    private String name;
+
+    @ExcelProperty(value = "固定电话")
+    @ApiModelProperty(value = "固定电话")
+    private String contactPhone;
+
+    @ExcelProperty(value = "移动电话")
+    @ApiModelProperty(value = "移动电话")
+    private String phone;
+
+    public TrainingInstitutionDTO(TrainingInstitution trainingInstitution) {
+        BeanUtil.copyProperties(trainingInstitution, this);
+    }
+}

+ 6 - 1
src/main/java/com/izouma/wenlvju/repo/TrainingInstitutionRepo.java

@@ -18,5 +18,10 @@ public interface TrainingInstitutionRepo extends JpaRepository<TrainingInstituti
     @Query("select phone from TrainingInstitution where submit = false and phone is not null")
     List<String> findAllBySubmitFalseAndPhoneIsNotNull();
 
-    List<TrainingInstitution> findAllByNameLike(String name);
+    List<TrainingInstitution> findAllByPhoneIsNull();
+
+    @Query(nativeQuery = true, value = "select name from training_institution where name like ?1 limit ?2,?3")
+    List<String> findAllByNameLike(String name, int page, int size);
+
+    TrainingInstitution findByUscc(String uscc);
 }

+ 54 - 2
src/main/java/com/izouma/wenlvju/service/TrainingInstitutionService.java

@@ -1,15 +1,26 @@
 package com.izouma.wenlvju.service;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.EasyExcel;
 import com.izouma.wenlvju.domain.TrainingInstitution;
 import com.izouma.wenlvju.dto.PageQuery;
+import com.izouma.wenlvju.dto.ProgUploadDTO;
+import com.izouma.wenlvju.dto.TrainingInstitutionDTO;
+import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.TrainingInstitutionRepo;
 import com.izouma.wenlvju.service.sms.NjwlSmsService;
 import com.izouma.wenlvju.utils.JpaUtils;
+import com.izouma.wenlvju.utils.excel.UploadDataListener;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import javax.transaction.Transactional;
+import java.io.IOException;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service
@@ -23,8 +34,8 @@ public class TrainingInstitutionService {
         return trainingInstitutionRepo.findAll(JpaUtils.toSpecification(pageQuery, TrainingInstitution.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    public void batchSend() throws InterruptedException {
-        List<String> phones = trainingInstitutionRepo.findAllBySubmitFalseAndPhoneIsNotNull();
+    public void batchSend(List<String> phones) throws InterruptedException {
+
         int count = phones.size() / 950;
         String body = "";
         for (int i = 0; i < count; i++) {
@@ -43,4 +54,45 @@ public class TrainingInstitutionService {
         }
 
     }
+
+    @Transactional(rollbackOn = Exception.class)
+    public void upload(MultipartFile file) throws IOException, InterruptedException {
+        UploadDataListener<TrainingInstitutionDTO> listener = new UploadDataListener<>();
+        List<TrainingInstitutionDTO> dtos = EasyExcel.read(file.getInputStream(), TrainingInstitutionDTO.class, listener)
+                .sheet()
+                .doReadSync();
+        List<Long> ids = dtos.stream().map(TrainingInstitutionDTO::getId).collect(Collectors.toList());
+        List<TrainingInstitution> all = trainingInstitutionRepo.findAllById(ids);
+        Map<Long, TrainingInstitution> tiMap = all
+                .stream()
+                .collect(Collectors.toMap(TrainingInstitution::getId, trainingInstitution -> trainingInstitution));
+
+        dtos.forEach(dto -> {
+            TrainingInstitution trainingInstitution = tiMap.get(dto.getId());
+            if (ObjectUtil.isNotNull(trainingInstitution)) {
+                trainingInstitution.setPhone(dto.getPhone());
+                trainingInstitutionRepo.save(trainingInstitution);
+            }
+        });
+
+        // 发送短信
+        this.batchSend(dtos.stream().map(TrainingInstitutionDTO::getPhone).collect(Collectors.toList()));
+
+    }
+
+    public List<String> byName(PageQuery pageQuery) {
+        String name = "%" + pageQuery.getSearch() + "%";
+        PageRequest pageRequest = JpaUtils.toPageRequest(pageQuery);
+        return trainingInstitutionRepo.findAllByNameLike(name, pageRequest.getPageNumber(), pageRequest.getPageSize());
+    }
+
+    public TrainingInstitution byUscc(String name, String uscc) {
+        TrainingInstitution byUscc = trainingInstitutionRepo.findByUscc(uscc);
+        if (ObjectUtil.isNotNull(byUscc)) {
+            if (byUscc.getName().equals(name)) {
+                return byUscc;
+            }
+        }
+        throw new BusinessException("企业名称或税号不正确");
+    }
 }

+ 125 - 118
src/main/java/com/izouma/wenlvju/service/performance/ProgrammeService.java

@@ -250,145 +250,152 @@ public class ProgrammeService {
         }
 
         File destDir = TempFile.createTempDirectory("import");
-        String originalFilename = file.getOriginalFilename();
-        boolean zip = Pattern.matches("zip", FilenameUtils.getExtension(originalFilename));
-        boolean rar = false;
-        if (!zip) {
-            rar = Pattern.matches("rar", FilenameUtils.getExtension(originalFilename));
-        }
-        if (rar) {
-            FileUtils.unrar(file.getInputStream(), destDir);
-        } else if (zip) {
-            try {
-                ZipUtil.unzip(file.getInputStream(), destDir, StandardCharsets.UTF_8);
-            } catch (Exception e) {
-                ZipUtil.unzip(file.getInputStream(), destDir, Charset.forName("gbk"));
-            }
-        } else {
-            throw new BusinessException("最能上传zip或者rar压缩包");
-        }
+        try {
 
 
-        File xlsxFile = FileUtils.findInDir(destDir, null);
-        if (xlsxFile == null) {
-            return;
-        }
-        InputStream indicatorStream = new FileInputStream(xlsxFile);
-        UploadDataListener<ProgUploadDTO> listener = new UploadDataListener<>();
-        List<ProgUploadDTO> dtos = EasyExcel.read(indicatorStream, ProgUploadDTO.class, listener).sheet().doReadSync();
+            String originalFilename = file.getOriginalFilename();
+            boolean zip = Pattern.matches("zip", FilenameUtils.getExtension(originalFilename));
+            boolean rar = false;
+            if (!zip) {
+                rar = Pattern.matches("rar", FilenameUtils.getExtension(originalFilename));
+            }
+            if (rar) {
+                FileUtils.unrar(file.getInputStream(), destDir);
+            } else if (zip) {
+                try {
+                    ZipUtil.unzip(file.getInputStream(), destDir, StandardCharsets.UTF_8);
+                } catch (Exception e) {
+                    ZipUtil.unzip(file.getInputStream(), destDir, Charset.forName("gbk"));
+                }
+            } else {
+                throw new BusinessException("最能上传zip或者rar压缩包");
+            }
 
-//        Map<String, Long> performanceMap = performanceRepo.findAll()
-//                .stream()
-//                .collect(Collectors.toMap(Performance::getName, Performance::getId));
 
-        Map<Integer, Map<String, Long>> mapMap = settingRepo.findAllByFlagIn(CollUtil.newArrayList(3, 4))
-                .stream()
-                .collect(Collectors.groupingBy(Setting::getFlag, Collectors.toMap(Setting::getName, Setting::getId)));
+            File xlsxFile = FileUtils.findInDir(destDir, null);
+            if (xlsxFile == null) {
+                return;
+            }
+            InputStream indicatorStream = new FileInputStream(xlsxFile);
+            UploadDataListener<ProgUploadDTO> listener = new UploadDataListener<>();
+            List<ProgUploadDTO> dtos = EasyExcel.read(indicatorStream, ProgUploadDTO.class, listener)
+                    .sheet()
+                    .doReadSync();
 
-        Map<String, Long> gradeMap = gradingOrganizationRepo.findAll()
-                .stream()
-                .collect(Collectors.toMap(GradingOrganization::getName, GradingOrganization::getId));
+            Map<Integer, Map<String, Long>> mapMap = settingRepo.findAllByFlagIn(CollUtil.newArrayList(3, 4))
+                    .stream()
+                    .collect(Collectors.groupingBy(Setting::getFlag, Collectors.toMap(Setting::getName, Setting::getId)));
 
-        Map<String, ArtType> artTypeMap = artTypeRepo.findAll()
-                .stream()
-                .collect(Collectors.toMap(ArtType::getName, artType -> artType));
-
-
-        List<Participant> participants = new ArrayList<>();
-        Long pid = null;
-        for (ProgUploadDTO dto : dtos) {
-            if (dto.getName() != null && dto.getSpecialty() != null) {
-                Programme programme = new Programme(dto);
-                System.out.println(dto.getSpecialty());
-                ArtType specialty = artTypeMap.get(dto.getSpecialty());
-                programme.setOrganizationId(organization.getId());
-                programme.setGradingOrganizationId(gradeMap.get(dto.getGradingOrganization()));
-                programme.setPerformanceId(performance);
-
-                // 专业
-                if (ObjectUtil.isNotNull(specialty)){
-                    programme.setSpecialtyId(specialty.getId());
-                }
+            Map<String, Long> gradeMap = gradingOrganizationRepo.findAll()
+                    .stream()
+                    .collect(Collectors.toMap(GradingOrganization::getName, GradingOrganization::getId));
 
-                // 节目状态
-                programme.setProgrammeStatus(ProgrammeStatus.INITIAL);
-                String level = dto.getLevel();
-                if (StrUtil.isNotBlank(level)) {
-                    level = level.substring(0, 2);
-                }
-                if (dto.getCompetitionGroup().equals(CompetitionGroup.SINGLE)) {
-                    programme.setLevelSettingId(mapMap.get(3).get(level));
-                } else if (dto.getCompetitionGroup().equals(CompetitionGroup.COLLECTIVE)) {
-                    programme.setLevelSettingId(mapMap.get(4).get(level));
-                }
+            Map<String, ArtType> artTypeMap = artTypeRepo.findAll()
+                    .stream()
+                    .collect(Collectors.toMap(ArtType::getName, artType -> artType));
+
+
+            List<Participant> participants = new ArrayList<>();
+            Long pid = null;
+            for (ProgUploadDTO dto : dtos) {
+                if (dto.getName() != null && dto.getSpecialty() != null) {
+                    Programme programme = new Programme(dto);
+                    System.out.println(dto.getSpecialty());
+                    ArtType specialty = artTypeMap.get(dto.getSpecialty());
+                    programme.setOrganizationId(organization.getId());
+                    programme.setGradingOrganizationId(gradeMap.get(dto.getGradingOrganization()));
+                    programme.setPerformanceId(performance);
+
+                    // 专业
+                    if (ObjectUtil.isNotNull(specialty)) {
+                        programme.setSpecialtyId(specialty.getId());
+                    }
+
+                    // 节目状态
+                    programme.setProgrammeStatus(ProgrammeStatus.INITIAL);
+                    String level = dto.getLevel();
+                    if (StrUtil.isNotBlank(level)) {
+                        level = level.substring(0, 2);
+                    }
+                    if (dto.getCompetitionGroup().equals(CompetitionGroup.SINGLE)) {
+                        programme.setLevelSettingId(mapMap.get(3).get(level));
+                    } else if (dto.getCompetitionGroup().equals(CompetitionGroup.COLLECTIVE)) {
+                        programme.setLevelSettingId(mapMap.get(4).get(level));
+                    }
 
-                File uploadFile = FileUtils.findInDir(destDir, dto.getName());
-                if (dto.getVideo() != null) {
+                    File uploadFile = FileUtils.findInDir(destDir, dto.getName());
+                    if (dto.getVideo() != null) {
 //                    File uploadFile = new File(destDir, dto.getVideo());
-                    uploadFile = FileUtils.findInDir(destDir, dto.getVideo());
+                        uploadFile = FileUtils.findInDir(destDir, dto.getVideo());
+                    }
+                    if (ObjectUtil.isNotNull(uploadFile) && uploadFile.exists()) {
+                        // 视频
+                        if (!specialty.getCode().startsWith("03")) {
+                            // 上传
+                            String videoPath = "video/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
+                                    + RandomStringUtils.randomAlphabetic(8)
+                                    + "." + FilenameUtils.getExtension(uploadFile.getName());
+                            String url = storageService.uploadFromInputStream(new FileInputStream(uploadFile), videoPath);
+                            VideoObject vo = new VideoObject();
+                            vo.setSrc(url);
+                            programme.setVideo(vo);
+                        } else {
+                            // 图片
+                            programme.setAnnex(this.saveImg(uploadFile));
+                        }
+
+                    }
+
+                    pid = programmeRepo.save(programme).getId();
                 }
-                if (ObjectUtil.isNotNull(uploadFile) && uploadFile.exists()) {
-                    // 视频
-                    if (!specialty.getCode().startsWith("03")) {
-                        // 上传
-                        String videoPath = "video/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date())
-                                + RandomStringUtils.randomAlphabetic(8)
-                                + "." + FilenameUtils.getExtension(uploadFile.getName());
-                        String url = storageService.uploadFromInputStream(new FileInputStream(uploadFile), videoPath);
-                        VideoObject vo = new VideoObject();
-                        vo.setSrc(url);
-                        programme.setVideo(vo);
+
+                Participant participant = new Participant(dto);
+                if (ObjectUtil.isNotNull(dto.getParticipantBirthday())) {
+                    if (dto.getParticipantBirthday().contains("/")) {
+                        LocalDate birthday = LocalDate.parse(dto.getParticipantBirthday(), DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT1));
+                        participant.setBirthday(birthday);
+                    } else if (dto.getParticipantBirthday().contains("-")) {
+                        LocalDate birthday = LocalDate.parse(dto.getParticipantBirthday(), DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT));
+                        participant.setBirthday(birthday);
                     } else {
-                        // 图片
-                        programme.setAnnex(this.saveImg(uploadFile));
+                        throw new BusinessException("日期格式错误!");
                     }
 
-                }
 
-                pid = programmeRepo.save(programme).getId();
-            }
+                }
 
-            Participant participant = new Participant(dto);
-            if (ObjectUtil.isNotNull(dto.getParticipantBirthday())) {
-                if (dto.getParticipantBirthday().contains("/")) {
-                    LocalDate birthday = LocalDate.parse(dto.getParticipantBirthday(), DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT1));
-                    participant.setBirthday(birthday);
-                } else if (dto.getParticipantBirthday().contains("-")) {
-                    LocalDate birthday = LocalDate.parse(dto.getParticipantBirthday(), DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT));
-                    participant.setBirthday(birthday);
+                participant.setProgrammeId(pid);
+                participant.setPerformanceId(performance);
+                participants.add(participant);
+                File uploadImg;
+                if (dto.getImg() != null) {
+//                File uploadFile = new File(destDir, dto.getImg());
+                    uploadImg = FileUtils.findInDir(destDir, dto.getImg());
                 } else {
-                    throw new BusinessException("日期格式错误!");
+                    uploadImg = FileUtils.findInDir(destDir, dto.getIdNo() + "证件照");
+                }
+                if (ObjectUtil.isNotNull(uploadImg) && uploadImg.exists()) {
+                    participant.setImg(this.saveImg(uploadImg));
                 }
 
-
-            }
-
-            participant.setProgrammeId(pid);
-            participant.setPerformanceId(performance);
-            participants.add(participant);
-            File uploadImg;
-            if (dto.getImg() != null) {
-//                File uploadFile = new File(destDir, dto.getImg());
-                uploadImg = FileUtils.findInDir(destDir, dto.getImg());
-            } else {
-                uploadImg = FileUtils.findInDir(destDir, dto.getIdNo() + "证件照");
-            }
-            if (ObjectUtil.isNotNull(uploadImg) && uploadImg.exists()) {
-                participant.setImg(this.saveImg(uploadImg));
+                File uploadCertificate;
+                if (dto.getCertificate() != null) {
+                    uploadCertificate = FileUtils.findInDir(destDir, dto.getCertificate());
+                } else {
+                    uploadCertificate = FileUtils.findInDir(destDir, dto.getIdNo() + "证书");
+                }
+                if (ObjectUtil.isNotNull(uploadCertificate) && uploadCertificate.exists()) {
+                    participant.setCertificate(this.saveImg(uploadCertificate));
+                }
             }
 
-            File uploadCertificate;
-            if (dto.getCertificate() != null) {
-                uploadCertificate = FileUtils.findInDir(destDir, dto.getCertificate());
-            } else {
-                uploadCertificate = FileUtils.findInDir(destDir, dto.getIdNo() + "证书");
-            }
-            if (ObjectUtil.isNotNull(uploadCertificate) && uploadCertificate.exists()) {
-                participant.setCertificate(this.saveImg(uploadCertificate));
-            }
-        }
+            participantRepo.saveAll(participants);
+        } catch (Exception e) {
+            throw e;
+        } finally {
+            FileUtils.delFiles(destDir);
 
-        participantRepo.saveAll(participants);
+         }
     }
 
     private String saveImg(File uploadFile) throws FileNotFoundException {

+ 25 - 0
src/main/java/com/izouma/wenlvju/utils/FileUtils.java

@@ -6,6 +6,7 @@ import com.github.junrar.Archive;
 import com.github.junrar.exception.RarException;
 import com.github.junrar.rarfile.FileHeader;
 import com.izouma.wenlvju.exception.BusinessException;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang3.StringUtils;
 
@@ -20,6 +21,7 @@ import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+@Slf4j
 public class FileUtils {
 
     public static String getExtension(String fileName) {
@@ -239,6 +241,29 @@ public class FileUtils {
         return null;
     }
 
+    public static boolean delFiles(File file) {
+        try {
+            boolean result;
+            //目录
+            if (file.isDirectory()) {
+                 File[] childrenFiles = file.listFiles();
+
+                for (File childFile : childrenFiles) {
+                    result = delFiles(childFile);
+                    if (!result) {
+                        return result;
+                    }
+                }
+            }
+            //删除 文件、空目录
+            result = file.delete();
+            return result;
+        } catch (Exception e) {
+            log.error("删除失败", e);
+        }
+        return false;
+    }
+
     public static File folderMethod1(File file, String fileName) {
         LinkedList<File> list = new LinkedList<>();
 

+ 31 - 2
src/main/java/com/izouma/wenlvju/web/TrainingInstitutionController.java

@@ -1,19 +1,22 @@
 package com.izouma.wenlvju.web;
 
 import com.izouma.wenlvju.domain.TrainingInstitution;
-import com.izouma.wenlvju.service.TrainingInstitutionService;
 import com.izouma.wenlvju.dto.PageQuery;
+import com.izouma.wenlvju.dto.TrainingInstitutionDTO;
 import com.izouma.wenlvju.exception.BusinessException;
 import com.izouma.wenlvju.repo.TrainingInstitutionRepo;
+import com.izouma.wenlvju.service.TrainingInstitutionService;
 import com.izouma.wenlvju.utils.ObjUtils;
 import com.izouma.wenlvju.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
 import org.springframework.data.domain.Page;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/trainingInstitution")
@@ -59,9 +62,35 @@ public class TrainingInstitutionController extends BaseController {
         ExcelUtils.export(response, data);
     }
 
+    @GetMapping("/excel1")
+    @ResponseBody
+    public void excel1(HttpServletResponse response) throws IOException {
+        List<TrainingInstitution> data = trainingInstitutionRepo.findAllByPhoneIsNull();
+        List<TrainingInstitutionDTO> dtos = data.stream()
+                .map(TrainingInstitutionDTO::new)
+                .collect(Collectors.toList());
+        ExcelUtils.export(response, dtos);
+    }
+
     @GetMapping("/batchSend")
     public void batchSend() throws InterruptedException {
-        trainingInstitutionService.batchSend();
+        List<String> phones = trainingInstitutionRepo.findAllBySubmitFalseAndPhoneIsNotNull();
+        trainingInstitutionService.batchSend(phones);
+    }
+
+    @PostMapping("/upload")
+    public void uploadFile(@RequestParam("file") MultipartFile file) throws Exception {
+        trainingInstitutionService.upload(file);
+    }
+
+    @PostMapping("/name")
+    public Page<String> name(@RequestBody PageQuery pageQuery) {
+        return trainingInstitutionService.all(pageQuery).map(TrainingInstitution::getName);
+    }
+
+    @PostMapping("/byUscc")
+    public TrainingInstitution byUscc(@RequestParam String name, @RequestParam String uscc) {
+        return trainingInstitutionService.byUscc(name, uscc);
     }
 }
 

+ 3 - 4
src/main/java/com/izouma/wenlvju/web/performance/ProgrammeController.java

@@ -106,11 +106,10 @@ public class ProgrammeController extends BaseController {
         programmeService.upload(file, SecurityUtils.getAuthenticatedUser().getId());
 //        try {
 //            programmeService.upload(file, SecurityUtils.getAuthenticatedUser().getId());
-//        } catch (IOException e) {
-//            log.error("上传失败", e);
-//            throw new BusinessException("上传失败", e.getMessage());
 //        } catch (Exception e) {
-//            e.printStackTrace();
+//            log.error("上传失败", e);
+////            throw new BusinessException("上传失败", e.getMessage());
+//            throw e;
 //        }
     }
 

+ 89 - 14
src/main/vue/src/views/TrainingInstitutionList.vue

@@ -3,16 +3,30 @@
         <div class="filters-container">
             <el-input placeholder="输入关键字" v-model="search" clearable class="filter-item"></el-input>
             <el-button @click="getData" type="primary" icon="el-icon-search" class="filter-item">搜索 </el-button>
-            <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button>
-            <el-button
-                @click="download"
-                type="primary"
-                icon="el-icon-download"
-                :loading="downloading"
-                class="filter-item"
-                >导出EXCEL
+            <!-- <el-button @click="addRow" type="primary" icon="el-icon-plus" class="filter-item">添加 </el-button> -->
+            <el-button @click="download" type="primary" icon="el-icon-download" :loading="downloading"
+                >导出所有
             </el-button>
-            <el-button @click="sendSms" type="primary" :loading="downloading" class="filter-item">短信通知 </el-button>
+            <el-button @click="downloadTel" type="primary" icon="el-icon-download" :loading="downloading"
+                >导出固定电话
+            </el-button>
+            <el-upload
+                :action="uploadUrl"
+                :before-upload="beforeUpload"
+                :headers="headers"
+                :show-file-list="false"
+                ref="upload"
+                :on-success="onSuccess"
+                class="uploader"
+                :on-error="onfail"
+                :loading="loading"
+                :disabled="loading"
+            >
+                <el-button slot="trigger" type="primary" icon="el-icon-upload2" :loading="loading" :disabled="loading"
+                    >批量上传</el-button
+                >
+            </el-upload>
+            <el-button @click="sendSms" type="primary">短信通知 </el-button>
         </div>
         <el-table
             :data="tableData"
@@ -88,6 +102,7 @@
 <script>
 import { mapState } from 'vuex';
 import pageableTable from '@/mixins/pageableTable';
+import resolveUrl from 'resolve-url';
 
 export default {
     name: 'TrainingInstitutionList',
@@ -97,14 +112,24 @@ export default {
             multipleMode: false,
             search: '',
             url: '/trainingInstitution/all',
-            downloading: false
+            downloading: false,
+            loading: false,
+            uploadUrl: ''
         };
     },
     computed: {
         selection() {
             return this.$refs.table.selection.map(i => i.id);
+        },
+        headers() {
+            return {
+                Authorization: 'Bearer ' + sessionStorage.getItem('token')
+            };
         }
     },
+    created() {
+        this.uploadUrl = resolveUrl(this.$baseUrl, 'trainingInstitution/upload');
+    },
     methods: {
         beforeGetData() {
             return { search: this.search };
@@ -136,7 +161,31 @@ export default {
             this.$axios
                 .get('/trainingInstitution/excel', {
                     responseType: 'blob',
-                    params: { size: 10000 }
+                    params: { size: 100000 }
+                })
+                .then(res => {
+                    console.log(res);
+                    this.downloading = false;
+                    const downloadUrl = window.URL.createObjectURL(new Blob([res.data]));
+                    const link = document.createElement('a');
+                    link.href = downloadUrl;
+                    link.setAttribute('download', res.headers['content-disposition'].split('filename=')[1]);
+                    document.body.appendChild(link);
+                    link.click();
+                    link.remove();
+                })
+                .catch(e => {
+                    console.log(e);
+                    this.downloading = false;
+                    this.$message.error(e.error);
+                });
+        },
+        downloadTel() {
+            this.downloading = true;
+            this.$axios
+                .get('/trainingInstitution/excel1', {
+                    responseType: 'blob',
+                    params: { size: 50000 }
                 })
                 .then(res => {
                     console.log(res);
@@ -180,21 +229,47 @@ export default {
                 });
         },
         sendSms() {
-            this.$alert('确认发送吗?', '提示')
+            this.$alert('确认发送短信吗?', '提示')
                 .then(() => {
                     return this.$http.post(`/trainingInstitution/batchSend`);
                 })
                 .then(() => {
                     this.$message.success('发送成功');
-                    this.getData();
+                    // this.getData();
                 })
                 .catch(e => {
                     if (e !== 'cancel') {
                         this.$message.error(e.error);
                     }
                 });
+        },
+        upload() {},
+        onfail(e) {
+            console.log(e);
+            this.$message.error('失败:' + e);
+            this.loading = false;
+            this.getData();
+        },
+        onSuccess() {
+            this.$message.success('上传成功');
+            this.loading = false;
+            this.getData();
+        },
+        beforeUpload() {
+            return this.$confirm('确认要上传文件吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                this.loading = true;
+            });
         }
     }
 };
 </script>
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.uploader {
+    display: inline-block;
+    margin: 0 10px;
+}
+</style>

+ 1 - 1
src/test/java/com/izouma/wenlvju/repo/UserRepoTest.java

@@ -74,7 +74,7 @@ public class UserRepoTest {
 
     @Test
     public void test3() {
-        System.out.println(jwtTokenUtil.generateToken(JwtUserFactory.create(userRepo.findById(10130L)
+        System.out.println(jwtTokenUtil.generateToken(JwtUserFactory.create(userRepo.findById(17369L)
                 .orElseThrow(new BusinessException("用户不存在")))));
     }
 

+ 1 - 3
src/test/java/com/izouma/wenlvju/service/sms/NjwlSmsServiceTest.java

@@ -11,10 +11,8 @@ public class NjwlSmsServiceTest extends ApplicationTests {
 
     @Test
     public void test() {
-        njwlSmsService.sendSms("19951988293", "test");
+        njwlSmsService.sendSms("15150689190", "http://wljtest.izouma.com/h5/trainingInstitution");
         // {"expiryDate":"1623808467934","tokenKey":"1fb4796840d8a7b8d43e022e5a1f693c","data":{"phone":"19951988293","message":"test"},"appId":"189610","operationType":"ADD"}
-
-
     }
 
     @Test

+ 3 - 2
src/test/java/com/izouma/wenlvju/web/TrainingInstitutionControllerTest.java

@@ -23,9 +23,10 @@ public class TrainingInstitutionControllerTest extends ApplicationTests {
     @Test
     public void test() throws InterruptedException {
         long count = trainingInstitutionRepo.count();
+
         PageQuery pageQuery = new PageQuery();
         pageQuery.setSize(1000);
-        for (int i = 0; i < count / 1000; i++) {
+        for (int i = 5; i < count / 1000; i++) {
             pageQuery.setPage(i);
             List<TrainingInstitution> content = trainingInstitutionController.all(pageQuery).getContent();
             List<TrainingInstitution> result = new ArrayList<>();
@@ -39,7 +40,7 @@ public class TrainingInstitutionControllerTest extends ApplicationTests {
             trainingInstitutionRepo.saveAll(result);
             System.out.println(i);
 //            Thread.sleep(5 * 60 * 1000);
-            Thread.sleep(30 * 1000);
+//            Thread.sleep(30 * 1000);
         }
 
 //        System.out.println("12".split(","));