|
|
|
|
package com.ruoyi.programManagement.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.programManagement.entity.BKeyEnterprise;
|
|
|
|
|
import com.ruoyi.programManagement.entity.BPlanEnterprise;
|
|
|
|
|
import com.ruoyi.programManagement.entity.request.BPlanEnterPriseTreeResponse;
|
|
|
|
|
import com.ruoyi.programManagement.entity.request.BPlanEnterprisePageRequest;
|
|
|
|
|
import com.ruoyi.programManagement.entity.request.PlanMxRequest;
|
|
|
|
|
import com.ruoyi.programManagement.entity.request.checkResultRequest;
|
|
|
|
|
import com.ruoyi.programManagement.entity.response.BPlanEnterpriseZhifaResponse;
|
|
|
|
|
import com.ruoyi.programManagement.mapper.BPlanEnterpriseMapper;
|
|
|
|
|
import com.ruoyi.programManagement.service.BKeyEnterpriseService;
|
|
|
|
|
import com.ruoyi.programManagement.service.BPlanEnterpriseService;
|
|
|
|
|
import com.ruoyi.programManagement.service.IBAdministrativeService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计划企业表(BPlanEnterprise)表控制层
|
|
|
|
|
*
|
|
|
|
|
* @author wu
|
|
|
|
|
* @since 2023-09-07 09:43:06
|
|
|
|
|
*/
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("pharmaceuticals/bPlanEnterprise")
|
|
|
|
|
@Api(tags = "计划企业")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public class BPlanEnterpriseController extends BaseController {
|
|
|
|
|
/**
|
|
|
|
|
* 服务对象
|
|
|
|
|
*/
|
|
|
|
|
@Resource
|
|
|
|
|
private BPlanEnterpriseService bPlanEnterpriseService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计划企业表(BPlanEnterprise)表数据库访问层
|
|
|
|
|
*/
|
|
|
|
|
@Resource
|
|
|
|
|
private BPlanEnterpriseMapper bPlanEnterpriseMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private BKeyEnterpriseService bKeyEnterpriseService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBAdministrativeService bAdministrativeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询计划企业列表
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "查询计划企业列表")
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public AjaxResult list(BPlanEnterprise bPlanEnterprise) {
|
|
|
|
|
List<BPlanEnterprise> list = bPlanEnterpriseService.selectBPlanEnterpriseList(bPlanEnterprise);
|
|
|
|
|
for (BPlanEnterprise a : list) {
|
|
|
|
|
String enterPriseId = String.valueOf(a.getEnterpriseId());
|
|
|
|
|
BKeyEnterprise count = bKeyEnterpriseService.getByentCode(enterPriseId);
|
|
|
|
|
if (count != null) {
|
|
|
|
|
a.setIsPoint(1);
|
|
|
|
|
} else {
|
|
|
|
|
a.setIsPoint(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bPlanEnterpriseService.updateById(a);
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询首页
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "查询首页", response = BPlanEnterPriseTreeResponse.class)
|
|
|
|
|
@GetMapping("/tree")
|
|
|
|
|
public TableDataInfo tree(BPlanEnterprisePageRequest req) {
|
|
|
|
|
|
|
|
|
|
List<BPlanEnterPriseTreeResponse> list = bAdministrativeService.selectBPlanEnterPriseTreeRequestRequestList(req);
|
|
|
|
|
int plannedEnterpriseCountSum = list.stream()
|
|
|
|
|
.mapToInt(BPlanEnterPriseTreeResponse::getPlannedEnterpriseCount)
|
|
|
|
|
.sum();
|
|
|
|
|
int checkEnterpriseCountSum = list.stream()
|
|
|
|
|
.mapToInt(BPlanEnterPriseTreeResponse::getCheckEnterpriseCount)
|
|
|
|
|
.sum();
|
|
|
|
|
double ptSum = (double) checkEnterpriseCountSum / plannedEnterpriseCountSum;
|
|
|
|
|
BPlanEnterPriseTreeResponse resultObject = new BPlanEnterPriseTreeResponse();
|
|
|
|
|
resultObject.setInstitutionName("苏州市");
|
|
|
|
|
resultObject.setPlannedEnterpriseCount(plannedEnterpriseCountSum);
|
|
|
|
|
resultObject.setCheckEnterpriseCount(checkEnterpriseCountSum);
|
|
|
|
|
resultObject.setPt(ptSum);
|
|
|
|
|
list.add(resultObject);
|
|
|
|
|
return getDataTable(list);
|
|
|
|
|
// List<List<BPlanEnterPriseTreeResponse>> groupedList = list.stream()
|
|
|
|
|
// .collect(Collectors.groupingBy(BPlanEnterPriseTreeResponse::getCounty))
|
|
|
|
|
// .values()
|
|
|
|
|
// .stream()
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
// List<BPlanEnterPriseTreeResponse> cascadingSelectData = new ArrayList<>();
|
|
|
|
|
// for (List<BPlanEnterPriseTreeResponse> group : groupedList) {
|
|
|
|
|
// for (BPlanEnterPriseTreeResponse item1 : group) {
|
|
|
|
|
// BPlanEnterPriseTreeResponse parentDto = new BPlanEnterPriseTreeResponse(item1.getCounty(), item1.getSubdistrict());
|
|
|
|
|
// for (BPlanEnterPriseTreeResponse item2 : list) {
|
|
|
|
|
// if (item2.getSubdistrict() != null) {
|
|
|
|
|
// if (item2.getSubdistrict().substring(0, 10).equals(item1.getCounty().substring(0, 10))) {
|
|
|
|
|
// BPlanEnterPriseTreeResponse childDto = new BPlanEnterPriseTreeResponse(item2.getCounty(), item2.getSubdistrict());
|
|
|
|
|
// parentDto.addChild(childDto);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// cascadingSelectData.add(parentDto);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过主键查询单条数据
|
|
|
|
|
*
|
|
|
|
|
* @param id 主键
|
|
|
|
|
* @return 单条数据
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("{id}")
|
|
|
|
|
@ApiOperation(value = "通过主键查询单条计划企业表", response = BPlanEnterprise.class)
|
|
|
|
|
public AjaxResult getById(@PathVariable String id) {
|
|
|
|
|
return success(bPlanEnterpriseService.selectById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增数据
|
|
|
|
|
*
|
|
|
|
|
* @param bPlanEnterprise 实体对象
|
|
|
|
|
* @return 新增结果
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping
|
|
|
|
|
@ApiOperation(value = "新增计划企业表", response = BPlanEnterprise.class)
|
|
|
|
|
public AjaxResult insert(@RequestBody BPlanEnterprise bPlanEnterprise) {
|
|
|
|
|
bPlanEnterprise.setCreateId(getUserId());
|
|
|
|
|
String enterPriseId = String.valueOf(bPlanEnterprise.getEnterpriseId());
|
|
|
|
|
String district = bPlanEnterprise.getDistrict();
|
|
|
|
|
String enterpriseName = bPlanEnterprise.getEnterpriseName();
|
|
|
|
|
String[] idArray = enterPriseId.split(",");
|
|
|
|
|
String[] districtArray = district.split(",");
|
|
|
|
|
String[] enterpriseNameArray = enterpriseName.split(",");
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (String entId : idArray) {
|
|
|
|
|
//根据企业id查询重点企业表是 1:重点企业 ,2:非重点企业
|
|
|
|
|
BKeyEnterprise count = bKeyEnterpriseService.getByentCode(entId);
|
|
|
|
|
if (count != null) {
|
|
|
|
|
bPlanEnterprise.setIsPoint(1);
|
|
|
|
|
}
|
|
|
|
|
bPlanEnterprise.setIsPoint(2);
|
|
|
|
|
bPlanEnterprise.setId(null);
|
|
|
|
|
bPlanEnterprise.setEnterpriseId(entId);
|
|
|
|
|
bPlanEnterprise.setCreateId(getUserId());
|
|
|
|
|
bPlanEnterprise.setDeptId(getDeptId());
|
|
|
|
|
bPlanEnterprise.setDistrict(districtArray[i]);
|
|
|
|
|
bPlanEnterprise.setEnterpriseName(enterpriseNameArray[i]);
|
|
|
|
|
bPlanEnterpriseService.save(bPlanEnterprise);
|
|
|
|
|
i += 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改数据
|
|
|
|
|
*
|
|
|
|
|
* @param bPlanEnterprise 实体对象
|
|
|
|
|
* @return 修改结果
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping
|
|
|
|
|
@ApiOperation(value = "修改计划企业表")
|
|
|
|
|
public AjaxResult update(@RequestBody BPlanEnterprise bPlanEnterprise) {
|
|
|
|
|
bPlanEnterprise.setUpdateId(getDeptId());
|
|
|
|
|
return success(bPlanEnterpriseService.updateById(bPlanEnterprise));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除数据
|
|
|
|
|
*
|
|
|
|
|
* @param idList 主键集合
|
|
|
|
|
* @return 删除结果
|
|
|
|
|
*/
|
|
|
|
|
@DeleteMapping
|
|
|
|
|
@ApiOperation(value = "删除计划企业表")
|
|
|
|
|
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
|
|
|
|
return success(bPlanEnterpriseService.removeByIds(idList));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 执法结果-企业详情
|
|
|
|
|
*
|
|
|
|
|
* @param req 请求类
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("/getZhifa")
|
|
|
|
|
@ApiOperation(value = "执法结果-企业详情")
|
|
|
|
|
public TableDataInfo getZhifa(@Valid checkResultRequest req) {
|
|
|
|
|
startPage();
|
|
|
|
|
return getDataTable(bPlanEnterpriseService.getZhifa(req));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出执法结果
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "导出执法结果")
|
|
|
|
|
@PostMapping("/export")
|
|
|
|
|
public void export(HttpServletResponse response, checkResultRequest req) {
|
|
|
|
|
List<BPlanEnterpriseZhifaResponse> list = bPlanEnterpriseMapper.getZhifa(req);
|
|
|
|
|
for (BPlanEnterpriseZhifaResponse a : list) {
|
|
|
|
|
String district = a.getDistrict();
|
|
|
|
|
String countyList = bAdministrativeService.getBydistinct(district);
|
|
|
|
|
a.setDistrict(countyList);
|
|
|
|
|
}
|
|
|
|
|
ExcelUtil<BPlanEnterpriseZhifaResponse> util = new ExcelUtil<BPlanEnterpriseZhifaResponse>(BPlanEnterpriseZhifaResponse.class);
|
|
|
|
|
util.exportExcel(response, list, "导出执法结果");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出计划管理
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "导出计划管理")
|
|
|
|
|
@PostMapping("/exportplan")
|
|
|
|
|
public void exportplan(HttpServletResponse response, BPlanEnterprise bPlanEnterprise) {
|
|
|
|
|
List<BPlanEnterprise> list = bPlanEnterpriseService.selectBPlanEnterpriseList(bPlanEnterprise);
|
|
|
|
|
for (BPlanEnterprise a : list) {
|
|
|
|
|
String district = a.getDistrict();
|
|
|
|
|
String countyList = bAdministrativeService.getBydistinct(district);
|
|
|
|
|
a.setDistrict(countyList);
|
|
|
|
|
}
|
|
|
|
|
ExcelUtil<BPlanEnterprise> util = new ExcelUtil<BPlanEnterprise>(BPlanEnterprise.class);
|
|
|
|
|
util.exportExcel(response, list, "计划管理数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查看计划明细
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "查看计划明细")
|
|
|
|
|
@PostMapping("/planmx")
|
|
|
|
|
public AjaxResult planmx(PlanMxRequest req) {
|
|
|
|
|
|
|
|
|
|
return AjaxResult.success(bPlanEnterpriseService.getPlanMx(req));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|