| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.client.RestTemplate; |
| | | import com.java110.core.context.SecureInvocation; |
| | | import com.java110.dto.businessDatabus.BusinessDatabusDto; |
| | | import com.java110.dto.businessTableHis.BusinessTableHisDto; |
| | | import com.java110.dto.order.OrderDto; |
| | |
| | | import com.java110.utils.util.StringUtil; |
| | | import com.java110.vo.ResultVo; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | } |
| | | List<BusinessDatabusDto> databusDtos = DatabusCache.getDatabuss(); |
| | | |
| | | if (!hasTypeCd(databusDtos, businesses)) { |
| | | if (!hasTypeCd(databusDtos, businesses) || !SecureInvocation.secure(this.getClass())) { |
| | | return ; |
| | | } |
| | | |
| | |
| | | JSONObject logText = JSONObject.parseObject(orderItem.get("logText").toString()); |
| | | if ("ADD".equals(orderItem.get("action")) || "MOD".equals(orderItem.get("action"))) { |
| | | data = logText.getJSONArray("afterValue").getJSONObject(0); |
| | | StringUtil.lineToHump(data); |
| | | data = StringUtil.lineToHump(data); |
| | | businessObj.setData(data); |
| | | } |
| | | if ("DEL".equals(orderItem.get("action"))) { |
| | | data = logText.getJSONArray("preValue").getJSONObject(0); |
| | | StringUtil.lineToHump(data); |
| | | data = StringUtil.lineToHump(data); |
| | | businessObj.setData(data); |
| | | } |
| | | businessObjs.add(businessObj); |
| | |
| | | params = generateBusinessInsertInsertSql(orderItemDto, businessTableHisDto); |
| | | break; |
| | | case "MOD": |
| | | params = generateBusinessDelInsertSql(orderItemDto, businessTableHisDto); |
| | | params = new JSONArray(); |
| | | JSONArray paramDels = generateBusinessDelInsertSql(orderItemDto, businessTableHisDto); |
| | | for(int delIndex = 0 ; delIndex < paramDels.size(); delIndex ++){ |
| | | params.add(paramDels.getJSONObject(delIndex)); |
| | | } |
| | | JSONArray paramAdds = generateBusinessInsertInsertSql(orderItemDto, businessTableHisDto); |
| | | params.add(paramAdds); |
| | | for(int addIndex = 0 ; addIndex < paramAdds.size(); addIndex ++){ |
| | | params.add(paramAdds.getJSONObject(addIndex)); |
| | | } |
| | | break; |
| | | case "DEL": |
| | | params = generateBusinessDelInsertSql(orderItemDto, businessTableHisDto); |
| | |
| | | private JSONArray generateBusinessInsertInsertSql(OrderItemDto orderItemDto, BusinessTableHisDto businessTableHisDto) { |
| | | JSONArray params = new JSONArray(); |
| | | JSONObject param = null; |
| | | JSONObject updateParam = null; |
| | | String sql = ""; |
| | | String updateSql = ""; |
| | | String logText = orderItemDto.getLogText(); |
| | | |
| | | JSONObject logTextObj = JSONObject.parseObject(logText); |
| | | JSONArray afterValues = logTextObj.getJSONArray("afterValue"); |
| | | for (int afterValueIndex = 0; afterValueIndex < afterValues.size(); afterValueIndex++) { |
| | | sql = "insert into " + businessTableHisDto.getActionObjHis() + " "; |
| | | updateSql = "update " + businessTableHisDto.getActionObj() +" set b_id='"+orderItemDto.getbId()+"' where 1=1 "; |
| | | |
| | | param = new JSONObject(); |
| | | updateParam = new JSONObject(); |
| | | JSONObject keyValue = afterValues.getJSONObject(afterValueIndex); |
| | | if (keyValue.isEmpty()) { |
| | | continue; |
| | |
| | | String keySql = "( "; |
| | | String valueSql = " values ("; |
| | | for (String key : keyValue.keySet()) { |
| | | if ("status_cd".equals(key) || "create_time".equals(key)) { |
| | | if ("status_cd".equals(key) || "create_time".equals(key) || "b_id".equals(key)) { |
| | | continue; |
| | | } |
| | | keySql += (key + ","); |
| | | valueSql += (keyValue.getString(key) + ","); |
| | | |
| | | updateSql += (" and "+key +"=" + keyValue.getString(key)); |
| | | } |
| | | keySql += "operate,b_id"; |
| | | valueSql += "'ADD','" + orderItemDto.getbId() + "'"; |
| | |
| | | } |
| | | sql = sql + keySql + ") " + valueSql + ") "; |
| | | param.put("fallBackSql", sql); |
| | | updateParam.put("fallBackSql", updateSql); |
| | | params.add(param); |
| | | params.add(updateParam); |
| | | } |
| | | |
| | | return params; |
| | |
| | | String keySql = "( "; |
| | | String valueSql = " values ("; |
| | | for (String key : keyValue.keySet()) { |
| | | if ("status_cd".equals(key) || "create_time".equals(key)) { |
| | | if ("status_cd".equals(key) || "create_time".equals(key) || "b_id".equals(key)) { |
| | | continue; |
| | | } |
| | | keySql += (key + ","); |