فهرست منبع

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 سال پیش
والد
کامیت
0c6f2b2588

+ 29 - 2
common/src/main/java/com/jpsoft/smart/modules/lapi/service/impl/LapiServiceImpl.java

@@ -187,6 +187,32 @@ public class LapiServiceImpl implements ILapiService {
         return faceDbId;
     }
 
+
+    public Boolean isExistFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception {
+        if (StringUtils.isBlank(companyName)) {
+            throw new Exception("公司名称为空");
+        }
+        String faceDbId = "";
+        JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
+        JSONObject dataJson = jsonObject.getJSONObject("Response");
+        JSONObject response = LApiUtil.getResponse(dataJson);
+        List listData = response.getJSONArray("LibList");
+        if (listData.size() <= 0) {
+            //
+            return false;
+        }
+        for (int i = 0; i < listData.size(); i++) {
+            JSONObject jsonObject1 = (JSONObject) JSONArray.toJSON(listData.get(i));
+            String name = jsonObject1.getString("Name");
+            if (StringUtils.isNotBlank(name) && companyName.equals(name)) {
+                return true;
+            }
+        }
+        return false;
+
+
+    }
+
     @Override
     public List<LapiMsgResult> deletePerson(Long id) throws Exception {
 
@@ -340,8 +366,8 @@ public class LapiServiceImpl implements ILapiService {
                 if (deviceInfo == null) {
                     throw new Exception("设备不存在");
                 }
-                String companyLibId = getFaceDbId(deviceInfo, companyInfo.getName());
-                if (StringUtils.isNotBlank(companyLibId) && !companyLibId.equals(deviceInfo.getDefaultFaceLibraryId())) {
+                Boolean isExist = isExistFaceDbId(deviceInfo, companyInfo.getName());
+                if (isExist) {
                     throw new Exception("已有人脸库不可重复创建");
                 }
                 HashMap map = new HashMap();
@@ -358,6 +384,7 @@ public class LapiServiceImpl implements ILapiService {
                 HashMap dataMap = new HashMap<>();
                 dataMap.put("CompanyId", companyInfoId);
                 dataMap.put("CompanyName", companyInfo.getName());
+                dataMap.put("deviceId",deviceInfoId);
                 dataMap.put("LibraryId", response.getString("ID"));
                 lapiResult.setData(dataMap);
 

+ 6 - 2
common/src/main/resources/mapper/base/PersonCompany.xml

@@ -80,8 +80,12 @@ id_,person_id,company_id,del_flag,create_by,create_time,update_by,update_time		f
 			select * from base_person_company
 		]]>
 		<where>
-			<if test="searchParams.id != null">
-				and ID_ like #{searchParams.id}
+			and del_flag = false
+			<if test="searchParams.personId != null">
+				and person_id = #{searchParams.personId}
+			</if>
+			<if test="searchParams.companyId != null">
+				and company_id = #{searchParams.companyId}
 			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">

+ 79 - 1
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonCompanyController.java

@@ -71,6 +71,54 @@ public class PersonCompanyController {
         return msgResult;
     }
 
+    @ApiOperation(value="批量添加信息")
+    @PostMapping("batchAdd")
+    public MessageResult<Integer> batchAdd(@RequestBody String personId,
+                                           @RequestBody List<String> companyIds,
+                                           @RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            MessageResult<List<PersonCompany>> list = list(personId,null,subject);
+            for(PersonCompany personCompany : list.getData()){
+                personCompanyService.delete(personCompany.getId());
+            }
+
+            for (String companyId : companyIds) {
+                PersonCompany personCompany = new PersonCompany();
+
+                personCompany.setId(UUID.randomUUID().toString());
+                personCompany.setPersonId(Long.valueOf(personId));
+                personCompany.setCompanyId(companyId);
+                personCompany.setDelFlag(false);
+                personCompany.setCreateBy(subject);
+                personCompany.setCreateTime(new Date());
+
+                personCompanyService.insert(personCompany);
+
+                affectCount++;
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
     @ApiOperation(value="获取信息")
     @GetMapping("edit/{id}")
     public MessageResult<PersonCompany> edit(@PathVariable("id") String id){
@@ -193,7 +241,7 @@ public class PersonCompanyController {
         return msgResult;
     }
 
-    @ApiOperation(value="列表")
+    @ApiOperation(value="分页列表")
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
@@ -222,4 +270,34 @@ public class PersonCompanyController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    public MessageResult<List<PersonCompany>> list(
+            @RequestParam(value="personId",defaultValue="") String personId,
+            @RequestParam(value="companyId",defaultValue="") String companyId,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<List<PersonCompany>> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+        if (StringUtils.isNotEmpty(personId)) {
+            searchParams.put("personId", personId);
+        }
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId", companyId);
+        }
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        Page<PersonCompany> page = personCompanyService.pageSearch(searchParams,1,1000,false,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(page.getResult());
+
+        return msgResult;
+    }
 }

+ 6 - 1
web/src/main/resources/application-production.yml

@@ -53,4 +53,9 @@ wx:
     subMchId: 1505070291
     mchKey: jpsoft11111111111111111111111111
     notifyUrl: http://wisdomhouse.sudaonline.net/wxPay/payNotify
-    ip: 101.37.31.116
+    ip: 101.37.31.116
+    token: weixin
+    tokenUrl: "https://api.weixin.qq.com/cgi-bin/token"
+    refreshOAuth2TokenUrl: "https://api.weixin.qq.com/sns/oauth2/refresh_token"
+    createQrCodeUrl: "https://api.weixin.qq.com/cgi-bin/qrcode/create"
+    showQrCodeUrl: "https://mp.weixin.qq.com/cgi-bin/showqrcode"