|
@@ -28,6 +28,7 @@ import com.boman.system.api.RemoteUserService;
|
|
|
import com.boman.web.core.domain.ActionType;
|
|
|
import com.boman.web.core.domain.RowResult;
|
|
|
import com.boman.web.core.domain.TableContext;
|
|
|
+import com.boman.web.core.service.common.ICommonService;
|
|
|
import com.boman.web.core.service.delete.IBaseDeleteService;
|
|
|
import com.boman.web.core.service.save.IBaseSaveService;
|
|
|
import com.boman.web.core.service.select.IBaseSelectService;
|
|
@@ -100,8 +101,6 @@ public class TableServiceCmdService {
|
|
|
private RemoteJflowProcessService remoteJflowProcessService;
|
|
|
@Resource
|
|
|
private RemoteWechatService remoteWechatService;
|
|
|
- @Resource
|
|
|
- private RemoteUserService remoteUserService;
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
|
|
@@ -132,7 +131,7 @@ public class TableServiceCmdService {
|
|
|
if (ActionType.INSERT.equals(context.getActionType())) {
|
|
|
List<GenTableColumn> columns = context.getColumns();
|
|
|
Long maxId = IdUtils.getMaxId(dto.getTable(), pkName);
|
|
|
- packUpdateByAndTime(columns, commitData, new Timestamp(System.currentTimeMillis()), true);
|
|
|
+ packUpdateByAndTime(columns, commitData, true);
|
|
|
// 处理默认值
|
|
|
handlerDefaultValue(commitData, columns);
|
|
|
// 如果有单据、按照单据编号规则
|
|
@@ -177,6 +176,8 @@ public class TableServiceCmdService {
|
|
|
boolean primaryTableUpdate = !ltZero(dto.getObjId());
|
|
|
recursionAllChildrenFromDto(dto, result);
|
|
|
|
|
|
+ List<FormDataDto> child = new ArrayList<>();
|
|
|
+
|
|
|
List<AjaxResult> resultList = new ArrayList<>(result.size());
|
|
|
Map<String, Long> tableNameIdMap = new HashMap<>(result.size());
|
|
|
AjaxResult ajaxResult;
|
|
@@ -189,39 +190,57 @@ public class TableServiceCmdService {
|
|
|
TableServiceCmdService proxy = (TableServiceCmdService) AopContext.currentProxy();
|
|
|
proxy.putFkValue(tableNameIdMap, formDataDto, optPrimaryTable, primaryTableUpdate);
|
|
|
String tableName = formDataDto.getTable();
|
|
|
- ajaxResult = objectSave(formDataDto);
|
|
|
- if (AjaxResult.checkFail(ajaxResult)) {
|
|
|
- throw new RuntimeException(String.format("保存失败, 表名为: %s ", tableName));
|
|
|
- }
|
|
|
+ // 暂且如此处理
|
|
|
+ if (optPrimaryTable) {
|
|
|
+ ajaxResult = objectSave(formDataDto);
|
|
|
+ if (AjaxResult.checkFail(ajaxResult)) {
|
|
|
+ throw new RuntimeException(String.format("保存失败, 表名为: %s ", tableName));
|
|
|
+ }
|
|
|
|
|
|
- Long fkId = (Long) ajaxResult.get(AjaxResult.DATA_TAG);
|
|
|
- if (null == fkId || NumberUtils.ltEqZero(fkId)) {
|
|
|
- throw new RuntimeException(String.format("保存失败, 表名为: %s ,主表id: %s", tableName, fkId));
|
|
|
+ Long fkId = (Long) ajaxResult.get(AjaxResult.DATA_TAG);
|
|
|
+ if (null == fkId || NumberUtils.ltEqZero(fkId)) {
|
|
|
+ throw new RuntimeException(String.format("保存失败, 表名为: %s ,主表id: %s", tableName, fkId));
|
|
|
+ }
|
|
|
+
|
|
|
+ tableNameIdMap.put(tableName, fkId);
|
|
|
+ resultList.add(ajaxResult);
|
|
|
+ } else {
|
|
|
+ child.add(formDataDto);
|
|
|
}
|
|
|
|
|
|
- tableNameIdMap.put(tableName, fkId);
|
|
|
- resultList.add(ajaxResult);
|
|
|
+ // 小程序推送消息 参数设置
|
|
|
+ putAppletParamValue(dto.getTable(), receiveUserIds, messageInfo, formDataDto, optPrimaryTable);
|
|
|
+ }
|
|
|
|
|
|
- if ("boman_message".equals(dto.getTable())) {
|
|
|
- if (optPrimaryTable) {
|
|
|
- messageInfo.put("thing1", formDataDto.getFixedData().getString("message_title"));
|
|
|
- messageInfo.put("thing2", formDataDto.getFixedData().getString("send_user_name"));
|
|
|
- messageInfo.put("thing4", formDataDto.getFixedData().getString("message_title"));
|
|
|
- messageInfo.put("thing5", formDataDto.getFixedData().getString("send_user_name"));
|
|
|
- } else {
|
|
|
- receiveUserIds.add(formDataDto.getFixedData().getLong("receive_user_id"));
|
|
|
- }
|
|
|
- }
|
|
|
+ List<JSONObject> dataList = new ArrayList<>();
|
|
|
+ for (FormDataDto formDataDto : child) {
|
|
|
+ JSONObject fixedData = formDataDto.getFixedData();
|
|
|
+ dataList.add(fixedData);
|
|
|
}
|
|
|
|
|
|
- // 获取发文相关信息
|
|
|
- if ("boman_message".equals(dto.getTable())) {
|
|
|
+ saveService.insertRelList("boman_message_receive", dataList);
|
|
|
+
|
|
|
+ // 小程序发送推送消息
|
|
|
+ sendMsgByApplet(dto.getTable(), receiveUserIds, messageInfo);
|
|
|
+
|
|
|
+ return AjaxResult.success(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: 小程序发送推送消息
|
|
|
+ *
|
|
|
+ * @param tableName tableName
|
|
|
+ * @param receiveUserIds 需要发送的userIds
|
|
|
+ * @param messageInfo 发送消息的参数
|
|
|
+ */
|
|
|
+ private void sendMsgByApplet(String tableName, List<Long> receiveUserIds, Map<String, Object> messageInfo) {
|
|
|
+ if ("boman_message".equals(tableName)) {
|
|
|
WxMsgDto wxMsgDto = new WxMsgDto();
|
|
|
wxMsgDto.setIds(receiveUserIds);
|
|
|
wxMsgDto.setParams(messageInfo);
|
|
|
LOGGER.info("收文人id:{}, 发送数据: {}", receiveUserIds, messageInfo);
|
|
|
remoteWechatService.pushMsg(wxMsgDto);
|
|
|
- List<Long> userIds = new ArrayList<>(new HashSet(receiveUserIds));
|
|
|
+ /*List<Long> userIds = new ArrayList<>(new HashSet(receiveUserIds));
|
|
|
AjaxResult userList = remoteUserService.selectUserByIds(userIds);
|
|
|
List<Map<String, Object>> users = (List<Map<String, Object>>) userList.get("data");
|
|
|
String accessKeyId = "LTAI5tNA2fcBJH6EWRH6Pxr6";
|
|
@@ -239,7 +258,7 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- /*if (StringUtils.isNotBlank(sb.toString())) {
|
|
|
+ if (StringUtils.isNotBlank(sb.toString())) {
|
|
|
try {
|
|
|
String phoneNumbers = sb.toString().substring(0, sb.toString().length() - 1);
|
|
|
SendSmsUtils.sendSms(phoneNumbers, templateParam, accessKeyId, accessKeySecret, signName, templateCode);
|
|
@@ -248,7 +267,28 @@ public class TableServiceCmdService {
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
- return AjaxResult.success(resultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 功能描述: 小程序发送推送消息的参数
|
|
|
+ *
|
|
|
+ * @param tableName tableName
|
|
|
+ * @param receiveUserIds 收件人
|
|
|
+ * @param messageInfo 小程序推送单数
|
|
|
+ * @param formDataDto formDataDto
|
|
|
+ * @param optPrimaryTable 是否是主表
|
|
|
+ */
|
|
|
+ private void putAppletParamValue(String tableName, List<Long> receiveUserIds, Map<String, Object> messageInfo, FormDataDto formDataDto, boolean optPrimaryTable) {
|
|
|
+ if ("boman_message".equals(tableName)) {
|
|
|
+ if (optPrimaryTable) {
|
|
|
+ messageInfo.put("thing1", formDataDto.getFixedData().getString("message_title"));
|
|
|
+ messageInfo.put("thing2", formDataDto.getFixedData().getString("send_user_name"));
|
|
|
+ messageInfo.put("thing4", formDataDto.getFixedData().getString("message_title"));
|
|
|
+ messageInfo.put("thing5", formDataDto.getFixedData().getString("send_user_name"));
|
|
|
+ } else {
|
|
|
+ receiveUserIds.add(formDataDto.getFixedData().getLong("receive_user_id"));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|