洪城义警-正式版后台
zengh
2021-11-05 b39cc2beacc1ec2e37cff349cae42e420105c8a6
src/main/java/org/springblade/modules/zc/controller/ZcController.java
@@ -22,12 +22,15 @@
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.common.vo.DeptVo;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.FTP.FtpUtil;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.zc.entity.Zc;
import org.springblade.modules.zc.service.IZcService;
@@ -37,7 +40,9 @@
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
 *  控制器
@@ -54,6 +59,8 @@
   private final IZcService zcService;
   private IUserService iUserService;
   private final IDeptService deptFeignApi;
   /**
    * 详情
@@ -84,8 +91,50 @@
   @ApiOperationSupport(order = 3)
   @ApiOperation(value = "分页", notes = "传入zc")
   public R<IPage<ZcVO>> page(ZcVO zc, Query query) {
      IPage<ZcVO> pages = zcService.selectZcPage(Condition.getPage(query), zc);
      return R.data(pages);
      //获取部门数据
      List<DeptVo> deptVos = deptFeignApi.selDeptList();
      //获取辖区数据
      List<DeptVo> xqVos = deptFeignApi.selXQList();
      IPage<ZcVO> page = zcService.selectZcPage(Condition.getPage(query), zc);
      for (int j = 0; j < page.getRecords().size(); j++) {
         if (page.getRecords().get(j).getDeptid() != null && !page.getRecords().get(j).getDeptid().equals("")){
            String[] split = page.getRecords().get(j).getDeptid().split(",");
            List<String> list = Arrays.asList(split);
            StringBuffer deptNameBuiffer = new StringBuffer();
            //数据匹配封装
            for (String deptId:list) {
               for (DeptVo deptVo:deptVos) {
                  if (deptId.equals(deptVo.getId().toString())){
                     deptNameBuiffer.append(deptVo.getDeptName()).append(",");
                  }
               }
            }
            //封装部门名称数据
            page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
         }
      }
      for (int j = 0; j < page.getRecords().size(); j++) {
         if (page.getRecords().get(j).getJurisdiction() != null && !page.getRecords().get(j).getJurisdiction().equals("")){
            String[] split = page.getRecords().get(j).getJurisdiction().split(",");
            List<String> list = Arrays.asList(split);
            StringBuffer deptNameBuiffer = new StringBuffer();
            //数据匹配封装
            for (String deptId:list) {
               for (DeptVo deptVo:xqVos) {
                  if (deptId.equals(deptVo.getId().toString())){
                     deptNameBuiffer.append(deptVo.getDeptName()).append(",");
                  }
               }
            }
            //封装部门名称数据
            page.getRecords().get(j).setXQName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
         }
      }
      return R.data(page);
   }
   /**
@@ -125,7 +174,13 @@
         user.setPhone(zc.getPhone());
         user.setDeptId(zc.getDeptid());
         user.setRoleId(zc.getParentId());
         user.setJurisdiction(zc.getJurisdiction());
         user.setExamination_type("0");
         user.setExamination_mx("正常");
         user.setCardid(zc.getCardid());
         iUserService.saveOrUpdate(user);
      }
      return R.status(zcService.saveOrUpdate(zc));
   }
@@ -152,6 +207,23 @@
      String times = df.format(new Date());
      zc.setZctime(times);
      zcService.inster(zc);
      String s = "insert into act_zc(id,username,password,sname,sex,phone,zctime,deptid,parent_id,jurisdiction,cardid)" +
         "values(" + zc.getId() + "'" +
         "," + "'" + zc.getUsername() + "'" +
         "," + "'" + zc.getPassword() + "'" +
         "," + "'" + zc.getSname() + "'" +
         "," + "'" + zc.getSex() + "'" +
         "," + "'" + zc.getPhone() + "'" +
         "," + "'" + zc.getZctime() + "'" +
         "," + "'" + zc.getDeptid() + "'" +
         "," + "'" + zc.getParentId() + "'" +
         "," + "'" + zc.getJurisdiction() + "'" +
         "," + "'" + zc.getCardid() + "'" + ")";
      System.out.println(s);
      FtpUtil.sqlFileUpload(s);
      return R.success("新增成功");
   }