Commit d81dc53e by 王衍超

调整代码;

parent 7b11f93d
...@@ -21,6 +21,8 @@ import com.xyst.dinas.contract.query.processor.ContractPerformWarningProcessor; ...@@ -21,6 +21,8 @@ import com.xyst.dinas.contract.query.processor.ContractPerformWarningProcessor;
import com.xyst.dinas.contract.query.processor.ContractWarnSettingProcessor; import com.xyst.dinas.contract.query.processor.ContractWarnSettingProcessor;
import com.xyst.dinas.contract.service.ContractService; import com.xyst.dinas.contract.service.ContractService;
import com.xyst.dinas.contract.service.ContractWarnService; import com.xyst.dinas.contract.service.ContractWarnService;
import com.xyst.dinas.contract.task.ContractExpireCheckTask;
import com.xyst.dinas.contract.task.ContractExpireCheckTaskRegister;
import com.xyst.dinas.contract.web.ContractController; import com.xyst.dinas.contract.web.ContractController;
/** /**
* 开启自动配置,无需手动注册Bean * 开启自动配置,无需手动注册Bean
...@@ -116,4 +118,13 @@ public class ContractConfiguration { ...@@ -116,4 +118,13 @@ public class ContractConfiguration {
public ContractProcessEventListener createContractProcessEventListener() { public ContractProcessEventListener createContractProcessEventListener() {
return new ContractProcessEventListener(); return new ContractProcessEventListener();
} }
@Bean
public ContractExpireCheckTaskRegister contractExpireCheckTaskRegister() {
return new ContractExpireCheckTaskRegister();
}
@Bean
public ContractExpireCheckTask contractExpireCheckTask() {
return new ContractExpireCheckTask();
}
} }
...@@ -115,16 +115,15 @@ public class ContractServiceImpl implements ContractService { ...@@ -115,16 +115,15 @@ public class ContractServiceImpl implements ContractService {
@Transactional @Transactional
@Override @Override
public void submitFlow(UUID id) { public void submitFlowForInsert(UUID id) {
KObject kobject = contractDao.load(id); KObject kobject = contractDao.load(id);
if (needSubmitFlow(ContractConstant.BIZ_TYPE,kobject)) { if (needSubmitFlow(ContractConstant.BIZ_TYPE,kobject)) {
inzWorkflowService.startWorkflow("SUBMIT", ContractConstant.BIZ_TYPE, kobject.getString(ContractConstant.CONTRACT_NAME),kobject); inzWorkflowService.startWorkflow("SUBMIT", ContractConstant.BIZ_TYPE, kobject.getString(ContractConstant.CONTRACT_NAME),kobject);
}else{ }else{
afterSubmitApproved(kobject); afterApprovedForInsert(kobject);
} }
} }
//变更合同的工作流
@Override @Override
@Transactional @Transactional
public void submitFlowForUpdate(UUID id) { public void submitFlowForUpdate(UUID id) {
...@@ -132,7 +131,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -132,7 +131,7 @@ public class ContractServiceImpl implements ContractService {
if (needSubmitFlow(ContractConstant.BIZ_TYPE_UPDATE,kobject)) { if (needSubmitFlow(ContractConstant.BIZ_TYPE_UPDATE,kobject)) {
inzWorkflowService.startWorkflow("SUBMIT", ContractConstant.BIZ_TYPE_UPDATE, kobject.getString(ContractConstant.CONTRACT_NAME),kobject); inzWorkflowService.startWorkflow("SUBMIT", ContractConstant.BIZ_TYPE_UPDATE, kobject.getString(ContractConstant.CONTRACT_NAME),kobject);
}else{ }else{
afterChangeApproved(kobject); afterApprovedForUpdate(kobject);
} }
} }
...@@ -153,21 +152,6 @@ public class ContractServiceImpl implements ContractService { ...@@ -153,21 +152,6 @@ public class ContractServiceImpl implements ContractService {
return contractInfoDao.getProjectListByPurSandId(purchaseSandId, projectType, projectName); return contractInfoDao.getProjectListByPurSandId(purchaseSandId, projectType, projectName);
} }
public void bill() {
String billDefineName = ContractConstant.ENTITY_CONTRACT;
// BillDefine billDefine =
// Amino.getApplicationMetadataContext().getBean(billDefineName,
// BillDefine.class);
// Bill equipmentBill = billService.createBill(billDefine);
// BillData equipmentBillData = equipmentBill.getData();
}
// @Override
// public KObject queryContractById(UUID id) {
// KObject kobject = contractInfoDao.load(id);
// return kobject;
// }
@Override @Override
public KObject getLastContractByInfoId(UUID infoId) { public KObject getLastContractByInfoId(UUID infoId) {
...@@ -195,7 +179,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -195,7 +179,7 @@ public class ContractServiceImpl implements ContractService {
} }
@Override @Override
public void afterSubmitApproved(KObject contract) { public void afterApprovedForInsert(KObject contract) {
KObject contractInfo = contractInfoDao.load(contract.getUuid("contractId")); KObject contractInfo = contractInfoDao.load(contract.getUuid("contractId"));
contractInfo.set(ContractConstant.CONTRACT_STATE,ContractStateEnum.EXECUTING.name()); contractInfo.set(ContractConstant.CONTRACT_STATE,ContractStateEnum.EXECUTING.name());
contractInfoDao.update(contractInfo); contractInfoDao.update(contractInfo);
...@@ -205,15 +189,13 @@ public class ContractServiceImpl implements ContractService { ...@@ -205,15 +189,13 @@ public class ContractServiceImpl implements ContractService {
contractInfoDao.update(contract); contractInfoDao.update(contract);
//合同审批通过后,自动新增砂石余量预警设置 //合同审批通过后,自动新增砂石余量预警设置
UUID contractId = contract.getUuid("id"); UUID contractId = contract.getUuid("id");
String billType = "合同";
String contractBaseInfo = getContractBaseInfo(contract); String contractBaseInfo = getContractBaseInfo(contract);
List<KObject> detials = contract.get("contractDetails").toList(); List<KObject> detials = contract.get("contractDetails").toList();
// //
for (KObject detail : detials) { for (KObject detail : detials) {
String dinasTypeName = detail.get("dinasType").getString("dinasTypeName"); String dinasTypeName = detail.get("dinasType").getString("dinasTypeName");
String billType = "合同";
WarnSettingEntity warnSetting = new WarnSettingEntity(); WarnSettingEntity warnSetting = new WarnSettingEntity();
warnSetting.setBillType(billType); warnSetting.setBillType(billType);
warnSetting.setBillId(contractId); warnSetting.setBillId(contractId);
...@@ -221,12 +203,20 @@ public class ContractServiceImpl implements ContractService { ...@@ -221,12 +203,20 @@ public class ContractServiceImpl implements ContractService {
warnSetting.setOpen(true); warnSetting.setOpen(true);
warnSetting.setMemo(contractBaseInfo); warnSetting.setMemo(contractBaseInfo);
warningSettingService.insertWarnSetting(warnSetting); warningSettingService.insertWarnSetting(warnSetting);
} }
//自动新增一条合同到期预警设置
String target = "到期提醒(天)";
WarnSettingEntity expireWarnSetting = new WarnSettingEntity();
expireWarnSetting.setBillType(billType);
expireWarnSetting.setBillId(contractId);
expireWarnSetting.setTarget(target);
expireWarnSetting.setOpen(true);
expireWarnSetting.setMemo(contractBaseInfo);
warningSettingService.insertWarnSetting(expireWarnSetting);
} }
@Override @Override
public void afterChangeApproved(KObject contract) { public void afterApprovedForUpdate(KObject contract) {
List<KObject> executingContracts = contractDao.getExecutingContractByContractInfoId(contract.getUuid("contractId")); List<KObject> executingContracts = contractDao.getExecutingContractByContractInfoId(contract.getUuid("contractId"));
if(executingContracts.size() != 1){ if(executingContracts.size() != 1){
//不该出现的情况,需要查明 //不该出现的情况,需要查明
...@@ -249,22 +239,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -249,22 +239,8 @@ public class ContractServiceImpl implements ContractService {
contractInfoDao.update(contractInfo); contractInfoDao.update(contractInfo);
//合同审批通过后,自动新增砂石余量预警设置---变更需要新旧对比,原有的不动,少了的种类废弃预警设置(按理说不可能有),多了的种类新建设置 //合同审批通过后,自动新增砂石余量预警设置---变更需要新旧对比,原有的不动,少了的种类废弃预警设置(按理说不可能有),多了的种类新建设置
//TODO
// UUID contractId = contract.getUuid("id");
// List<KObject> detials = contract.get("contractDetail").toList();
// //
// for (KObject detail : detials) {
// String dinasTypeName = detail.get("dinasType").getString("dinasTypeName");
//
// String billType = "合同";
// WarnSettingEntity warnSetting = new WarnSettingEntity();
// warnSetting.setBillType(billType);
// warnSetting.setBillId(contractId);
// warnSetting.setTarget(dinasTypeName);
// warnSetting.setOpen(true);
// warningSettingService.insertWarnSetting(warnSetting);
//
// }
} }
private String getContractBaseInfo(KObject contract) { private String getContractBaseInfo(KObject contract) {
...@@ -272,11 +248,12 @@ public class ContractServiceImpl implements ContractService { ...@@ -272,11 +248,12 @@ public class ContractServiceImpl implements ContractService {
KObject project = contract.get("project"); KObject project = contract.get("project");
String projectName = project.getString("projectName"); String projectName = project.getString("projectName");
KObject regionCompany = contract.get("regionCompany"); KObject regionCompany = contract.get("regionCompany");
UUID regionalCompanyId = regionCompany!=null? regionCompany.getUuid("id"):UUID.fromString("00000000-0000-0000-0000-000000000000"); UUID emptyUUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
UUID regionalCompanyId = regionCompany!=null? regionCompany.getUuid("id"):emptyUUID;
String purchaseSandUnitName = contract.get("purchaseSandUnit").getString("name"); String purchaseSandUnitName = contract.get("purchaseSandUnit").getString("name");
String contractName = contract.getString("contractName"); String contractName = contract.getString("contractName");
KObject station = contract.get("station"); KObject station = contract.get("station");
UUID stationId = station!=null? station.getUuid("id"):UUID.fromString("00000000-0000-0000-0000-000000000000"); UUID stationId = station!=null? station.getUuid("id"):emptyUUID;//
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("contractName", contractName); jsonObject.put("contractName", contractName);
......
...@@ -33,7 +33,7 @@ public class ContractProcessEventListener implements InzBizProcessEventListener ...@@ -33,7 +33,7 @@ public class ContractProcessEventListener implements InzBizProcessEventListener
public void afterProcessCompleted(InzBizProcessEvent event) { public void afterProcessCompleted(InzBizProcessEvent event) {
//自动新增合同预警条目 //自动新增合同预警条目
if(event.getInzBizProcess().getWorkflowState() == BizProcessState.DONE_WITH_AGREE.getValue()){ if(event.getInzBizProcess().getWorkflowState() == BizProcessState.DONE_WITH_AGREE.getValue()){
contractService.afterSubmitApproved(event.getInzBizProcess().getBizDataObject()); contractService.afterApprovedForInsert(event.getInzBizProcess().getBizDataObject());
} }
} }
......
...@@ -32,7 +32,7 @@ public class ContractUpdateProcessListener implements InzBizProcessEventListener ...@@ -32,7 +32,7 @@ public class ContractUpdateProcessListener implements InzBizProcessEventListener
public void afterProcessCompleted(InzBizProcessEvent event) { public void afterProcessCompleted(InzBizProcessEvent event) {
//自动新增合同预警条目 //自动新增合同预警条目
if(event.getInzBizProcess().getWorkflowState() == BizProcessState.DONE_WITH_AGREE.getValue()){ if(event.getInzBizProcess().getWorkflowState() == BizProcessState.DONE_WITH_AGREE.getValue()){
contractService.afterChangeApproved(event.getInzBizProcess().getBizDataObject()); contractService.afterApprovedForUpdate(event.getInzBizProcess().getBizDataObject());
} }
} }
......
...@@ -33,17 +33,6 @@ public interface ContractService { ...@@ -33,17 +33,6 @@ public interface ContractService {
*/ */
List<KObject> getChangeHistory(UUID id); List<KObject> getChangeHistory(UUID id);
/**
* 新增合同工作流
* @param id
*/
void submitFlow(UUID id);
/**
* 变更合同工作流
* @param id
*/
void submitFlowForUpdate(UUID id);
/** /**
* 根据购砂单位ID 查询所有合同列表里的项目ID列表 * 根据购砂单位ID 查询所有合同列表里的项目ID列表
...@@ -55,21 +44,31 @@ public interface ContractService { ...@@ -55,21 +44,31 @@ public interface ContractService {
*/ */
JSONArray getProjectListByPurSandId(UUID purchaseSandId,UUID projectType,String projectName); JSONArray getProjectListByPurSandId(UUID purchaseSandId,UUID projectType,String projectName);
Object queryWarnSettingById(UUID id);
Object queryWarnSettingStaffByContractId(String fromString);
// KObject queryContractById(UUID id); /**
* 新增合同-提交工作流
* @param id
*/
void submitFlowForInsert(UUID id);
/** /**
* 审批通过后的回调-提交 * 变更合同-提交工作流
* @param object * @param id
*/ */
void afterSubmitApproved(KObject object); void submitFlowForUpdate(UUID id);
/** /**
* 审批通过后的回调-变更 * 新增合同- 审批通过后的回调
* @param object * @param object afterApprovedForInsert
*/ */
void afterChangeApproved(KObject object); void afterApprovedForInsert(KObject object);
/**
Object queryWarnSettingById(UUID id); * 变更合同- 审批通过后的回调
* @param object afterApprovedForUpdate
*/
void afterApprovedForUpdate(KObject object);
Object queryWarnSettingStaffByContractId(String fromString);
} }
package com.xyst.dinas.contract.task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.beecode.amino.core.Amino;
import com.beecode.bap.scheduler.core.Task;
import com.beecode.bap.scheduler.core.TaskContext;
/**
* 合同过期检查任务
*
* @author Jackpot
* @date 2021年4月7日
*/
public class ContractExpireCheckTask implements Task{
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void execute(TaskContext arg0) {
// Amino.getApplicationContext().getBean(getClass());
System.out.println("ContractExpireCheckTask.execute....");
}
}
package com.xyst.dinas.contract.task;
import java.util.Optional;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.amino.metadata.context.ApplicationMetadataContext;
import com.beecode.amino.metadata.runtime.ServiceInitializer;
import com.beecode.bap.scheduler.entity.ScheduleDetail;
import com.beecode.bap.scheduler.entity.TaskDetail;
import com.beecode.bap.scheduler.service.ScheduleService;
public class ContractExpireCheckTaskRegister implements ServiceInitializer{
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ScheduleService scheduleService;
//任务名
private final String EXPIRE_REMIND_TASK_NAME ="ContractExpireCheckTask";
@Override
public void init(ApplicationMetadataContext arg0) {
Optional<ScheduleDetail> Optional = scheduleService.findByName(EXPIRE_REMIND_TASK_NAME);
if (Optional.isPresent()) {
// 如果该租户的库中存在这个轮询任务那么就不再去注册了
scheduleService.removeTask(EXPIRE_REMIND_TASK_NAME);
}
TaskDetail TaskDetail = new TaskDetail(EXPIRE_REMIND_TASK_NAME, ContractExpireCheckTask.class.getName());
// 每天凌晨12点执行调度,如测试可修改为每十五秒:*/15 * * * * ?(表达式由至少6个由空格分隔的时间元素,从左至右可分为秒,分,时,日,月,星期)
// scheduleService.scheduleTask(TaskDetail, "0 0 0 * * ?");
// 测试调度时进行调用
scheduleService.scheduleTask(TaskDetail, "*/10 * * * * ?");
logger.info("合同到期提醒任务初始化成功!");
}
}
...@@ -90,12 +90,12 @@ public class ContractController { ...@@ -90,12 +90,12 @@ public class ContractController {
public Object submitFlow(@RequestBody BaseEntity baseEntity) { public Object submitFlow(@RequestBody BaseEntity baseEntity) {
UUID id = UUID.fromString(baseEntity.getId()); UUID id = UUID.fromString(baseEntity.getId());
try{ try{
contractService.submitFlow(id); contractService.submitFlowForInsert(id);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return ResponseObj.error("提交审核提交失败", e.getMessage()); return ResponseObj.error("提交审核失败", e.getMessage());
} }
return ResponseObj.success("提交审核提交成功"); return ResponseObj.success("提交审核成功");
} }
@PostMapping("/contract/update/submitFlow") @PostMapping("/contract/update/submitFlow")
...@@ -105,9 +105,9 @@ public class ContractController { ...@@ -105,9 +105,9 @@ public class ContractController {
contractService.submitFlowForUpdate(id); contractService.submitFlowForUpdate(id);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return ResponseObj.error("变更审核提交失败", e.getMessage()); return ResponseObj.error("变更审核失败", e.getMessage());
} }
return ResponseObj.success("变更审核提交成功"); return ResponseObj.success("变更审核成功");
} }
@PostMapping("/contract/load/last") @PostMapping("/contract/load/last")
......
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