diff --git a/src/main/java/com/glxp/api/constant/ConstantStatus.java b/src/main/java/com/glxp/api/constant/ConstantStatus.java index 40294ab58..0a2c77894 100644 --- a/src/main/java/com/glxp/api/constant/ConstantStatus.java +++ b/src/main/java/com/glxp/api/constant/ConstantStatus.java @@ -193,7 +193,7 @@ public class ConstantStatus { public static final int FROM_PDAUN = 4; //pda未校验 public static final int FROM_PC = 5; //pc端扫码精灵 public static final int FROM_CHANGE = 6; //单据流转 - public static final int FROM_UDISP = 7; //供应商平台 + public static final int FROM_UDISP = 7; //供应商平台|| UDI管理系统 public static final int FROM_PEACE_CHANGE = 8; //平衡补单 public static final int FROM_REVIEW = 9; //单据验收直接补单 public static final int FROM_COPY = 10; //单据复制 diff --git a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java b/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java index 745d232ce..24e735322 100644 --- a/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java +++ b/src/main/java/com/glxp/api/controller/inout/ioCodeRelController.java @@ -51,70 +51,70 @@ public class ioCodeRelController { //判断码有没有重复 - List list=ioCodeRelServicec.selectIoCodeRelByCode("",code); - if(list.size()>0){ - return ResultVOUtils.error(999,"此码已做关联!"); + List list = ioCodeRelServicec.selectIoCodeRelByCode("", code); + if (list.size() > 0) { + return ResultVOUtils.error(999, "此码已做关联!"); } - if(StrUtil.isNotEmpty(code)){ - UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(code); - UdiProductEntity udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); - if(udiProductEntity.getPackLevel()!=null){ - if(Integer.valueOf(udiProductEntity.getPackLevel())>1){ - return ResultVOUtils.success(udiProductEntity.getBhxjcpbm()); + if (StrUtil.isNotEmpty(code)) { + UdiEntity udiEntity = FilterUdiUtils.getUdi(code); + UdiProductEntity udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi()); + if (udiProductEntity.getPackLevel() != null) { + if (Integer.valueOf(udiProductEntity.getPackLevel()) > 1) { + return ResultVOUtils.success(udiProductEntity.getBhxjcpbm()); } } } - return ResultVOUtils.error(999,"扫码错误!"); + return ResultVOUtils.error(999, "扫码错误!"); } @GetMapping("/udi/ioCode/Rel/checkLowProduct") - public BaseResponse checkLowProduct(String upCode,String lowCode) { + public BaseResponse checkLowProduct(String upCode, String lowCode) { - UdiProductEntity udiProductEntity=new UdiProductEntity(); + UdiProductEntity udiProductEntity = new UdiProductEntity(); //查询上级产品信息 - if(StrUtil.isNotEmpty(upCode)){ - UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(upCode); - udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); + if (StrUtil.isNotEmpty(upCode)) { + UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(upCode); + udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi()); } //判断码有没有重复 - List list=ioCodeRelServicec.selectIoCodeRelByCode(lowCode,upCode); - if(list.size()>0){ - return ResultVOUtils.error(999,"此码已做关联!"); + List list = ioCodeRelServicec.selectIoCodeRelByCode(lowCode, upCode); + if (list.size() > 0) { + return ResultVOUtils.error(999, "此码已做关联!"); } //判断条数是否超出 - Long count=ioCodeRelServicec.selectIoCodeRelCount(upCode); - if(count>=udiProductEntity.getBhxjsl()){ - return ResultVOUtils.error(999,"数量超出!"); + Long count = ioCodeRelServicec.selectIoCodeRelCount(upCode); + if (count >= udiProductEntity.getBhxjsl()) { + return ResultVOUtils.error(999, "数量超出!"); } //查询下级产品信息 - if(StrUtil.isNotEmpty(lowCode)){ - UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(lowCode); - UdiProductEntity udiProductEntity1=udiProductService.findByNameCode(udiEntity.getUdi()); - if(udiProductEntity!=null){ - if(udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())){ - IoCodeRelEntity ioCodeRelEntity=new IoCodeRelEntity(); - ioCodeRelEntity.setCode(lowCode); - ioCodeRelEntity.setParentCode(upCode); - ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode()); - ioCodeRelEntity.setDiType(udiProductEntity1.getDiType()); - ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel()); - ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate()); - ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate()); - ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo()); - ioCodeRelEntity.setCreateTime(new Date()); - ioCodeRelEntity.setUpdateTime(new Date()); - ioCodeRelServicec.insert(ioCodeRelEntity); - return ResultVOUtils.success(); - }else{ - return ResultVOUtils.error(999,"该条码不属于下级产品!"); - } - } + if (StrUtil.isNotEmpty(lowCode)) { + UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(lowCode); + UdiProductEntity udiProductEntity1 = udiProductService.findByNameCode(udiEntity.getUdi()); + if (udiProductEntity != null) { + if (udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())) { + IoCodeRelEntity ioCodeRelEntity = new IoCodeRelEntity(); + ioCodeRelEntity.setCode(lowCode); + ioCodeRelEntity.setParentCode(upCode); + ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode()); + ioCodeRelEntity.setDiType(udiProductEntity1.getDiType()); + ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel()); + ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate()); + ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate()); + ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo()); + ioCodeRelEntity.setCreateTime(new Date()); + ioCodeRelEntity.setUpdateTime(new Date()); + ioCodeRelServicec.insert(ioCodeRelEntity); + return ResultVOUtils.success(); + } else { + return ResultVOUtils.error(999, "该条码不属于下级产品!"); + } + } } - return ResultVOUtils.error(999,""); + return ResultVOUtils.error(999, ""); } @GetMapping("/udi/ioCode/Rel/delectList") @@ -131,13 +131,13 @@ public class ioCodeRelController { @GetMapping("/udi/ioCode/Rel/del") - public BaseResponse del(String code,String parentCode) { + public BaseResponse del(String code, String parentCode) { - int count=ioCodeRelServicec.delIoCodeRel(code,parentCode); - if(count>0){ + int count = ioCodeRelServicec.delIoCodeRel(code, parentCode); + if (count > 0) { return ResultVOUtils.success("删除成功"); - }else{ - return ResultVOUtils.error(999,"删除失败"); + } else { + return ResultVOUtils.error(999, "删除失败"); } } diff --git a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java index f2e77b934..6068991b6 100644 --- a/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java +++ b/src/main/java/com/glxp/api/idc/service/impl/IdcServiceImpl.java @@ -79,7 +79,7 @@ public class IdcServiceImpl implements IdcService { "//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业", "manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息", "dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"}; - + private int orderNum=0; @Resource @@ -102,6 +102,7 @@ public class IdcServiceImpl implements IdcService { return ResultVOUtils.success(list); } + @Override public BaseResponse download(HttpServletRequest request,Map params) { Map map = dbDao.get("select * from basic_upload_status where taskId='"+params.get("taskId")+"'"); @@ -112,7 +113,7 @@ public class IdcServiceImpl implements IdcService { return ResultVOUtils.success(object); } - + /*UDI系统上传自助平台*/ @Override public void asyncUdiTask() { @@ -125,12 +126,12 @@ public class IdcServiceImpl implements IdcService { logger.info("自助平台同步任务开始--------"); asyncDataTask(false); } - + /*拉取前一级中继服务数据*/ @Async @Override public void asyncFetchTask() { - + Map query = new HashMap(); String host = getNextHost(); if(!StringUtils.isEmpty(host)) { @@ -149,7 +150,7 @@ public class IdcServiceImpl implements IdcService { } } } - + } @Async @@ -161,7 +162,7 @@ public class IdcServiceImpl implements IdcService { dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')"); } } - + private void asyncDataTask(boolean isUpload) { initTable(); @@ -175,15 +176,15 @@ public class IdcServiceImpl implements IdcService { } } } - + private void syncData(String t,boolean isUpload) { boolean sync = true; String[] tnames = t.split("/"); - + String lastUpdateTime = getUpdateTime(tnames[0]); Date nowUpdateTime = new Date(); if(!StringUtils.isEmpty(tnames[0])) { - + List> keyList = dbDao.listKeyMysql(tnames[2]); String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id"; Map map = new HashMap(); @@ -194,7 +195,7 @@ public class IdcServiceImpl implements IdcService { map.put("isEnd", "1"); } map.put("sqlWhere", sqlWhere); - + map.put("tableKey", tnames[0]); map.put("tableName", tnames[2]); map.put("uniqueColumn", tnames[3]); @@ -208,7 +209,7 @@ public class IdcServiceImpl implements IdcService { scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", "")); ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); String cron = scheduledEntity!=null ? scheduledEntity.getCron() : ""; - + if(!StringUtils.isEmpty(cron)) { CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron); Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime)); @@ -221,8 +222,8 @@ public class IdcServiceImpl implements IdcService { } } } - - + + private String fetchData(String url,Map params) { OkHttpClient client = new OkHttpClient().newBuilder() @@ -330,14 +331,14 @@ public class IdcServiceImpl implements IdcService { /*数据同步,从数据库获取数据下发或上传下级中继服务*/ @Override public BaseResponse send(Map params) { - - return send(params.get("messageType").toString(),params.get("tableName").toString(),params); - - + + return send(params.get("messageType").toString(),params.get("tableName").toString(),params); + + } @Override public BaseResponse send(String messageType,String tableName,Map params) { - + return ResultVOUtils.error(9999, ""); } @@ -355,7 +356,7 @@ public class IdcServiceImpl implements IdcService { dbDao.save(sql); } - + private void saveExportStatus(String messageType,String taskId,String fileName) { Map map = new HashMap(); map.put("id", CustomUtil.getId()); @@ -397,8 +398,8 @@ public class IdcServiceImpl implements IdcService { dbDao.save(sql); } - - + + private boolean syncMasterData(Map params,boolean isUplaod) { boolean success=false; String tableName = params.get("tableName").toString(); @@ -421,13 +422,13 @@ public class IdcServiceImpl implements IdcService { Map whereParams = new HashMap(); whereParams.put("sqlWhere", params.get("sqlWhere")); whereParams.put("dataWhere", params.get("dataWhere")); - + Map map = new HashMap(); String where = DBAUtils.convertWhere(column,whereParams,""); sql+=!StringUtils.isEmpty(where) ? " where "+where : ""; map.put("sql", sql); int total = dbDao.count(map); - + String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0"; int limit = 50; String[] files = new String[limit]; @@ -435,14 +436,14 @@ public class IdcServiceImpl implements IdcService { orderNum++; String messageType = params.get("messageType").toString(); saveIdcLog(messageType,"",tableName +">"+where,0,total); - - + + if(total>0) { success = true; - + whereParams.put("page", 0); whereParams.put("limit", limit); - + List> keyList = dbDao.listKeyMysql(tableName); String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id"; for(int i=0;i json) { String content = JSON.toJSONString(json); @@ -529,12 +530,12 @@ public class IdcServiceImpl implements IdcService { String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi"; FileUtils.SaveFileAs(content, fileName); FileUtils.SaveFileAs(content, backFileName); - - + + saveExportStatus(json.get("messageType").toString(),json.get("messageId").toString(),fileName); } - - + + /*解析到数据库*/ private void analyToDB(JSONObject jsonObject,MultipartFile[] files) { @@ -594,7 +595,7 @@ public class IdcServiceImpl implements IdcService { updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :""); } } - + if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere)) dbDao.delete(del+updateWhere); } @@ -611,7 +612,7 @@ public class IdcServiceImpl implements IdcService { value = DBAUtils.escape(value); String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ? "C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N" ; - + sql+=m>0 ? "," : ""; boolean ups = list.get(i).containsKey(attrName) ? true : false ; updateSet+=ups&&h>0 ? "," : ""; @@ -639,11 +640,11 @@ public class IdcServiceImpl implements IdcService { dbDao.update(upd + updateSet+" where "+updateWhere); h+=ups ? 1 : 0; } - + sql+=")"; n++; } - + for(int m=0;m<30;m++) { if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) { Object obj = list.get(i).get("data"+m); @@ -656,7 +657,7 @@ public class IdcServiceImpl implements IdcService { break; } } - + } if(n>0) dbDao.save(sql); @@ -732,7 +733,7 @@ public class IdcServiceImpl implements IdcService { Map map = dbDao.get("select * from idc_var where code='system_type'"); return !(map!=null&&map.get("content")!=null&&map.get("content").toString().equals("IDC")) ; } - + /*是否需要转发*/ private boolean isRelay() { String relayHost = getNextHost(); @@ -743,7 +744,7 @@ public class IdcServiceImpl implements IdcService { private List> getList(String tableName,Map params) { String sql = "select "+tableName+".*,'A' as operateMode from "+tableName; Map column = getColumn(tableName); - + String where = DBAUtils.convertWhere(column,params,""); sql+=!StringUtils.isEmpty(where) ? " where "+where : ""; Map map = new HashMap(); @@ -869,7 +870,7 @@ public class IdcServiceImpl implements IdcService { jdbcTemplate.execute("alter table basic_export_status add column cacheFilePath varchar(255)"); jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)"); } catch (Exception e) { - + } } private void alterTable(String tableName,String sql) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a3fb0cb76..1c0966353 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: pro + active: dev jmx: enabled: false