代码备份

master
anthonywj 2 years ago
parent e514676578
commit 1569560f5f

@ -193,7 +193,7 @@ public class ConstantStatus {
public static final int FROM_PDAUN = 4; //pda未校验 public static final int FROM_PDAUN = 4; //pda未校验
public static final int FROM_PC = 5; //pc端扫码精灵 public static final int FROM_PC = 5; //pc端扫码精灵
public static final int FROM_CHANGE = 6; //单据流转 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_PEACE_CHANGE = 8; //平衡补单
public static final int FROM_REVIEW = 9; //单据验收直接补单 public static final int FROM_REVIEW = 9; //单据验收直接补单
public static final int FROM_COPY = 10; //单据复制 public static final int FROM_COPY = 10; //单据复制

@ -51,70 +51,70 @@ public class ioCodeRelController {
//判断码有没有重复 //判断码有没有重复
List<IoCodeRelEntity> list=ioCodeRelServicec.selectIoCodeRelByCode("",code); List<IoCodeRelEntity> list = ioCodeRelServicec.selectIoCodeRelByCode("", code);
if(list.size()>0){ if (list.size() > 0) {
return ResultVOUtils.error(999,"此码已做关联!"); return ResultVOUtils.error(999, "此码已做关联!");
} }
if(StrUtil.isNotEmpty(code)){ if (StrUtil.isNotEmpty(code)) {
UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(code); UdiEntity udiEntity = FilterUdiUtils.getUdi(code);
UdiProductEntity udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); UdiProductEntity udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi());
if(udiProductEntity.getPackLevel()!=null){ if (udiProductEntity.getPackLevel() != null) {
if(Integer.valueOf(udiProductEntity.getPackLevel())>1){ if (Integer.valueOf(udiProductEntity.getPackLevel()) > 1) {
return ResultVOUtils.success(udiProductEntity.getBhxjcpbm()); return ResultVOUtils.success(udiProductEntity.getBhxjcpbm());
} }
} }
} }
return ResultVOUtils.error(999,"扫码错误!"); return ResultVOUtils.error(999, "扫码错误!");
} }
@GetMapping("/udi/ioCode/Rel/checkLowProduct") @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)){ if (StrUtil.isNotEmpty(upCode)) {
UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(upCode); UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(upCode);
udiProductEntity=udiProductService.findByNameCode(udiEntity.getUdi()); udiProductEntity = udiProductService.findByNameCode(udiEntity.getUdi());
} }
//判断码有没有重复 //判断码有没有重复
List<IoCodeRelEntity> list=ioCodeRelServicec.selectIoCodeRelByCode(lowCode,upCode); List<IoCodeRelEntity> list = ioCodeRelServicec.selectIoCodeRelByCode(lowCode, upCode);
if(list.size()>0){ if (list.size() > 0) {
return ResultVOUtils.error(999,"此码已做关联!"); return ResultVOUtils.error(999, "此码已做关联!");
} }
//判断条数是否超出 //判断条数是否超出
Long count=ioCodeRelServicec.selectIoCodeRelCount(upCode); Long count = ioCodeRelServicec.selectIoCodeRelCount(upCode);
if(count>=udiProductEntity.getBhxjsl()){ if (count >= udiProductEntity.getBhxjsl()) {
return ResultVOUtils.error(999,"数量超出!"); return ResultVOUtils.error(999, "数量超出!");
} }
//查询下级产品信息 //查询下级产品信息
if(StrUtil.isNotEmpty(lowCode)){ if (StrUtil.isNotEmpty(lowCode)) {
UdiEntity udiEntity=FilterUdiUtils.getGS1Udi(lowCode); UdiEntity udiEntity = FilterUdiUtils.getGS1Udi(lowCode);
UdiProductEntity udiProductEntity1=udiProductService.findByNameCode(udiEntity.getUdi()); UdiProductEntity udiProductEntity1 = udiProductService.findByNameCode(udiEntity.getUdi());
if(udiProductEntity!=null){ if (udiProductEntity != null) {
if(udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())){ if (udiProductEntity1.getNameCode().equals(udiProductEntity.getBhxjcpbm())) {
IoCodeRelEntity ioCodeRelEntity=new IoCodeRelEntity(); IoCodeRelEntity ioCodeRelEntity = new IoCodeRelEntity();
ioCodeRelEntity.setCode(lowCode); ioCodeRelEntity.setCode(lowCode);
ioCodeRelEntity.setParentCode(upCode); ioCodeRelEntity.setParentCode(upCode);
ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode()); ioCodeRelEntity.setNameCode(udiProductEntity1.getNameCode());
ioCodeRelEntity.setDiType(udiProductEntity1.getDiType()); ioCodeRelEntity.setDiType(udiProductEntity1.getDiType());
ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel()); ioCodeRelEntity.setLevel(udiProductEntity1.getPackLevel());
ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate()); ioCodeRelEntity.setProduceDate(udiProductEntity1.getProduceDate());
ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate()); ioCodeRelEntity.setExpireDate(udiProductEntity1.getExpireDate());
ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo()); ioCodeRelEntity.setSerialNo(udiProductEntity1.getSerialNo());
ioCodeRelEntity.setCreateTime(new Date()); ioCodeRelEntity.setCreateTime(new Date());
ioCodeRelEntity.setUpdateTime(new Date()); ioCodeRelEntity.setUpdateTime(new Date());
ioCodeRelServicec.insert(ioCodeRelEntity); ioCodeRelServicec.insert(ioCodeRelEntity);
return ResultVOUtils.success(); return ResultVOUtils.success();
}else{ } else {
return ResultVOUtils.error(999,"该条码不属于下级产品!"); return ResultVOUtils.error(999, "该条码不属于下级产品!");
} }
} }
} }
return ResultVOUtils.error(999,""); return ResultVOUtils.error(999, "");
} }
@GetMapping("/udi/ioCode/Rel/delectList") @GetMapping("/udi/ioCode/Rel/delectList")
@ -131,13 +131,13 @@ public class ioCodeRelController {
@GetMapping("/udi/ioCode/Rel/del") @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); int count = ioCodeRelServicec.delIoCodeRel(code, parentCode);
if(count>0){ if (count > 0) {
return ResultVOUtils.success("删除成功"); return ResultVOUtils.success("删除成功");
}else{ } else {
return ResultVOUtils.error(999,"删除失败"); return ResultVOUtils.error(999, "删除失败");
} }
} }

@ -79,7 +79,7 @@ public class IdcServiceImpl implements IdcService {
"//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业", "//sup_cert_set/id///updateTime///供应商资质证书设置","companyCert//sup_company/customerId///updateTime///配送企业",
"manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息", "manufacturerCert//sup_manufacturer/id///updateTime///生产企业","productCert//sup_product/id///updateTime///产品资质信息",
"dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"}; "dbDiProducts//productinfo/id///updateTime///DI产品信息","//udicompany/id///updateTime///国际库医疗器械注册人信息"};
private int orderNum=0; private int orderNum=0;
@Resource @Resource
@ -102,6 +102,7 @@ public class IdcServiceImpl implements IdcService {
return ResultVOUtils.success(list); return ResultVOUtils.success(list);
} }
@Override @Override
public BaseResponse download(HttpServletRequest request,Map<String,Object> params) { public BaseResponse download(HttpServletRequest request,Map<String,Object> params) {
Map<String,Object> map = dbDao.get("select * from basic_upload_status where taskId='"+params.get("taskId")+"'"); Map<String,Object> 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); return ResultVOUtils.success(object);
} }
/*UDI系统上传自助平台*/ /*UDI系统上传自助平台*/
@Override @Override
public void asyncUdiTask() { public void asyncUdiTask() {
@ -125,12 +126,12 @@ public class IdcServiceImpl implements IdcService {
logger.info("自助平台同步任务开始--------"); logger.info("自助平台同步任务开始--------");
asyncDataTask(false); asyncDataTask(false);
} }
/*拉取前一级中继服务数据*/ /*拉取前一级中继服务数据*/
@Async @Async
@Override @Override
public void asyncFetchTask() { public void asyncFetchTask() {
Map<String,Object> query = new HashMap<String,Object>(); Map<String,Object> query = new HashMap<String,Object>();
String host = getNextHost(); String host = getNextHost();
if(!StringUtils.isEmpty(host)) { if(!StringUtils.isEmpty(host)) {
@ -149,7 +150,7 @@ public class IdcServiceImpl implements IdcService {
} }
} }
} }
} }
@Async @Async
@ -161,7 +162,7 @@ public class IdcServiceImpl implements IdcService {
dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')"); dbDao.save("insert into idc_var (code,content) values ('system_type','IDC')");
} }
} }
private void asyncDataTask(boolean isUpload) { private void asyncDataTask(boolean isUpload) {
initTable(); initTable();
@ -175,15 +176,15 @@ public class IdcServiceImpl implements IdcService {
} }
} }
} }
private void syncData(String t,boolean isUpload) { private void syncData(String t,boolean isUpload) {
boolean sync = true; boolean sync = true;
String[] tnames = t.split("/"); String[] tnames = t.split("/");
String lastUpdateTime = getUpdateTime(tnames[0]); String lastUpdateTime = getUpdateTime(tnames[0]);
Date nowUpdateTime = new Date(); Date nowUpdateTime = new Date();
if(!StringUtils.isEmpty(tnames[0])) { if(!StringUtils.isEmpty(tnames[0])) {
List<Map<String, String>> keyList = dbDao.listKeyMysql(tnames[2]); List<Map<String, String>> keyList = dbDao.listKeyMysql(tnames[2]);
String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id"; String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id";
Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map = new HashMap<String,Object>();
@ -194,7 +195,7 @@ public class IdcServiceImpl implements IdcService {
map.put("isEnd", "1"); map.put("isEnd", "1");
} }
map.put("sqlWhere", sqlWhere); map.put("sqlWhere", sqlWhere);
map.put("tableKey", tnames[0]); map.put("tableKey", tnames[0]);
map.put("tableName", tnames[2]); map.put("tableName", tnames[2]);
map.put("uniqueColumn", tnames[3]); map.put("uniqueColumn", tnames[3]);
@ -208,7 +209,7 @@ public class IdcServiceImpl implements IdcService {
scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", "")); scheduledRequest.setCronName("sync"+WordUtils.capitalizeFully(tnames[2], new char[]{'_'}).replace("_", ""));
ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest); ScheduledEntity scheduledEntity = scheduledDao.findScheduled(scheduledRequest);
String cron = scheduledEntity!=null ? scheduledEntity.getCron() : ""; String cron = scheduledEntity!=null ? scheduledEntity.getCron() : "";
if(!StringUtils.isEmpty(cron)) { if(!StringUtils.isEmpty(cron)) {
CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron); CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron);
Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime)); Date nextTimePoint = cronSequenceGenerator.next(DateUtil.parseDate(lastUpdateTime));
@ -221,8 +222,8 @@ public class IdcServiceImpl implements IdcService {
} }
} }
} }
private String fetchData(String url,Map<String,Object> params) { private String fetchData(String url,Map<String,Object> params) {
OkHttpClient client = new OkHttpClient().newBuilder() OkHttpClient client = new OkHttpClient().newBuilder()
@ -330,14 +331,14 @@ public class IdcServiceImpl implements IdcService {
/*数据同步,从数据库获取数据下发或上传下级中继服务*/ /*数据同步,从数据库获取数据下发或上传下级中继服务*/
@Override @Override
public BaseResponse send(Map<String,Object> params) { public BaseResponse send(Map<String,Object> params) {
return send(params.get("messageType").toString(),params.get("tableName").toString(),params); return send(params.get("messageType").toString(),params.get("tableName").toString(),params);
} }
@Override @Override
public BaseResponse send(String messageType,String tableName,Map<String,Object> params) { public BaseResponse send(String messageType,String tableName,Map<String,Object> params) {
return ResultVOUtils.error(9999, ""); return ResultVOUtils.error(9999, "");
} }
@ -355,7 +356,7 @@ public class IdcServiceImpl implements IdcService {
dbDao.save(sql); dbDao.save(sql);
} }
private void saveExportStatus(String messageType,String taskId,String fileName) { private void saveExportStatus(String messageType,String taskId,String fileName) {
Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map = new HashMap<String,Object>();
map.put("id", CustomUtil.getId()); map.put("id", CustomUtil.getId());
@ -397,8 +398,8 @@ public class IdcServiceImpl implements IdcService {
dbDao.save(sql); dbDao.save(sql);
} }
private boolean syncMasterData(Map<String,Object> params,boolean isUplaod) { private boolean syncMasterData(Map<String,Object> params,boolean isUplaod) {
boolean success=false; boolean success=false;
String tableName = params.get("tableName").toString(); String tableName = params.get("tableName").toString();
@ -421,13 +422,13 @@ public class IdcServiceImpl implements IdcService {
Map<String,Object> whereParams = new HashMap<String,Object>(); Map<String,Object> whereParams = new HashMap<String,Object>();
whereParams.put("sqlWhere", params.get("sqlWhere")); whereParams.put("sqlWhere", params.get("sqlWhere"));
whereParams.put("dataWhere", params.get("dataWhere")); whereParams.put("dataWhere", params.get("dataWhere"));
Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map = new HashMap<String,Object>();
String where = DBAUtils.convertWhere(column,whereParams,""); String where = DBAUtils.convertWhere(column,whereParams,"");
sql+=!StringUtils.isEmpty(where) ? " where "+where : ""; sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
map.put("sql", sql); map.put("sql", sql);
int total = dbDao.count(map); int total = dbDao.count(map);
String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0"; String isEnd = params.get("isEnd")!=null ? params.get("isEnd").toString() : "0";
int limit = 50; int limit = 50;
String[] files = new String[limit]; String[] files = new String[limit];
@ -435,14 +436,14 @@ public class IdcServiceImpl implements IdcService {
orderNum++; orderNum++;
String messageType = params.get("messageType").toString(); String messageType = params.get("messageType").toString();
saveIdcLog(messageType,"",tableName +">"+where,0,total); saveIdcLog(messageType,"",tableName +">"+where,0,total);
if(total>0) { if(total>0) {
success = true; success = true;
whereParams.put("page", 0); whereParams.put("page", 0);
whereParams.put("limit", limit); whereParams.put("limit", limit);
List<Map<String, String>> keyList = dbDao.listKeyMysql(tableName); List<Map<String, String>> keyList = dbDao.listKeyMysql(tableName);
String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id"; String keyColumn = keyList!=null&&keyList.size()>0 ? keyList.get(0).get("columnName").toString() : "id";
for(int i=0;i<Math.ceil(total/limit)+1;i++) { for(int i=0;i<Math.ceil(total/limit)+1;i++) {
@ -477,13 +478,13 @@ public class IdcServiceImpl implements IdcService {
} }
orderNum++; orderNum++;
if(isUplaod) { if(isUplaod) {
String result = ""; String result = "";
try { try {
result = relay("",JSON.toJSONString(data),files); result = relay("",JSON.toJSONString(data),files);
} catch (Exception ex) { } catch (Exception ex) {
} }
if(IDCUtils.isJson(result)) { if(IDCUtils.isJson(result)) {
JSONObject json = JSON.parseObject(result); JSONObject json = JSON.parseObject(result);
@ -512,12 +513,12 @@ public class IdcServiceImpl implements IdcService {
} }
} }
} }
} }
return success; return success;
} }
/*增加同步任务*/ /*增加同步任务*/
private void syncAddTask(Map<String,Object> json) { private void syncAddTask(Map<String,Object> json) {
String content = JSON.toJSONString(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"; String backFileName = backFilePath +datePath+"/"+json.get("messageType")+"-"+json.get("messageId")+".udi";
FileUtils.SaveFileAs(content, fileName); FileUtils.SaveFileAs(content, fileName);
FileUtils.SaveFileAs(content, backFileName); FileUtils.SaveFileAs(content, backFileName);
saveExportStatus(json.get("messageType").toString(),json.get("messageId").toString(),fileName); saveExportStatus(json.get("messageType").toString(),json.get("messageId").toString(),fileName);
} }
/*解析到数据库*/ /*解析到数据库*/
private void analyToDB(JSONObject jsonObject,MultipartFile[] files) { 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") ? "'" :""); updateWhere+=keyColumn[z]+" = "+(keyDataType[z].equals("C") ? "'" :"") +value +(keyDataType[z].equals("C") ? "'" :"");
} }
} }
if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere)) if("A,D".contains(operateMode)&&!StringUtils.isEmpty(updateWhere))
dbDao.delete(del+updateWhere); dbDao.delete(del+updateWhere);
} }
@ -611,7 +612,7 @@ public class IdcServiceImpl implements IdcService {
value = DBAUtils.escape(value); value = DBAUtils.escape(value);
String dataType = columnList.get(k).get("dataType").toLowerCase().contains("char") || columnList.get(k).get("dataType").toLowerCase().contains("text") ? 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" ; "C" : columnList.get(k).get("dataType").toLowerCase().contains("date") ? "D" : "N" ;
sql+=m>0 ? "," : ""; sql+=m>0 ? "," : "";
boolean ups = list.get(i).containsKey(attrName) ? true : false ; boolean ups = list.get(i).containsKey(attrName) ? true : false ;
updateSet+=ups&&h>0 ? "," : ""; updateSet+=ups&&h>0 ? "," : "";
@ -639,11 +640,11 @@ public class IdcServiceImpl implements IdcService {
dbDao.update(upd + updateSet+" where "+updateWhere); dbDao.update(upd + updateSet+" where "+updateWhere);
h+=ups ? 1 : 0; h+=ups ? 1 : 0;
} }
sql+=")"; sql+=")";
n++; n++;
} }
for(int m=0;m<30;m++) { for(int m=0;m<30;m++) {
if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) { if(list.get(i).get("tableName"+m)!=null&&list.get(i).get("data"+m)!=null) {
Object obj = list.get(i).get("data"+m); Object obj = list.get(i).get("data"+m);
@ -656,7 +657,7 @@ public class IdcServiceImpl implements IdcService {
break; break;
} }
} }
} }
if(n>0) if(n>0)
dbDao.save(sql); dbDao.save(sql);
@ -732,7 +733,7 @@ public class IdcServiceImpl implements IdcService {
Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'"); Map<String,Object> map = dbDao.get("select * from idc_var where code='system_type'");
return !(map!=null&&map.get("content")!=null&&map.get("content").toString().equals("IDC")) ; return !(map!=null&&map.get("content")!=null&&map.get("content").toString().equals("IDC")) ;
} }
/*是否需要转发*/ /*是否需要转发*/
private boolean isRelay() { private boolean isRelay() {
String relayHost = getNextHost(); String relayHost = getNextHost();
@ -743,7 +744,7 @@ public class IdcServiceImpl implements IdcService {
private List<Map<String,Object>> getList(String tableName,Map<String,Object> params) { private List<Map<String,Object>> getList(String tableName,Map<String,Object> params) {
String sql = "select "+tableName+".*,'A' as operateMode from "+tableName; String sql = "select "+tableName+".*,'A' as operateMode from "+tableName;
Map<String,Object> column = getColumn(tableName); Map<String,Object> column = getColumn(tableName);
String where = DBAUtils.convertWhere(column,params,""); String where = DBAUtils.convertWhere(column,params,"");
sql+=!StringUtils.isEmpty(where) ? " where "+where : ""; sql+=!StringUtils.isEmpty(where) ? " where "+where : "";
Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map = new HashMap<String,Object>();
@ -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_export_status add column cacheFilePath varchar(255)");
jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)"); jdbcTemplate.execute("alter table basic_upload_status add column cacheFilePath varchar(255)");
} catch (Exception e) { } catch (Exception e) {
} }
} }
private void alterTable(String tableName,String sql) { private void alterTable(String tableName,String sql) {

@ -1,6 +1,6 @@
spring: spring:
profiles: profiles:
active: pro active: dev
jmx: jmx:
enabled: false enabled: false

Loading…
Cancel
Save