/* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.information.controller; import io.swagger.annotations.*; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; import javax.validation.Valid; import org.springblade.common.cache.DictCache; import org.springblade.common.enums.DictEnum; 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.core.tool.utils.Func; import org.springblade.modules.desk.entity.Notice; import org.springblade.modules.desk.vo.NoticeVO; import org.springblade.modules.desk.wrapper.NoticeWrapper; import org.springblade.modules.jurisdiction.service.JurisdictionService; import org.springblade.modules.jurisdiction.vo.JurisdictionVO; import org.springblade.modules.member.service.IMemberService; import org.springblade.modules.shareholder.service.IShareholderService; import org.springblade.modules.system.entity.Dept; import org.springblade.modules.system.service.IDeptService; import org.springblade.modules.system.service.IUserDeptService; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.modules.information.entity.Information; import org.springblade.modules.information.vo.InformationVO; import org.springblade.modules.information.service.IInformationService; import org.springblade.core.boot.ctrl.BladeController; import springfox.documentation.annotations.ApiIgnore; import java.util.*; import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE; /** * 控制器 * * @author BladeX * @since 2021-07-07 */ @RestController @AllArgsConstructor @RequestMapping("/information") @Api(value = "", tags = "接口") public class InformationController extends BladeController { private final IInformationService informationService; private final IDeptService iDeptService; private final JurisdictionService jurisdictionService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入information") public R detail(Information information) { Information detail = informationService.getOne(Condition.getQueryWrapper(information)); return R.data(detail); } /** * 分页 */ @GetMapping("/list") @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入information") public R> list(@ApiIgnore @RequestParam Map information, Query query) { IPage pages = informationService.page(Condition.getPage(query), Condition.getQueryWrapper(information, Information.class)); return R.data(pages); } /** * 自定义分页 */ @GetMapping("/page") @ApiOperationSupport(order = 3) @ApiOperation(value = "分页", notes = "传入information") public R> page(Information information, Query query) { IPage pages = informationService.selectInformationPage(Condition.getPage(query), information); return R.data(pages); } /** * 新增 */ @PostMapping("/save") @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入information") public R save(@Valid @RequestBody Information information) { Dept dept= new Dept(); Long i = 1413470343230877697L; dept.setParentId(i); dept.setTenantId("000000"); dept.setDeptName(information.getEnterprisename()); dept.setAncestors("0,1413470343230877697"); 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); } return R.status(informationService.save(information)); } /** * 修改 */ @PostMapping("/update") @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入information") public R update(@Valid @RequestBody Information information) { return R.status(informationService.updateById(information)); } /** * 新增或修改 */ @PostMapping("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入information") public R submit(@Valid @RequestBody Information information) { return R.status(informationService.saveOrUpdate(information)); } /** * 删除 */ @PostMapping("/remove") @ApiOperationSupport(order = 8) @ApiOperation(value = "删除", notes = "传入ids") public R remove(String creditcode) { informationService.deleteIn(creditcode); informationService.deleteSh(creditcode); informationService.deleteMe(creditcode); return R.success("删除成功"); } /** * 首页保安公司统计接口 * * @return */ @PostMapping("/SelectCount") public R SelectCount() { List> list = iDeptService.selectCount(); List> 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 map = new HashMap(); Map maps = informationService.selectCount(departmentid); map.put("name", title); map.put("server", maps); lists.add(map); } return R.data(lists); } /** * 首页保安持证统计接口 * * @return */ @PostMapping("/SelectCounthold") public R SelectCounthold() { List> list = iDeptService.selectCount(); List> 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 map = new HashMap(); Map objectStringMap = iDeptService.selectHold(String.valueOf(list.get(i).get("jurisdiction"))); if (objectStringMap==null) { map.put("name", title); map.put("cz", cznumber); map.put("wcz", wcznumber); lists.add(map); } else { cznumber = objectStringMap.get("cz"); wcznumber = objectStringMap.get("wcz"); map.put("name", title); map.put("cz", cznumber); map.put("wcz", wcznumber); lists.add(map); } } return R.data(lists); } /** * 统计保安公司未持证的保安的公司数量 */ @PostMapping("/selectInCount") public R selectInCount(String jurisdiction,String deptid) { List> maps = informationService.selectInCount(jurisdiction,deptid); Map map = new HashMap(); map.put("Count",maps.size()); map.put("List",maps); List> lists = new ArrayList<>(); lists.add(map); return R.data(lists); } /** 未缴社保数量 * 通过辖区查询机构id,然后通过机构id查询当前机构交社保的人数(numj单位已交社保数量;numz单位人员总数) */ @PostMapping("/selectCs") public R selectCs(String jurisdiction,String deptid) { List> maps = informationService.selectCs(jurisdiction,deptid); List> lists = new ArrayList<>(); List> lists1 = new ArrayList<>(); Map map1 = new HashMap(); Integer count=0; for (int i=0;i map = new HashMap(); //交社保数 String numjs = maps.get(i).get("numj").toString(); Integer numj = Integer.parseInt(numjs); //单位总人数 String numzs = maps.get(i).get("numz").toString(); Integer numz = Integer.parseInt(numzs); String deptname = maps.get(i).get("deptname").toString(); //统计未交社保人数 int i1 = numz - numj; count+=i1; map.put("count",i1); map.put("name",deptname); lists1.add(map); } map1.put("Count",count); map1.put("List",lists1); lists.add(map1); return R.data(lists); } /** * 管辖区域下拉 */ @PostMapping("/selecttree") public R selecttree() { List> maps = iDeptService.selectCount(); return R.data(maps); } /** * 管辖区域下拉 */ @PostMapping("/lazyTreeJu") public R lazyTreeJu() { List jurisdictionVOS = jurisdictionService.lazyTreeJu(); return R.data(jurisdictionVOS); } /** * 统计这个月和上个月交社保的人数,以及金额 * @return */ @PostMapping("/selectTo") public R selectTo(String jurisdiction,String deptid) { //上个月人数数量 Integer lnum=0; //这个月人数数量 Integer tnum=0; //上个月金额 Double lmount=0.0; //这个月金额 Double tmount=0.0; Map map = new HashMap(); List> lists = new ArrayList<>(); List> list = informationService.selectTo(jurisdiction,deptid); for (int i=0;i map = informationService.queryYearSoil(year,jurisdiction,deptid); map = (HashMap) sortMapBykeyAsc(map) ;//key升序 return R.data(map); } /** * 查询本年所有月份社保金额 * @return */ @GetMapping("/queryYearAn") public R queryYearAn(String jurisdiction,String deptid) { Calendar cal = Calendar.getInstance(); String year = String.valueOf(cal.get(Calendar.YEAR)); Map map = informationService.queryYearAn(year,jurisdiction,deptid); map = (HashMap) sortMapBykeyAsc(map) ;//key升序 return R.data(map); } /** * 公司运营智能统计 * @return */ @GetMapping("/queryCounts") public R queryCounts(String jurisdiction,String deptid) { List> lists = new ArrayList<>(); Integer a=0; Integer b=0; Integer zca=0; Integer zcb=0; Integer cza=0; Integer czb=0; Integer sba=0; Integer sbb=0; Integer kha=0; Integer khb=0; Integer pqa=0; Integer pqb=0; String deptname=null; String jurname=null; //保安员数量 Map map = new HashMap(); Map mapzc = new HashMap(); Map mapcz = new HashMap(); Map mapsb = new HashMap(); Map mapkh = new HashMap(); Map mappq = new HashMap(); Map mapC = new HashMap(); List> maps = informationService.queryCountB(jurisdiction, deptid); for (int i=0;i> maps1 = informationService.queryCountZc(jurisdiction, deptid); for (int i=0;i> maps2 = informationService.queryCountCz(jurisdiction, deptid); for (int i=0;i> maps3 = informationService.queryCountSb(jurisdiction, deptid); for (int i=0;i> maps4 = informationService.queryCountKh(jurisdiction, deptid); for (int i=0;i> maps5 = informationService.queryCountPq(jurisdiction, deptid); for (int i=0;i mapz = new HashMap(); Map mapzc1= new HashMap(); Map mapcz1= new HashMap(); Map mapsb1= new HashMap(); List> lists = new ArrayList<>(); Map map = informationService.queryYearZ(year,jurisdiction,deptid); map = (HashMap) sortMapBykeyAsc(map) ;//key升序 mapz.put("baoan",map); lists.add(mapz); //正常保安数量 Map mapzc = informationService.queryYearZc(year,jurisdiction,deptid); mapzc = (HashMap) sortMapBykeyAsc(mapzc) ;//key升序 mapzc1.put("zc",mapzc); lists.add(mapzc1); //保安持证数量 Map mapcz = informationService.queryYearZc(year,jurisdiction,deptid); mapcz = (HashMap) sortMapBykeyAsc(mapcz) ;//key升序 mapcz1.put("chiz",mapcz); lists.add(mapcz1); //缴纳社保数 Map mapsb = informationService.queryYearSoil(year,jurisdiction,deptid); mapsb = (HashMap) sortMapBykeyAsc(mapsb) ;//key升序 mapsb1.put("sheb",mapsb); //保安派遣 Map mapde = informationService.queryYearBanan(year, jurisdiction, deptid); mapde = (HashMap) sortMapBykeyAsc(mapde) ;//key升序 mapsb1.put("paiq",mapde); lists.add(mapsb1); return R.data(lists); } /** * 查询本年所有月份的客户数量 * @return */ @GetMapping("/queryYearKh") public R queryYearKh(String jurisdiction,String deptid) { Calendar cal = Calendar.getInstance(); String year = String.valueOf(cal.get(Calendar.YEAR)); Map map = informationService.queryYearKh(year,jurisdiction,deptid); map = (HashMap) sortMapBykeyAsc(map) ;//key升序 return R.data(map); } /** * 查询本年所有月份的保安派遣数量 * @return */ @GetMapping("/queryYearBanan") public R queryYearBanan(String jurisdiction,String deptid) { Calendar cal = Calendar.getInstance(); String year = String.valueOf(cal.get(Calendar.YEAR)); Map map = informationService.queryYearBanan(year,jurisdiction,deptid); map = (HashMap) sortMapBykeyAsc(map) ;//key升序 return R.data(map); } //升序 public static Map sortMapBykeyAsc(Map oriMap) { Map sortedMap = new LinkedHashMap(); try { if (oriMap != null && !oriMap.isEmpty()) { List> entryList = new ArrayList>(oriMap.entrySet()); Collections.sort(entryList, new Comparator>() { public int compare(Map.Entry entry2, Map.Entry entry1) { int value2 = 0, value1 = 0; try { value2 = Integer.parseInt(entry1.getKey()); value1 = Integer.parseInt(entry2.getKey()); } catch (NumberFormatException e) { value2 = 0; value1 = 0; } return value1 - value2; } }); Iterator> iter = entryList.iterator(); Map.Entry tmpEntry = null; while (iter.hasNext()) { tmpEntry = iter.next(); sortedMap.put(tmpEntry.getKey(), tmpEntry.getValue()); } } } catch (Exception e) { } return sortedMap; } /** * 统计保安员资格异常的数量 */ @PostMapping("/selectExtype") public R selectExtype(String jurisdiction,String deptid) { Map map = new HashMap(); Integer count=0; List> lists = new ArrayList<>(); List> maps = informationService.selectExtype(jurisdiction, deptid); for (int i=0;i map = new HashMap(); Integer count=0; List> lists = new ArrayList<>(); List> maps = informationService.selectBx(jurisdiction, deptid); for (int i=0;i> list = informationService.selectJur(); List> lists = new ArrayList<>(); for (int i=0;i map = new HashMap(); //辖区id String jurisdiction = list.get(i).get("id").toString(); //辖区名称 String jurname = list.get(i).get("dept_name").toString(); //保安员表现差预警数量 List> mapbx = informationService.selectBx(jurisdiction, ""); for (int ibx=0;ibx> mapEx = informationService.selectExtype(jurisdiction, ""); for (int iex=0;iex> mapgs = informationService.selectInCount(jurisdiction,""); count+=mapgs.size(); //未缴社保数量 List> mapsb = informationService.selectCs(jurisdiction,""); for (int isb=0;isb map = new HashMap(); List> lists = new ArrayList<>(); Map map1 = informationService.selectPcount(jurisdiction, deptid); String pnum = map1.get("pnum").toString(); Integer a=Integer.valueOf(pnum); Map map2 = informationService.selectWPcount(jurisdiction, deptid); String wpnum = map2.get("wpnum").toString(); Integer b=Integer.valueOf(wpnum); map.put("PCount",a); map.put("WPCount",b); lists.add(map); return R.data(lists); } /** * 单位列表 */ @PostMapping("/selectIn") public R selectIn(String jurisdiction) { List> maps = informationService.selectIn(jurisdiction); return R.data(maps); } }