Commit 2bb54d36 authored by xixinzhao's avatar xixinzhao

告知单修改

parent a1047513
...@@ -23,6 +23,11 @@ ...@@ -23,6 +23,11 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-tcm-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-common-api</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
......
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jg.api.service; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.jg.api.service;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import java.util.Map;
/** /**
* 接口类 * 接口类
* *
...@@ -13,7 +15,8 @@ public interface IJgInstallationNoticeService { ...@@ -13,7 +15,8 @@ public interface IJgInstallationNoticeService {
/** /**
* 保存安装告知单 * 保存安装告知单
* @param model * @param model 数据
* @param submitType 保存类型
*/ */
void saveNotice(JgInstallationNoticeDto model); void saveNotice(String submitType, Map<String, JgInstallationNoticeDto> model);
} }
package com.yeejoin.amos.boot.module.jg.biz.controller; package com.yeejoin.amos.boot.module.jg.biz.controller;
import cn.hutool.core.bean.BeanUtil; import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import org.omg.PortableInterceptor.SUCCESSFUL;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.JgInstallationNoticeDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
...@@ -19,6 +24,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -19,6 +24,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -41,12 +47,12 @@ public class JgInstallationNoticeController extends BaseController { ...@@ -41,12 +47,12 @@ public class JgInstallationNoticeController extends BaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save") @PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增安装告知", notes = "新增安装告知") @ApiOperation(httpMethod = "POST", value = "新增安装告知", notes = "新增安装告知")
public ResponseModel<JgInstallationNoticeDto> save(@RequestBody JgInstallationNoticeDto model) { public ResponseModel<String> save(@RequestParam String submitType,@RequestBody Map<String, JgInstallationNoticeDto> model) {
jgInstallationNoticeServiceImpl.saveNotice(model); jgInstallationNoticeServiceImpl.saveNotice(submitType, model);
return ResponseHelper.buildResponse(model); return ResponseHelper.buildResponse("");
} }
/** /**
* 根据sequenceNbr更新 * 根据sequenceNbr更新
......
...@@ -9,12 +9,19 @@ import com.yeejoin.amos.boot.module.jg.api.enums.FlowStatusEnum; ...@@ -9,12 +9,19 @@ import com.yeejoin.amos.boot.module.jg.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgRelationEquipMapper; import com.yeejoin.amos.boot.module.jg.api.mapper.JgRelationEquipMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.tcm.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.tcm.api.service.ICreateCodeService;
import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.feign.workflow.Workflow; import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO; import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult; import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -33,63 +40,18 @@ import java.util.stream.Collectors; ...@@ -33,63 +40,18 @@ import java.util.stream.Collectors;
@Service @Service
public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationNoticeDto, JgInstallationNotice, JgInstallationNoticeMapper> implements IJgInstallationNoticeService { public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationNoticeDto, JgInstallationNotice, JgInstallationNoticeMapper> implements IJgInstallationNoticeService {
@Autowired public static final String SUBMIT_TYPE_FLOW = "1";
JgRelationEquipMapper jgRelationEquipMapper; public static final String PROCESS_DEFINITION_KEY = "installationNotification";
@Autowired public static final String TABLE_PAGE_ID = "1734141426742095873";
private JgInstallationNoticeMapper jgInstallationNoticeMapper;
@Autowired
private ICommonService commonService;
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return 安装告知
*/
public Map<String, Map<String, Object>> queryBySequenceNbr(Long sequenceNbr) {
// 安装告知信息
JgInstallationNotice notice = jgInstallationNoticeMapper.selectById(sequenceNbr);
Map<String, Object> installationInfo = BeanUtil.beanToMap(notice);
installationInfo.put("province", notice.getProvince() + "_" + notice.getProvinceName());
installationInfo.put("city", notice.getCity() + "_" + notice.getCityName());
installationInfo.put("county", notice.getCounty() + "_" + notice.getCountyName());
// 设备信息 @Autowired
List<Map<String, Object>> equipmentInfos = jgInstallationNoticeMapper.queryEquipInformation(sequenceNbr); private JgInstallationNoticeMapper jgInstallationNoticeMapper;
return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", installationInfo);
this.put("equipmentInfo", equipmentInfos.get(0));
}};
}
/**
* 更新安装告知
*
* @param noticeDto 安装告知
*/
@SuppressWarnings("rawtypes")
public JgInstallationNoticeDto updateInstallationNotice(JgInstallationNoticeDto noticeDto) {
this.convertField(noticeDto);
ActWorkflowStartDTO dto = new ActWorkflowStartDTO(); @Autowired
dto.setProcessDefinitionKey("installationNotification"); private ICreateCodeService iCreateCodeService;
dto.setBusinessKey("1"); @Autowired
AjaxResult ajaxResult; JgRelationEquipMapper jgRelationEquipMapper;
try {
ajaxResult = Workflow.taskClient.startByVariable(dto);
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString();
noticeDto.setInstanceId(instanceId);
noticeDto.setStatus(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;
}
/** /**
* 分页查询 * 分页查询
...@@ -143,19 +105,40 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -143,19 +105,40 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
} }
@Override @Override
public void saveNotice(JgInstallationNoticeDto model) { @Transactional(rollbackFor = Exception.class)
public void saveNotice(String submitType, Map<String, JgInstallationNoticeDto> jgInstallationNoticeDtoMap) {
JgInstallationNoticeDto model = jgInstallationNoticeDtoMap.get(TABLE_PAGE_ID);
// 字段转换 // 字段转换
convertField(model); convertField(model);
// 获取告知设备列表 // 获取告知设备列表
List<Map<String, Object>> deviceList = model.getDeviceList(); List<Map<String, Object>> deviceList = model.getDeviceList();
if (CollectionUtils.isEmpty(deviceList)) {
return;
}
// 获取告知单号 // 获取告知单号
// 调用方法 List<String> applyNoList = iCreateCodeService.createApplicationFormCode(ApplicationFormTypeEnum.GZ.getCode(), deviceList.size());
List<String> applyNoList = new ArrayList<>(); if (CollectionUtils.isEmpty(applyNoList)) {
Random random = new Random(); return;
for (int i = 0; i < deviceList.size(); i++) { }
applyNoList.add(String.valueOf(random.nextInt()));
// 判断当前是否为提交
List<String> instanceIdList = new ArrayList<>();
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
for (int i = 0 ; i< deviceList.size(); i++) {
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
AjaxResult ajaxResult = null;
try {
ajaxResult = Workflow.taskClient.startByVariable(dto);
String instanceId = ((Map) ajaxResult.get("data")).get("id").toString();
instanceIdList.add(instanceId);
} catch (Exception e) {
log.error("流程启动失败:{}", e);
}
}
} }
List<JgInstallationNotice> list = new ArrayList<>(); List<JgInstallationNotice> list = new ArrayList<>();
...@@ -167,10 +150,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN ...@@ -167,10 +150,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
int i = deviceList.indexOf(obj); int i = deviceList.indexOf(obj);
String applyNo = applyNoList.get(i); String applyNo = applyNoList.get(i);
dto.setApplyNo(applyNo); dto.setApplyNo(applyNo);
dto.setEquList(String.valueOf(obj.get("sequenceNbr"))); dto.setEquList(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipId(String.valueOf(obj.get("sequenceNbr"))); jgRelationEquip.setEquipId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setApplyNo(applyNo); jgRelationEquip.setApplyNo(applyNo);
jgRelationEquip.setBusinessType("GZ"); jgRelationEquip.setBusinessType("GZ");
if (!CollectionUtils.isEmpty(instanceIdList)) {
dto.setInstanceId(instanceIdList.get(i));
dto.setStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
} else {
dto.setStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
}
list.add(dto); list.add(dto);
equipList.add(jgRelationEquip); equipList.add(jgRelationEquip);
}); });
......
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