更新运维系统新增工单时获取场站ID

This commit is contained in:
panshuling321 2022-10-24 15:04:15 +08:00 committed by yuyang
parent 9c1d65f7c9
commit 9609bc794a

View File

@ -55,12 +55,12 @@ public class WorkOrderServiceImpl implements WorkOrderService {
WorkTypeService typeService;
@Override
public List<Map<String, Object>> getOrderPage(Map<String,Object> params){
public List<Map<String, Object>> getOrderPage(Map<String, Object> params) {
return orderMapper.findOrderListByParams(params);
}
@Override
public XhpcWorkOrderDomain selectOrderById(Long orderId){
public XhpcWorkOrderDomain selectOrderById(Long orderId) {
XhpcWorkOrderDomain orderDomain = orderMapper.selectByPrimaryKey(orderId);
orderDomain.setUserList(workUserService.findByOrderId(orderId));
@ -71,19 +71,19 @@ public class WorkOrderServiceImpl implements WorkOrderService {
}
private Boolean insertDomain(XhpcWorkOrderDomain domain){
private Boolean insertDomain(XhpcWorkOrderDomain domain) {
List<XhpcWorkUserDomain> userDomains = new ArrayList<>();
if(domain.getUserList() != null){
for(XhpcWorkUserDomain userDomain: domain.getUserList()){
if (domain.getUserList() != null) {
for (XhpcWorkUserDomain userDomain : domain.getUserList()) {
userDomain = workUserService.findByPk(userDomain.getWorkUserId());
userDomains.add(userDomain);
}
domain.setUserList(userDomains);
}
if(StringUtils.isNotEmpty(domain.getSerialNumber())){
if (StringUtils.isNotEmpty(domain.getSerialNumber())) {
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectStationGunDeviceBySerialNumber(domain.getSerialNumber());
if (deviceDomain == null){
if (deviceDomain == null) {
throw new RuntimeException("设备编码不存在");
}
}
@ -91,8 +91,8 @@ public class WorkOrderServiceImpl implements WorkOrderService {
orderMapper.insertSelective(domain);
// 上传文件
if(domain.getQuestionImgList() != null && !domain.getQuestionImgList().isEmpty()){
for(XhpcWorkOrderImageDomain imageDomain : domain.getQuestionImgList()){
if (domain.getQuestionImgList() != null && !domain.getQuestionImgList().isEmpty()) {
for (XhpcWorkOrderImageDomain imageDomain : domain.getQuestionImgList()) {
imageDomain.setOrderId(domain.getWorkOrderId());
imageDomain.setType(Short.valueOf("1"));
imageDomain.setDelFlag(Short.valueOf("0"));
@ -101,10 +101,10 @@ public class WorkOrderServiceImpl implements WorkOrderService {
}
// 绑定人员
if(domain.getUserList() != null && !domain.getUserList().isEmpty()){
if (domain.getUserList() != null && !domain.getUserList().isEmpty()) {
List<XhpcWorkOrderUserDomain> orderUserDomainList = new ArrayList<>();
StringBuilder userIdList = new StringBuilder();
for (XhpcWorkUserDomain userDomain: domain.getUserList()){
for (XhpcWorkUserDomain userDomain : domain.getUserList()) {
XhpcWorkOrderUserDomain orderUserDomain = new XhpcWorkOrderUserDomain();
orderUserDomain.setOrderId(domain.getWorkOrderId());
orderUserDomain.setUserId(userDomain.getWorkUserId());
@ -112,45 +112,45 @@ public class WorkOrderServiceImpl implements WorkOrderService {
userIdList.insert(0, userDomain.getWorkUserId() + ",");
}
if(orderUserDomainList.size() > 0){
if (orderUserDomainList.size() > 0) {
orderMapper.insertOrderUser(orderUserDomainList);
}
if(StringUtils.isNotEmpty(userIdList.toString()) && domain.getStatus() != null && domain.getStatus()==1){
if (StringUtils.isNotEmpty(userIdList.toString()) && domain.getStatus() != null && domain.getStatus() == 1) {
sendSms(userIdList.toString(), domain.getWorkOrderId().toString());
}
}
return true;
}
private Boolean updateDomain(XhpcWorkOrderDomain domain){
private Boolean updateDomain(XhpcWorkOrderDomain domain) {
orderMapper.updateByPrimaryKeySelective(domain);
List<Long> imageIds = imageMapper.selectImageIdByOrderIdAndType(domain.getWorkOrderId(), 1);
if(domain.getQuestionImgList() != null && !domain.getQuestionImgList().isEmpty()){
for (XhpcWorkOrderImageDomain imageDomain: domain.getQuestionImgList()){
if( imageDomain.getOrderImageId() == null || StringUtils.isEmpty(imageDomain.getOrderImageId().toString())){
if (domain.getQuestionImgList() != null && !domain.getQuestionImgList().isEmpty()) {
for (XhpcWorkOrderImageDomain imageDomain : domain.getQuestionImgList()) {
if (imageDomain.getOrderImageId() == null || StringUtils.isEmpty(imageDomain.getOrderImageId().toString())) {
imageDomain.setOrderId(domain.getWorkOrderId());
imageDomain.setType(Short.valueOf("1"));
imageDomain.setDelFlag(Short.valueOf("0"));
imageMapper.insertSelective(imageDomain);
} else {
if(imageIds.contains(imageDomain.getOrderImageId())){
if (imageIds.contains(imageDomain.getOrderImageId())) {
imageIds.remove(imageDomain.getOrderImageId());
}
}
}
if(imageIds.size() > 0){
if (imageIds.size() > 0) {
imageMapper.deleteByImageIds(imageIds);
}
}
if(domain.getUserList() != null && !domain.getUserList().isEmpty()){
if (domain.getUserList() != null && !domain.getUserList().isEmpty()) {
// 更新处理人
StringBuilder userIdList = new StringBuilder();
orderMapper.deleteOrderUserByOrderId(domain.getWorkOrderId());
List<XhpcWorkOrderUserDomain> orderUserDomainList = new ArrayList<>();
for(XhpcWorkUserDomain userDomain: domain.getUserList()){
for (XhpcWorkUserDomain userDomain : domain.getUserList()) {
XhpcWorkOrderUserDomain orderUserDomain = new XhpcWorkOrderUserDomain();
orderUserDomain.setOrderId(domain.getWorkOrderId());
orderUserDomain.setUserId(userDomain.getWorkUserId());
@ -159,11 +159,11 @@ public class WorkOrderServiceImpl implements WorkOrderService {
userIdList.insert(0, userDomain.getWorkUserId() + ",");
}
if(orderUserDomainList.size() > 0){
if (orderUserDomainList.size() > 0) {
orderMapper.insertOrderUser(orderUserDomainList);
}
if(StringUtils.isNotEmpty(userIdList.toString()) && domain.getStatus() != null && domain.getStatus()==1){
if (StringUtils.isNotEmpty(userIdList.toString()) && domain.getStatus() != null && domain.getStatus() == 1) {
sendSms(userIdList.toString(), domain.getWorkOrderId().toString());
}
}
@ -172,22 +172,26 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public Boolean updateOrder(XhpcWorkOrderDomain domain){
public Boolean updateOrder(XhpcWorkOrderDomain domain) {
// 是否自动派送
XhpcWorkTypeDictDomain typeDictDomain = typeService.getInfoByPk(domain.getType());
if(typeDictDomain != null){
if(typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()){
if (typeDictDomain != null) {
if (typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()) {
XhpcWorkUserDomain userDomain = new XhpcWorkUserDomain();
userDomain.setWorkUserId(Long.parseLong(typeDictDomain.getUserId() + ""));
domain.getUserList().add(userDomain);
domain.setStatus(Short.valueOf("1"));
}
if(typeDictDomain.getAutoRun() == 1){
if (typeDictDomain.getAutoRun() == 1) {
domain.setStatus(Short.valueOf("1"));
}
}
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
if (StringUtils.isNotEmpty(domain.getSerialNumber())) {
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectBySerialNumber(domain.getSerialNumber());
domain.setStationId(deviceDomain.getStationId());
}
if (domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L) {
insertDomain(domain);
} else {
updateDomain(domain);
@ -197,9 +201,9 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public Boolean replyOrder(XhpcWorkOrderDomain domain){
public Boolean replyOrder(XhpcWorkOrderDomain domain) {
XhpcWorkOrderDomain orderDomain = orderMapper.selectByPrimaryKey(domain.getWorkOrderId());
if(orderDomain == null){
if (orderDomain == null) {
throw new RuntimeException("订单不存在");
}
@ -209,7 +213,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
orderDomain.setRemark(domain.getRemark());
orderMapper.updateByPrimaryKeySelective(orderDomain);
for(XhpcWorkOrderImageDomain imageDomain: domain.getReplyImgList()){
for (XhpcWorkOrderImageDomain imageDomain : domain.getReplyImgList()) {
imageDomain.setOrderId(domain.getWorkOrderId());
imageDomain.setType(Short.valueOf("2"));
imageDomain.setDelFlag(Short.valueOf("0"));
@ -220,22 +224,28 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public Boolean insertOrder(XhpcWorkOrderDomain domain){
public Boolean insertOrder(XhpcWorkOrderDomain domain) {
// 是否自动派送
XhpcWorkTypeDictDomain typeDictDomain = typeService.getInfoByPk(domain.getType());
if(typeDictDomain != null){
if(typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()){
if (typeDictDomain != null) {
if (typeDictDomain.getAutoSend() == 1 && domain.getUserList().isEmpty()) {
XhpcWorkUserDomain userDomain = new XhpcWorkUserDomain();
userDomain.setWorkUserId(Long.parseLong(typeDictDomain.getUserId() + ""));
domain.getUserList().add(userDomain);
domain.setStatus(Short.valueOf("1"));
}
if(typeDictDomain.getAutoRun() == 1){
if (typeDictDomain.getAutoRun() == 1) {
domain.setStatus(Short.valueOf("1"));
}
}
if(domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L){
if (StringUtils.isNotEmpty(domain.getSerialNumber())) {
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectBySerialNumber(domain.getSerialNumber());
domain.setStationId(deviceDomain.getStationId());
}
if (domain.getWorkOrderId() == null || domain.getWorkOrderId() < 1L) {
insertDomain(domain);
} else {
updateDomain(domain);
@ -247,7 +257,7 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public Boolean deleteOrder(Long orderId) throws Exception {
XhpcWorkOrderDomain domain = orderMapper.selectByPrimaryKey(orderId);
if(domain == null){
if (domain == null) {
throw new Exception("工单不存在");
}
orderMapper.deleteByPrimaryKey(orderId);
@ -256,9 +266,9 @@ public class WorkOrderServiceImpl implements WorkOrderService {
}
@Override
public Boolean addNewOrder(String type, String title, String content, String reason,String stationId,String deviceType,String serialNumber) {
try{
XhpcWorkOrderDomain domain =new XhpcWorkOrderDomain();
public Boolean addNewOrder(String type, String title, String content, String reason, String stationId, String deviceType, String serialNumber) {
try {
XhpcWorkOrderDomain domain = new XhpcWorkOrderDomain();
domain.setType(Integer.parseInt(type));
domain.setTitle(title);
domain.setContent(content);
@ -266,18 +276,20 @@ public class WorkOrderServiceImpl implements WorkOrderService {
domain.setFaultTime(date);
domain.setContent(content);
domain.setCreateTime(date);
if(stationId!=null && !"".equals(stationId)){
if (stationId != null && !"".equals(stationId)) {
domain.setStationId(Long.valueOf(stationId));
}
if(deviceType!=null &&!"".equals(deviceType)){
if (deviceType != null && !"".equals(deviceType)) {
domain.setDeviceType(deviceType);
}
if(serialNumber!=null && !"".equals(serialNumber)){
if (serialNumber != null && !"".equals(serialNumber)) {
domain.setSerialNumber(serialNumber);
XhpcStationDeviceDomain deviceDomain = deviceMapper.selectBySerialNumber(domain.getSerialNumber());
domain.setStationId(deviceDomain.getStationId());
}
insertDomain(domain);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
@ -287,31 +299,31 @@ public class WorkOrderServiceImpl implements WorkOrderService {
@Override
public R workOrderMessage(Integer type, String time) {
int i = orderMapper.workOrderMessage(type, time);
if(i>0){
if (i > 0) {
return R.fail();
}
return R.ok();
}
private void sendSms(String userIds, String orderId){
private void sendSms(String userIds, String orderId) {
String phoneList = workUserService.getPhoneListByUserIds(userIds);
if(StringUtils.isEmpty(phoneList)){
if (StringUtils.isEmpty(phoneList)) {
throw new CustomException("没有待发送短信");
}
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("orderNo", orderId);
paramMap.put("phone", phoneList);
paramMap.put("content", "【小华充电】您好,您有新的工单(工单号:"+ orderId +")待处理,请及时登陆后台查看并处理,谢谢。");
paramMap.put("content", "【小华充电】您好,您有新的工单(工单号:" + orderId + ")待处理,请及时登陆后台查看并处理,谢谢。");
R r = smsService.sendNotice(paramMap);
XhpcWorkOrderPushMessageDomain messageDomain = new XhpcWorkOrderPushMessageDomain();
messageDomain.setContent(paramMap.get("content"));
messageDomain.setTarget(phoneList);
messageDomain.setType(Short.valueOf("1"));
if (r!= null && r.getCode() != 200){
if (r != null && r.getCode() != 200) {
messageDomain.setFailMsg("发送失败");
messageDomain.setStatus(Short.valueOf("2"));
} else {