|
@@ -1,128 +0,0 @@
|
|
|
-package com.sooka.sponest.mobile.data.housingconstruction;
|
|
|
-
|
|
|
-import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
-import com.ruoyi.common.core.utils.StringUtils;
|
|
|
-import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
-import com.ruoyi.common.core.web.page.PageDomain;
|
|
|
-import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
|
-import com.ruoyi.common.core.web.page.TableSupport;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.domain.HousingconstructionAttach;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.domain.HousingconstructionSafetyinspectionitem;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.domain.HousingconstructionSafetyinspectionrecords;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.domain.HousingconstructionSafetyinspectionrecordsdetail;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.service.RemoteHousingconstructionSafetyinspectionitemService;
|
|
|
-import com.sooka.sponest.data.api.housingconstruction.service.RemoteHousingconstructionSafetyinspectionrecordsService;
|
|
|
-import com.sooka.sponest.mobile.remoteapi.RemoteSystemBaseService;
|
|
|
-import org.apache.commons.collections4.MapUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
-@RestController
|
|
|
-@RequestMapping("AppHousingconstructionSafetyinspectionrecordsController")
|
|
|
-public class HousingconstructionSafetyinspectionrecordsController {
|
|
|
-
|
|
|
- @Resource
|
|
|
- RemoteHousingconstructionSafetyinspectionrecordsService safetyinspectionrecordsService;
|
|
|
-
|
|
|
- @Resource
|
|
|
- RemoteHousingconstructionSafetyinspectionitemService housingconstructionSafetyinspectionitemService;
|
|
|
-
|
|
|
- @GetMapping("/safetyinspectionrecords/list")
|
|
|
- public AjaxResult getList(HousingconstructionSafetyinspectionrecords records) {
|
|
|
- PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
|
- Integer pageNum = pageDomain.getPageNum();
|
|
|
- Integer pageSize = pageDomain.getPageSize();
|
|
|
- TableDataInfo resultData = safetyinspectionrecordsService.getList(pageNum, pageSize, records.getEnterpriseInspectionType());
|
|
|
-
|
|
|
- if (200 == resultData.getCode()) {
|
|
|
- return AjaxResult.success(resultData.getRows());
|
|
|
- } else {
|
|
|
- return AjaxResult.error(resultData.getCode(), resultData.getMsg());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @GetMapping("/safetyinspectionrecords/edit")
|
|
|
- public AjaxResult getRecordDetailById(HousingconstructionSafetyinspectionrecords recordVO) {
|
|
|
- if (StringUtils.isEmpty(recordVO.getId())) {
|
|
|
- return getTemplate(recordVO.getEnterpriseInspectionType());
|
|
|
- } else {
|
|
|
- AjaxResult recordDetailById = safetyinspectionrecordsService.getRecordDetailById(recordVO.getId());
|
|
|
- Map<String, Object> record = (Map<String, Object>) recordDetailById.get("data");
|
|
|
- String oldIp = SpringUtils.getBean(RemoteSystemBaseService.class).selectConfigKey("fileUrl").getData();
|
|
|
- String newIp = SpringUtils.getBean(RemoteSystemBaseService.class).selectConfigKey("appUrl").getData();
|
|
|
-
|
|
|
- List<Map<String, Object>> detailList = (List<Map<String, Object>>) record.get("detailList");
|
|
|
- for (Map<String, Object> detail : detailList) {
|
|
|
- List<Map<String, Object>> attachList = (List<Map<String, Object>>) detail.get("attachList");
|
|
|
- for (Map<String, Object> attach : attachList) {
|
|
|
- String string = MapUtils.getString(attach, "attachPath");
|
|
|
- attach.put("realUrl",string.replaceAll(oldIp, newIp));
|
|
|
- }
|
|
|
- }
|
|
|
- return AjaxResult.success(record);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/safetyinspectionrecords")
|
|
|
- public AjaxResult addSafetyinspectionrecords(@RequestBody HousingconstructionSafetyinspectionrecords record) {
|
|
|
- List<HousingconstructionSafetyinspectionrecordsdetail> detailList = record.getDetailList();
|
|
|
- detailList.forEach(detail->{
|
|
|
- List<HousingconstructionAttach> attachList = detail.getAttachList();
|
|
|
- for (int i = 0; i < attachList.size(); i++) {
|
|
|
- HousingconstructionAttach attach = attachList.get(i);
|
|
|
- attach.setAttachPath(attach.getRealUrl());
|
|
|
- attach.setAttachSorts(Long.parseLong(String.valueOf(i)));
|
|
|
- }
|
|
|
- });
|
|
|
- return safetyinspectionrecordsService.addSafetyinspectionrecords(record);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping("/safetyinspectionrecords/put")
|
|
|
- public AjaxResult putSafetyinspectionrecords(@RequestBody HousingconstructionSafetyinspectionrecords record) {
|
|
|
- List<HousingconstructionSafetyinspectionrecordsdetail> detailList = record.getDetailList();
|
|
|
- detailList.forEach(detail->{
|
|
|
- List<HousingconstructionAttach> attachList = detail.getAttachList();
|
|
|
- for (int i = 0; i < attachList.size(); i++) {
|
|
|
- HousingconstructionAttach attach = attachList.get(i);
|
|
|
- attach.setBusId(detail.getId());
|
|
|
- attach.setAttachPath(attach.getRealUrl());
|
|
|
- attach.setAttachSorts(Long.parseLong(String.valueOf(i)));
|
|
|
- }
|
|
|
- });
|
|
|
- return safetyinspectionrecordsService.putSafetyinspectionrecords(record);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public AjaxResult getTemplate(String enterpriseInspectionType) {
|
|
|
- // 获取列表数据
|
|
|
- AjaxResult listResult = housingconstructionSafetyinspectionitemService.getList(enterpriseInspectionType);
|
|
|
-
|
|
|
- // 从 AjaxResult 中提取数据
|
|
|
- List<Map<String, Object>> data = (List<Map<String, Object>>) listResult.get("data");
|
|
|
- if (data == null) {
|
|
|
- return AjaxResult.error("No data found");
|
|
|
- }
|
|
|
-
|
|
|
- // 将数据转换为详细记录列表
|
|
|
- List<HousingconstructionSafetyinspectionrecordsdetail> detailList = new ArrayList<>();
|
|
|
- for (Map<String, Object> item : data) {
|
|
|
- try {
|
|
|
- String id = MapUtils.getString(item, "id");
|
|
|
- String inspectionName = MapUtils.getString(item, "inspectionName");
|
|
|
- int inspectionSort = MapUtils.getInteger(item, "inspectionSort");
|
|
|
- HousingconstructionSafetyinspectionrecordsdetail detail = new HousingconstructionSafetyinspectionrecordsdetail(id, inspectionName, inspectionSort, "0", "", new ArrayList<>());
|
|
|
- detailList.add(detail);
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- // 处理解析整数失败的情况
|
|
|
- return AjaxResult.error("Invalid data format");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 创建并返回结果数据
|
|
|
- HousingconstructionSafetyinspectionrecords resultData = new HousingconstructionSafetyinspectionrecords();
|
|
|
- resultData.setDetailList(detailList);
|
|
|
- return AjaxResult.success(resultData);
|
|
|
- }
|
|
|
-}
|