rk
10 小时以前 42ad8dcebd40baa9f7933fcb9b5308fdb5756085
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/JkCabinetGridServiceImpl.java
@@ -7,6 +7,9 @@
import com.doumee.core.dingTalk.DingTalkStream;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.haikang.model.HKConstants;
import com.doumee.core.jiandaoyun.api.arch.DeptApiClient;
import com.doumee.core.jiandaoyun.api.jdy.FormDataApiClient;
import com.doumee.core.jiandaoyun.model.form.FormDataCreateParam;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.dao.business.*;
@@ -256,6 +259,7 @@
                //更新钥匙柜信息
                jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda()
                        .set(JkCabinetGrid::getKeyId,null)
                        .set(JkCabinetGrid::getActualLable,null)
                        .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime())
                        .eq(JkCabinetGrid::getId,model.getId()));
                JkKeys keysModel = jkKeysMapper.selectById(model.getKeyId());
@@ -274,6 +278,7 @@
            if(CollectionUtils.isNotEmpty(jkCabinetGridList)){
                jkCabinetGridMapper.update(new UpdateWrapper<JkCabinetGrid>().lambda()
                        .set(JkCabinetGrid::getKeyId,null)
                        .set(JkCabinetGrid::getActualLable,null)
                        .set(JkCabinetGrid::getEditDate, DateUtil.getCurrDateTime())
                        .in(JkCabinetGrid::getId,jkCabinetGridList.stream().map(i->i.getId()).collect(Collectors.toList())));
                List<Integer> keyIdList = jkCabinetGridList.stream().filter(i->Objects.nonNull(i.getKeyId())).map(i->i.getKeyId()).collect(Collectors.toList());
@@ -485,6 +490,14 @@
                                .set(JkKeys::getStatus,dto.getKeyStatus())
                                .eq(JkKeys::getId,jkKeys.getId())
                        );
                        if(Constants.equalsInteger(dto.getKeyStatus(),Constants.ONE)&&
                                (StringUtils.isBlank(jkCabinetGrid.getActualLable())||!StringUtils.equals(jkCabinetGrid.getActualLable(),jkKeys.getRfidLable()))){
                            //更新钥匙实际编码
                            jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>().lambda()
                                    .set(JkCabinetGrid::getActualLable,jkKeys.getRfidLable())
                                    .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
                            );
                        }
                    }
                }
            }
@@ -715,9 +728,7 @@
                            if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){
                                for (String ddUserId:ddUserIdList) {
                                    this.getJDYData(warningEvent,ddUserId,
                                            systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(),
                                            systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(),
                                            systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode()
                                            systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.JDY_ENTRY_ID).getCode()
                                    );
                                }
                            }
@@ -758,34 +769,44 @@
     * 简道云消息推送 定制
     * @param warningEvent
     * @param ddUserId 接收人 钉钉主键
     * @param jdyApiKey  简单云APIKEY
     * @param appid  应用ID
     * @param entryId 表单ID
     * @throws IOException
     */
    public void getJDYData(WarningEvent warningEvent,String ddUserId,String jdyApiKey,String appid,String entryId) throws IOException {
        Map<String,Object> map = new HashMap<>();
        map.put("app_id",appid);
        map.put("entry_id",entryId);
        map.put("is_start_workflow","false");
        map.put("is_start_trigger","true");
        map.put("data",this.getJdyChildData(warningEvent,ddUserId));
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(map));//"{\"data\":{\"notice_time\":{\"value\":\"2025-12-23 04:56:29\"},\"title\":{\"value\":\"跨越生产线\"},\"user\":{\"value\":\"1568490244651036\"},\"content\":{\"value\":\"跨越生产线-芜湖物流中心北围墙过道东\"},\"notice_type\":{\"value\":\"跨越生产线\"}},\"is_start_trigger\":\"true\",\"app_id\":\"6909d0fbdb93b068192dc4a9\",\"entry_id\":\"694a19ecf57e071788efc20b\",\"is_start_workflow\":\"false\"}");
        log.error("简道云发送通知请求信息" + JSONObject.toJSONString(map));
        Request request = new Request.Builder()
                .url("https://api.jiandaoyun.com/api/v5/app/entry/data/create")
                .method("POST", body)
                .addHeader("Authorization", "Bearer "+jdyApiKey)
                .addHeader("Content-Type", "application/json")
                .build();
        Response response = client.newCall(request).execute();
        log.error("简道云发送通知返回信息" + JSONObject.toJSONString(response));
    public void getJDYData(WarningEvent warningEvent,String ddUserId , String entryId)  {
        try {
            log.error("简道云发送通知返回信息开始"  );
            FormDataApiClient apiClient = new FormDataApiClient(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_KEY).getCode()
                    ,systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode());
            FormDataCreateParam param  =new FormDataCreateParam();
            param.setData(this.getJdyChildData(warningEvent,ddUserId));
            param.setApp_id(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_APPID).getCode());
            param.setEntry_id(entryId);
            param.setIs_start_trigger(false);
            param.setIs_start_trigger(true);
            Map<String, Object>  response =  apiClient.singleDataCreate(param,apiClient.getDefaultVersion());
            /*
             Map<String,Object> map = new HashMap<>();
            map.put("app_id",appid);
            map.put("entry_id",entryId);
            map.put("is_start_workflow","false");
            map.put("is_start_trigger","true");
            map.put("data",this.getJdyChildData(warningEvent,ddUserId));
            OkHttpClient client = new OkHttpClient().newBuilder()
                    .build();
            MediaType mediaType = MediaType.parse("application/json");
            RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(map));//"{\"data\":{\"notice_time\":{\"value\":\"2025-12-23 04:56:29\"},\"title\":{\"value\":\"跨越生产线\"},\"user\":{\"value\":\"1568490244651036\"},\"content\":{\"value\":\"跨越生产线-芜湖物流中心北围墙过道东\"},\"notice_type\":{\"value\":\"跨越生产线\"}},\"is_start_trigger\":\"true\",\"app_id\":\"6909d0fbdb93b068192dc4a9\",\"entry_id\":\"694a19ecf57e071788efc20b\",\"is_start_workflow\":\"false\"}");
            log.error("简道云发送通知请求信息" + JSONObject.toJSONString(map));
            Request request = new Request.Builder()
                    .url(systemDictDataBiz.queryByCode(Constants.JDY_CONFIG, Constants.JDY_API_HOST).getCode()+"v5/app/entry/data/create")
                    .method("POST", body)
                    .addHeader("Authorization", "Bearer "+jdyApiKey)
                    .addHeader("Content-Type", "application/json")
                    .build();
            Response response = client.newCall(request).execute();*/
            log.error("简道云发送通知返回信息" + JSONObject.toJSONString(response));
        }catch (Exception e){
            log.error("简道云发送通知返回信息异常:" + e.getMessage());
        }
    }
@@ -1105,9 +1126,7 @@
                        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ddUserIdList)){
                            for (String ddUserId:ddUserIdList) {
                                this.getJDYData(warningEvent,ddUserId,
                                        systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.API_KEY).getCode(),
                                        systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.APPID).getCode(),
                                        systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.ENTRY_ID).getCode()
                                        systemDictDataBiz.queryByCode(Constants.JDY_CONFIG,Constants.JDY_ENTRY_ID).getCode()
                                );
                            }
@@ -1135,5 +1154,53 @@
    @Override
    public void syncGridData(SyncCabinetDTO dto){
        if(Objects.isNull(dto)
                ||StringUtils.isBlank(dto.getCode())
                || CollectionUtils.isEmpty(dto.getGridDTOList())){
            return;
        }
        List<JkCabinetGrid> jkCabinetGridList =
                jkCabinetGridMapper.selectJoinList(JkCabinetGrid.class, new MPJLambdaWrapper<JkCabinetGrid>()
                        .selectAll(JkCabinetGrid.class)
                        .selectAs(JkKeys::getCarCode,JkCabinetGrid::getCarCode)
                        .selectAs(JkKeys::getRfidLable,JkCabinetGrid::getKeyCode)
                        .selectAs(JkKeys::getStatus,JkCabinetGrid::getKeyStatus)
                        .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetGrid::getKeyId)
                        .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetGrid::getCabinetId)
                        .eq(JkCabinet::getCode,dto.getCode())
                        .eq(JkCabinetGrid::getIsdeleted,Constants.ZERO)
                        .isNotNull(JkCabinetGrid::getBoardCode)
                        .isNotNull(JkCabinetGrid::getChannelCode)
                        .orderByAsc(JkCabinetGrid::getCode)
                );
        if(CollectionUtils.isEmpty(jkCabinetGridList)){
            return;
        }
        List<SyncGridDTO> gridDTOList = dto.getGridDTOList();
        for (JkCabinetGrid jkCabinetGrid:jkCabinetGridList) {
            List<SyncGridDTO> gridSyncList = gridDTOList.stream().filter(i->StringUtils.isNotBlank(i.getBoardCode())&&
                    StringUtils.isNotBlank(i.getChannelCode())&&StringUtils.isNotBlank(i.getActualLable())&&i.getBoardCode().equals(jkCabinetGrid.getBoardCode())
                    && i.getChannelCode().equals(jkCabinetGrid.getChannelCode())).collect(Collectors.toList());
            if(CollectionUtils.isEmpty(gridSyncList)){
                continue;
            }
            SyncGridDTO syncGridDTO = gridSyncList.get(Constants.ZERO);
            if(StringUtils.isBlank(jkCabinetGrid.getKeyCode())
                    || (!jkCabinetGrid.getKeyCode().equals(syncGridDTO.getActualLable())
                    && !jkCabinetGrid.getActualLable().equals(syncGridDTO.getActualLable()))){
                //更新数据 标记对应code
                jkCabinetGridMapper.update(null,new UpdateWrapper<JkCabinetGrid>().lambda()
                        .set(JkCabinetGrid::getActualLable,syncGridDTO.getActualLable())
                        .eq(JkCabinetGrid::getId,jkCabinetGrid.getId())
                );
            }
        }
    }
}