智慧保安后台管理-外网项目备份
钟日健
2026-06-01 62eb499b0c969f246d3245d1429a97da4de1ce28
src/main/java/org/springblade/modules/experience/controller/ExperienceController.java
@@ -28,12 +28,17 @@
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.experience.entity.Experience;
import org.springblade.modules.experience.service.IExperienceService;
import org.springblade.modules.experience.vo.ExperienceVO;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.service.MyAsyncService;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
@@ -50,6 +55,10 @@
public class ExperienceController extends BladeController {
   private final IExperienceService experienceService;
   private final IUserService userService;
   private final MyAsyncService myAsyncService;
   /**
    * 详情
@@ -100,20 +109,22 @@
    */
   @PostMapping("/saveOrUpdate")
   public R save(@Valid @RequestBody Map<String,Object> experience ) {
      String cardid = experience.get("cardid").toString();
      //先删除原有的从业信息
      experienceService.delbyCardId(cardid);
      //重新新增从业信息
      List<Experience> experiences = (List<Experience>)experience.get("userPractitionersInfo");
      int count = 0;
      if (experiences.size()>0){
         for(int i = 0;i<experiences.size();i++){
            Experience e = JSON.parseObject(JSON.toJSONString(experiences.get(i)),Experience.class);
            experienceService.save(e);
            count++;
         }
         if(count<1){
            return R.status(false);
      if (experience.size()>0) {
         String securityid = experience.get("securityid").toString();
         //先删除原有的从业信息
         experienceService.delbyCardId(securityid);
         //重新新增从业信息
         List<Experience> experiences = (List<Experience>) experience.get("userPractitionersInfo");
         int count = 0;
         if (experiences.size() > 0) {
            for (int i = 0; i < experiences.size(); i++) {
               Experience e = JSON.parseObject(JSON.toJSONString(experiences.get(i)), Experience.class);
               experienceService.save(e);
               count++;
            }
            if (count < 1) {
               return R.status(false);
            }
         }
      }
      return R.status(true);
@@ -136,7 +147,53 @@
   @ApiOperationSupport(order = 6)
   @ApiOperation(value = "新增或修改", notes = "传入experience")
   public R submit(@Valid @RequestBody Experience experience) {
      return R.status(experienceService.saveOrUpdate(experience));
      boolean status = false;
      if (null!=experience.getId()){
         //更新
         status = experienceService.updateById(experience);
         String s1 =
            "update sys_experience set name = " + "'" + experience.getName() + "'"
               + ",post = " + "'" + experience.getPost() + "'"
               + ",department = " + "'" + experience.getDepartment() + "'"
               + ",responsibilities = " + "'" + experience.getResponsibilities() + "'"
               + ",entryTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'"
               + ",departureTime = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'"
               + ",leaving = " + "'" + experience.getLeaving() + "'"
               + ",cardId = " + "'" + experience.getCardid() + "'"
               + ",companyname = " + "'" + experience.getCompanyname() + "'"
               + ",securityId = " + "'" + experience.getSecurityid() + "'"
               + " " + "where id = " + "'" + experience.getId() + "'";
         //FtpUtil.sqlFileUpload(s1);
         myAsyncService.dataSync(s1);
      }else {
         //新增
         //查询用户身份证号
         User user = userService.getById(experience.getSecurityid());
         experience.setCardid(user.getCardid());
         experience.setName(user.getRealName());
         status = experienceService.save(experience);
         //内网同步
         String s = "insert into sys_experience(id,name,post,department,responsibilities,entryTime,departureTime,leaving," +
            "cardId,companyname,securityId) " +
            "values(" + "'" + experience.getId() + "'" +
            "," + "'" + experience.getName() + "'" +
            "," + "'" + experience.getPost() + "'" +
            "," + "'" + experience.getDepartment() + "'" +
            "," + "'" + experience.getResponsibilities() + "'" +
            "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getEntrytime()) + "'" +
            "," + "'" + new SimpleDateFormat("yyyy-MM-dd").format(experience.getDeparturetime()) + "'" +
            "," + "'" + experience.getLeaving() + "'" +
            "," + "'" + experience.getCardid() + "'" +
            "," + "'" + experience.getCompanyname() + "'" +
            "," + "'" + experience.getSecurityid() + "'"
            + ")";
         //FtpUtil.sqlFileUpload(s);
         myAsyncService.dataSync(s);
      }
      return R.status(status);
   }
@@ -152,12 +209,12 @@
   /**
     * 保安就业记录
    * @param cardid 身份证
    * @param securityid 身份证
    * @return
     */
   @GetMapping("/selectExperienceInfo")
   public R selectExperienceInfo(String cardid) {
      return R.data(experienceService.selectExperienceInfo(cardid));
   public R selectExperienceInfo(String securityid) {
      return R.data(experienceService.selectExperienceInfo(securityid));
   }