package com.product.face.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.google.common.collect.Lists; import com.product.admin.entity.FaceListEntity; import com.product.admin.service.SystemFaceService; import com.product.common.lang.StringUtils; import com.product.core.cache.util.RedisUtil; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; import com.product.core.service.support.AbstractBaseService; import com.product.face.config.ErrorCode; import com.product.face.config.FaceConst; import com.product.face.entity.TableColumn; import com.product.face.util.FaceUtil; import com.product.util.BaseUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Author cheng * @Date 2023/5/16 18:36 * @Desc 表单使用 */ @Service public class FaceApplyService extends AbstractBaseService { @Resource private SystemFaceService systemFaceService; @Resource private FaceCacheService faceCacheService; public Object getFaceListConf(FieldSetEntity fse) { String faceUuid = fse.getString(FaceConst.FIELD_FACE_UUID); String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER); if (StringUtils.isEmpty(faceNumber) && StringUtils.isEmpty(faceUuid)) { throw new BaseException(ErrorCode.REQUEST_PARAM_ERROR); } if (!StringUtils.isEmpty(faceUuid) && StringUtils.isEmpty(faceNumber)) { return systemFaceService.getFaceFieldList(faceUuid); } final String redisKey = FaceConst.FACE_LIST_KEY + ":face-number" + faceNumber; if (RedisUtil.exists(redisKey)) { return RedisUtil.get(redisKey); } return null; } /** * 录入表单获取表单配置 * * @param fse * @return * @throws BaseException */ public String getFaceFormConfig(FieldSetEntity fse) throws BaseException { String faceNumber = fse.getString(FaceConst.FIELD_FACE_NUMBER); if (StringUtils.isEmpty(faceNumber)) { throw new BaseException(ErrorCode.REQUEST_PARAM_ERROR); } //根据表单号查询 FieldSetEntity faceConf = getBaseDao().getFieldSetByFilter(FaceConst.TABLE_FACE_CONFIG, "face_number=?", new Object[]{faceNumber}, true); DataTableEntity fieldPropertyDt = faceConf.getSubDataTable(FaceConst.TABLE_FACE_FIELD_CONTROL_PROPERTY); if (DataTableEntity.isEmpty(fieldPropertyDt)) { throw new BaseException(ErrorCode.GET_FACE_CONFIG_FAIL); } List faceControlList = FaceUtil.getFaceControlList(fieldPropertyDt); Map other = new HashMap<>(); other.put("drawingList", faceControlList); faceConf.getSubData().clear(); return BaseUtil.success(faceConf, other); } }