Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. import java.io.File
  2. class Example {
  3. static void main(String[] args) {
  4. new File("/tmp/csv/SIR_STAT_59.PROC_STEP.2017.08.12.FULL.001_1 - копия.csv").eachLine {
  5. line ->
  6. //intln "line : $line";
  7. def colCount = line.split(',').length // кол-во столбцов
  8.  
  9. def rows = line.replaceAll("'", '')
  10. def row = rows.split(',')
  11. println row[1];
  12. /*
  13. for (int i = 1; i < colCount; i++) {
  14. def row = line.split(',')
  15. println row[0]
  16. }*/
  17.  
  18.  
  19. subjectName = FilterGroup.single('ID_PROC_STEP', FilterElement.FilterOperator.contains, [row[0].toDouble()])
  20. subject = externalDataSource.getObjectList('ARM_Static_PROC_STEP_SIR', null, subjectName, null, null, null, null)
  21. // println 'из сущности: ' + subject[0].properties.id
  22. //obj = externalDataSource.getNewObject('A9_PROC_STEP_SIR')
  23.  
  24. if (subject[0] != null) {
  25. obj = subject[0]
  26. } else if (subject[0] == null) {
  27. obj = externalDataSource.getNewObject('ARM_Static_PROC_STEP_SIR')
  28. }
  29. obj.fields.ID_PROC_STEP.value = row[0].toDouble()
  30. obj.fields.PROC_INSTANCE_ID.value = row[1].toDouble()
  31. obj.fields.cSTEP_NAME.value = row[2]
  32. obj.fields.cASSIGNEE.value = row[4]
  33. if (row[6] != null && row[6] != '') {
  34. Date d4 = Date.parse("yyyy-MM-dd HH:mm:ss", row[6])
  35. obj.fields.dSTEP_START.value = d4
  36. } else {
  37. def d4 = null
  38. }
  39. if (row[7] != '' && row[7] != null) {
  40. Date d5 = Date.parse("yyyy-MM-dd HH:mm:ss", row[7])
  41. obj.fields.dSTEP_FINISH.value = d5
  42. } else {
  43. def d5 = null
  44. }
  45. obj.fields.CMODIFIED.value = row[10]
  46. obj.fields.Code.value = row[11]
  47.  
  48. tenant = 0
  49. externalDataSource.updateObject(obj)
  50. tenant = securityDataProvider.getTenant(arr[i][11].toString().trim())
  51. externalDataSource.source.query().update('update "ARM_Static_PROC_STEP_SIR" set "Sys_owner" = :code where "Id" = :id').namedParams([code:tenant.id, id:obj.id as Integer]).run()
  52.  
  53.  
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement