服务指令-生成即时指令工单

This commit is contained in:
曹磊 2026-01-12 17:13:04 +08:00
parent 944858c74e
commit 4190b077b9
9 changed files with 318 additions and 34 deletions

View File

@ -37,7 +37,4 @@ public interface IInvoicingDataPoolService extends IService<DirectiveDataPool> {
*/ */
void editDataPool(InvoicingDirectivePlan invoicingDirectivePlan); void editDataPool(InvoicingDirectivePlan invoicingDirectivePlan);
// Result<?> addInstant(InvoicingDataPool dataPool);
} }

View File

@ -38,4 +38,6 @@ public interface DirectiveOrderMapper extends BaseMapper<DirectiveOrder> {
List<DirectiveOrderEntity> queryCurrent(@Param("dto") CareDirectiveEntity dto); List<DirectiveOrderEntity> queryCurrent(@Param("dto") CareDirectiveEntity dto);
DirectiveOrder getDirectiveById(DirectiveOrder orders); DirectiveOrder getDirectiveById(DirectiveOrder orders);
DirectiveOrder getEmployeeById(@Param("employeeId") String employeeId);
} }

View File

@ -3,6 +3,8 @@ package com.nu.modules.biz.order.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nu.modules.biz.order.entity.DirectiveOrder; import com.nu.modules.biz.order.entity.DirectiveOrder;
import com.nu.modules.biz.order.entity.DirectiveOrderSub; import com.nu.modules.biz.order.entity.DirectiveOrderSub;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
@ -13,4 +15,6 @@ import java.util.List;
*/ */
public interface DirectiveOrderSubMapper extends BaseMapper<DirectiveOrderSub> { public interface DirectiveOrderSubMapper extends BaseMapper<DirectiveOrderSub> {
List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders); List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders);
List<DirectiveOrderSub> getDirectiveList(@Param("directiveId") String directiveId);
List<DirectiveOrderSub> getSubDirectiveList(@Param("packageId") String packageId);
} }

View File

@ -116,6 +116,7 @@
<select id="queryDataPoolList" resultType="com.nu.modules.biz.order.entity.DirectiveOrder"> <select id="queryDataPoolList" resultType="com.nu.modules.biz.order.entity.DirectiveOrder">
select select
a.id as poolId, a.id as poolId,
a.pool_type as orderType,
a.biz_id as bizId, a.biz_id as bizId,
a.nu_id as nuId, a.nu_id as nuId,
a.nu_name as nuName, a.nu_name as nuName,
@ -426,13 +427,15 @@
<select id="getDirectiveById" resultType="com.nu.modules.biz.order.entity.DirectiveOrder"> <select id="getDirectiveById" resultType="com.nu.modules.biz.order.entity.DirectiveOrder">
select select
id, m.id as bizId,
nu_id as nuId, m.nu_id as nuId,
nu_name as nuName, m.nu_name as nuName,
elder_id as elderId, elder_id as elderId,
elder_name as elderName, elder_name as elderName,
directive_id as directiveId, directive_id as directiveId,
directive_name as directiveName, directive_name as directiveName,
'3' as cycleTypeId,
(select item_text from sys_dict_item where dict_id = '1900374791386140674' and item_value = '3') as cycleType,
preview_file as previewFile, preview_file as previewFile,
net_preview_file as netPreviewFile, net_preview_file as netPreviewFile,
preview_file_small as previewFileSmall, preview_file_small as previewFileSmall,
@ -443,9 +446,18 @@
net_mp4_file as netMp4File, net_mp4_file as netMp4File,
service_duration as serviceDuration, service_duration as serviceDuration,
service_content as serviceContent, service_content as serviceContent,
iz_package iz_package,
(case when b.orderly is null then 2 else 1 end) as orderEmp
from ${tableName} m from ${tableName} m
left join nu_biz_elder_info b on m.elder_id = b.id
where m.id = #{id} where m.id = #{id}
</select> </select>
<select id="getEmployeeById" resultType="com.nu.modules.biz.order.entity.DirectiveOrder">
select a.id as employeeId,
a.name as employeeName
from nu_biz_employees_info a
where a.id = #{employeeId}
</select>
</mapper> </mapper>

View File

@ -5,6 +5,7 @@
<select id="queryDataPoolSubList" resultType="com.nu.modules.biz.order.entity.DirectiveOrderSub"> <select id="queryDataPoolSubList" resultType="com.nu.modules.biz.order.entity.DirectiveOrderSub">
select select
id as poolSubId, id as poolSubId,
pool_type as orderType,
nu_id as nuId, nu_id as nuId,
nu_name as nuName, nu_name as nuName,
elder_id as elderId, elder_id as elderId,
@ -39,4 +40,57 @@
where main_id = #{poolId} where main_id = #{poolId}
</select> </select>
<select id="getDirectiveList" resultType="com.nu.modules.biz.order.entity.DirectiveOrderSub">
select
a.instruction_tag_id as instructionTagId,
b.instruction_name as instructionTagName,
a.category_id as categoryId,
c.category_name AS categoryName,
a.type_id as typeId,
d.type_name as typeName,
a.id as directiveId,
a.directive_name as directiveName,
a.cycle_type as cycleTypeId,
f.item_text AS cycleType,
a.preview_file as previewFile,
a.preview_file_small as previewFileSmall,
a.mp3_file as mp3File,
a.mp4_file as mp4File,
a.service_duration as serviceDuration,
a.service_content as serviceContent
from nu_config_service_directive a
left join nu_config_service_instruction_tag b on a.instruction_tag_id = b.id
left join nu_config_service_category c on a.category_id = c.id
left join nu_config_service_type d on a.type_id = d.id
left join sys_dict_item f on f.dict_id = '1900374791386140674' and f.item_value = a.cycle_type
where a.id = #{directiveId}
</select>
<select id="getSubDirectiveList" resultType="com.nu.modules.biz.order.entity.DirectiveOrderSub">
select
b.instruction_tag_id as instructionTagId,
e.instruction_name as instructionTagName,
b.category_id as categoryId,
c.category_name AS categoryName,
b.type_id as typeId,
d.type_name as typeName,
b.id as directiveId,
b.directive_name as directiveName,
b.cycle_type as cycleTypeId,
f.item_text AS cycleType,
b.preview_file as previewFile,
b.preview_file_small as previewFileSmall,
b.mp3_file as mp3File,
b.mp4_file as mp4File,
b.service_duration as serviceDuration,
b.service_content as serviceContent
from nu_config_package_directive a
left join nu_config_service_directive b on a.directive_id = b.id
left join nu_config_service_category c on b.category_id = c.id
left join nu_config_service_type d on b.type_id = d.id
left join nu_config_service_instruction_tag e on b.instruction_tag_id = e.id
left join sys_dict_item f on f.dict_id = '1900374791386140674' and f.item_value = b.cycle_type
where a.package_id = #{packageId}
</select>
</mapper> </mapper>

View File

@ -3,6 +3,8 @@ package com.nu.modules.biz.order.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.nu.modules.biz.order.entity.DirectiveOrder; import com.nu.modules.biz.order.entity.DirectiveOrder;
import com.nu.modules.biz.order.entity.DirectiveOrderSub; import com.nu.modules.biz.order.entity.DirectiveOrderSub;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
@ -13,4 +15,6 @@ import java.util.List;
*/ */
public interface IDirectiveOrderSubService extends IService<DirectiveOrderSub> { public interface IDirectiveOrderSubService extends IService<DirectiveOrderSub> {
List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders); List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders);
List<DirectiveOrderSub> getDirectiveList(String directiveId);
List<DirectiveOrderSub> getSubDirectiveList(String packageId);
} }

View File

@ -50,6 +50,7 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
SendOrderRule sendOrderRule; SendOrderRule sendOrderRule;
List<SendOrderRuleSub> ruleSubList; List<SendOrderRuleSub> ruleSubList;
private String allowedTimeout; private String allowedTimeout;
private String serverNetUrl;
@Autowired @Autowired
private SdWebsocket sdWebsocket; private SdWebsocket sdWebsocket;
@ -167,8 +168,8 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
if (orders.getIzPackage().equals("N")) { if (orders.getIzPackage().equals("N")) {
//获取满足条件的员工 //获取满足条件的员工
DirectiveOrder employee = employeeScreening(directiveIds, orders.getElderId(), null, orders.getStartTime()); DirectiveOrder employee = employeeScreening(directiveIds, orders.getElderId(), null, orders.getStartTime());
if (employee != null) { if(employee!=null){
String orderNo = getOrderNo(); String orderNo = getOrderNo(orders.getOrderType());
orders.setOrderNo(orderNo); orders.setOrderNo(orderNo);
orders.setEmployeeId(employee.getEmployeeId()); orders.setEmployeeId(employee.getEmployeeId());
orders.setEmployeeName(employee.getEmployeeName()); orders.setEmployeeName(employee.getEmployeeName());
@ -188,7 +189,10 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
ordersSub.setEmployeeName(employee.getEmployeeName()); ordersSub.setEmployeeName(employee.getEmployeeName());
ordersSub.setIzStart("N"); ordersSub.setIzStart("N");
ordersSub.setIzFinish("N"); ordersSub.setIzFinish("N");
ordersSub.setOrderType("1"); ordersSub.setOptType("1");
ordersSub.setOptIds(employee.getEmployeeId());
ordersSub.setOptNames(employee.getEmployeeName());
ordersSub.setServiceAllowedTimeout(allowedTimeout);
ordersSubService.save(ordersSub);//生成工单子表 ordersSubService.save(ordersSub);//生成工单子表
} }
baseMapper.updatePoolIzOrder(orders.getPoolId()); baseMapper.updatePoolIzOrder(orders.getPoolId());
@ -201,9 +205,9 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
List<DirectiveOrder> emps = baseMapper.getPermissionEmps(directiveIds);//获取服务标签中的员工和数量 List<DirectiveOrder> emps = baseMapper.getPermissionEmps(directiveIds);//获取服务标签中的员工和数量
emps.removeIf(data -> data.getOwnCn() < ordersSubList.size());//删除没有权限的数据 emps.removeIf(data -> data.getOwnCn() < ordersSubList.size());//删除没有权限的数据
String employeeIds = emps.stream().map(DirectiveOrder::getEmployeeId).collect(Collectors.joining(",")); String employeeIds = emps.stream().map(DirectiveOrder::getEmployeeId).collect(Collectors.joining(","));
DirectiveOrder employee = employeeScreening(directiveIds, orders.getElderId(), employeeIds, orders.getStartTime()); DirectiveOrder employee = employeeScreening(directiveIds,orders.getElderId(),employeeIds,orders.getStartTime());
if (employee != null) { if(employee!=null){
String orderNo = getOrderNo(); String orderNo = getOrderNo(orders.getOrderType());
orders.setOrderNo(orderNo); orders.setOrderNo(orderNo);
orders.setEmployeeId(employee.getEmployeeId()); orders.setEmployeeId(employee.getEmployeeId());
orders.setEmployeeName(employee.getEmployeeName()); orders.setEmployeeName(employee.getEmployeeName());
@ -223,7 +227,10 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
ordersSub.setEmployeeName(employee.getEmployeeName()); ordersSub.setEmployeeName(employee.getEmployeeName());
ordersSub.setIzStart("N"); ordersSub.setIzStart("N");
ordersSub.setIzFinish("N"); ordersSub.setIzFinish("N");
ordersSub.setOrderType("1"); ordersSub.setOptType("1");
ordersSub.setOptIds(employee.getEmployeeId());
ordersSub.setOptNames(employee.getEmployeeName());
ordersSub.setServiceAllowedTimeout(allowedTimeout);
ordersSubService.save(ordersSub);//生成工单子表 ordersSubService.save(ordersSub);//生成工单子表
} }
baseMapper.updatePoolIzOrder(orders.getPoolId()); baseMapper.updatePoolIzOrder(orders.getPoolId());
@ -589,12 +596,25 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
* *
* @return * @return
*/ */
private String getOrderNo() { private String getOrderNo(String orderType){
JSONObject deptInfo = sysBaseAPI.getDeptInfo(); JSONObject deptInfo = sysBaseAPI.getDeptInfo();
String deptCode = deptInfo.getString("code"); String deptCode = deptInfo.getString("code");
String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")); String today = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
// 构建今天的前缀模式 // 构建今天的前缀模式
String todayPrefix = "HL" + deptCode + today; String todayPrefix = "";
if(orderType.equals("1")){
todayPrefix = "HL";
}
if(orderType.equals("2")){
todayPrefix = "YL";
}
if(orderType.equals("3")){
todayPrefix = "CK";
}
if(orderType.equals("4")){
todayPrefix = "HQ";
}
todayPrefix = todayPrefix + deptCode + today;
QueryWrapper<DirectiveOrder> qw = new QueryWrapper<>(); QueryWrapper<DirectiveOrder> qw = new QueryWrapper<>();
qw.likeRight("order_no", todayPrefix); qw.likeRight("order_no", todayPrefix);
qw.select("order_no"); qw.select("order_no");
@ -668,19 +688,212 @@ public class DirectiveOrderServiceImpl extends ServiceImpl<DirectiveOrderMapper,
//后勤即时 //后勤即时
directiveOrder.setTableName("nu_biz_nu_logistics_directive_plan_instant"); directiveOrder.setTableName("nu_biz_nu_logistics_directive_plan_instant");
} }
DirectiveOrder directiveInfo = baseMapper.getDirectiveById(directiveOrder); getAllowedTimeout();
DirectiveOrder orders = baseMapper.getDirectiveById(directiveOrder);
List<DirectiveOrderSub> packageSubList = null;
String employeeId = "";
String employeeName = "";
Calendar c = Calendar.getInstance();
Date startTime = c.getTime();
String duration = orders.getServiceDuration();
if(duration.equals("")||duration.equals("0")){
c.set(Calendar.YEAR,3000);
c.set(Calendar.MONTH,Calendar.DECEMBER);
c.set(Calendar.DAY_OF_MONTH,31);
c.set(Calendar.HOUR_OF_DAY,0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
c.set(Calendar.MILLISECOND,0);
}else{
c.add(Calendar.MINUTE,Integer.valueOf(duration));
}
Date endTime = c.getTime();
orders.setStartTime(startTime);
orders.setEndTime(endTime);
if(orders.getIzPackage().equals("N")){
packageSubList = ordersSubService.getDirectiveList(orders.getDirectiveId());
String directiveIds = packageSubList.stream().map(DirectiveOrderSub::getDirectiveId).collect(Collectors.joining(","));
if(!directiveOrder.getTriggerMode().equals("1")){
DirectiveOrder employee = employeeScreening(directiveIds,orders.getElderId(),null,orders.getStartTime());
employeeId = employee.getEmployeeId();
employeeName = employee.getEmployeeName();
}
}else{
orders.setPackageId(orders.getDirectiveId());
orders.setPackageName(orders.getDirectiveName());
orders.setDirectiveId(null);
orders.setDirectiveName(null);
packageSubList = ordersSubService.getSubDirectiveList(orders.getPackageId());
String directiveIds = packageSubList.stream().map(DirectiveOrderSub::getDirectiveId).collect(Collectors.joining(","));
if(!directiveOrder.getTriggerMode().equals("1")){
List<DirectiveOrder> emps = baseMapper.getPermissionEmps(directiveIds);//获取服务标签中的员工和数量
if(packageSubList!=null){
int size = packageSubList.size();
emps.removeIf(data -> data.getOwnCn() < size);//删除没有权限的数据
}
String employeeIds = emps.stream().map(DirectiveOrder::getEmployeeId).collect(Collectors.joining(","));
DirectiveOrder employee = employeeScreening(directiveIds,orders.getElderId(),employeeIds,orders.getStartTime());
employeeId = employee.getEmployeeId();
employeeName = employee.getEmployeeName();
}
}
if (directiveOrder.getTriggerMode().equals("1")) { if (directiveOrder.getTriggerMode().equals("1")) {
//直接派单给发起人 //直接派单给发起人
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String employeeId = sysUser.getEmployessId(); employeeId = sysUser.getEmployessId();
} else { employeeName = getEmployeeName(employeeId);
//按规则派单
getSendOrderRule();
} }
getNetImages(orders);
String orderNo = getOrderNo(orderType);
orders.setOrderNo(orderNo);
orders.setOrderType(orderType);
orders.setOptType("1");
orders.setEmployeeId(employeeId);
orders.setEmployeeName(employeeName);
orders.setIzStart("N");
orders.setIzFinish("N");
orders.setOptIds(employeeId);
orders.setOptNames(employeeName);
orders.setServiceAllowedTimeout(allowedTimeout);
orders.setDelFlag("0");
this.save(orders);//生成工单主表
if(packageSubList!=null){
for(int i=0;i<packageSubList.size();i++){
DirectiveOrderSub ordersSub = packageSubList.get(i);
getSubNetImages(ordersSub);
ordersSub.setOrderNo(getOrderSubNo(orderNo));
ordersSub.setOrderType(orderType);
ordersSub.setMainId(orders.getId());
ordersSub.setNuId(orders.getNuId());
ordersSub.setNuName(orders.getNuName());
ordersSub.setElderId(orders.getElderId());
ordersSub.setElderName(orders.getElderName());
ordersSub.setEmployeeId(employeeId);
ordersSub.setEmployeeName(employeeName);
ordersSub.setIzPackage(orders.getIzPackage());
if(!orders.getIzPackage().equals("N")){
ordersSub.setPackageId(orders.getPackageId());
ordersSub.setPackageName(orders.getPackageName());
}
ordersSub.setStartTime(startTime);
ordersSub.setEndTime(endTime);
ordersSub.setIzStart("N");
ordersSub.setIzFinish("N");
ordersSub.setOptType("1");
ordersSub.setOptIds(employeeId);
ordersSub.setOptNames(employeeName);
ordersSub.setServiceAllowedTimeout(allowedTimeout);
ordersSub.setDelFlag("0");
ordersSubService.save(ordersSub);//生成工单子表
}
}
//todo
return map; return map;
} }
private DirectiveOrder getNetImages(DirectiveOrder par) {
if (par.getPreviewFile() != null && !par.getPreviewFile().equals("")) {
String previewFile = getImageNetUrl(par.getPreviewFile());
par.setNetPreviewFile(previewFile);
} else {
par.setPreviewFile("");
par.setNetPreviewFile("");
}
if (par.getPreviewFileSmall() != null && !par.getPreviewFileSmall().equals("")) {
String previewFileSmall = getImageNetUrl(par.getPreviewFileSmall());
par.setNetPreviewFileSmall(previewFileSmall);
} else {
par.setPreviewFileSmall("");
par.setNetPreviewFileSmall("");
}
if (par.getMp3File() != null && !par.getMp3File().equals("")) {
String netMp3File = getImageNetUrl(par.getMp3File());
par.setNetMp3File(netMp3File);
} else {
par.setMp3File("");
par.setNetMp3File("");
}
if (par.getMp4File() != null && !par.getMp4File().equals("")) {
String netMp4File = getImageNetUrl(par.getMp4File());
par.setNetMp4File(netMp4File);
} else {
par.setMp4File("");
par.setNetMp4File("");
}
return par;
}
private DirectiveOrderSub getSubNetImages(DirectiveOrderSub par) {
if (par.getPreviewFile() != null && !par.getPreviewFile().equals("")) {
String previewFile = getImageNetUrl(par.getPreviewFile());
par.setNetPreviewFile(previewFile);
} else {
par.setPreviewFile("");
par.setNetPreviewFile("");
}
if (par.getPreviewFileSmall() != null && !par.getPreviewFileSmall().equals("")) {
String previewFileSmall = getImageNetUrl(par.getPreviewFileSmall());
par.setNetPreviewFileSmall(previewFileSmall);
} else {
par.setPreviewFileSmall("");
par.setNetPreviewFileSmall("");
}
if (par.getMp3File() != null && !par.getMp3File().equals("")) {
String netMp3File = getImageNetUrl(par.getMp3File());
par.setNetMp3File(netMp3File);
} else {
par.setMp3File("");
par.setNetMp3File("");
}
if (par.getMp4File() != null && !par.getMp4File().equals("")) {
String netMp4File = getImageNetUrl(par.getMp4File());
par.setNetMp4File(netMp4File);
} else {
par.setMp4File("");
par.setNetMp4File("");
}
return par;
}
/**
* 获取管理平台静态资源路径
*
* @return
*/
private void getOpeMediaAddress() {
if (serverNetUrl == null || serverNetUrl.equals("")) {
JSONObject json = sysConfigApi.getByKey("ope_media_address");
if (json != null) {
String configValue = json.getString("configValue");
if (!configValue.endsWith("/")) {
configValue += "/";
}
serverNetUrl = configValue;
}
}
}
private String getImageNetUrl(String imageUrl) {
getOpeMediaAddress();
return serverNetUrl + imageUrl;
}
/**
* 获取员工姓名
* @param employeeId
*/
private String getEmployeeName(String employeeId){
String employeeName = "";
if(employeeId!=null&&!employeeId.equals("")){
DirectiveOrder employeeInfo = baseMapper.getEmployeeById(employeeId);
if(employeeInfo!=null){
employeeName = employeeInfo.getEmployeeName();
}
}
return employeeName;
}
} }

View File

@ -23,4 +23,14 @@ public class DirectiveOrderSubServiceImpl extends ServiceImpl<DirectiveOrderSubM
public List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders){ public List<DirectiveOrderSub> queryDataPoolSubList(DirectiveOrder orders){
return baseMapper.queryDataPoolSubList(orders); return baseMapper.queryDataPoolSubList(orders);
} }
@Override
public List<DirectiveOrderSub> getDirectiveList(String directiveId){
return baseMapper.getDirectiveList(directiveId);
}
@Override
public List<DirectiveOrderSub> getSubDirectiveList(String packageId){
return baseMapper.getSubDirectiveList(packageId);
}
} }

View File

@ -363,18 +363,6 @@ public class CareDirectivePlanServiceImpl extends ServiceImpl<CareDirectivePlanM
bizNuCareDirectivePlanInstantService.save(instant); bizNuCareDirectivePlanInstantService.save(instant);
//TODO 增加日志 //TODO 增加日志
//生成即时指令到数据池测试
// DataPool dataPool = new DataPool();
// dataPool.setBizId(customerServerInstant.getId());
// dataPool.setNuId(customerServerInstant.getNuId());
// dataPool.setNuName(customerServerInstant.getNuName());
// dataPool.setCustomerId(customerServerInstant.getCustomerId());
// dataPool.setCustomerName(customerServerInstant.getCustomerName());
// dataPool.setDirectiveId(customerServerInstant.getDirectiveId());
// dataPool.setDirectiveName(customerServerInstant.getDirectiveName());
// dataPool.setServiceDuration(customerServerInstant.getServiceDuration());
// dataPoolServiceImpl.addInstant(dataPool);
BeanUtils.copyProperties(instant,careDirectiveInstantEntity); BeanUtils.copyProperties(instant,careDirectiveInstantEntity);
return careDirectiveInstantEntity; return careDirectiveInstantEntity;
} }