Commit e8e0d019 authored by suhuiguang's avatar suhuiguang

refactor(大编辑):代码重构

1.安装告知详情接口增加返回公司类型,用来区分是监管还是企业 2.发起单位编辑单据时,去掉校验附件及变更说明校验
parent 5a574e05
package com.yeejoin.amos.boot.module.jg.api.dto;
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;
......@@ -26,10 +28,13 @@ public class RequestChangeData extends JSONObject {
*/
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)) {
throw new BadRequest("变更说明和变更说明附件不能为空!");
}
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ package com.yeejoin.amos.boot.module.jg.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
......@@ -26,7 +27,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param sequenceNbr 主键
* @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;
import com.alibaba.fastjson.JSONObject;
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.module.jg.api.dto.RequestChangeData;
import com.yeejoin.amos.boot.module.jg.biz.edit.BizDataChangeServiceImpl;
......@@ -79,9 +80,11 @@ public class BizDataChangeController extends BaseController {
@ApiParam(required = true, value = "业务类型") @PathVariable String bizType,
@ApiParam(required = true, value = "设备处理器类型") @RequestParam IBizDataChangeHandleStrategy.ModelType modelType,
@RequestBody RequestChangeData changeData) {
ReginParams reginParams = getSelectedOrgInfo();
// 基础数据校验
changeData.validated();
bizDataChangeService.save(bizId, applyNo, bizType, modelType, changeData, getSelectedOrgInfo());
changeData.validated(reginParams);
bizDataChangeService.save(bizId, applyNo, bizType, modelType, changeData, reginParams);
return ResponseHelper.buildResponse("success");
}
......
......@@ -112,8 +112,7 @@ public class JgInstallationNoticeController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个安装告知", notes = "根据sequenceNbr查询单个安装告知")
public ResponseModel<Map<String,
Map<String, Object>>> selectOne(@RequestParam("sequenceNbr") Long sequenceNbr) {
String companyLevel = (String) iJgInstallationNoticeService.getCompanyType().get("companyLevel");
return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryBySequenceNbr(sequenceNbr, companyLevel));
return ResponseHelper.buildResponse(iJgInstallationNoticeService.queryBySequenceNbr(sequenceNbr, getSelectedOrgInfo().getCompany()));
}
......
......@@ -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.biz.context.BizDataHandleStrategyContext;
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.service.impl.FillingEditPermForCurrentUser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -44,8 +43,7 @@ public class BizDataChangeServiceImpl {
public Map<String, Object> querySubDetail(String applyNo, String bizId, String bizType, BizDataChangeController.DetailType type, ReginParams selectedOrgInfo) {
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
// 装饰器模式增强结果
CompanyDecorator companyDecorator = new CompanyDecorator(new PlainDecorator<>(), selectedOrgInfo);
return companyDecorator.process(handleStrategy.getSubDetail(applyNo, bizId, type));
return new FillingEditPermForCurrentUser(new JSONObject(handleStrategy.getSubDetail(applyNo, bizId, type)), selectedOrgInfo.getCompany()).getData();
}
public IPage<?> getChangeLogPage(String bizId, String bizType, int current, int size) {
......
......@@ -3059,4 +3059,12 @@ public class CommonServiceImpl implements ICommonService {
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
@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")
})
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);
if (Objects.isNull(notice)) {
......@@ -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()));
}
}
String companyLevel = CommonServiceImpl.getCompanyType(company);
if (Integer.parseInt(notice.getNoticeStatus()) >= FlowStatusEnum.TO_BE_FINISHED.getCode()) {
// 完成及作废时显示历史数据
JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr());
......@@ -313,6 +314,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// todo companyLevel赋值这个不能少,控制前端页面的字段(安装负责人)显示隐藏
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
this.fillingEquCategoryNameForHisData(detail, notice);
new FillingEditPermForCurrentUser(new JSONObject(detail), company).getData();;
return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", detail);
}};
......@@ -320,6 +322,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
hisData.putAll(installationInfo);
CommonServiceImpl.formatTime2StrDateForEquip(hisData);
this.fillingEquCategoryNameForHisData(hisData, notice);
new FillingEditPermForCurrentUser(hisData, company).getData();
// todo 这个不能少 控制前端页面的字段(安装负责人)显示隐藏
hisData.put("companyLevel", companyLevel);
return new HashMap<String, Map<String, Object>>() {{
......@@ -332,6 +335,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
detail.put("startLatitudeLongitude", JSON.parseObject(notice.getStartLatitudeLongitude()));
detail.put("endLatitudeLongitude", JSON.parseObject(notice.getEndLatitudeLongitude()));
new FillingEditPermForCurrentUser(new JSONObject(detail), company).getData();
return new HashMap<String, Map<String, Object>>() {{
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