Commit 77dea08c authored by litengwei's avatar litengwei

安装告知代码优化

parent 1990e510
...@@ -31,7 +31,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot ...@@ -31,7 +31,7 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param noticeDto 安装告知 * @param noticeDto 安装告知
* @param op 操作类型 * @param op 操作类型
*/ */
JgInstallationNoticeDto updateInstallationNotice(JgInstallationNoticeDto noticeDto, String op); JgInstallationNoticeDto updateInstallationNotice(String submitType, JgInstallationNoticeDto noticeDto, String op);
/** /**
* 分页查询 * 分页查询
......
...@@ -19,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper; ...@@ -19,6 +19,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
...@@ -59,12 +60,16 @@ public class JgInstallationNoticeController extends BaseController { ...@@ -59,12 +60,16 @@ public class JgInstallationNoticeController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/update") @PutMapping(value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新安装告知", notes = "根据sequenceNbr更新安装告知") @ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新安装告知", notes = "根据sequenceNbr更新安装告知")
public ResponseModel<JgInstallationNoticeDto> updateBySequenceNbrJgInstallationNotice(@RequestBody Map<String, Object> model, @RequestParam("op") String op) { public ResponseModel<JgInstallationNoticeDto> updateBySequenceNbrJgInstallationNotice(@RequestParam String submitType, @RequestBody Map<String, Object> model, @RequestParam(value = "op", required = false) String op) {
JgInstallationNoticeDto installationInfo = BeanUtil.mapToBean(((LinkedHashMap) model.get("installationInfo")), JgInstallationNoticeDto.class, true); JgInstallationNoticeDto installationInfo = BeanUtil.mapToBean(((LinkedHashMap) model.get("installationInfo")), JgInstallationNoticeDto.class, true);
if (Objects.isNull(installationInfo)) { if (Objects.isNull(installationInfo)) {
throw new IllegalArgumentException("参数installationInfo不能为空"); throw new IllegalArgumentException("参数installationInfo不能为空");
} }
return ResponseHelper.buildResponse(iJgInstallationNoticeService.updateInstallationNotice(installationInfo, op)); Object o = ((LinkedHashMap<?, ?>) model.get("installationInfo")).get("proxyStatementAttachment");
Object o1 = ((LinkedHashMap<?, ?>) model.get("installationInfo")).get("installContractAttachment");
installationInfo.setProxyStatementAttachmentList((List<Map<String, Object>>) o);
installationInfo.setInstallContractAttachmentList((List<Map<String, Object>>) o1);
return ResponseHelper.buildResponse(iJgInstallationNoticeService.updateInstallationNotice(submitType,installationInfo, op));
} }
/** /**
......
...@@ -44,6 +44,7 @@ import org.springframework.util.Assert; ...@@ -44,6 +44,7 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.io.File; import java.io.File;
...@@ -134,7 +135,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -134,7 +135,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
installationInfo.put("county", notice.getCounty() + "_" + notice.getCountyName()); installationInfo.put("county", notice.getCounty() + "_" + notice.getCountyName());
installationInfo.put("useUnitCreditCode", notice.getUseUnitCreditCode() + "_" + notice.getUseUnitName()); installationInfo.put("useUnitCreditCode", notice.getUseUnitCreditCode() + "_" + notice.getUseUnitName());
installationInfo.put("receiveOrgCreditCode", notice.getReceiveOrgCreditCode() + "_" + notice.getReceiveOrgName()); installationInfo.put("receiveOrgCreditCode", notice.getReceiveOrgCreditCode() + "_" + notice.getReceiveOrgName());
installationInfo.put("inspectUnitId", notice.getInspectUnitId() + "_" + notice.getInspectUnitName()); if(!ValidationUtil.isEmpty(notice.getInspectUnitId()) && ValidationUtil.isEmpty(notice.getInspectUnitName())) {
installationInfo.put("inspectUnitId", notice.getInspectUnitId() + "_" + notice.getInspectUnitName());
}
String[] fields = {"productPhoto", "designDoc", "designStandard", "factoryStandard", String[] fields = {"productPhoto", "designDoc", "designStandard", "factoryStandard",
"productQualityYieldProve", "insUseMaintainExplain", "inspectReport", "productQualityYieldProve", "insUseMaintainExplain", "inspectReport",
...@@ -164,52 +167,57 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -164,52 +167,57 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
* @param noticeDto 安装告知 * @param noticeDto 安装告知
*/ */
@SuppressWarnings({"rawtypes", "Duplicates"}) @SuppressWarnings({"rawtypes", "Duplicates"})
public JgInstallationNoticeDto updateInstallationNotice(JgInstallationNoticeDto noticeDto, String op) { public JgInstallationNoticeDto updateInstallationNotice(String submitType, JgInstallationNoticeDto noticeDto, String op) {
if (Objects.isNull(noticeDto) || StringUtils.isEmpty(op)) { if (Objects.isNull(noticeDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空"); throw new IllegalArgumentException("参数不能为空");
} }
// 字段转换 // 字段转换
this.convertField(noticeDto); this.convertField(noticeDto);
AjaxResult ajaxResult; if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程 AjaxResult ajaxResult;
if (!StringUtils.hasText(noticeDto.getInstanceId())) { // 发起流程
ActWorkflowStartDTO dto = new ActWorkflowStartDTO(); if (!StringUtils.hasText(noticeDto.getInstanceId())) {
dto.setProcessDefinitionKey("installationNotification"); ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setBusinessKey("1"); dto.setProcessDefinitionKey("installationNotification");
dto.setBusinessKey("1");
try {
ajaxResult = Workflow.taskClient.startByVariable(dto);
} catch (Exception e) {
log.error("提交失败:{}", e);
}
}
ajaxResult = Workflow.taskClient.getTask(noticeDto.getInstanceId());
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO taskResultDTO = new TaskResultDTO();
taskResultDTO.setResultCode("approvalStatus");
taskResultDTO.setTaskId(taskId);
taskResultDTO.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", op);
taskResultDTO.setVariable(map);
//执行流程
AjaxResult ajaxResult1;
try { try {
ajaxResult = Workflow.taskClient.startByVariable(dto); ajaxResult1 = Workflow.taskClient.completeByTask(taskId, taskResultDTO);
if (ajaxResult1.get("code").equals(200)) {
noticeDto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
JgInstallationNotice bean = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto, bean);
jgInstallationNoticeMapper.updateById(bean);
}
} catch (Exception e) { } catch (Exception e) {
log.error("提交失败:{}", e); log.error("提交失败:{}", e);
} }
} else {
JgInstallationNotice bean = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto, bean);
jgInstallationNoticeMapper.updateById(bean);
} }
ajaxResult = Workflow.taskClient.getTask(noticeDto.getInstanceId());
JSONObject dataObject = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")));
String taskId = dataObject.getString("id");
//组装信息
TaskResultDTO taskResultDTO = new TaskResultDTO();
taskResultDTO.setResultCode("approvalStatus");
taskResultDTO.setTaskId(taskId);
taskResultDTO.setComment("提交流程");
HashMap<String, Object> map = new HashMap<>();
map.put("approvalStatus", op);
taskResultDTO.setVariable(map);
//执行流程
AjaxResult ajaxResult1;
try {
ajaxResult1 = Workflow.taskClient.completeByTask(taskId, taskResultDTO);
if (ajaxResult1.get("code").equals(200)) {
noticeDto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
JgInstallationNotice bean = new JgInstallationNotice();
BeanUtils.copyProperties(noticeDto, bean);
jgInstallationNoticeMapper.updateById(bean);
}
} catch (Exception e) {
log.error("提交失败:{}", e);
}
return noticeDto; return noticeDto;
} }
...@@ -477,8 +485,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -477,8 +485,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private void convertField(JgInstallationNoticeDto model) { private void convertField(JgInstallationNoticeDto model) {
// 处理图片 // 处理图片
model.setProxyStatementAttachment(JSON.toJSONString(model.getProxyStatementAttachmentList())); if(!ValidationUtil.isEmpty(model.getProxyStatementAttachmentList())) {
model.setInstallContractAttachment(JSON.toJSONString(model.getInstallContractAttachmentList())); model.setProxyStatementAttachment(JSON.toJSONString(model.getProxyStatementAttachmentList()));
}
if(!ValidationUtil.isEmpty(model.getInstallContractAttachmentList())) {
model.setInstallContractAttachment(JSON.toJSONString(model.getInstallContractAttachmentList()));
}
// 分割省市区字段 // 分割省市区字段
String province = model.getProvince(); String province = model.getProvince();
......
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