diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java index e28e9382..3566a128 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/constant/AliyunTemplateKeyWord.java @@ -43,5 +43,5 @@ public class AliyunTemplateKeyWord { /** * 工单派送 */ - public static final String WORK_ORDER_CREATED = "新的工单待处理"; + public static final String WORK_ORDER_CREATED = "新的工单"; } diff --git a/xhpc-modules/xhpc-log/src/main/resources/logback.xml b/xhpc-modules/xhpc-log/src/main/resources/logback.xml index 05979096..b9558135 100644 --- a/xhpc-modules/xhpc-log/src/main/resources/logback.xml +++ b/xhpc-modules/xhpc-log/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/xhpc-modules/xhpc-tradebill/src/main/resources/logback.xml b/xhpc-modules/xhpc-tradebill/src/main/resources/logback.xml index 05979096..be0d0138 100644 --- a/xhpc-modules/xhpc-tradebill/src/main/resources/logback.xml +++ b/xhpc-modules/xhpc-tradebill/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/xhpc-modules/xhpc-workorder/pom.xml b/xhpc-modules/xhpc-workorder/pom.xml index 7f999d24..73b7b23a 100644 --- a/xhpc-modules/xhpc-workorder/pom.xml +++ b/xhpc-modules/xhpc-workorder/pom.xml @@ -86,31 +86,6 @@ compile - - javax.websocket - javax.websocket-api - 1.1 - provided - - - org.springframework.boot - spring-boot-starter-websocket - - - - - com.alipay.sdk - alipay-sdk-java - 4.15.14.ALL - - - - - com.github.binarywang - weixin-java-pay - 4.2.0 - - org.apache.ant ant diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/XhpcWorkOrderApplication.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/XhpcWorkOrderApplication.java similarity index 87% rename from xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/XhpcWorkOrderApplication.java rename to xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/XhpcWorkOrderApplication.java index e4513504..6a0d9c03 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/XhpcWorkOrderApplication.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/XhpcWorkOrderApplication.java @@ -1,4 +1,4 @@ -package com.xhpc.workorder; +package com.xhpc; import com.xhpc.common.security.annotation.EnableCustomConfig; import com.xhpc.common.security.annotation.EnableRyFeignClients; @@ -7,15 +7,15 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; @EnableConfigurationProperties @ConfigurationPropertiesScan(basePackages = {"com.xhpc.workorder.config"}) @EnableCustomConfig -@SpringBootApplication @EnableRyFeignClients -@EnableDiscoveryClient +@EnableFeignClients +@SpringBootApplication @MapperScan("com.xhpc.workorder.mapper") public class XhpcWorkOrderApplication { diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/api/SmsService.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/api/SmsService.java deleted file mode 100644 index ce03a677..00000000 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/api/SmsService.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xhpc.workorder.api; - -import com.xhpc.common.api.factory.SmsFallbackFactory; -import com.xhpc.common.core.constant.ServiceNameConstants; -import com.xhpc.common.core.domain.R; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.Map; - -@FeignClient(contextId = "smsService", value = ServiceNameConstants.XHPC_GENERAL, fallbackFactory = SmsFallbackFactory.class) -public interface SmsService { - - @PostMapping("/sms/send") - R sendNotice(@RequestBody Map paramMap); - -} \ No newline at end of file diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java index c298dabd..69e7670c 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/mapper/XhpcWorkOrderMapper.java @@ -10,11 +10,9 @@ public interface XhpcWorkOrderMapper { List> findOrderListByParams(@Param("params") Map params); - XhpcWorkOrderDomain selectByTypeAndTitleAndDeviceSerialNumber(@Param("type")Integer type, + XhpcWorkOrderDomain selectByTypeAndTitle(@Param("type")Integer type, @Param("title")String title, - @Param("serialNumber")String serialNumber, - @Param("userId")Long userId, - @Param("status") Integer status); + @Param("userId")Long userId); int deleteByPrimaryKey(Long workOrderId); diff --git a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java index e3db9b47..e786899f 100644 --- a/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java +++ b/xhpc-modules/xhpc-workorder/src/main/java/com/xhpc/workorder/service/impl/WorkOrderServiceImpl.java @@ -2,13 +2,19 @@ package com.xhpc.workorder.service.impl; import cn.hutool.core.util.StrUtil; import com.xhpc.common.api.SmsService; +import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.StringUtils; +import com.xhpc.workorder.domain.XhpcStationDeviceDomain; import com.xhpc.workorder.domain.XhpcWorkOrderDomain; import com.xhpc.workorder.domain.XhpcWorkOrderPushMessageDomain; import com.xhpc.workorder.domain.XhpcWorkUserDomain; +import com.xhpc.workorder.mapper.XhpcStationDeviceMapper; import com.xhpc.workorder.mapper.XhpcWorkOrderMapper; import com.xhpc.workorder.mapper.XhpcWorkOrderPushMessageMapper; import com.xhpc.workorder.mapper.XhpcWorkUserMapper; import com.xhpc.workorder.service.WorkOrderService; +import com.xhpc.workorder.service.WorkUserService; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -16,7 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - +@Slf4j @Service public class WorkOrderServiceImpl implements WorkOrderService { @@ -26,12 +32,18 @@ public class WorkOrderServiceImpl implements WorkOrderService { @Resource XhpcWorkUserMapper userMapper; + @Resource + XhpcStationDeviceMapper deviceMapper; + @Resource XhpcWorkOrderPushMessageMapper messageMapper; @Resource SmsService smsService; + @Resource + WorkUserService workUserService; + @Override public List> getOrderPage(Map params){ return orderMapper.findOrderListByParams(params); @@ -49,36 +61,50 @@ public class WorkOrderServiceImpl implements WorkOrderService { @Override public Boolean insertOrder(XhpcWorkOrderDomain domain){ + if (StrUtil.hasBlank(domain.getUserName()) || StrUtil.hasBlank(domain.getUserPhone())){ + throw new RuntimeException("派发人姓名或手机号不能为空"); + } - if(!StrUtil.hasBlank(domain.getUserName()) && !StrUtil.hasBlank(domain.getUserPhone())){ - XhpcWorkUserDomain userDomain = userMapper.selectByUserNameAndPhone(domain.getUserName(), domain.getUserPhone()); - if(userDomain == null){ - domain.setUserId(userDomain.getWorkUserId()); - domain.setDeptId(userDomain.getDeptId()); - } else { - // todo + XhpcWorkUserDomain userDomain = userMapper.selectByUserNameAndPhone(domain.getUserName(), domain.getUserPhone()); + if(userDomain != null){ + domain.setUserId(userDomain.getWorkUserId()); + domain.setDeptId(userDomain.getDeptId()); + } else { + userDomain = workUserService.insertUserReturnDomain(domain.getUserName(), domain.getUserPhone()); + } + domain.setUserId(userDomain.getWorkUserId()); + domain.setDeptId(userDomain.getDeptId()); + + if(StringUtils.isNotEmpty(domain.getSerialNumber())){ + XhpcStationDeviceDomain deviceDomain = deviceMapper.selectStationGunDeviceBySerialNumber(domain.getSerialNumber()); + if (deviceDomain == null){ + throw new RuntimeException("设备编码不存在"); } } + orderMapper.insertSelective(domain); - XhpcWorkOrderDomain resDomain = orderMapper.selectByTypeAndTitleAndDeviceSerialNumber(domain.getType().intValue(), + XhpcWorkOrderDomain resDomain = orderMapper.selectByTypeAndTitle(domain.getType().intValue(), domain.getTitle(), - domain.getSerialNumber(), - domain.getUserId(), - domain.getStatus().intValue()); + domain.getUserId()); HashMap paramMap = new HashMap<>(); paramMap.put("orderNo", resDomain.getWorkOrderId().toString()); paramMap.put("phone", domain.getUserPhone()); paramMap.put("content", "【小华充电】您好,您有新的工单(工单号:"+ resDomain.getWorkOrderId() +")待处理,请及时登陆后台查看并处理,谢谢。"); - smsService.sendNotice(paramMap); + R r = smsService.sendNotice(paramMap); XhpcWorkOrderPushMessageDomain messageDomain = new XhpcWorkOrderPushMessageDomain(); messageDomain.setContent(paramMap.get("content")); - messageDomain.setTarget(domain.getUserName()); + messageDomain.setTarget(domain.getUserPhone()); messageDomain.setType(Short.valueOf("1")); messageDomain.setStatus(Short.valueOf("1")); - messageDomain.setFailMsg("发送成功"); + if (r!= null && r.getCode() != 200){ + messageDomain.setFailMsg("发送失败"); + } else { + messageDomain.setFailMsg("发送成功"); + } + messageMapper.insertSelective(messageDomain); return true; } diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/logback.xml b/xhpc-modules/xhpc-workorder/src/main/resources/logback.xml index 05979096..fbbfd992 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/logback.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml index e5acbaa6..6795fea8 100644 --- a/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml +++ b/xhpc-modules/xhpc-workorder/src/main/resources/mapper/XhpcStationDeviceMapper.xml @@ -26,7 +26,7 @@ select from xhpc_station_device - where device_id = #{deviceId,jdbcType=INTEGER} + where serial_number = #{serialNumber} +