2 Коміти 69be924528 ... 4e5adfc475

Автор SHA1 Опис Дата
  yanliming 4e5adfc475 Merge remote-tracking branch 'origin/master' 2 тижнів тому
  yanliming c4db2947e3 修改后台功能逻辑 2 тижнів тому

+ 12 - 0
common/pom.xml

@@ -239,6 +239,18 @@
             <artifactId>joda-time</artifactId>
             <version>2.6</version>
         </dependency>
+        <!-- OkHttp:处理HTTP请求(Java8友好) -->
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.14.9</version>
+        </dependency>
+        <!-- FastJSON2:JSON解析 -->
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.45</version>
+        </dependency>
     </dependencies>
 
 

+ 3 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/ProvinceInfoDAO.java

@@ -1,6 +1,8 @@
 package com.jpsoft.employment.modules.base.dao;
 
 import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.jpsoft.employment.modules.base.entity.ProvinceInfo;
 import java.util.Map;
@@ -14,5 +16,6 @@ public interface ProvinceInfoDAO {
 	ProvinceInfo get(String id);
 	int delete(String id);
 	List<ProvinceInfo> list();
+	List<ProvinceInfo> findByParentId(@Param("parentId") Integer parentId);
 	List<ProvinceInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
 }

+ 1 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/ProvinceInfoService.java

@@ -13,5 +13,6 @@ public interface ProvinceInfoService {
 	int update(ProvinceInfo model);
 	int delete(String id);
 	List<ProvinceInfo> list();
+	List<ProvinceInfo> findByParentId(Integer parentId);
 	Page<ProvinceInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/ProvinceInfoServiceImpl.java

@@ -58,6 +58,11 @@ public class ProvinceInfoServiceImpl implements ProvinceInfoService {
 		// TODO Auto-generated method stub
 		return provinceInfoDAO.list();
 	}
+
+	@Override
+	public List<ProvinceInfo> findByParentId(Integer parentId){
+		return provinceInfoDAO.findByParentId(parentId);
+	}
 		
 	@Override
 	public Page<ProvinceInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {

+ 11 - 11
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/WorkOrderServiceImpl.java

@@ -426,6 +426,15 @@ public class WorkOrderServiceImpl implements WorkOrderService {
                     installationRequirement.setConstructionLocationName(constructionLocationName);
                 }
             }
+
+            List<String> imageList = new ArrayList<>();
+
+            if (StringUtils.isNotEmpty(installationRequirement.getImage())) {
+                String[] imageArr = installationRequirement.getImage().split(",");
+                imageList = Arrays.asList(imageArr);
+            }
+
+            dto.setImageList(imageList);
         }
 
         dto.setInstallationRequirement(installationRequirement);
@@ -462,15 +471,6 @@ public class WorkOrderServiceImpl implements WorkOrderService {
         dto.setImage(image);
         dto.setCustomerStatusN(customerStatusN);
 
-        List<String> imageList = new ArrayList<>();
-
-        if (StringUtils.isNotEmpty(workOrder.getImage())) {
-            String[] imageArr = workOrder.getImage().split(",");
-            imageList = Arrays.asList(imageArr);
-        }
-
-        dto.setImageList(imageList);
-
         if (StringUtils.isNotEmpty(workOrder.getStatus())) {
             String statusN = dataDictionaryDAO.findNameByCatalogNameAndValue("工单状态", workOrder.getStatus());
             if (StringUtils.isNotEmpty(statusN)) {
@@ -544,13 +544,13 @@ public class WorkOrderServiceImpl implements WorkOrderService {
 
             if ("1".equals(constructionProgress.getSubmitType())) {
                 //客户
-                CustomerInfo customerInfo = customerInfoDAO.get(constructionProgress.getSubmitType());
+                CustomerInfo customerInfo = customerInfoDAO.get(constructionProgress.getSubmitBy());
                 if (customerInfo != null) {
                     constructionProgress.setSubmitByN(customerInfo.getCompanyName());
                 }
             } else if ("2".equals(constructionProgress.getSubmitType())) {
                 //师傅
-                TechnicianInfo technicianInfo1 = technicianInfoDAO.get(constructionProgress.getSubmitType());
+                TechnicianInfo technicianInfo1 = technicianInfoDAO.get(constructionProgress.getSubmitBy());
                 if (technicianInfo1 != null) {
                     constructionProgress.setSubmitByN(technicianInfo1.getRealName());
                 }

+ 88 - 0
common/src/main/java/com/jpsoft/employment/modules/common/utils/WeixinUtil.java

@@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
+import okhttp3.*;
 
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletResponse;
@@ -23,7 +24,12 @@ import java.net.URL;
 import java.security.MessageDigest;
 import java.util.Arrays;
 import java.util.Comparator;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
 
 /**
  * 公众平台通用接口工具类
@@ -39,6 +45,15 @@ public class WeixinUtil {
 	// 获取access_token的接口地址(GET) 限200(次/天),可以在配置文件中修改
 	public static String access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
 
+	private static final String MINI_CODE_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=";
+
+	// OkHttp客户端(全局单例)
+	private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient.Builder()
+			.connectTimeout(10, TimeUnit.SECONDS)
+			.readTimeout(10, TimeUnit.SECONDS)
+			.writeTimeout(10, TimeUnit.SECONDS)
+			.build();
+
 	//获取微信的code
 	public static String code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";
 	public static String getCodeRequest(String appid, String url,String scope){
@@ -472,6 +487,79 @@ public class WeixinUtil {
 		return phone;
 	}
 
+
+
+	public static String generateMiniProgramCode(String pagePath,String scene ,int width,String accessToken) throws IOException {
+
+		// 关键1:page参数格式校验(强制修正常见错误)
+		if (pagePath == null || pagePath.isEmpty()) {
+			throw new IllegalArgumentException("page参数不能为空");
+		}
+		// 移除开头的/
+		pagePath = pagePath.startsWith("/") ? pagePath.substring(1) : pagePath;
+		// 移除.html后缀
+		pagePath = pagePath.endsWith(".html") ? pagePath.replace(".html", "") : pagePath;
+		// 校验是否包含pages开头(最低要求)
+		if (!pagePath.startsWith("pages/")) {
+			throw new IllegalArgumentException("page参数必须以pages/开头,正确格式如:pages/index/index");
+		}
+
+
+		// 2. 构建请求参数(JSON格式)
+		com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject();
+		params.put("scene", scene); // 场景值(非必填,可传递自定义参数)
+		params.put("page", pagePath); // 小程序页面路径(必填)
+		params.put("width", width); // 小程序码宽度
+		params.put("auto_color", false); // 是否自动配置颜色
+		params.put("line_color", new com.alibaba.fastjson.JSONObject().fluentPut("r", 0).fluentPut("g", 0).fluentPut("b", 0)); // 线条颜色(黑色)
+		params.put("is_hyaline", false); // 是否透明
+
+		// 3. 发送POST请求
+		MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+		RequestBody requestBody = RequestBody.create(mediaType,params.toJSONString());
+		Request request = new Request.Builder()
+				.url(MINI_CODE_URL + accessToken)
+				.post(requestBody)
+				.build();
+
+
+
+		try (Response response = OK_HTTP_CLIENT.newCall(request).execute()) {
+			if (!response.isSuccessful()) {
+				throw new IOException("生成小程序码失败:" + response);
+			}
+
+			//通过body()方法获取响应体,而非Body属性
+			ResponseBody body = response.body();
+			if (body == null) {
+				throw new IOException("小程序码接口返回空响应体");
+			}
+
+			String s = body.contentType().type();
+			if (body.contentType().type().equals("image")) {
+				// 响应是图片流,保存为文件
+				byte[] imageBytes;
+				try (InputStream inputStream = body.byteStream();
+				 ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+						byte[] buffer = new byte[1024];
+						int len;
+						while ((len = inputStream.read(buffer)) != -1) {
+							outputStream.write(buffer, 0, len);
+						}
+						imageBytes = outputStream.toByteArray();
+					}
+
+				return Base64.getEncoder().encodeToString(imageBytes);
+			} else {
+				// 响应是JSON,说明有错误
+				String errorMsg = body.string();
+				throw new IOException("生成小程序码失败:" + errorMsg);
+			}
+
+
+		}
+	}
+
 	public static void main(String[] args) {
 		JSONObject sendData = JSONObject.fromObject("{\"first\":{\"value\":\"尊敬的用户,本次充电已结束!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"地下停车场充电桩\",\"color\":\"#173177\"},\"keyword2\":{\"value\":\"2022-03-08 17:37:50至2022-03-08 17:44:41\",\"color\":\"#173177\"},\"keyword3\":{\"value\":\"6分钟\"},\"keyword4\":{\"value\":\"0.25元(账户余额:98.5元)\"}}");
 

+ 1 - 0
common/src/main/resources/mapper/base/AboutUs.xml

@@ -149,6 +149,7 @@
 			select * from base_about_us
 		]]>
 		<where>
+			del_flag=false
 			<if test="searchParams.id != null">
 				and ID_ like #{searchParams.id}
 			</if>

+ 3 - 0
common/src/main/resources/mapper/base/Feedback.xml

@@ -104,6 +104,9 @@
 			<if test="searchParams.companyId != null">
 				and company_id = #{searchParams.companyId}
 			</if>
+			<if test="searchParams.technicianId != null">
+				and technician_id = #{searchParams.technicianId}
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 12 - 0
common/src/main/resources/mapper/base/ProvinceInfo.xml

@@ -74,6 +74,18 @@
 	<select id="list" resultMap="ProvinceInfoMap">
 		select * from base_province_info
 	</select>
+	<select id="findByParentId" resultMap="ProvinceInfoMap">
+		select * from base_province_info
+		<where>
+			del_flag=false
+			<if test="parentId != null">
+				and parent_id = #{parentId}
+			</if>
+			<if test="parentId == null">
+				and parent_id is null
+			</if>
+		</where>
+	</select>
 	<select id="search" parameterType="hashmap" resultMap="ProvinceInfoMap">
 		<![CDATA[
 			select * from base_province_info

+ 7 - 1
common/src/main/resources/mapper/base/TechnicianInfo.xml

@@ -248,7 +248,13 @@
 				and ID_ like #{searchParams.id}
 			</if>
 			<if test="searchParams.name != null">
-				and ID_ like #{searchParams.name}
+				and name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.isVerified != null">
+				and is_verified = #{searchParams.isVerified}
+			</if>
+			<if test="searchParams.businessScope != null">
+				and business_scope = #{searchParams.businessScope}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 1 - 1
web/src/main/java/com/jpsoft/employment/modules/base/controller/ProvinceInfoController.java

@@ -18,7 +18,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 @RestController
-@RequestMapping("/provinceInfo")
+@RequestMapping("/base/provinceInfo")
 public class ProvinceInfoController {
     private Logger logger = LoggerFactory.getLogger(getClass());
 

+ 15 - 8
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/CustomerInfoApiController.java

@@ -113,7 +113,7 @@ public class CustomerInfoApiController {
                 }
             }
 
-            searchParams.put("status", "5");
+            searchParams.put("status", "0");
 
             Map completedNumMap = workOrderService.countByCustomerId(searchParams);
 
@@ -650,7 +650,7 @@ public class CustomerInfoApiController {
     @ApiOperation(value = "师傅列表")
     @RequestMapping(value = "technicianPageList", method = RequestMethod.POST)
     public MessageResult<Map> technicianPageList(
-            String name, String status, String token,
+            String name, String businessScope,String token,
             @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
             @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
             HttpServletRequest request) {
@@ -666,14 +666,17 @@ public class CustomerInfoApiController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("create_time", "desc"));
 
-        if (StringUtils.isNotEmpty(status)) {
-            searchParams.put("status", status);
-        }
+        //只查询已认证过的师傅
+        searchParams.put("isVerified", true);
 
         if (StringUtils.isNotEmpty(name)) {
             searchParams.put("name", "%" + name + "%");
         }
 
+        if (StringUtils.isNotEmpty(businessScope)) {
+            searchParams.put("businessScope", businessScope);
+        }
+
 
         Page<TechnicianInfo> page = technicianInfoService.pageSearchMobile(searchParams, pageIndex, pageSize, true, sortList);
 
@@ -876,7 +879,7 @@ public class CustomerInfoApiController {
 
     @ApiOperation(value = "问题反馈列表")
     @RequestMapping(value = "feedbackPageList", method = RequestMethod.POST)
-    public MessageResult<Map> feedbackPageList(
+    public MessageResult<Map> feedbackPageList(String type,
             @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
             @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
             HttpServletRequest request) {
@@ -892,8 +895,12 @@ public class CustomerInfoApiController {
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("create_time", "desc"));
 
-        searchParams.put("companyId",subject);
-
+        if(type.equals("1")){
+            searchParams.put("companyId",subject);
+        }
+        else if(type.equals("2")){
+            searchParams.put("technicianId",subject);
+        }
 
         Page<Feedback> page = feedbackService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 

+ 78 - 0
web/src/main/java/com/jpsoft/employment/modules/mobile/controller/ProvinceInfoApiController.java

@@ -0,0 +1,78 @@
+package com.jpsoft.employment.modules.mobile.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.employment.modules.base.entity.ProvinceInfo;
+import com.jpsoft.employment.modules.base.service.ProvinceInfoService;
+import com.jpsoft.employment.modules.common.dto.MessageResult;
+import com.jpsoft.employment.modules.common.dto.Sort;
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/mobile/provinceInfo")
+public class ProvinceInfoApiController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private ProvinceInfoService provinceInfoService;
+
+
+    @ApiOperation(value="获取地区JSON数据")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    public MessageResult<List<Map>> list(String token,HttpServletRequest request){
+        String subject = (String)request.getAttribute("subject");
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<List<Map>> msgResult = new MessageResult<>();
+
+        List<ProvinceInfo> provinceInfoList = provinceInfoService.findByParentId(null);
+
+        List<Map> mapList = new ArrayList<>();
+
+        for (ProvinceInfo provinceInfo:provinceInfoList){
+            Map map = new HashMap();
+            map.put("id",provinceInfo.getId());
+            map.put("name",provinceInfo.getName());
+            map.put("parentId",provinceInfo.getParentId());
+
+            List<ProvinceInfo> childrenList = provinceInfoService.findByParentId(provinceInfo.getId());
+
+            List<Map> childMapList = new ArrayList<>();
+
+            for (ProvinceInfo child:childrenList) {
+                Map childMap = new HashMap();
+                childMap.put("id",child.getId());
+                childMap.put("name",child.getName());
+                childMap.put("parentId",child.getParentId());
+
+                childMapList.add(childMap);
+            }
+
+            map.put("children",childMapList);
+
+            mapList.add(map);
+        }
+
+        msgResult.setResult(true);
+        msgResult.setData(mapList);
+
+        return msgResult;
+    }
+
+}

+ 27 - 4
web/src/main/java/com/jpsoft/employment/modules/wechat/controller/WxMiniController.java

@@ -8,16 +8,18 @@ import com.jpsoft.employment.modules.wechat.entity.SessionKey;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.ValueOperations;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.concurrent.TimeUnit;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
 
 @Slf4j
 @RequestMapping("/wechatMini")
@@ -85,4 +87,25 @@ public class WxMiniController {
             return new MessageResult(false, "系统错误", "", 500);
         }
     }
+
+
+    @ApiOperation(value = "生成小程序二维码图片")
+    @PostMapping(value = "generateQrCode")
+    public MessageResult generateQrCode(String pagePath,String scene) {
+        try {
+
+            String accessToken = (String)valueOperations.get("accessToken");
+            if(StringUtils.isEmpty(accessToken)){
+                AccessToken token = WeixinUtil.getAccessToken(wxMini.getAppId(), wxMini.getAppSecret());
+                accessToken = token.getToken();
+                valueOperations.set("accessToken",token.getToken(),2, TimeUnit.HOURS);
+            }
+            String base64Str = WeixinUtil.generateMiniProgramCode(pagePath,scene,430,accessToken);
+
+            return new MessageResult(true, "成功", base64Str, 200);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return new MessageResult(false, "系统错误", "", 500);
+        }
+    }
 }

+ 6 - 6
web/src/main/resources/application-dev.yml

@@ -6,13 +6,13 @@ server:
 spring:
   datasource:
     #开发环境
-     url: jdbc:log4jdbc:mysql://192.168.33.20:3306/water-tank-installation?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
-     username: root
-     password: jpsoft2016
-    #正式环境
-#     url: jdbc:log4jdbc:mysql://127.0.0.1:3306/water-tank-installation?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+#     url: jdbc:log4jdbc:mysql://192.168.33.20:3306/water-tank-installation?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 #     username: root
-#     password: 123456
+#     password: jpsoft2016
+    #正式环境
+      url: jdbc:log4jdbc:mysql://39.97.193.160:3306/water-tank-installation?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+      username: root
+      password: MySql@123456
   devtools:
     add-properties: false
     restart: