智慧保安后台管理-外网项目备份
tangzy
2021-07-29 f1918fc9554dedeee1fbfe6f5d1886440ec0b85f
src/main/java/org/springblade/modules/information/controller/InformationController.java
@@ -21,13 +21,19 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.DictCache;
import org.springblade.common.enums.DictEnum;
import org.springblade.common.utils.arg;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
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.support.Kv;
import org.springblade.modules.information.entity.Information;
import org.springblade.modules.information.service.IInformationService;
import org.springblade.modules.information.vo.InformationVO;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.service.IDeptService;
import org.springframework.web.bind.annotation.*;
@@ -37,8 +43,10 @@
import java.util.List;
import java.util.Map;
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
/**
 *  控制器
 * 控制器
 *
 * @author BladeX
 * @since 2021-07-07
@@ -92,7 +100,53 @@
   @PostMapping("/save")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入information")
   public R save(@Valid @RequestBody Information information) {
   public R save(@Valid @RequestBody Information information) throws Exception {
      Dept dept = new Dept();
      //自招保安公司
      if (information.getStats().equals("0")) {
         Long i = 1420222768149966850L;
         dept.setParentId(i);
         dept.setTenantId("000000");
         dept.setDeptName(information.getEnterprisename());
         dept.setAncestors("0,1420222768149966850");
         dept.setDeptCategory(1);
      }
      //保安培训公司
      if (information.getStats().equals("1")) {
         Long i = 1418458374477549569L;
         dept.setParentId(i);
         dept.setTenantId("000000");
         dept.setDeptName(information.getEnterprisename());
         dept.setAncestors("0,1418458374477549569");
         dept.setDeptCategory(1);
      }
      //保安服务公司
      if (information.getStats().equals("2")) {
         Long i = 1413470343230877697L;
         dept.setParentId(i);
         dept.setTenantId("000000");
         dept.setDeptName(information.getEnterprisename());
         dept.setAncestors("0,1413470343230877697");
         dept.setDeptCategory(1);
      }
      //武装守押公司
      if (information.getStats().equals("3")) {
         Long i = 1420222961377357825L;
         dept.setParentId(i);
         dept.setTenantId("000000");
         dept.setDeptName(information.getEnterprisename());
         dept.setAncestors("0,1420222961377357825");
         dept.setDeptCategory(1);
      }
      if (iDeptService.submit(dept)) {
         CacheUtil.clear(SYS_CACHE);
         // 返回懒加载树更新节点所需字段
         Kv kv = Kv.create().set("id", String.valueOf(dept.getId())).set("tenantId", dept.getTenantId())
            .set("deptCategoryName", DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory()));
         String id = kv.get("id").toString();
         information.setDepartmentid(id);
      }
      arg.test01(arg.url + "/information/save", information);
      return R.status(informationService.save(information));
   }
@@ -102,7 +156,8 @@
   @PostMapping("/update")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入information")
   public R update(@Valid @RequestBody Information information) {
   public R update(@Valid @RequestBody Information information) throws Exception {
      arg.test01(arg.url + "/information/update", information);
      return R.status(informationService.updateById(information));
   }
@@ -123,78 +178,80 @@
   @PostMapping("/remove")
   @ApiOperationSupport(order = 8)
   @ApiOperation(value = "删除", notes = "传入ids")
   public R remove(String creditcode) {
      informationService.deleteIn(creditcode);
      informationService.deleteSh(creditcode);
      informationService.deleteMe(creditcode);
   public R remove(String creditcode, String departmentid) throws Exception {
      String[] strArray = creditcode.split(",");
      String[] strArrays = departmentid.split(",");
      for (int i = 0; i < strArray.length; i++) {
         informationService.deleteIn(strArray[i]);
         informationService.deleteSh(strArray[i]);
         informationService.deleteMe(strArray[i]);
         arg.sendPostRemoveByIds(arg.url + "/information/remove", strArray[i]);
      }
      for (int j = 0; j < strArrays.length; j++) {
         //机构删除
         informationService.deleteDept(strArrays[j]);
         arg.sendPostRemoveByIds(arg.url + "/information/deleteDept", strArrays[j]);
      }
      return R.success("删除成功");
   }
   /**
    * 首页保安公司统计接口
    * @return
    * 统计保安员资格异常的数量
    */
   @PostMapping("/SelectCount")
   public R SelectCount() {
      String name="分局";
      List<Map<Object, String>> list = iDeptService.selectCount(name);
      List<Map<String, Object>> lists = new ArrayList<>();
      for (int i=0;i<list.size();i++){
         String title = list.get(i).get("title");//部门名称
         String departmentid =  String.valueOf(list.get(i).get("jurisdiction"));//部门id
         Map<String, Object> map = new HashMap<String, Object>();
         Map maps = informationService.selectCount(departmentid);
         map.put("name",title);
         map.put("server",maps);
         lists.add(map);
      }
   @PostMapping("/selectExtype")
   public R selectExtype(String deptid) {
      List<Map<Object, Object>> lists = informationService.selectExtype(deptid);
      return R.data(lists);
   }
   /**
    * 首页保安持证统计接口
    * @return
    * 统计保安员持证的数量
    */
   @PostMapping("/SelectCounthold")
   public R SelectCounthold() {
      String name="分局";
      List<Map<Object, String>> list = iDeptService.selectCount(name);
      List<Map<String, Object>> lists = new ArrayList<>();
      for (int i=0;i<list.size();i++){
         int cznumber=0;//总的持证数量
         int wcznumber=0;//总的未持证数量
         String title = list.get(i).get("title");//部门名称
         Map<String, Object> map = new HashMap<String, Object>();
         Map<Object, Integer> objectStringMap = iDeptService.selectHold(String.valueOf(list.get(i).get("jurisdiction")));
         cznumber=objectStringMap.get("cz");;
         wcznumber=objectStringMap.get("wcz");;
         map.put("name",title);
         map.put("cz",cznumber);
         map.put("wcz",wcznumber);
         lists.add(map);
      }
   @PostMapping("/selectHold")
   public R selectHold(String deptid) {
      List<Map<Object, Object>> lists = informationService.selectHold(deptid);
      return R.data(lists);
   }
   /**
    * 派遣服务单位统计
    */
   @PostMapping("/selectDis")
   public R selectDis(String deptid) {
      List<Map<Object, Object>> lists = informationService.selectDis(deptid);
      return R.data(lists);
   }
    /**
    *统计保安公司未持证的保安的公司数量
   /**
    * 保安派遣数量统计
    */
   @PostMapping("/selectInCount")
   public R selectInCount() {
      List<Map<Object, String>> maps = informationService.selectInCount();
      return R.data(maps);
   @PostMapping("/selectDisp")
   public R selectDisp(String deptid) {
      List<Map<Object, Object>> lists = informationService.selectDisp(deptid);
      return R.data(lists);
   }
   /**
    *管辖区域下拉
    * 保安派遣数量统计
    */
   @PostMapping("/selecttree")
   public R selecttree() {
      String name="分局";
      List<Map<Object, String>> maps = iDeptService.selectCount(name);
      return R.data(maps);
   @PostMapping("/selectSoil")
   public R selectSoil(String deptid) {
      List<Map<Object, Object>> lists = informationService.selectSoil(deptid);
      List<Map<String, Object>> list = new ArrayList<>();
      for (int i=0;i<lists.size();i++){
         Map<String, Object> map = new HashMap<String, Object>();
         String numj = lists.get(i).get("numj").toString();
         Integer a=Integer.valueOf(numj);
         String numz = lists.get(i).get("numz").toString();
         Integer b=Integer.valueOf(numz);
         Integer c=b-a;
         map.put("numj",a);
         map.put("nmuwj",c);
         list.add(map);
      }
      return R.data(list);
   }
}