Commit e8e0d019 authored by suhuiguang's avatar suhuiguang

refactor(大编辑):代码重构

1.安装告知详情接口增加返回公司类型,用来区分是监管还是企业 2.发起单位编辑单据时,去掉校验附件及变更说明校验
parent 5a574e05
package com.yeejoin.amos.boot.module.jg.api.dto; package com.yeejoin.amos.boot.module.jg.api.dto;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -26,10 +28,13 @@ public class RequestChangeData extends JSONObject { ...@@ -26,10 +28,13 @@ public class RequestChangeData extends JSONObject {
*/ */
public static final String changeReasonAttachmentKey = "changeAttachment"; public static final String changeReasonAttachmentKey = "changeAttachment";
public void validated() { public void validated(ReginParams reginParams) {
// 监管单位编辑需要上传变更说明
if (!reginParams.getCompany().getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
if (!this.containsKey(changeReasonKey) || !this.containsKey(changeReasonAttachmentKey)) { if (!this.containsKey(changeReasonKey) || !this.containsKey(changeReasonAttachmentKey)) {
throw new BadRequest("变更说明和变更说明附件不能为空!"); throw new BadRequest("变更说明和变更说明附件不能为空!");
} }
} }
}
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ package com.yeejoin.amos.boot.module.jg.api.service; ...@@ -4,6 +4,7 @@ package com.yeejoin.amos.boot.module.jg.api.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
...@@ -26,7 +27,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot ...@@ -26,7 +27,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param sequenceNbr 主键 * @param sequenceNbr 主键
* @return 安装告知 * @return 安装告知
*/ */
Map<String, Map<String, Object>> queryBySequenceNbr(Long sequenceNbr, String companyLevel); Map<String, Map<String, Object>> queryBySequenceNbr(Long sequenceNbr, CompanyBo company);
/** /**
* 更新安装告知 * 更新安装告知
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.controller; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.api.dto.RequestChangeData; import com.yeejoin.amos.boot.module.jg.api.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.edit.BizDataChangeServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.edit.BizDataChangeServiceImpl;
...@@ -79,9 +80,11 @@ public class BizDataChangeController extends BaseController { ...@@ -79,9 +80,11 @@ public class BizDataChangeController extends BaseController {
@ApiParam(required = true, value = "业务类型") @PathVariable String bizType, @ApiParam(required = true, value = "业务类型") @PathVariable String bizType,
@ApiParam(required = true, value = "设备处理器类型") @RequestParam IBizDataChangeHandleStrategy.ModelType modelType, @ApiParam(required = true, value = "设备处理器类型") @RequestParam IBizDataChangeHandleStrategy.ModelType modelType,
@RequestBody RequestChangeData changeData) { @RequestBody RequestChangeData changeData) {
ReginParams reginParams = getSelectedOrgInfo();
// 基础数据校验 // 基础数据校验
changeData.validated(); changeData.validated(reginParams);
bizDataChangeService.save(bizId, applyNo, bizType, modelType, changeData, getSelectedOrgInfo()); bizDataChangeService.save(bizId, applyNo, bizType, modelType, changeData, reginParams);
return ResponseHelper.buildResponse("success"); return ResponseHelper.buildResponse("success");
} }
......
...@@ -112,8 +112,7 @@ public class JgInstallationNoticeController extends BaseController { ...@@ -112,8 +112,7 @@ public class JgInstallationNoticeController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个安装告知", notes = "根据sequenceNbr查询单个安装告知") @ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个安装告知", notes = "根据sequenceNbr查询单个安装告知")
public ResponseModel<Map<String, public ResponseModel<Map<String,
Map<String, Object>>> selectOne(@RequestParam("sequenceNbr") Long sequenceNbr) { Map<String, Object>>> selectOne(@RequestParam("sequenceNbr") Long sequenceNbr) {
String companyLevel = (String) iJgInstallationNoticeService.getCompanyType().get("companyLevel"); return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryBySequenceNbr(sequenceNbr, getSelectedOrgInfo().getCompany()));
return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryBySequenceNbr(sequenceNbr, companyLevel));
} }
......
...@@ -6,9 +6,8 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams; ...@@ -6,9 +6,8 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.RequestChangeData; import com.yeejoin.amos.boot.module.jg.api.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.context.BizDataHandleStrategyContext; import com.yeejoin.amos.boot.module.jg.biz.context.BizDataHandleStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.controller.BizDataChangeController; import com.yeejoin.amos.boot.module.jg.biz.controller.BizDataChangeController;
import com.yeejoin.amos.boot.module.jg.biz.edit.decorator.CompanyDecorator;
import com.yeejoin.amos.boot.module.jg.biz.edit.decorator.PlainDecorator;
import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.biz.edit.process.biz.strategy.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.FillingEditPermForCurrentUser;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -44,8 +43,7 @@ public class BizDataChangeServiceImpl { ...@@ -44,8 +43,7 @@ public class BizDataChangeServiceImpl {
public Map<String, Object> querySubDetail(String applyNo, String bizId, String bizType, BizDataChangeController.DetailType type, ReginParams selectedOrgInfo) { public Map<String, Object> querySubDetail(String applyNo, String bizId, String bizType, BizDataChangeController.DetailType type, ReginParams selectedOrgInfo) {
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType); IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
// 装饰器模式增强结果 // 装饰器模式增强结果
CompanyDecorator companyDecorator = new CompanyDecorator(new PlainDecorator<>(), selectedOrgInfo); return new FillingEditPermForCurrentUser(new JSONObject(handleStrategy.getSubDetail(applyNo, bizId, type)), selectedOrgInfo.getCompany()).getData();
return companyDecorator.process(handleStrategy.getSubDetail(applyNo, bizId, type));
} }
public IPage<?> getChangeLogPage(String bizId, String bizType, int current, int size) { public IPage<?> getChangeLogPage(String bizId, String bizType, int current, int size) {
......
...@@ -3059,4 +3059,12 @@ public class CommonServiceImpl implements ICommonService { ...@@ -3059,4 +3059,12 @@ public class CommonServiceImpl implements ICommonService {
return commonMapper.queryUnitInfoByCreditCode(unitCreditCode); return commonMapper.queryUnitInfoByCreditCode(unitCreditCode);
} }
public static String getCompanyType(CompanyBo companyBo){
if (companyBo.getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
return BaseController.COMPANY_TYPE_COMPANY;
} else {
return BaseController.COMPANY_TYPE_SUPERVISION;
}
}
} }
\ No newline at end of file
...@@ -214,7 +214,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -214,7 +214,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@ResultFieldMapping.ResultFieldMap(sourceField = "installationInfo.useUnitCreditCode", targetField = "installationInfo.useUnitSeq", serviceClass = CommonServiceImpl.class, queryMethod = "queryUnitInfoByCreditCode"), @ResultFieldMapping.ResultFieldMap(sourceField = "installationInfo.useUnitCreditCode", targetField = "installationInfo.useUnitSeq", serviceClass = CommonServiceImpl.class, queryMethod = "queryUnitInfoByCreditCode"),
@ResultFieldMapping.ResultFieldMap(sourceField = "installationInfo.propertyUnitName", targetField = "installationInfo.propertyUnitSeq", serviceClass = CommonServiceImpl.class, queryMethod = "queryUnitInfoByCreditCode") @ResultFieldMapping.ResultFieldMap(sourceField = "installationInfo.propertyUnitName", targetField = "installationInfo.propertyUnitSeq", serviceClass = CommonServiceImpl.class, queryMethod = "queryUnitInfoByCreditCode")
}) })
public Map<String, Map<String, Object>> queryBySequenceNbr(Long sequenceNbr, String companyLevel) { public Map<String, Map<String, Object>> queryBySequenceNbr(Long sequenceNbr, CompanyBo company) {
// 安装告知信息 // 安装告知信息
JgInstallationNotice notice = jgInstallationNoticeMapper.selectById(sequenceNbr); JgInstallationNotice notice = jgInstallationNoticeMapper.selectById(sequenceNbr);
if (Objects.isNull(notice)) { if (Objects.isNull(notice)) {
...@@ -305,6 +305,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -305,6 +305,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
installationInfo.put(s, ObjectUtils.isEmpty(installationInfo.get(s)) ? null : JSON.parseObject(installationInfo.get(s).toString())); installationInfo.put(s, ObjectUtils.isEmpty(installationInfo.get(s)) ? null : JSON.parseObject(installationInfo.get(s).toString()));
} }
} }
String companyLevel = CommonServiceImpl.getCompanyType(company);
if (Integer.parseInt(notice.getNoticeStatus()) >= FlowStatusEnum.TO_BE_FINISHED.getCode()) { if (Integer.parseInt(notice.getNoticeStatus()) >= FlowStatusEnum.TO_BE_FINISHED.getCode()) {
// 完成及作废时显示历史数据 // 完成及作废时显示历史数据
JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr()); JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr());
...@@ -313,6 +314,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -313,6 +314,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// todo companyLevel赋值这个不能少,控制前端页面的字段(安装负责人)显示隐藏 // todo companyLevel赋值这个不能少,控制前端页面的字段(安装负责人)显示隐藏
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo); Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
this.fillingEquCategoryNameForHisData(detail, notice); this.fillingEquCategoryNameForHisData(detail, notice);
new FillingEditPermForCurrentUser(new JSONObject(detail), company).getData();;
return new HashMap<String, Map<String, Object>>() {{ return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", detail); this.put("installationInfo", detail);
}}; }};
...@@ -320,6 +322,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -320,6 +322,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
hisData.putAll(installationInfo); hisData.putAll(installationInfo);
CommonServiceImpl.formatTime2StrDateForEquip(hisData); CommonServiceImpl.formatTime2StrDateForEquip(hisData);
this.fillingEquCategoryNameForHisData(hisData, notice); this.fillingEquCategoryNameForHisData(hisData, notice);
new FillingEditPermForCurrentUser(hisData, company).getData();
// todo 这个不能少 控制前端页面的字段(安装负责人)显示隐藏 // todo 这个不能少 控制前端页面的字段(安装负责人)显示隐藏
hisData.put("companyLevel", companyLevel); hisData.put("companyLevel", companyLevel);
return new HashMap<String, Map<String, Object>>() {{ return new HashMap<String, Map<String, Object>>() {{
...@@ -332,6 +335,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -332,6 +335,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo); Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
detail.put("startLatitudeLongitude", JSON.parseObject(notice.getStartLatitudeLongitude())); detail.put("startLatitudeLongitude", JSON.parseObject(notice.getStartLatitudeLongitude()));
detail.put("endLatitudeLongitude", JSON.parseObject(notice.getEndLatitudeLongitude())); detail.put("endLatitudeLongitude", JSON.parseObject(notice.getEndLatitudeLongitude()));
new FillingEditPermForCurrentUser(new JSONObject(detail), company).getData();
return new HashMap<String, Map<String, Object>>() {{ return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", detail); this.put("installationInfo", detail);
}}; }};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment