|
|
@@ -38,7 +38,7 @@ public class ContractionListener |
|
|
|
} |
|
|
|
|
|
|
|
@CallbackHandler(protocol = "" + NSProtocol.NS_PROTOCOL_CONTRACTION) |
|
|
|
public void handle(ContractionSession session) |
|
|
|
public void reportContraction(ContractionSession session) |
|
|
|
{ |
|
|
|
TAgentContraction contraction = conv(session.message); |
|
|
|
Result result = session.result; |
|
|
@@ -46,7 +46,35 @@ public class ContractionListener |
|
|
|
SqlUtil.transaction(() -> { |
|
|
|
TAgentTask task = syncTask(session.message.getData(), contraction); |
|
|
|
contraction.setTaskId(task.getId()); |
|
|
|
itAgentContractionService.insertTAgentContraction(contraction); |
|
|
|
if(null == contraction.getId()) |
|
|
|
{ |
|
|
|
itAgentContractionService.insertTAgentContraction(contraction); |
|
|
|
result.setMessage("新增合同报账成功"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
itAgentContractionService.updateTAgentContraction(contraction); |
|
|
|
result.setMessage("更新合同报账成功"); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
result.setData(contraction); |
|
|
|
} |
|
|
|
|
|
|
|
@CallbackHandler(protocol = "" + NSProtocol.NS_PROTOCOL_UPDATE_CONTRACTION) |
|
|
|
public void updateContraction(ContractionSession session) |
|
|
|
{ |
|
|
|
NSContractionEntity inContraction = session.message.getData(); |
|
|
|
Result result = session.result; |
|
|
|
TAgentContraction contraction = itAgentContractionService.selectTAgentContraction(new TAgentContraction().setOrgCode(inContraction.getOrgCode()).setOutId(inContraction.getOutId())); |
|
|
|
Assert.notNull(contraction, "报账合同不存在"); |
|
|
|
Assert.isTrue(TAgentTask.AGENT_STATUS_PROCESSING.equals(contraction.getAgentStatus()), "报账合同任务未分配"); |
|
|
|
Assert.isTrue("2".equals(contraction.getOrderStatus()), "报账合同状态不是待记账状态"); |
|
|
|
|
|
|
|
SqlUtil.transaction(() -> { |
|
|
|
contraction.setOrderStatus(inContraction.getOrderStatus()); |
|
|
|
itAgentContractionService.updateTAgentContraction(contraction); |
|
|
|
syncFinishTask(contraction); |
|
|
|
}); |
|
|
|
|
|
|
|
result.setData(contraction); |
|
|
@@ -54,20 +82,39 @@ public class ContractionListener |
|
|
|
|
|
|
|
private TAgentContraction conv(Message<NSContractionEntity> message) |
|
|
|
{ |
|
|
|
TAgentContraction contraction = new TAgentContraction(); |
|
|
|
NSContractionEntity data = message.getData(); |
|
|
|
contraction.setBookId(data.getBookId()) |
|
|
|
.setDeptId(data.getDeptId()) |
|
|
|
.setOutId(data.getOutId()) |
|
|
|
.setOrgCode(data.getOrgCode()) |
|
|
|
.setName(data.getName()) |
|
|
|
.setBuildingTime(data.getBuildingTime()) |
|
|
|
.setOrderAt(new Date()) |
|
|
|
.setAgentStatus(TAgentTask.AGENT_STATUS_READY) |
|
|
|
.setOrderStatus("2") |
|
|
|
.normalized() |
|
|
|
; |
|
|
|
contraction.setCreateBy("admin"); |
|
|
|
|
|
|
|
TAgentContraction contractionCond = new TAgentContraction(); |
|
|
|
contractionCond.setOrgCode(data.getOrgCode()) |
|
|
|
.setOutId(data.getOutId()); |
|
|
|
TAgentContraction contraction = itAgentContractionService.selectTAgentContraction(contractionCond); |
|
|
|
if(null != contraction) |
|
|
|
{ |
|
|
|
Assert.isTrue("2".equals(contraction.getOrderStatus()), "非待记账状态的合同保障不能修改"); |
|
|
|
contraction.setBookId(data.getBookId()) |
|
|
|
.setDeptId(data.getDeptId()) |
|
|
|
.setName(data.getName()) |
|
|
|
.setBuildingTime(data.getBuildingTime()) |
|
|
|
; |
|
|
|
contraction.setUpdateBy("admin"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
contraction = new TAgentContraction(); |
|
|
|
contraction.setBookId(data.getBookId()) |
|
|
|
.setDeptId(data.getDeptId()) |
|
|
|
.setOutId(data.getOutId()) |
|
|
|
.setName(data.getName()) |
|
|
|
.setOrgCode(data.getOrgCode()) |
|
|
|
.setBuildingTime(data.getBuildingTime()) |
|
|
|
.setOrderAt(new Date()) |
|
|
|
.setAgentStatus(TAgentTask.AGENT_STATUS_READY) |
|
|
|
.setOrderStatus("2") |
|
|
|
.normalized() |
|
|
|
; |
|
|
|
contraction.setCreateBy("admin"); |
|
|
|
} |
|
|
|
|
|
|
|
return contraction; |
|
|
|
} |
|
|
|
|
|
|
@@ -86,6 +133,19 @@ public class ContractionListener |
|
|
|
task.setId(tAgentTask.getId()); |
|
|
|
itAgentTaskService.updateTAgentTaskCount(task); |
|
|
|
|
|
|
|
return task; |
|
|
|
return tAgentTask; |
|
|
|
} |
|
|
|
|
|
|
|
private void syncFinishTask(TAgentContraction contraction) |
|
|
|
{ |
|
|
|
String orgCode = contraction.getOrgCode(); |
|
|
|
|
|
|
|
TAgentTask tAgentTask = itAgentTaskService.getTAgentTask(orgCode, contraction.getOrderYear(), contraction.getOrderMonth()); |
|
|
|
Assert.notNull(tAgentTask, "{}下{}年{}月无任务", orgCode, contraction.getOrderYear(), contraction.getOrderMonth()); |
|
|
|
|
|
|
|
TAgentTask task = new TAgentTask(); |
|
|
|
task.setFinishCount(1); |
|
|
|
task.setId(tAgentTask.getId()); |
|
|
|
itAgentTaskService.updateTAgentTaskCount(task); |
|
|
|
} |
|
|
|
} |