old mode 100644
new mode 100755
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.businessTableHis.BusinessTableHisDto; |
| | | import com.java110.dto.order.OrderDto; |
| | | import com.java110.dto.order.OrderItemDto; |
| | | import com.java110.order.dao.ICenterServiceDAO; |
| | | import com.java110.order.smo.IAsynNotifySubService; |
| | | import com.java110.order.smo.IOIdServiceSMO; |
| | | import com.java110.utils.cache.BusinessTableHisCache; |
| | | import com.java110.utils.constant.StatusConstant; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private IAsynNotifySubService asynNotifySubServiceImpl; |
| | | |
| | | |
| | | @Override |
| | |
| | | return params; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成insert语句 |
| | | * |
| | |
| | | sql = "insert into " + orderItemDto.getActionObj() + " "; |
| | | param = new JSONObject(); |
| | | JSONObject keyValue = preValues.getJSONObject(preValueIndex); |
| | | if (keyValue.isEmpty()) { |
| | | continue; |
| | | } |
| | | String keySql = "( "; |
| | | String valueSql = " values ("; |
| | | for (String key : keyValue.keySet()) { |
| | |
| | | param = new JSONObject(); |
| | | JSONObject keyValue = preValues.getJSONObject(preValueIndex); |
| | | JSONObject afterKeyValue = afterValues.getJSONObject(preValueIndex); |
| | | if (keyValue.isEmpty() || afterKeyValue.isEmpty()) { |
| | | continue; |
| | | } |
| | | String whereSql = " where 1=1 "; |
| | | for (String key : keyValue.keySet()) { |
| | | sql += (key + "=" + keyValue.getString(key) + ","); |
| | | if ("''".equals(afterKeyValue.getString(key))) { //条件中不拼写 为空的结果 |
| | | continue; |
| | | } |
| | | whereSql += (" and " + key + " = " + afterKeyValue.getString(key)); |
| | | } |
| | | if (sql.endsWith(",")) { |
| | | sql = sql.substring(0, sql.length() - 1); |
| | | } |
| | | |
| | | if (sql.endsWith(whereSql)) { // 说明没有条件 不做回退 回退整个表是有问题的 |
| | | continue; |
| | | } |
| | | |
| | | sql += whereSql; |
| | |
| | | |
| | | JSONObject logTextObj = JSONObject.parseObject(logText); |
| | | JSONArray afterValues = logTextObj.getJSONArray("afterValue"); |
| | | String whereSql = " where 1=1 "; |
| | | for (int preValueIndex = 0; preValueIndex < afterValues.size(); preValueIndex++) { |
| | | sql = "delete from " + orderItemDto.getActionObj() + " where 1=1 "; |
| | | sql = "delete from " + orderItemDto.getActionObj() + whereSql; |
| | | param = new JSONObject(); |
| | | JSONObject keyValue = afterValues.getJSONObject(preValueIndex); |
| | | if (keyValue.isEmpty()) { |
| | | continue; |
| | | } |
| | | for (String key : keyValue.keySet()) { |
| | | if (StringUtil.isEmpty(keyValue.getString(key))) { |
| | | if (!StringUtil.isEmpty(keyValue.getString(key))) { |
| | | sql += (" and " + key + "=" + keyValue.getString(key)); |
| | | } |
| | | } |
| | | if (sql.endsWith(whereSql)) { // 说明没有条件 不做回退 回退整个表是有问题的 |
| | | continue; |
| | | } |
| | | sql += " limit 1";//防止程序异常删除 尴尬 根据业务场景 没有需要删除多余 1条的场景 |
| | | param.put("fallBackSql", sql); |
| | | params.add(param); |
| | | } |
| | |
| | | } |
| | | centerServiceDAOImpl.saveOrderItem(BeanConvertUtil.beanCovertMap(orderItemDto)); |
| | | |
| | | //判断是否配置了 轨迹 |
| | | BusinessTableHisDto businessTableHisDto = BusinessTableHisCache.getBusinessTableHisDto(orderItemDto.getAction(), orderItemDto.getActionObj()); |
| | | if (businessTableHisDto == null) { |
| | | return ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK); |
| | | } |
| | | |
| | | //补充 c_business #{bId},#{oId},#{businessTypeCd},#{remark},#{statusCd} |
| | | Map business = new HashMap(); |
| | | business.put("oId", orderItemDto.getoId()); |
| | | business.put("businessTypeCd", businessTableHisDto.getBusinessTypeCd()); |
| | | business.put("remark", ""); |
| | | business.put("statusCd", StatusConstant.STATUS_CD_SAVE); |
| | | business.put("bId", orderItemDto.getbId()); |
| | | centerServiceDAOImpl.saveBusiness(business); |
| | | |
| | | //通知子服务生成 business 数据,如果配置NO 不通知生成 business 数据 |
| | | if (BusinessTableHisDto.ACTION_OBJ_HIS_NO.equals(businessTableHisDto.getActionObjHis())) { |
| | | return ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK); |
| | | } |
| | | |
| | | doNoticeServiceGeneratorBusiness(orderItemDto, businessTableHisDto); |
| | | return ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK); |
| | | } |
| | | |
| | | private void doNoticeServiceGeneratorBusiness(OrderItemDto orderItemDto, BusinessTableHisDto businessTableHisDto) { |
| | | asynNotifySubServiceImpl.notifySubService(orderItemDto, businessTableHisDto); |
| | | } |
| | | |
| | | /** |
| | |
| | | info.put("oId", orderDto.getoId()); |
| | | centerServiceDAOImpl.updateOrderItem(info); |
| | | |
| | | //删除 事务日志 |
| | | //centerServiceDAOImpl.deleteUnItemLog(info); |
| | | |
| | | //完成订单 |
| | | info = new HashMap(); |
| | | info.put("finishTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | |
| | | info.put("oId", orderDto.getoId()); |
| | | centerServiceDAOImpl.updateOrder(info); |
| | | |
| | | //将c_business 修改为完成 |
| | | //完成订单项 |
| | | info = new HashMap(); |
| | | info.put("finishTime", DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | | info.put("statusCd", "C"); |
| | | info.put("oId", orderDto.getoId()); |
| | | centerServiceDAOImpl.updateBusiness(info); |
| | | |
| | | //触发databug |
| | | //查询 事务项 |
| | | Map orderItem = new HashMap(); |
| | | orderItem.put("oId", orderDto.getoId()); |
| | | List<Map> orderItemMaps = centerServiceDAOImpl.getOrderItems(orderItem); |
| | | |
| | | //删除 事务日志 |
| | | //centerServiceDAOImpl.deleteUnItemLog(info); |
| | | |
| | | asynNotifySubServiceImpl.notifyDatabus(orderItemMaps, orderDto); |
| | | |
| | | return ResultVo.createResponseEntity(ResultVo.CODE_OK, ResultVo.MSG_OK); |
| | | } |
| | | |
| | | |
| | | } |